Author: davidillsley
Date: Fri May 25 17:41:12 2007
New Revision: 541830

URL: http://svn.apache.org/viewvc?view=rev&rev=541830
Log:
Yes, more local transport tests.. seems to save about 6 seconds per test.

Added:
    
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalWithAddressingTestCase.java
Removed:
    
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounterMessageReceiver.java
Modified:
    webservices/axis2/trunk/java/modules/integration/itest-build.xml
    
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
    
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounter.java
    
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalTestCase.java

Modified: webservices/axis2/trunk/java/modules/integration/itest-build.xml
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/itest-build.xml?view=diff&rev=541830&r1=541829&r2=541830
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/itest-build.xml (original)
+++ webservices/axis2/trunk/java/modules/integration/itest-build.xml Fri May 25 
17:41:12 2007
@@ -125,6 +125,10 @@
                          
tofile="target/test-resources/repository-client/conf/axis2.xml"/>
                <mkdir dir="target/toWar/services/"/>
 
+               <mkdir dir="target/test-resources/local"/>
+               <copy 
file="../addressing/target/addressing-${addressing_version}.mar"
+                                         
tofile="target/test-resources/local/addressing.mar"/>
+                               
                <!-- Create Chunked enabled Repository -->
                <mkdir dir="target/test-resources/chunking-enabledRepository"/>
                <mkdir 
dir="target/test-resources/chunking-enabledRepository/conf"/>

Modified: 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java?view=diff&rev=541830&r1=541829&r2=541830
==============================================================================
--- 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
 Fri May 25 17:41:12 2007
