private Configuration serverConfiguration() { Properties props = new Properties(); props.put("keystore", "src/test/resources/keystore.jks"); props.put("storepassword", "password"); props.put("keypassword", "password"); // props.put("addEnabledCipherSuite", "SSL_RSA_WITH_3DES_EDE_CBC_SHA"); return new SimpleConfiguration(props); }
@Test public void testGet() throws Throwable { String result = new SimpleConfiguration(new Properties()).get("testSimpleConfigurationName", null); assertNull("result", result); }
@Test public void testGetAll1() throws Throwable { String[] result = new SimpleConfiguration(new Properties()).getAll("testSimpleConfigurationName"); assertEquals("result.length", 0, result.length); }
@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 testGet2() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(new Properties()); simpleConfiguration.put("testString", ""); String result = simpleConfiguration.get("testString", "testSimpleConfigurationDef"); assertEquals("result", "", result); }
@Test public void testGetBoolean() throws Throwable { boolean result = new SimpleConfiguration().getBoolean("testSimpleConfigurationName", true); assertTrue("result", result); }
@Test public void testGetDouble() throws Throwable { double result = new SimpleConfiguration(new Properties()).getDouble("testSimpleConfigurationName"); assertEquals("result", 0.0, result, 1.0E-6); }
@Test public void testGetInt() throws Throwable { int result = new SimpleConfiguration(new Properties()).getInt("testSimpleConfigurationName", 100); assertEquals("result", 100, result); }
@Test public void testGetLong3() throws Throwable { Properties props = new Properties(); props.clear(); props.put("testString", "testString"); String name = (String) props.put("testString", "4"); long result = new SimpleConfiguration(props).getLong(name); assertEquals("result", 4L, result); }
@Test public void testLoadThrowsNullPointerException() throws Throwable { SimpleConfiguration simpleConfiguration = new SimpleConfiguration(); try { simpleConfiguration.load(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { // expected } }
@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 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 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 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()); } }
public double[] getDoubles (String name) { String[] ss = getAll (name); double[] dd = new double[ss.length]; for (int i=0; i<ss.length; i++) dd[i] = Double.valueOf(ss[i].trim()); return dd; } public boolean[] getBooleans (String name) {
public String get (String name) { return get(name, ""); } public int getInt (String name) {
public SimpleConfiguration (String filename) throws IOException { props = new Properties(); load (filename); }
@Test public void testGetBoolean6() throws Throwable { Properties props = new Properties(); SimpleConfiguration simpleConfiguration = new SimpleConfiguration(props); props.clear(); props.put("testString", "testString"); String name = (String) props.put("testString", new ArrayList()); boolean result = simpleConfiguration.getBoolean(name); assertFalse("result", result); }
@Test public void testGetDouble2() throws Throwable { double result = new SimpleConfiguration(new Properties()).getDouble("testSimpleConfigurationName", 100.0); assertEquals("result", 100.0, result, 1.0E-6); }
@Test public void testGetInt1() throws Throwable { int result = new SimpleConfiguration(new Properties()).getInt("testSimpleConfigurationName", 0); assertEquals("result", 0, result); }