Permalink
Browse files

Restore boot time ssl property after test cases complete. Revert chan…

…ge to assertion test. Safely remove existing ssl property.
  • Loading branch information...
whitingjr committed Dec 2, 2015
1 parent b86e07a commit 274f38254203c26b0ad890cfd93548ce5a2cd3a9
Showing with 28 additions and 5 deletions.
  1. +2 −2 org/postgresql/test/TestUtil.java
  2. +26 −3 org/postgresql/test/jdbc2/PGPropertyTest.java
@@ -58,11 +58,11 @@ public static String getURL(String server, int port)
sendBufferSize = "&sendBufferSize="+getSendBufferSize();
}

String ssl = "";
String ssl = "";
if (getSSL() != null ){
ssl = "&ssl="+getSSL();
}
return "jdbc:postgresql://"
+ server + ":"
+ port + "/"
@@ -204,9 +204,11 @@ public void testIsPresentWithParseURLResult() throws Exception
givenProperties.setProperty("user", TestUtil.getUser());
givenProperties.setProperty("password", TestUtil.getPassword());

System.setProperty("ssl", null);
Properties sysProperties = System.getProperties();
sysProperties.remove("ssl");
System.setProperties(sysProperties);
Properties parsedProperties = Driver.parseURL(TestUtil.getURL(), givenProperties);
Assert.assertTrue("SSL property should not be present", PGProperty.SSL.isPresent(parsedProperties));
Assert.assertFalse("SSL property should not be present", PGProperty.SSL.isPresent(parsedProperties));

System.setProperty("ssl", "true");
givenProperties.setProperty("ssl", "true");
@@ -236,10 +238,31 @@ public void testNullValue()
{
Properties empty = new Properties();
assertNull(PGProperty.LOG_LEVEL.getSetString(empty));
assertNull(PGProperty.LOG_LEVEL.getSetString(empty));
Properties withLogging = new Properties();
withLogging.setProperty(PGProperty.LOG_LEVEL.getName(), "2");
assertNotNull(PGProperty.LOG_LEVEL.getSetString(withLogging));
}

public void setUp()
{
bootSSLPropertyValue = System.getProperty("ssl");
}

public void tearDown()
{
if (bootSSLPropertyValue == null) {
System.getProperties().remove("ssl");
}
else
{
System.setProperty("ssl", bootSSLPropertyValue);
}
}

/**
* Some tests modify the "ssl" system property. To not disturb
* other test cases in the suite store the value of the property
* and restore it.
*/
private String bootSSLPropertyValue;
}

0 comments on commit 274f382

Please sign in to comment.