axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hemap...@apache.org
Subject svn commit: r111243 - in webservices/axis/trunk/java/dev/scratch/prototype2: . src/java/org/apache/axis/client src/java/org/apache/axis/impl/transport/http src/test-resources src/test/org/apache/axis/engine
Date Wed, 08 Dec 2004 10:23:03 GMT
Author: hemapani
Date: Wed Dec  8 02:23:01 2004
New Revision: 111243

URL: http://svn.apache.org/viewcvs?view=rev&rev=111243
Log:
include the full path test case
Added:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/SimpleAxisServerTest.java
Modified:
   webservices/axis/trunk/java/dev/scratch/prototype2/project.xml
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/transport/http/SimpleAxisServer.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/project.xml
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/project.xml?view=diff&rev=111243&p1=webservices/axis/trunk/java/dev/scratch/prototype2/project.xml&r1=111242&p2=webservices/axis/trunk/java/dev/scratch/prototype2/project.xml&r2=111243
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/project.xml	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/project.xml	Wed Dec  8 02:23:01 2004
@@ -81,7 +81,7 @@
       <excludes>
         <exclude>**/*Abstract*.java</exclude>
 	    <exclude>**/*Util*.java</exclude>
-		<exclude>**/*EchoRawXMLTest.java</exclude>
+		<!-- <exclude>**/*EchoRawXMLTest.java</exclude> -->
       </excludes>
       <includes>
         <include>**/*Test.java</include>

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java?view=diff&rev=111243&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java&r1=111242&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java&r2=111243
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java
(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/client/Call.java
Wed Dec  8 02:23:01 2004
@@ -43,20 +43,25 @@
 import org.apache.axis.om.SOAPBody;
 import org.apache.axis.om.SOAPEnvelope;
 import org.apache.axis.registry.EngineRegistry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * This is conveneice API for the User who do not need to see the complexity of the 
- * Engine.  
+ * Engine. 
+ * //TODO this a a MOCK call things are subjected to be decided  
  * @author Srinath Perera (hemapani@opensource.lk)
  */
 public class Call {
     private EngineRegistry registry;
+    protected Log log = LogFactory.getLog(getClass());
+    
     
     public Call(){
         //TODO look for the Client XML and creatre a Engine registy
         this.registry = new EngineRegistryImpl(new GlobalImpl());
     }
-    //TODO this a a MOCK call things are subjected to be decided 
+    
     
     public OMElement syncCall(OMElement in,URL url) throws AxisFault{
         try {
@@ -74,7 +79,6 @@
             msgctx.setProperty(MessageContext.TRANSPORT_DATA,out);
             msgctx.setProperty(MessageContext.TRANSPORT_TYPE,TransportSenderLocator.TRANSPORT_HTTP);
             msgctx.setProperty(MessageContext.REQUEST_URL,url);
-            
             engine.send(msgctx);
             
             MessageContext reposne = createIncomingMessageContext(urlConnect.getInputStream(),engine);

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/transport/http/SimpleAxisServer.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/transport/http/SimpleAxisServer.java?view=diff&rev=111243&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/transport/http/SimpleAxisServer.java&r1=111242&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/transport/http/SimpleAxisServer.java&r2=111243
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/transport/http/SimpleAxisServer.java
(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/transport/http/SimpleAxisServer.java
Wed Dec  8 02:23:01 2004
@@ -43,10 +43,11 @@
  * @author Alireza Taherkordi (a_taherkordi@users.sourceforge.net)
  */
 public class SimpleAxisServer implements Runnable {
-    protected static Log log =
+    protected Log log =
             LogFactory.getLog(SimpleAxisServer.class.getName());
-    private static AxisEngine myAxisServer = null;
-    private ServerSocket serverSocket;    
+    private AxisEngine engine = null;
+    private ServerSocket serverSocket;  
+    private Socket socket = null;  
     /**
     are we stopped?
     latch to true if stop() is called
@@ -55,11 +56,10 @@
     
 
     public SimpleAxisServer(AxisEngine myAxisServer) {
-    	SimpleAxisServer.myAxisServer = myAxisServer;
+    	this.engine = myAxisServer;
 		
     }
 
-
     /**
      * stop the server if not already told to.
      * @throws Throwable
@@ -69,10 +69,6 @@
         super.finalize();
     }
 
-
-
-
-
     /**
      * Accept requests from a given TCP port and send them through the
      * Axis engine for processing.
@@ -81,9 +77,8 @@
         try {
             // Accept and process requests from the socket
             while (!stopped) {
-                Socket socket = null;
                 try {
-                    socket = serverSocket.accept();
+                    this.socket = serverSocket.accept();
                    
                 } catch (java.io.InterruptedIOException iie) {
                 } catch (Exception e) {
@@ -91,16 +86,17 @@
                     break;
                 }
                 if (socket != null) {
-                    ServerHttpHandler worker = new ServerHttpHandler(this, socket,myAxisServer);
+                    ServerHttpHandler worker = new ServerHttpHandler(this, socket,engine);
                     MessageContext msgContext = worker.parseHTTPHeaders();
-                    myAxisServer.recive(msgContext);
-                    socket.close();
+                    engine.recive(msgContext);
+                    this.socket.close();
+                    this.socket = null;
                 }
             }
         } catch (AxisFault e) {
-            e.printStackTrace();
+            log.error(e);
         }catch (IOException e) {
-            e.printStackTrace();
+            log.error(e);
         }
         stop();
         log.info("Simple Axis Server Quit");
@@ -138,6 +134,7 @@
      * This will interrupt any pending accept().
      */
     public void stop() {
+        log.info("stop called");
         //recognise use before we are live
         if(stopped ) {
             return;
@@ -151,15 +148,22 @@
         try {
             if(serverSocket != null) {
                 serverSocket.close();
+                while(socket != null){
+                    try {
+                        //make sure all sockets closed by the time 
+                        //else we got in to lot of trouble testing
+                        Thread.sleep(1000);
+                    } catch (InterruptedException e1) {
+                        log.error(e1);
+                    }
+                }
             }
         } catch (IOException e) {
             log.info(e);
         } finally {
             serverSocket=null;
         }
-
         log.info("Simple Axis Server Quits");
-
     }
 
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties?view=diff&rev=111243&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties&r1=111242&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties&r2=111243
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties
(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties
Wed Dec  8 02:23:01 2004
@@ -1,9 +1,9 @@
 #### Use two appenders, one to log to console, another to log to a file
-log4j.rootCategory=debug, R
+log4j.rootCategory=info, R
 
 ####  appender writes to a file
 log4j.appender.R=org.apache.log4j.RollingFileAppender
-log4j.appender.R.File=target/axis.log
+log4j.appender.R.File=axis.log
 
 # Control the maximum log file size
 log4j.appender.R.MaxFileSize=10000KB

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java?view=diff&rev=111243&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java&r1=111242&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java&r2=111243
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java
(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java
Wed Dec  8 02:23:01 2004
@@ -50,7 +50,7 @@
     private MessageContext mc;
     private Thread thisThread = null;
     private SimpleAxisServer sas;
-    private int testingPort = 1234;
+    private int testingPort = 7777;
     private int testCount = 0;
     
     public EchoRawXMLTest(){
@@ -62,54 +62,47 @@
     }
 
     protected void setUp() throws Exception {
-        if(testCount == 0 ){
-            testCount = 1;
-            engineRegistry = Utils.createMockRegistry(serviceName,operationName,transportName);
-            Service service = new ServiceImpl(serviceName);
-            service.setClassLoader(Thread.currentThread().getContextClassLoader());
-            Parameter classParam = new ParameterImpl("className",EchoXML.class.getName());
-            service.addParameter(classParam);
-            service.setProvider(new RawXMLProvider());
-            Operation operation = new OperationImpl(operationName,service);
-            
-            service.addOperation(operation);
-            
-            ExecutionChain inchain = new ExecutionChain();
-            inchain.addPhase(new Phase(Constants.PHASE_SERVICE));
-            EngineUtils.addHandlers(service.getInFlow(),inchain,Constants.PHASE_SERVICE);
-            service.setInputExecutionChain(inchain);
-            
-            ExecutionChain outchain = new ExecutionChain();
-            outchain.addPhase(new Phase(Constants.PHASE_SERVICE));
-            EngineUtils.addHandlers(service.getOutFlow(),outchain,Constants.PHASE_SERVICE);
-            service.setOutExecutionChain(outchain);
-            
-            ExecutionChain faultchain = new ExecutionChain();
-            
-            faultchain.addPhase(new Phase(Constants.PHASE_SERVICE));
-            
-            EngineUtils.addHandlers(service.getFaultFlow(),faultchain,Constants.PHASE_SERVICE);
-            service.setFaultExecutionChain(outchain);
-            
-            engineRegistry.addService(service);
-            
-            AxisEngine engine = new AxisEngine(engineRegistry);
-            sas = new SimpleAxisServer(engine);
-            ServerSocket serverSoc = new ServerSocket(testingPort);
-            sas.setServerSocket(serverSoc);
-            thisThread = new Thread(sas);
-            thisThread.setDaemon(true);
-            thisThread.start();
-
-        }
+        engineRegistry = Utils.createMockRegistry(serviceName,operationName,transportName);
+        Service service = new ServiceImpl(serviceName);
+        service.setClassLoader(Thread.currentThread().getContextClassLoader());
+        Parameter classParam = new ParameterImpl("className",EchoXML.class.getName());
+        service.addParameter(classParam);
+        service.setProvider(new RawXMLProvider());
+        Operation operation = new OperationImpl(operationName,service);
+        
+        service.addOperation(operation);
+        
+        ExecutionChain inchain = new ExecutionChain();
+        inchain.addPhase(new Phase(Constants.PHASE_SERVICE));
+        EngineUtils.addHandlers(service.getInFlow(),inchain,Constants.PHASE_SERVICE);
+        service.setInputExecutionChain(inchain);
+        
+        ExecutionChain outchain = new ExecutionChain();
+        outchain.addPhase(new Phase(Constants.PHASE_SERVICE));
+        EngineUtils.addHandlers(service.getOutFlow(),outchain,Constants.PHASE_SERVICE);
+        service.setOutExecutionChain(outchain);
+        
+        ExecutionChain faultchain = new ExecutionChain();
+        
+        faultchain.addPhase(new Phase(Constants.PHASE_SERVICE));
+        
+        EngineUtils.addHandlers(service.getFaultFlow(),faultchain,Constants.PHASE_SERVICE);
+        service.setFaultExecutionChain(outchain);
+        
+        engineRegistry.addService(service);
+        
+        AxisEngine engine = new AxisEngine(engineRegistry);
+        ServerSocket serverSoc = new ServerSocket(testingPort);
+        sas = new SimpleAxisServer(engine);
+        sas.setServerSocket(serverSoc);
+        thisThread = new Thread(sas);
+        thisThread.setDaemon(true);
+        thisThread.start();
     }
 
     protected void tearDown() throws Exception {
-        if(testCount == 0 ){
-            testCount = 1;
-        }else{
-            sas.stop();            
-        }
+            sas.stop();   
+            Thread.sleep(1000);
     }
 
 

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java?view=diff&rev=111243&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java&r1=111242&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java&r2=111243
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java
(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java
Wed Dec  8 02:23:01 2004
@@ -61,6 +61,7 @@
 
     protected void tearDown() throws Exception {
     	sas.stop();
+        Thread.sleep(1000);
     }
 
 

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/SimpleAxisServerTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/SimpleAxisServerTest.java?view=auto&rev=111243
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/SimpleAxisServerTest.java
Wed Dec  8 02:23:01 2004
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2003,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.
+ */
+package org.apache.axis.engine;
+
+//todo
+import java.net.ServerSocket;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis.AbstractTestCase;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.impl.engine.OperationImpl;
+import org.apache.axis.impl.engine.ServiceImpl;
+import org.apache.axis.impl.providers.RawXMLProvider;
+import org.apache.axis.impl.registry.ParameterImpl;
+import org.apache.axis.impl.transport.http.SimpleAxisServer;
+import org.apache.axis.registry.EngineRegistry;
+import org.apache.axis.registry.Operation;
+import org.apache.axis.registry.Parameter;
+import org.apache.axis.registry.Service;
+
+/**
+ * @author Srinath Perera(hemapani@opensource.lk)
+ */
+public class SimpleAxisServerTest extends AbstractTestCase{
+    private QName serviceName = new QName("","EchoXMLService");
+    private QName operationName = new QName("http://localhost/my","echoOMElement");
+    private QName transportName = new QName("http://localhost/my","NullTransport");
+
+    private EngineRegistry engineRegistry;
+    private MessageContext mc;
+    private Thread thisThread = null;
+    private SimpleAxisServer sas;
+    private int testingPort = 7777;
+    private int testCount = 0;
+    private AxisEngine engine;
+    
+    public SimpleAxisServerTest(){
+        super(SimpleAxisServerTest.class.getName());
+    }
+
+    public SimpleAxisServerTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        engineRegistry = Utils.createMockRegistry(serviceName,operationName,transportName);
+        Service service = new ServiceImpl(serviceName);
+        service.setClassLoader(Thread.currentThread().getContextClassLoader());
+        Parameter classParam = new ParameterImpl("className",EchoXML.class.getName());
+        service.addParameter(classParam);
+        service.setProvider(new RawXMLProvider());
+        Operation operation = new OperationImpl(operationName,service);
+        
+        service.addOperation(operation);
+        
+        ExecutionChain inchain = new ExecutionChain();
+        inchain.addPhase(new Phase(Constants.PHASE_SERVICE));
+        EngineUtils.addHandlers(service.getInFlow(),inchain,Constants.PHASE_SERVICE);
+        service.setInputExecutionChain(inchain);
+        
+        ExecutionChain outchain = new ExecutionChain();
+        outchain.addPhase(new Phase(Constants.PHASE_SERVICE));
+        EngineUtils.addHandlers(service.getOutFlow(),outchain,Constants.PHASE_SERVICE);
+        service.setOutExecutionChain(outchain);
+        
+        ExecutionChain faultchain = new ExecutionChain();
+        
+        faultchain.addPhase(new Phase(Constants.PHASE_SERVICE));
+        
+        EngineUtils.addHandlers(service.getFaultFlow(),faultchain,Constants.PHASE_SERVICE);
+        service.setFaultExecutionChain(outchain);
+        
+        engineRegistry.addService(service);
+        
+        engine = new AxisEngine(engineRegistry);
+    }
+
+    protected void tearDown() throws Exception {
+    }
+
+
+    public void testEchoXMLSync() throws Exception{
+        ServerSocket serverSoc = new ServerSocket(testingPort);
+        sas = new SimpleAxisServer(engine);
+        sas.setServerSocket(serverSoc);
+        thisThread = new Thread(sas);
+        thisThread.setDaemon(true);
+        thisThread.start();
+        sas.stop();
+        Thread.sleep(1000);
+        serverSoc = new ServerSocket(testingPort);
+        sas = new SimpleAxisServer(engine);
+        sas.setServerSocket(serverSoc);
+        thisThread = new Thread(sas);
+        thisThread.setDaemon(true);
+        thisThread.start();
+        sas.stop();            
+        Thread.sleep(1000);
+        serverSoc = new ServerSocket(testingPort);
+        sas = new SimpleAxisServer(engine);
+        sas.setServerSocket(serverSoc);
+        thisThread = new Thread(sas);
+        thisThread.setDaemon(true);
+        thisThread.start();
+        sas.stop();            
+    }
+}

Mime
View raw message