private long getLong (String l) throws ConfigurationException { try { return Long.parseLong (l); } catch (Exception e) { throw new ConfigurationException (e); } } private synchronized void touch (String id, String detail) {
@Test public void testConstructor() throws Throwable { Throwable nested = new ConfigurationException(); ConfigurationException configurationException = new ConfigurationException("testConfigurationExceptionDetail", nested); assertEquals("configurationException.getMessage()", "testConfigurationExceptionDetail", configurationException.getMessage()); assertSame("configurationException.getNested()", nested, configurationException.getNested()); }
@Test public void testConstructor3() throws Throwable { ConfigurationException configurationException = new ConfigurationException(); assertNull("configurationException.getNested()", configurationException.getNested()); }
@Test public void testSetConfigurationThrowsConfigurationException() throws Throwable { FilterLogListener filterLogListener = new FilterLogListener(new PrintStream(new ByteArrayOutputStream())); Configuration cfg = new SubConfiguration(); try { filterLogListener.setConfiguration(cfg); fail("Expected ConfigurationException to be thrown"); } catch (ConfigurationException ex) { assertEquals("ex.getMessage()", "java.lang.NullPointerException", ex.getMessage()); assertNull("ex.getNested().getMessage()", ex.getNested().getMessage()); assertEquals("filterLogListener.getPriority()", "info", filterLogListener.getPriority()); } }
@Test public void testInitService_InvalidThreadPoolType() throws Exception { qbeanConfigPw .println("<QThreadPoolExecutor type='somethingNotValid' />"); qbeanConfigPw.flush(); setQBeanConfig(qbeanConfigBos.toByteArray()); try { qbean.initService(); fail("ConfigurationException was expected"); } catch (ConfigurationException e) { assertThat(e.getMessage().contains( QThreadPoolExecutor.XML_CONFIG_ATTR__EXEC_SRV_TYPE)); } }
ce.fillInStackTrace(); throw ce;
@Test public void testGetObjectThrowsConfigurationException() throws Throwable { Configuration cfg = new SubConfiguration(); SubConfiguration subConfiguration = new SubConfiguration(cfg, "testSubConfigurationPrefix"); try { subConfiguration.getObject("testSubConfigurationPropertyName"); fail("Expected ConfigurationException to be thrown"); } catch (ConfigurationException ex) { assertEquals("ex.getMessage()", "Error trying to create an object from property testSubConfigurationPrefixtestSubConfigurationPropertyName", ex.getMessage()); assertNull("ex.getNested().getMessage()", ex.getNested().getMessage()); assertSame("subConfiguration.cfg", cfg, subConfiguration.cfg); } }
@Test public void testInitService_FixedThreadPool_TypeAttributeIsMissing() throws Exception { qbeanConfigPw.println("<QThreadPoolExecutor />"); qbeanConfigPw.flush(); setQBeanConfig(qbeanConfigBos.toByteArray()); try { qbean.initService(); fail("ConfigurationException was expected"); } catch (ConfigurationException e) { assertThat(e.getMessage().contains( QThreadPoolExecutor.XML_CONFIG_ATTR__EXEC_SRV_TYPE)); } }
private String get (String prop) throws ConfigurationException { String value = cfg.get (prop); if (value == null) throw new ConfigurationException ("null property "+prop); return value; } }
@Test public void testConstructor1() throws Throwable { Throwable nested = new ConfigurationException(); ConfigurationException configurationException = new ConfigurationException(nested); assertEquals("configurationException.getMessage()", "org.jpos.core.ConfigurationException", configurationException.getMessage()); assertSame("configurationException.getNested()", nested, configurationException.getNested()); }
@Test public void testSetConfigurationThrowsConfigurationException() throws Throwable { String[] args = new String[0]; try { new QFactory(null, new Q2(args)).setConfiguration(new BSHTransactionParticipant(), null); fail("Expected ConfigurationException to be thrown"); } catch (ConfigurationException ex) { assertEquals("ex.getMessage()", "org.jpos.core.ConfigurationException (java.lang.NullPointerException)", ex.getMessage()); assertNull("ex.getNested().getMessage()", ex.getNested().getMessage()); } }
@Test public void testInitService_FixedThreadPool_CorePoolSizeAttributeIsMissing() throws Exception { qbeanConfigPw.println("<QThreadPoolExecutor type='fixed' />"); qbeanConfigPw.flush(); setQBeanConfig(qbeanConfigBos.toByteArray()); try { qbean.initService(); fail("ConfigurationException was expected"); } catch (ConfigurationException e) { assertThat(e.getMessage().contains( QThreadPoolExecutor.XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE)); } }
private String get (String prop) throws ConfigurationException { String value = cfg.get (prop); if (value == null) throw new ConfigurationException ("null property "+prop); return value; } /**
@Test public void testConstructor2() throws Throwable { ConfigurationException configurationException = new ConfigurationException("testConfigurationExceptionDetail"); assertEquals("configurationException.getMessage()", "testConfigurationExceptionDetail", configurationException.getMessage()); assertNull("configurationException.getNested()", configurationException.getNested()); }
@Test public void testSetConfigurationThrowsConfigurationException1() throws Throwable { BSHTransactionParticipant bSHTransactionParticipant = new BSHTransactionParticipant(); try { bSHTransactionParticipant.setConfiguration(null); fail("Expected ConfigurationException to be thrown"); } catch (ConfigurationException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertNull("ex.getNested().getMessage()", ex.getNested().getMessage()); assertNull("bSHTransactionParticipant.prepareForAbortMethod", bSHTransactionParticipant.prepareForAbortMethod); assertNull("bSHTransactionParticipant.abortMethod", bSHTransactionParticipant.abortMethod); assertNull("bSHTransactionParticipant.commitMethod", bSHTransactionParticipant.commitMethod); assertNull("bSHTransactionParticipant.prepareMethod", bSHTransactionParticipant.prepareMethod); assertFalse("bSHTransactionParticipant.trace", bSHTransactionParticipant.trace); } } }
private void initJDBC() throws ConfigurationException { try { Class.forName(cfg.get("jdbc.driver")).newInstance(); } catch (Exception e) { throw new ConfigurationException (e); } } public synchronized Connection getConnection() {
@Test public void testSetConfigurationThrowsConfigurationException() throws Throwable { BSHGroupSelector bSHGroupSelector = new BSHGroupSelector(); try { bSHGroupSelector.setConfiguration(null); fail("Expected ConfigurationException to be thrown"); } catch (ConfigurationException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertNull("ex.getNested().getMessage()", ex.getNested().getMessage()); assertNull("bSHGroupSelector.prepareForAbortMethod", bSHGroupSelector.prepareForAbortMethod); assertNull("bSHGroupSelector.selectMethod", bSHGroupSelector.selectMethod); assertNull("bSHGroupSelector.commitMethod", bSHGroupSelector.commitMethod); assertNull("bSHGroupSelector.abortMethod", bSHGroupSelector.abortMethod); assertNull("bSHGroupSelector.prepareMethod", bSHGroupSelector.prepareMethod); assertFalse("bSHGroupSelector.trace", bSHGroupSelector.trace); } } }
public void setConfiguration (Configuration cfg) throws ConfigurationException { try { String log_priority = cfg.get("priority"); if ( log_priority != null && !log_priority.trim().equals("") && levels.containsKey(log_priority) ) { priority = log_priority; } } catch (Exception e) { throw new ConfigurationException (e); } }
@Ignore ("test failing") @Test public void testSetConfigurationThrowsConfigurationException() throws Throwable { GenericPackager genericPackager = new GenericPackager(); Configuration cfg = new SimpleConfiguration(); try { genericPackager.setConfiguration(cfg); fail("Expected ConfigurationException to be thrown"); } catch (ConfigurationException ex) { assertEquals( "ex.getMessage()", "org.jpos.iso.ISOException: java.lang.ClassNotFoundException: org.apache.crimson.parser.XMLReaderImpl (java.lang.ClassNotFoundException: org.apache.crimson.parser.XMLReaderImpl)", ex.getMessage()); assertEquals("ex.getNested().getMessage()", "java.lang.ClassNotFoundException: org.apache.crimson.parser.XMLReaderImpl", ex.getNested().getMessage()); assertEquals("(GenericValidatingPackager) genericValidatingPackager.getLogger().getName()", "", genericPackager.getLogger().getName()); assertEquals("(GenericValidatingPackager) genericValidatingPackager.getRealm()", "", genericPackager.getRealm()); } }
public void setConfiguration (Configuration cfg) throws ConfigurationException { this.cfg = cfg; serviceName = cfg.get ("channel", null); if (serviceName == null) throw new ConfigurationException ("property 'channel' is null"); } }