@Test public void testGetBoolean1() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(new Properties()); simpleConfiguration.put("testString", ""); boolean result = simpleConfiguration.getBoolean("testString", false); assertFalse("result", result); }
@Test public void testGetBoolean5() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(new Properties()); simpleConfiguration.put("testString", ""); boolean result = simpleConfiguration.getBoolean("testString"); assertFalse("result", result); }
@Test public void testGetIntThrowsNumberFormatException() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(new Properties()); simpleConfiguration.put("testString", ""); try { simpleConfiguration.getInt("testString", 100); fail("Expected NumberFormatException to be thrown"); } catch (NumberFormatException ex) { assertEquals("ex.getMessage()", "For input string: \"\"", ex.getMessage()); } }
@Test public void testGet2() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(new Properties()); simpleConfiguration.put("testString", ""); String result = simpleConfiguration.get("testString", "testSimpleConfigurationDef"); assertEquals("result", "", result); }
@Test public void testGet4() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(new Properties()); simpleConfiguration.put("E", ""); String result = simpleConfiguration.get("E"); assertEquals("result", "", result); }
@Test public void testGetBoolean2() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(new Properties()); simpleConfiguration.put("testString", "testString"); boolean result = simpleConfiguration.getBoolean("testString", true); assertFalse("result", result); }
@Test public void testGetDoubleThrowsNumberFormatException1() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(new Properties()); simpleConfiguration.put("testString", ""); try { simpleConfiguration.getDouble("testString", 100.0); fail("Expected NumberFormatException to be thrown"); } catch (NumberFormatException ex) { assertEquals("ex.getMessage()", "empty String", ex.getMessage()); } }
@Test public void testPutThrowsNullPointerException() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration((Properties) null); try { simpleConfiguration.put("testSimpleConfigurationName", "testString"); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
@Test public void testGetAll() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(); simpleConfiguration.put("testString", ""); String[] result = simpleConfiguration.getAll("testString"); assertEquals("result.length", 1, result.length); assertEquals("result[0]", "", result[0]); }
@Test public void testSerializable() throws Throwable { SimpleConfiguration cfg = new SimpleConfiguration(); cfg.put ("A", "The Quick Brown Fox Jumps Over The Lazy Dog"); Configuration cfg1 = Serializer.serializeDeserialize(cfg); assertEquals("cfg.A should equal cfg1.A", cfg.get("A"), cfg1.get("A")); assertEquals ("cfg should equal cfg1", cfg, cfg1); } }
@Test public void testConvertToIRC() throws ConfigurationException { CMFConverter c = new CMFConverter(); SimpleConfiguration cfg = new SimpleConfiguration(); cfg.put("10000","----,jPOS error message"); c.setConfiguration(cfg); IRC irc = c.convert(new SimpleRC("0000", "")); assertEquals(c.convert(new SimpleRC("0000", "")), CMF.APPROVED); assertEquals(c.convert(new SimpleRC("0001", "")), CMF.HONOR_WITH_ID); assertEquals(c.convert(new SimpleRC("ZZZZ", "")), CMF.GENERAL_DECLINE); } }
@Test public void testCMFConverterOverride() throws ConfigurationException { CMFConverter c = new CMFConverter(); SimpleConfiguration cfg = new SimpleConfiguration(); cfg.put("10000","----,jPOS error message"); c.setConfiguration(cfg); assertEquals("Standard RC", new SimpleRC("0000", "APPROVED"), c.convert(CMF.APPROVED)); assertEquals("ResourceBundle override", new SimpleRC("ZZZZ", "General decline"), c.convert(CMF.GENERAL_DECLINE)); assertEquals("ResourceBundle override", new SimpleRC("9999", "Internal error"), c.convert(CMF.INTERNAL_ERROR)); assertEquals("Configuration override", new SimpleRC("----", "jPOS error message"), c.convert(CMF.JPOS)); }