Author: ropalka
Date: 2012-02-27 07:36:04 -0500 (Mon, 27 Feb 2012)
New Revision: 15753
Modified:
shared-testsuite/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/secureejb/SecureEJBTestCase.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/serviceref/ServiceRefClientTestCase.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/serviceref/ServiceRefEJBTestCase.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1581/JBWS1581EarTestCase.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1581/JBWS1581WarTestCase.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1841/JBWS1841TestCase.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws944/JBWS944TestCase.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefClientTestCase.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefEJBTestCase.java
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java
Log:
[JBWS-3444] properly teardown initial context to cleanup caches
Modified: shared-testsuite/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java
===================================================================
--- shared-testsuite/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java 2012-02-27
10:48:47 UTC (rev 15752)
+++ shared-testsuite/trunk/src/main/java/org/jboss/wsf/test/JBossWSTest.java 2012-02-27
12:36:04 UTC (rev 15753)
@@ -292,19 +292,19 @@
return env;
}
- /** Get the appclient remote env context
+ /** Gets the appclient remote env context.
+ * Every test calling this method have to ensure InitialContext.close()
+ * method is called at end of test to clean up all associated caches.
*/
protected static InitialContext getAppclientInitialContext() throws NamingException,
IOException
{
-// InitialContext iniCtx = new InitialContext();
-// Hashtable env = iniCtx.getEnvironment();
-// env.put(Context.PROVIDER_URL, "remote://" +
JBossWSTestHelper.getServerHost() + ":4448");
-// return new InitialContext(env);
final Hashtable<String, String> env =
getEnvironment("appclient.jndi.properties");
return new InitialContext(env);
}
/** Get the server remote env context
+ * Every test calling this method have to ensure InitialContext.close()
+ * method is called at end of test to clean up all associated caches.
*/
protected static InitialContext getServerInitialContext() throws NamingException,
IOException
{
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/secureejb/SecureEJBTestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/secureejb/SecureEJBTestCase.java 2012-02-27
10:48:47 UTC (rev 15752)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/secureejb/SecureEJBTestCase.java 2012-02-27
12:36:04 UTC (rev 15753)
@@ -43,16 +43,32 @@
{
public static final String USERNAME = "kermit";
public static final String PASSWORD = "thefrog";
+ private InitialContext appclientCtx;
public static Test suite() throws Exception
{
return new JBossWSTestSetup(SecureEJBTestCase.class,
"jaxrpc-samples-secureejb.jar,
jaxrpc-samples-secureejb-appclient.ear#jaxrpc-samples-secureejb-appclient.jar",
true);
}
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ appclientCtx = getAppclientInitialContext();
+ }
+
+ public void tearDown() throws Exception
+ {
+ if (appclientCtx != null)
+ {
+ appclientCtx.close();
+ appclientCtx = null;
+ }
+ super.tearDown();
+ }
+
public void testRoleSecuredServiceAccess() throws Exception
{
- InitialContext iniCtx = getAppclientInitialContext();
- Service service = (Service)iniCtx.lookup("java:service/RoleSecured");
+ Service service =
(Service)appclientCtx.lookup("java:service/RoleSecured");
QName portName = new QName("http://org.jboss.ws/samples/secureejb",
"RoleSecuredPort");
OrganizationService port = (OrganizationService)service.getPort(portName,
OrganizationService.class);
@@ -76,8 +92,7 @@
public void testBasicSecuredServiceAccess() throws Exception
{
- InitialContext iniCtx = getAppclientInitialContext();
- Service service = (Service)iniCtx.lookup("java:service/BasicSecured");
+ Service service =
(Service)appclientCtx.lookup("java:service/BasicSecured");
QName portName = new QName("http://org.jboss.ws/samples/secureejb",
"BasicSecuredPort");
OrganizationService port = (OrganizationService)service.getPort(portName,
OrganizationService.class);
@@ -101,8 +116,7 @@
public void testConfidentialServiceAccess() throws Exception
{
- InitialContext iniCtx = getAppclientInitialContext();
- Service service =
(Service)iniCtx.lookup("java:service/ConfidentialSecured");
+ Service service =
(Service)appclientCtx.lookup("java:service/ConfidentialSecured");
QName portName = new QName("http://org.jboss.ws/samples/secureejb",
"ConfidentialPort");
OrganizationService port = (OrganizationService)service.getPort(portName,
OrganizationService.class);
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/serviceref/ServiceRefClientTestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/serviceref/ServiceRefClientTestCase.java 2012-02-27
10:48:47 UTC (rev 15752)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/serviceref/ServiceRefClientTestCase.java 2012-02-27
12:36:04 UTC (rev 15753)
@@ -71,13 +71,24 @@
public void testApplicationClient() throws Exception
{
- final InitialContext ctx = getAppclientInitialContext();
- final TestEndpoint port1 =
(TestEndpoint)((Service)ctx.lookup("java:service1")).getPort(TestEndpoint.class);
- final TestEndpoint port2 =
((TestEndpointService)ctx.lookup("java:service2")).getTestEndpointPort();
- final String msg = "Hello World!";
+ InitialContext ctx = null;
+ try
+ {
+ ctx = getAppclientInitialContext();
+ final TestEndpoint port1 =
(TestEndpoint)((Service)ctx.lookup("java:service1")).getPort(TestEndpoint.class);
+ final TestEndpoint port2 =
((TestEndpointService)ctx.lookup("java:service2")).getTestEndpointPort();
+ final String msg = "Hello World!";
- assertEquals(msg, port1.echo(msg));
- assertEquals(msg, port2.echo(msg));
+ assertEquals(msg, port1.echo(msg));
+ assertEquals(msg, port2.echo(msg));
+ }
+ finally
+ {
+ if (ctx != null)
+ {
+ ctx.close();
+ }
+ }
}
}
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/serviceref/ServiceRefEJBTestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/serviceref/ServiceRefEJBTestCase.java 2012-02-27
10:48:47 UTC (rev 15752)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxrpc/samples/serviceref/ServiceRefEJBTestCase.java 2012-02-27
12:36:04 UTC (rev 15753)
@@ -21,13 +21,7 @@
*/
package org.jboss.test.ws.jaxrpc.samples.serviceref;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
import javax.naming.InitialContext;
-import javax.xml.namespace.QName;
-import javax.xml.rpc.Service;
import junit.framework.Test;
@@ -51,12 +45,23 @@
public void testEJBClient() throws Exception
{
- InitialContext iniCtx = getInitialContext();
- EJBRemoteHome ejbHome =
(EJBRemoteHome)iniCtx.lookup("ejb:/jaxrpc-samples-serviceref-ejbclient//EJBClient!"
+ EJBRemoteHome.class.getName());
- EJBRemote ejbRemote = ejbHome.create();
+ InitialContext iniCtx = null;
+ try
+ {
+ iniCtx = getServerInitialContext();
+ EJBRemoteHome ejbHome =
(EJBRemoteHome)iniCtx.lookup("ejb:/jaxrpc-samples-serviceref-ejbclient//EJBClient!"
+ EJBRemoteHome.class.getName());
+ EJBRemote ejbRemote = ejbHome.create();
- String helloWorld = "Hello World!";
- Object retObj = ejbRemote.echo(helloWorld);
- assertEquals(helloWorld, retObj);
+ String helloWorld = "Hello World!";
+ Object retObj = ejbRemote.echo(helloWorld);
+ assertEquals(helloWorld, retObj);
+ }
+ finally
+ {
+ if (iniCtx != null)
+ {
+ iniCtx.close();
+ }
+ }
}
}
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1581/JBWS1581EarTestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1581/JBWS1581EarTestCase.java 2012-02-27
10:48:47 UTC (rev 15752)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1581/JBWS1581EarTestCase.java 2012-02-27
12:36:04 UTC (rev 15753)
@@ -23,6 +23,7 @@
import java.net.URL;
+import javax.naming.InitialContext;
import javax.wsdl.Definition;
import javax.wsdl.factory.WSDLFactory;
@@ -55,8 +56,20 @@
public void testEJBVehicle() throws Exception
{
- EJB3Remote remote =
(EJB3Remote)getInitialContext().lookup("ejb:/jaxws-jbws1581-ejb3//EJB3Bean!" +
EJB3Remote.class.getName());
- String retStr = remote.runTest("Hello World!");
- assertEquals("Hello World!", retStr);
+ InitialContext iniCtx = null;
+ try
+ {
+ iniCtx = getServerInitialContext();
+ EJB3Remote remote =
(EJB3Remote)iniCtx.lookup("ejb:/jaxws-jbws1581-ejb3//EJB3Bean!" +
EJB3Remote.class.getName());
+ String retStr = remote.runTest("Hello World!");
+ assertEquals("Hello World!", retStr);
+ }
+ finally
+ {
+ if (iniCtx != null)
+ {
+ iniCtx.close();
+ }
+ }
}
}
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1581/JBWS1581WarTestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1581/JBWS1581WarTestCase.java 2012-02-27
10:48:47 UTC (rev 15752)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1581/JBWS1581WarTestCase.java 2012-02-27
12:36:04 UTC (rev 15753)
@@ -23,6 +23,7 @@
import java.net.URL;
+import javax.naming.InitialContext;
import javax.wsdl.Definition;
import javax.wsdl.factory.WSDLFactory;
@@ -55,8 +56,20 @@
public void testEJBVehicle() throws Exception
{
- EJB3Remote remote =
(EJB3Remote)getInitialContext().lookup("ejb:/jaxws-jbws1581-ejb3//EJB3Bean!" +
EJB3Remote.class.getName());
- String retStr = remote.runTest("Hello World!");
- assertEquals("Hello World!", retStr);
+ InitialContext iniCtx = null;
+ try
+ {
+ iniCtx = getServerInitialContext();
+ EJB3Remote remote =
(EJB3Remote)iniCtx.lookup("ejb:/jaxws-jbws1581-ejb3//EJB3Bean!" +
EJB3Remote.class.getName());
+ String retStr = remote.runTest("Hello World!");
+ assertEquals("Hello World!", retStr);
+ }
+ finally
+ {
+ if (iniCtx != null)
+ {
+ iniCtx.close();
+ }
+ }
}
}
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1841/JBWS1841TestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1841/JBWS1841TestCase.java 2012-02-27
10:48:47 UTC (rev 15752)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws1841/JBWS1841TestCase.java 2012-02-27
12:36:04 UTC (rev 15753)
@@ -43,7 +43,7 @@
private static EndpointInterface port;
private static StatelessRemote remote;
-
+ private static InitialContext ctx;
public static Test suite()
{
return new JBossWSTestSetup(JBWS1841TestCase.class,
"jaxws-jbws1841.jar");
@@ -57,11 +57,20 @@
QName serviceName = new
QName("http://www.openuri.org/2004/04/HelloWorld",
"EndpointService");
port = Service.create(wsdlURL, serviceName).getPort(EndpointInterface.class);
- InitialContext ctx = getInitialContext();
+ ctx = getServerInitialContext();
remote = (StatelessRemote)ctx.lookup("ejb:/jaxws-jbws1841//" +
StatelessBean.class.getSimpleName() + "!" + StatelessRemote.class.getName());
}
}
+ protected void tearDown() throws Exception
+ {
+ if (ctx != null)
+ {
+ ctx.close();
+ ctx = null;
+ }
+ }
+
public void testDirectWSInvocation() throws Exception
{
String result = port.echo("DirectWSInvocation");
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws944/JBWS944TestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws944/JBWS944TestCase.java 2012-02-27
10:48:47 UTC (rev 15752)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws944/JBWS944TestCase.java 2012-02-27
12:36:04 UTC (rev 15753)
@@ -56,26 +56,46 @@
public void testRemoteAccess() throws Exception
{
- InitialContext iniCtx = getInitialContext();
- EJB3RemoteBusinessInterface ejb3Remote =
(EJB3RemoteBusinessInterface)iniCtx.lookup("ejb:/jaxws-jbws944//FooBean01!" +
EJB3RemoteBusinessInterface.class.getName());
+ InitialContext iniCtx = null;
+ try {
+ iniCtx = getServerInitialContext();
+ EJB3RemoteBusinessInterface ejb3Remote =
(EJB3RemoteBusinessInterface)iniCtx.lookup("ejb:/jaxws-jbws944//FooBean01!" +
EJB3RemoteBusinessInterface.class.getName());
- String helloWorld = "Hello world!";
- Object retObj = ejb3Remote.echo(helloWorld);
- assertEquals(helloWorld, retObj);
+ String helloWorld = "Hello world!";
+ Object retObj = ejb3Remote.echo(helloWorld);
+ assertEquals(helloWorld, retObj);
+ }
+ finally
+ {
+ if (iniCtx != null)
+ {
+ iniCtx.close();
+ }
+ }
}
// This tests whether the remote proxy also implements
// the home interface and that it can be narrowed to it.
public void testNarrowedRemoteAccess() throws Exception
{
- InitialContext iniCtx = getInitialContext();
- Object obj = iniCtx.lookup("ejb:/jaxws-jbws944//FooBean01!" +
EJB3RemoteHome.class.getName());
- EJB3RemoteHome ejb3Home = (EJB3RemoteHome)PortableRemoteObject.narrow(obj,
EJB3RemoteHome.class);
- EJB3RemoteInterface ejb3Remote = ejb3Home.create();
+ InitialContext iniCtx = null;
+ try {
+ iniCtx = getServerInitialContext();
+ Object obj = iniCtx.lookup("ejb:/jaxws-jbws944//FooBean01!" +
EJB3RemoteHome.class.getName());
+ EJB3RemoteHome ejb3Home = (EJB3RemoteHome)PortableRemoteObject.narrow(obj,
EJB3RemoteHome.class);
+ EJB3RemoteInterface ejb3Remote = ejb3Home.create();
- String helloWorld = "Hello world!";
- Object retObj = ejb3Remote.echo(helloWorld);
- assertEquals(helloWorld, retObj);
+ String helloWorld = "Hello world!";
+ Object retObj = ejb3Remote.echo(helloWorld);
+ assertEquals(helloWorld, retObj);
+ }
+ finally
+ {
+ if (iniCtx != null)
+ {
+ iniCtx.close();
+ }
+ }
}
public void testWebService() throws Exception
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefClientTestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefClientTestCase.java 2012-02-27
10:48:47 UTC (rev 15752)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefClientTestCase.java 2012-02-27
12:36:04 UTC (rev 15753)
@@ -73,26 +73,36 @@
public void testApplicationClient() throws Exception
{
- InitialContext iniCtx = getAppclientInitialContext();
- Service service = (Service) iniCtx.lookup("java:service2");
- Endpoint port = service.getPort(Endpoint.class);
- assertNotNull(port);
+ InitialContext iniCtx = null;
+ try
+ {
+ iniCtx = getAppclientInitialContext();
+ Service service = (Service) iniCtx.lookup("java:service2");
+ Endpoint port = service.getPort(Endpoint.class);
+ assertNotNull(port);
- if(isIntegrationNative())
- {
- BindingProvider bp = (BindingProvider)port;
- boolean mtomEnabled = ((SOAPBinding)bp.getBinding()).isMTOMEnabled();
- assertTrue("MTOM should be enabled on port", mtomEnabled);
+ if(isIntegrationNative())
+ {
+ BindingProvider bp = (BindingProvider)port;
+ boolean mtomEnabled = ((SOAPBinding)bp.getBinding()).isMTOMEnabled();
+ assertTrue("MTOM should be enabled on port", mtomEnabled);
+ }
+ else
+ {
+ // MTOM property at service-ref level not possible with sun-ri
+ }
+
+ String request = "ApplicationClient";
+ String response = port.echo(request);
+ assertEquals(response, request);
}
- else
+ finally
{
- // MTOM property at service-ref level not possible with sun-ri
+ if (iniCtx != null)
+ {
+ iniCtx.close();
+ }
}
-
- String request = "ApplicationClient";
- String response = port.echo(request);
- assertEquals(response, request);
-
}
}
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefEJBTestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefEJBTestCase.java 2012-02-27
10:48:47 UTC (rev 15752)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/serviceref/ServiceRefEJBTestCase.java 2012-02-27
12:36:04 UTC (rev 15753)
@@ -72,12 +72,23 @@
public void testEJBClient() throws Exception
{
- InitialContext iniCtx = getInitialContext();
- EJBRemote ejbRemote =
(EJBRemote)iniCtx.lookup("ejb:/jaxws-samples-serviceref-ejbclient//EJBClient!" +
EJBRemote.class.getName());
+ InitialContext iniCtx = null;
+ try
+ {
+ iniCtx = getServerInitialContext();
+ EJBRemote ejbRemote =
(EJBRemote)iniCtx.lookup("ejb:/jaxws-samples-serviceref-ejbclient//EJBClient!" +
EJBRemote.class.getName());
- String helloWorld = "Hello World!";
- Object retObj = ejbRemote.echo(helloWorld);
- assertEquals(helloWorld, retObj);
+ String helloWorld = "Hello World!";
+ Object retObj = ejbRemote.echo(helloWorld);
+ assertEquals(helloWorld, retObj);
+ }
+ finally
+ {
+ if (iniCtx != null)
+ {
+ iniCtx.close();
+ }
+ }
}
}
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java 2012-02-27
10:48:47 UTC (rev 15752)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java 2012-02-27
12:36:04 UTC (rev 15753)
@@ -62,10 +62,11 @@
public void testEJB3Client() throws Exception
{
+ InitialContext iniCtx = null;
deploy("jaxws-samples-webserviceref-ejb3-client.jar");
try
{
- InitialContext iniCtx = getInitialContext();
+ iniCtx = getServerInitialContext();
EJB3Remote ejb3Remote =
(EJB3Remote)iniCtx.lookup("ejb:/jaxws-samples-webserviceref-ejb3-client//EJB3Client!"
+ EJB3Remote.class.getName());
String helloWorld = "Hello World!";
@@ -74,6 +75,10 @@
}
finally
{
+ if (iniCtx != null)
+ {
+ iniCtx.close();
+ }
undeploy("jaxws-samples-webserviceref-ejb3-client.jar");
}
}