@@ -1,110 +1,53 @@
+/*
+ * 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.axis2.engine;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axis2.Constants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.engine.util.RequestCounter;
-import org.apache.axis2.engine.util.RequestCounterMessageReceiver;
-import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.integration.UtilServerBasedTestCase;
-import org.apache.axis2.util.Utils;
-
-import javax.xml.namespace.QName;
-
-/*
-* Copyright 2001-2004 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.
-*
-*/
-
-public class ServiceGroupContextTest extends UtilServerBasedTestCase {
-
-    /**
-     * This test will first sends a request to a dummy service deployed. That 
service will get
-     * message contexts as inputs and will put a property in the service group 
context to count the
-     * number of requests. Then the client, upon receiving the response, 
extracts the sgc id from
-     * the received message (this will come as a reference parameter in the 
ReplyTo EPR) and sets
-     * that as a top level soap header in the next request to the same service 
group. Server will
-     * correctly identify the service group from the information sent by the 
client and retrieve the
-     * sgc earlier used and will use that for the current request as well. The 
service will retrieve
-     * the request count from the sgc and increase that by one.
-     * <p/>
-     * Test will asserts whether the client gets the number of requests as 2, 
when he invokes two
-     * times.
-     */
-
-    protected EndpointReference targetEPR = new 
EndpointReference("http://127.0.0.1:"; +
-            (UtilServer.TESTING_PORT) +
-            "/axis2/services/RequestCounter");
-    protected QName serviceName = new QName("RequestCounter");
-    protected QName operationName = new QName("getRequestCount");
-    protected QName transportName = new QName("http://localhost/my";, 
"NullTransport");
-    protected AxisService service;
-
-    public static Test suite() {
-        return getTestSetup(new TestSuite(ServiceGroupContextTest.class));
-    }
+import org.apache.axis2.integration.LocalWithAddressingTestCase;
 
+/**
+ * This test will first sends a request to a dummy service deployed. That 
service will get
+ * message contexts as inputs and will put a property in the service group 
context to count the
+ * number of requests. Then the client, upon receiving the response, extracts 
the sgc id from
+ * the received message (this will come as a reference parameter in the 
ReplyTo EPR) and sets
+ * that as a top level soap header in the next request to the same service 
group. Server will
+ * correctly identify the service group from the information sent by the 
client and retrieve the
+ * sgc earlier used and will use that for the current request as well. The 
service will retrieve
+ * the request count from the sgc and increase that by one.
+ * <p/>
+ * Test will asserts whether the client gets the number of requests as 2, when 
he invokes two
+ * times.
+ */
+public class ServiceGroupContextTest extends LocalWithAddressingTestCase {
     protected void setUp() throws Exception {
-        service = Utils.createSimpleService(serviceName, new 
RequestCounterMessageReceiver(),
-                                            RequestCounter.class.getName(), 
operationName);
-//        service.setScope(Constants.SCOPE_TRANSPORT_SESSION);
+       super.setUp();
+       AxisService service = deployClassAsService("RequestCounter", 
RequestCounter.class);
         service.setScope(Constants.SCOPE_SOAP_SESSION);
-        UtilServer.deployService(service);
-    }
-
-    protected void tearDown() throws Exception {
-        UtilServer.unDeployService(serviceName);
-        UtilServer.unDeployClientService();
     }
 
     public void testEchoXMLSync() throws Exception {
-        SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
-
-        SOAPEnvelope payload = fac.getDefaultEnvelope();
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setManageSession(true);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-
-        options.setAction(operationName.getLocalPart());
+        ServiceClient sender = getClient("RequestCounter", "getRequestCount");
+        sender.getOptions().setManageSession(true);
+        
+        sender.sendReceive(null);
 
-        ConfigurationContext configContext =
-                
ConfigurationContextFactory.createConfigurationContextFromFileSystem(
-                        "target/test-resources/integrationRepo", null);
-        configContext.getAxisConfiguration().engageModule("addressing");
-        ServiceClient sender = new ServiceClient(configContext, null);
-        sender.setOptions(options);
-
-        sender.sendReceive(payload.getBody().getFirstElement());
-
-        SOAPEnvelope defaultEnvelope = fac.getDefaultEnvelope();
-
-        //TODO : ple imporove this , what I have done is a hack
-        OMElement result2 = 
sender.sendReceive(defaultEnvelope.getBody().getFirstElement());
+        OMElement result2 = sender.sendReceive(null);
         String text = result2.getText();
         assertEquals("Number of requests should be 2", 2, 
Integer.parseInt(text));
     }
-
 }

Modified: 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounter.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounter.java?view=diff&rev=541830&r1=541829&r2=541830
==============================================================================
--- 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounter.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/RequestCounter.java
 Fri May 25 17:41:12 2007
@@ -1,10 +1,4 @@
-package org.apache.axis2.engine.util;
-
-import org.apache.axis2.context.MessageContext;
-
 /*
- * Copyright 2001-2004 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
@@ -18,21 +12,36 @@
  * limitations under the License.
  *
  */
+package org.apache.axis2.engine.util;
 
-public class RequestCounter {
+import javax.xml.namespace.QName;
 
-    public static final String REQUEST_COUNT = "Request_Count";
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceGroupContext;
+
+public class RequestCounter {
 
-    public void getRequestCount(MessageContext inMessageContext, 
MessageContext outMessageContext) {
-        Integer requestCount =
-                
(Integer)inMessageContext.getServiceGroupContext().getProperty(REQUEST_COUNT);
-        if (requestCount == null) {
-            requestCount = new Integer(1);
-        } else {
-            requestCount = new Integer(requestCount.intValue() + 1);
-        }
+       private static final String REQUEST_COUNT = "Request_Count";
 
-        inMessageContext.getServiceGroupContext().setProperty(REQUEST_COUNT, 
requestCount);
-    }
+       public OMElement getRequestCount(OMElement oe) {
+               ServiceGroupContext sgc = 
MessageContext.getCurrentMessageContext().getServiceGroupContext();
+               
+               Integer requestCount = (Integer)sgc.getProperty(REQUEST_COUNT);
+               if (requestCount == null) {
+                       requestCount = new Integer(1);
+               } else {
+                       requestCount = new Integer(requestCount.intValue() + 1);
+               }
+
+               sgc.setProperty(REQUEST_COUNT, requestCount);
+               
+               QName qn = new QName("http://ws.apache.org/axis2/namespaces/";, 
"RequestCount","axis2");
+               OMElement response = 
OMAbstractFactory.getOMFactory().createOMElement(qn);
+               response.setText(requestCount.toString());
+               
+               return response;
+       }
 
 }

Modified: 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalTestCase.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalTestCase.java?view=diff&rev=541830&r1=541829&r2=541830
==============================================================================
--- 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalTestCase.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalTestCase.java
 Fri May 25 17:41:12 2007
@@ -71,12 +71,6 @@
         addOutPhases(serverConfig.getOutFlowPhases());
         addOutPhases(serverConfig.getOutFaultFlowPhases());
 
-        // NOTE : If you want addressing (which you probably do), we can do 
something
-        // like this, or we can pull it off the classpath (better solution?)
-        //
-        // serverConfig.deployModule("repo/modules/addressing.mar");
-        // serverConfig.engageModule("addressing");
-
         ///////////////////////////////////////////////////////////////////////
         // Set up raw message receivers for OMElement based tests
 

Added: 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalWithAddressingTestCase.java
URL: 
http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalWithAddressingTestCase.java?view=auto&rev=541830
==============================================================================
--- 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalWithAddressingTestCase.java
 (added)
+++ 
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/LocalWithAddressingTestCase.java
 Fri May 25 17:41:12 2007
@@ -0,0 +1,36 @@
+/*
+ * 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.axis2.integration;
+
+
+/**
+ * LocalWithAddressingTestCase is an extendable base class which provides 
common functionality
+ * for building JUnit tests which exercise Axis2 using the (fast, in-process)
+ * "local" transport (with the addressing module engaged).
+ */
+public class LocalWithAddressingTestCase extends LocalTestCase {
+    protected void setUp() throws Exception {
+       super.setUp();
+        // NOTE : If you want addressing (which you probably do), we can do 
something
+        // like this, or we can pull it off the classpath (better solution?)
+        
+       String addressingModuleLocation = 
System.getProperty("basedir",".")+"/target/test-resources/local/addressing.mar";
+       
+        serverConfig.deployModule(addressingModuleLocation);
+        serverConfig.engageModule("addressing");
+        
+        
clientCtx.getAxisConfiguration().deployModule(addressingModuleLocation);
+        clientCtx.getAxisConfiguration().engageModule("addressing");
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to