Author: veithen
Date: Sun Sep 28 04:51:44 2008
New Revision: 699803

URL: http://svn.apache.org/viewvc?rev=699803&view=rev
Log:
Transport test kit: Introduced two additional configuration hooks and added 
some documentation.

Added:
    
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContextConfigurator.java
    
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContextConfigurator.java
Modified:
    
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/TransportDescriptionFactory.java
    
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContext.java
    
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java

Modified: 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/TransportDescriptionFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/TransportDescriptionFactory.java?rev=699803&r1=699802&r2=699803&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/TransportDescriptionFactory.java
 (original)
+++ 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/TransportDescriptionFactory.java
 Sun Sep 28 04:51:44 2008
@@ -21,7 +21,18 @@
 
 import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.description.TransportOutDescription;
+import 
org.apache.axis2.transport.testkit.axis2.client.AxisTestClientContextConfigurator;
+import 
org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpointContextConfigurator;
 
+/**
+ * Resource used to create the [EMAIL PROTECTED] TransportInDescription} and
+ * [EMAIL PROTECTED] TransportOutDescription} objects for a transport under 
test.
+ * <p>
+ * Note that this resource is used on both client and server side.
+ * If the transport needs different configurations on client and server side,
+ * use [EMAIL PROTECTED] AxisTestClientContextConfigurator} and/or
+ * [EMAIL PROTECTED] AxisTestEndpointContextConfigurator}.
+ */
 public interface TransportDescriptionFactory {
     TransportOutDescription createTransportOutDescription() throws Exception;
     

Modified: 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContext.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContext.java?rev=699803&r1=699802&r2=699803&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContext.java
 (original)
+++ 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContext.java
 Sun Sep 28 04:51:44 2008
@@ -21,33 +21,80 @@
 
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.ListenerManager;
 import org.apache.axis2.transport.CustomAxisConfigurator;
 import org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory;
 
+/**
+ * Resource maintaining the [EMAIL PROTECTED] ConfigurationContext} for [EMAIL 
PROTECTED] AxisTestClient}
+ * instances.
+ * <p>
+ * Dependencies:
+ * <dl>
+ *   <dt>[EMAIL PROTECTED] TransportDescriptionFactory} (1)</dt>
+ *   <dd>Used to create transport descriptions.</dd>
+ *   <dt>[EMAIL PROTECTED] AxisTestClientContextConfigurator} (0..*)</dt>
+ *   <dd>Used to determine whether a transport listener is required and to
+ *       configure the transport.</dd>
+ * </dl>
+ */
 public class AxisTestClientContext {
     public static final AxisTestClientContext INSTANCE = new 
AxisTestClientContext();
     
     private TransportOutDescription trpOutDesc;
     private ConfigurationContext cfgCtx;
+    private ListenerManager listenerManager;
     
     private AxisTestClientContext() {}
     
     @SuppressWarnings("unused")
-    private void setUp(TransportDescriptionFactory tdf) throws Exception {
+    private void setUp(TransportDescriptionFactory tdf, 
AxisTestClientContextConfigurator[] configurators) throws Exception {
         cfgCtx = ConfigurationContextFactory.createConfigurationContext(new 
CustomAxisConfigurator());
         AxisConfiguration axisCfg = cfgCtx.getAxisConfiguration();
 
         trpOutDesc = tdf.createTransportOutDescription();
         axisCfg.addTransportOut(trpOutDesc);
         trpOutDesc.getSender().init(cfgCtx, trpOutDesc);
+        
+        boolean useListener = false;
+        for (AxisTestClientContextConfigurator configurator : configurators) {
+            if (configurator.isTransportListenerRequired()) {
+                useListener = true;
+                break;
+            }
+        }
+        
+        TransportInDescription trpInDesc;
+        if (useListener) {
+            trpInDesc = tdf.createTransportInDescription();
+        } else {
+            trpInDesc = null;
+        }
+        
+        for (AxisTestClientContextConfigurator configurator : configurators) {
+            configurator.setupTransport(trpInDesc, trpOutDesc);
+        }
+        
+        if (useListener) {
+            listenerManager = new ListenerManager();
+            listenerManager.init(cfgCtx);
+            cfgCtx.setTransportManager(listenerManager);
+            listenerManager.addListener(trpInDesc, false);
+            listenerManager.start();
+        }
     }
     
     @SuppressWarnings("unused")
     private void tearDown() throws Exception {
         trpOutDesc.getSender().stop();
         trpOutDesc = null;
+        if (listenerManager != null) {
+            listenerManager.stop();
+            listenerManager = null;
+        }
         cfgCtx.terminate();
         cfgCtx = null;
     }

Added: 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContextConfigurator.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContextConfigurator.java?rev=699803&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContextConfigurator.java
 (added)
+++ 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/client/AxisTestClientContextConfigurator.java
 Sun Sep 28 04:51:44 2008
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.transport.testkit.axis2.client;
+
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.TransportOutDescription;
+
+public interface AxisTestClientContextConfigurator {
+    /**
+     * Determine whether a transport listener is required on client side.
+     * 
+     * @return true if a transport listener instance is required
+     */
+    boolean isTransportListenerRequired();
+    
+    /**
+     * Setup the transport on client side.
+     * 
+     * @param trpInDesc
+     * @param trpOutDesc
+     */
+    void setupTransport(TransportInDescription trpInDesc, 
TransportOutDescription trpOutDesc);
+}

Modified: 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java?rev=699803&r1=699802&r2=699803&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java
 (original)
+++ 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContext.java
 Sun Sep 28 04:51:44 2008
@@ -30,6 +30,18 @@
 import org.apache.axis2.transport.UtilsTransportServer;
 import org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory;
 
+/**
+ * Resource maintaining the [EMAIL PROTECTED] ConfigurationContext} for [EMAIL 
PROTECTED] AxisTestEndpoint}
+ * instances. This class provides the Axis2 server environment.
+ * <p>
+ * Dependencies:
+ * <dl>
+ *   <dt>[EMAIL PROTECTED] TransportDescriptionFactory} (1)</dt>
+ *   <dd>Used to create transport descriptions.</dd>
+ *   <dt>[EMAIL PROTECTED] AxisTestEndpointContextConfigurator} (0..*)</dt>
+ *   <dd>Used to configure the transport.</dd>
+ * </dl>
+ */
 public class AxisTestEndpointContext {
     public static final AxisTestEndpointContext INSTANCE = new 
AxisTestEndpointContext();
     
@@ -39,7 +51,7 @@
     private AxisTestEndpointContext() {}
     
     @SuppressWarnings("unused")
-    private void setUp(TransportDescriptionFactory tdf) throws Exception {
+    private void setUp(TransportDescriptionFactory tdf, 
AxisTestEndpointContextConfigurator[] configurators) throws Exception {
         
         server = new UtilsTransportServer();
         
@@ -48,6 +60,10 @@
         listener = trpInDesc.getReceiver();
         server.addTransport(trpInDesc, trpOutDesc);
         
+        for (AxisTestEndpointContextConfigurator configurator : configurators) 
{
+            configurator.setupTransport(trpInDesc, trpOutDesc);
+        }
+        
         ConfigurationContext cfgCtx = server.getConfigurationContext();
         
         cfgCtx.setContextRoot("/");

Added: 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContextConfigurator.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContextConfigurator.java?rev=699803&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContextConfigurator.java
 (added)
+++ 
webservices/commons/trunk/modules/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpointContextConfigurator.java
 Sun Sep 28 04:51:44 2008
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.transport.testkit.axis2.endpoint;
+
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.TransportOutDescription;
+
+public interface AxisTestEndpointContextConfigurator {
+    /**
+     * Setup the transport on server side.
+     * 
+     * @param trpInDesc
+     * @param trpOutDesc
+     */
+    void setupTransport(TransportInDescription trpInDesc, 
TransportOutDescription trpOutDesc);
+}


Reply via email to