Repository: qpid-jms Updated Branches: refs/heads/master cbded4573 -> f315bd309
Cover some additional code paths. Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/936098ec Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/936098ec Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/936098ec Branch: refs/heads/master Commit: 936098ec5ebc8f577d5fd5c29150fddae9d7dff6 Parents: cbded45 Author: Timothy Bish <[email protected]> Authored: Tue Oct 7 17:58:32 2014 -0400 Committer: Timothy Bish <[email protected]> Committed: Tue Oct 7 17:58:32 2014 -0400 ---------------------------------------------------------------------- .../apache/qpid/jms/util/PropertyUtilTest.java | 76 +++++++++++++++++++- 1 file changed, 73 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/936098ec/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/PropertyUtilTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/PropertyUtilTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/PropertyUtilTest.java index feb14a7..38bb946 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/PropertyUtilTest.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/PropertyUtilTest.java @@ -65,7 +65,7 @@ public class PropertyUtilTest { private URI uriValue; private SSLContext context; - private final Embedded embedded = new Embedded(); + private Embedded embedded = new Embedded(); public Options() { } @@ -115,28 +115,49 @@ public class PropertyUtilTest { return booleanValue; } - public URI getUriValue() { + public URI getURIValue() { return uriValue; } - public URL getUrlValue() { + public void setURIValue(URI uriValue) { + this.uriValue = uriValue; + } + + public URL getURLValue() { return urlValue; } + public void setURLValue(URL urlValue) { + this.urlValue = urlValue; + } + public SSLContext getSSLContext() { return context; } + public void setSSLContext(SSLContext context) { + this.context = context; + } + public Embedded getEmbedded() { return embedded; } + public void setEmbedded(Embedded embedded) { + this.embedded = embedded; + } + public void setNotReadable(String value) { this.notReadable = value; } } @Test + public void test() { + new PropertyUtil(); + } + + @Test public void testReplaceQueryUsingMap() throws URISyntaxException { URI original = new URI("http://www.example.com?option=true"); @@ -426,6 +447,48 @@ public class PropertyUtilTest { } @Test + public void testGetPropertiesHandlesURIs() throws Exception { + Options configObject = new Options("foo", "bar"); + + configObject.setURIValue(new URI("test://test")); + + Map<String, String> properties = PropertyUtil.getProperties(configObject); + + assertFalse(properties.isEmpty()); + assertEquals("foo", properties.get("firstName")); + assertEquals("bar", properties.get("lastName")); + assertEquals("test://test", properties.get("URIValue")); + } + + @Test + public void testGetPropertiesHandlesURLs() throws Exception { + Options configObject = new Options("foo", "bar"); + + configObject.setURLValue(new URL("http://www.domain.com")); + + Map<String, String> properties = PropertyUtil.getProperties(configObject); + + assertFalse(properties.isEmpty()); + assertEquals("foo", properties.get("firstName")); + assertEquals("bar", properties.get("lastName")); + assertEquals("http://www.domain.com", properties.get("URLValue")); + } + + @Test + public void testGetPropertiesIgnoresSSLContext() throws Exception { + Options configObject = new Options("foo", "bar"); + + configObject.setSSLContext(SSLContext.getDefault()); + Map<String, String> properties = PropertyUtil.getProperties(configObject); + + assertFalse(properties.isEmpty()); + assertEquals("foo", properties.get("firstName")); + assertEquals("bar", properties.get("lastName")); + + assertFalse(properties.containsKey("sslContext")); + } + + @Test public void testGetProperty() throws Exception { Options configObject = new Options("foo", "bar"); Object result = PropertyUtil.getProperty(configObject, "firstName"); @@ -456,6 +519,13 @@ public class PropertyUtilTest { } @Test + public void testSetPropertyOfURI() throws Exception { + Options configObject = new Options(); + assertTrue(PropertyUtil.setProperty(configObject, "URIValue", "test://foo")); + assertEquals("test://foo", configObject.getURIValue().toString()); + } + + @Test public void testSetPropertyToNull() throws Exception { Options configObject = new Options(); configObject.setFirstName("foo"); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
