Repository: juddi Updated Branches: refs/heads/master 968e9e643 -> 1dcd5285f
JUDDI-943 WebHelper class: Client name not set in servletContext after getUDDIClient is called JUDDI-944 gitignore file Project: http://git-wip-us.apache.org/repos/asf/juddi/repo Commit: http://git-wip-us.apache.org/repos/asf/juddi/commit/1dcd5285 Tree: http://git-wip-us.apache.org/repos/asf/juddi/tree/1dcd5285 Diff: http://git-wip-us.apache.org/repos/asf/juddi/diff/1dcd5285 Branch: refs/heads/master Commit: 1dcd5285f3513f48aff5b763c8328dfbd2027dbb Parents: 968e9e6 Author: Alex <[email protected]> Authored: Mon Nov 16 19:58:39 2015 -0500 Committer: Alex <[email protected]> Committed: Mon Nov 16 19:58:39 2015 -0500 ---------------------------------------------------------------------- .gitignore | 4 + juddi-client/pom.xml | 6 + .../juddi/v3/client/config/WebHelper.java | 1 + .../juddi/v3/client/config/WebHelperTest.java | 152 +++++++++++++++++++ 4 files changed, 163 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/juddi/blob/1dcd5285/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index d229ff0..9c16e4f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ target **/.project **/.classpath **/.settings/ +.gradle/ +.svn/ +docs/db/ddl/*.ddl +uddi-tck/pref-rpt-*.txt \ No newline at end of file http://git-wip-us.apache.org/repos/asf/juddi/blob/1dcd5285/juddi-client/pom.xml ---------------------------------------------------------------------- diff --git a/juddi-client/pom.xml b/juddi-client/pom.xml index 5138cae..8c38d92 100644 --- a/juddi-client/pom.xml +++ b/juddi-client/pom.xml @@ -63,6 +63,12 @@ <artifactId>httpclient</artifactId> <version>4.2.5</version> </dependency> + <dependency> + <groupId>org.easymock</groupId> + <artifactId>easymock</artifactId> + <version>3.4</version> + <scope>test</scope> + </dependency> </dependencies> <build> <plugins> http://git-wip-us.apache.org/repos/asf/juddi/blob/1dcd5285/juddi-client/src/main/java/org/apache/juddi/v3/client/config/WebHelper.java ---------------------------------------------------------------------- diff --git a/juddi-client/src/main/java/org/apache/juddi/v3/client/config/WebHelper.java b/juddi-client/src/main/java/org/apache/juddi/v3/client/config/WebHelper.java index 0c33bc0..5935e05 100644 --- a/juddi-client/src/main/java/org/apache/juddi/v3/client/config/WebHelper.java +++ b/juddi-client/src/main/java/org/apache/juddi/v3/client/config/WebHelper.java @@ -81,6 +81,7 @@ public class WebHelper { } if (client.getName()!=null) { logger.info("Starting Client " + client.getName() + "..."); + clientName = client.getName(); } else { throw new ConfigurationException("A client name needs to be specified in the client config file."); } http://git-wip-us.apache.org/repos/asf/juddi/blob/1dcd5285/juddi-client/src/test/java/org/apache/juddi/v3/client/config/WebHelperTest.java ---------------------------------------------------------------------- diff --git a/juddi-client/src/test/java/org/apache/juddi/v3/client/config/WebHelperTest.java b/juddi-client/src/test/java/org/apache/juddi/v3/client/config/WebHelperTest.java new file mode 100644 index 0000000..57fdc2d --- /dev/null +++ b/juddi-client/src/test/java/org/apache/juddi/v3/client/config/WebHelperTest.java @@ -0,0 +1,152 @@ +/* + * Copyright 2015 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.juddi.v3.client.config; + +import java.util.UUID; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import org.apache.commons.configuration.ConfigurationException; +import static org.apache.juddi.v3.client.config.WebHelper.JUDDI_CLIENT_NAME; +import static org.apache.juddi.v3.client.config.WebHelper.UDDI_CLIENT_CONFIG_FILE; +import static org.apache.juddi.v3.client.config.WebHelper.UDDI_CLIENT_NAME; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; +import static org.easymock.EasyMock.*; +import org.junit.Assert; + +/** + * + * @author alex + */ +public class WebHelperTest { + + public WebHelperTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getUDDIClient method, of class WebHelper. + */ + @Test + public void testGetUDDIClient() throws Exception { + System.out.println("getUDDIClient"); + + ServletContext req = createNiceMock(ServletContext.class); + req.setAttribute(JUDDI_CLIENT_NAME, null); + expect(req.getInitParameter(WebHelper.JUDDI_CLIENT_NAME)).andReturn(null).times(0, 1); + //using default config + // expect(req.getInitParameter(WebHelper.UDDI_CLIENT_NAME)).andReturn(null).times(0, 2); + // expect(req.getInitParameter(WebHelper.UDDI_CLIENT_CONFIG_FILE)).andReturn(null).times(0, 2); + // expect(req.getInitParameter(WebHelper.JUDDI_CLIENT_TRANSPORT)).andReturn(null).times(0, 2); + //expect(req.getAttribute(WebHelper.JUDDI_CLIENT_NAME)).andReturn(null).times(0, 2); + //using default config + // expect(req.getAttribute(WebHelper.UDDI_CLIENT_NAME)).andReturn(null).times(0, 2); + //expect(req.getAttribute(WebHelper.UDDI_CLIENT_CONFIG_FILE)).andReturn(null).times(0, 2); + //expect(req.getAttribute(WebHelper.JUDDI_CLIENT_TRANSPORT)).andReturn(null).times(0, 2); + + replay(req); + + UDDIClient result = WebHelper.getUDDIClient(req); + Assert.assertNotNull(result); + } + + + @Test + public void testGetUDDIClientRandom() throws Exception { + System.out.println("testGetUDDIClientRandom"); + + String random = UUID.randomUUID().toString(); + ServletContext req = createNiceMock(ServletContext.class); + req.setAttribute(UDDI_CLIENT_NAME, random); + req.setAttribute(JUDDI_CLIENT_NAME, null); + expect(req.getInitParameter(WebHelper.JUDDI_CLIENT_NAME)).andReturn(null).times(0, 1); + expect(req.getInitParameter(WebHelper.UDDI_CLIENT_NAME)).andReturn(random).times(0, 1); + + + + + + //using default config + // expect(req.getInitParameter(WebHelper.UDDI_CLIENT_NAME)).andReturn(null).times(0, 2); + // expect(req.getInitParameter(WebHelper.UDDI_CLIENT_CONFIG_FILE)).andReturn(null).times(0, 2); + // expect(req.getInitParameter(WebHelper.JUDDI_CLIENT_TRANSPORT)).andReturn(null).times(0, 2); + //expect(req.getAttribute(WebHelper.JUDDI_CLIENT_NAME)).andReturn(null).times(0, 2); + //using default config + // expect(req.getAttribute(WebHelper.UDDI_CLIENT_NAME)).andReturn(null).times(0, 2); + //expect(req.getAttribute(WebHelper.UDDI_CLIENT_CONFIG_FILE)).andReturn(null).times(0, 2); + //expect(req.getAttribute(WebHelper.JUDDI_CLIENT_TRANSPORT)).andReturn(null).times(0, 2); + + replay(req); + + UDDIClient result = WebHelper.getUDDIClient(req); + Assert.assertNotNull(result); + } + + + @Test(expected = ConfigurationException.class) + public void testGetUDDIClientNoConfig() throws Exception { + System.out.println("testGetUDDIClientNoConfig"); + + + String random = UUID.randomUUID().toString(); + ServletContext req = createNiceMock(ServletContext.class); + + req.setAttribute(JUDDI_CLIENT_NAME, null); + expect(req.getInitParameter(WebHelper.JUDDI_CLIENT_NAME)).andReturn(null).times(0, 1); + req.setAttribute(UDDI_CLIENT_CONFIG_FILE, random); + expect(req.getInitParameter(WebHelper.UDDI_CLIENT_CONFIG_FILE)).andReturn(random).times(0, 1); + + + + + + + //using default config + // expect(req.getInitParameter(WebHelper.UDDI_CLIENT_NAME)).andReturn(null).times(0, 2); + // expect(req.getInitParameter(WebHelper.UDDI_CLIENT_CONFIG_FILE)).andReturn(null).times(0, 2); + // expect(req.getInitParameter(WebHelper.JUDDI_CLIENT_TRANSPORT)).andReturn(null).times(0, 2); + //expect(req.getAttribute(WebHelper.JUDDI_CLIENT_NAME)).andReturn(null).times(0, 2); + //using default config + // expect(req.getAttribute(WebHelper.UDDI_CLIENT_NAME)).andReturn(null).times(0, 2); + //expect(req.getAttribute(WebHelper.UDDI_CLIENT_CONFIG_FILE)).andReturn(null).times(0, 2); + //expect(req.getAttribute(WebHelper.JUDDI_CLIENT_TRANSPORT)).andReturn(null).times(0, 2); + + replay(req); + + UDDIClient result = WebHelper.getUDDIClient(req); + Assert.assertNotNull(result); + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
