[wsas-java-dev] svn commit r1083 - in branches/wsas/java/standalone-tomcat/java/modules: core/src/org/wso2/wsas core/src/org/wso2/wsas/deployment standalone-edition/src/org/wso2/wsas standalone-edition/test/org/wso2/wsas standalone-edition/test/org/wso2/wsas/util

svn at wso2.org svn at wso2.org
Wed Feb 28 00:46:01 PST 2007


Author: azeez
Date: Wed Feb 28 00:44:47 2007
New Revision: 1083

Modified:
   branches/wsas/java/standalone-tomcat/java/modules/core/src/org/wso2/wsas/ServerManager.java
   branches/wsas/java/standalone-tomcat/java/modules/core/src/org/wso2/wsas/deployment/ServerConfigurator.java
   branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/src/org/wso2/wsas/Main.java
   branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/src/org/wso2/wsas/TomcatServer.java
   branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/TomcatServerTest.java
   branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/util/ServerUtils.java
Log:
Cleaning up code & Starting work on fixing testcases



Modified: branches/wsas/java/standalone-tomcat/java/modules/core/src/org/wso2/wsas/ServerManager.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/core/src/org/wso2/wsas/ServerManager.java	(original)
+++ branches/wsas/java/standalone-tomcat/java/modules/core/src/org/wso2/wsas/ServerManager.java	Wed Feb 28 00:44:47 2007
@@ -64,7 +64,6 @@
     public static int httpsPort = 11001;
 
     public String axis2RepoLocation = "target/repository";
-    boolean isTestMode;
     public Monitor monitor;
     public ConfigurationContext configContext;
     public String serverWorkDir;

Modified: branches/wsas/java/standalone-tomcat/java/modules/core/src/org/wso2/wsas/deployment/ServerConfigurator.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/core/src/org/wso2/wsas/deployment/ServerConfigurator.java	(original)
+++ branches/wsas/java/standalone-tomcat/java/modules/core/src/org/wso2/wsas/deployment/ServerConfigurator.java	Wed Feb 28 00:44:47 2007
@@ -45,6 +45,7 @@
 import java.io.InputStream;
 import java.util.Iterator;
 import java.util.List;
+import java.util.ArrayList;
 
 /**
  * WSO2 WSAS's implementation of AxisConfigurator to load Axis2
@@ -54,7 +55,7 @@
 
     private static Log log = LogFactory.getLog(ServerConfigurator.class);
 
-    private static List globallyEngagedModules;
+    private static List globallyEngagedModules = new ArrayList();
     /**
      * To check whether need to create a service side or client side
      */

Modified: branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/src/org/wso2/wsas/Main.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/src/org/wso2/wsas/Main.java	(original)
+++ branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/src/org/wso2/wsas/Main.java	Wed Feb 28 00:44:47 2007
@@ -73,10 +73,6 @@
         }
     }
 
-    public void setTestMode(boolean isTestMode) {
-        ServerManager.getInstance().isTestMode = isTestMode;
-    }
-
     public void stop() throws IOException, ServerException {
         ServerManager.getInstance().stop();
         stopListeners();
@@ -87,16 +83,7 @@
     }
 
     public void shutdown() throws ServerException {
-        try {
-            if (webServer != null) {
-                webServer.stop();
-            }
-        } catch (Exception e) {
-            String msg = "Error occurred while shutting down WSO2 WSAS";
-            log.error(msg, e);
-            throw new ServerException(msg, e);
-        }
-        webServer = null;
+        stopListeners();
         ServerManager.getInstance().stopHouseKeeping();
         cleanupSystem();
     }
@@ -187,6 +174,7 @@
                 throw new ServerException(axisFault);
             }
         }
+        webServer = null;
     }
 
     private void cleanupSystem() {

Modified: branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/src/org/wso2/wsas/TomcatServer.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/src/org/wso2/wsas/TomcatServer.java	(original)
+++ branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/src/org/wso2/wsas/TomcatServer.java	Wed Feb 28 00:44:47 2007
@@ -41,8 +41,7 @@
         Engine engine;
 
         String wso2wsasHome = System.getProperty(ServerConstants.WSO2WSAS_HOME);
-        String catalinaHome = new File(wso2wsasHome) +
-                              File.separator + "tomcat";
+        String catalinaHome = new File(wso2wsasHome).getAbsolutePath() + File.separator + "tomcat";
         embedded.setCatalinaHome(catalinaHome);
         String webappsDir = catalinaHome + File.separator + "webapps";
         String docsDir = wso2wsasHome + File.separator + "docs";

Modified: branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/TomcatServerTest.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/TomcatServerTest.java	(original)
+++ branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/TomcatServerTest.java	Wed Feb 28 00:44:47 2007
@@ -35,6 +35,7 @@
 public class TomcatServerTest extends TestCase {
     protected QName operationName = new QName("getVersion");
     protected ServerUtils serverUtils;
+    protected Thread serverThread;
 
     protected void setUp() throws Exception {
         ServerConfiguration.configurationXMLLocation = "conf/server.xml";
@@ -42,34 +43,61 @@
         System.setProperty("axis2.xml", "target/repository/axis2.xml");
         System.setProperty(ServerConstants.DERBY_HOME, "conf");
         serverUtils = new ServerUtils();
-        serverUtils.startServer();
+        serverThread = new Thread() {
+            public void run() {
+                serverUtils.startServer();
+//                serverUtils.deployServiceUsingInOutMsgReceiver();
+
+                /* try {
+                    Thread.sleep(5000);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }*/
+                System.err.println("##### Server started successfully");
+            }
+        };
     }
 
     public void testEchoXMLSync() throws Exception {
-        OMElement payload = getTestPayload();
+        Thread clientThread = new Thread() {
+            public void run() {
 
-        ConfigurationContext configContext =
-                ConfigurationContextFactory.
-                        createConfigurationContextFromFileSystem(TestConstants.TESTING_REPO, null);
-        ServiceClient sender = new ServiceClient(configContext, null);
-
-        EndpointReference targetEPR =
-                new EndpointReference("http://" + NetworkUtils.getLocalHostname() + ":"
-                                      + TestConstants.TESTING_PORT
-                                      + "/soap/version/getVersion");
-
-        Options options = new Options();
-        options.setTo(targetEPR);
-        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
-        options.setUseSeparateListener(false);
-        sender.setOptions(options);
-        options.setAction("getVersion");
-
-        OMElement result = sender.sendReceive(payload);
-        String versionText = result.getFirstElement().getText();
-
-        int i = versionText.indexOf("Hello I am WSO2 WSAS version service. My version is ");
-        assertTrue(i != -1);
+                try {
+                    System.err.println("##### Starting client");
+                    ConfigurationContext configContext =
+                            ConfigurationContextFactory.
+                                    createConfigurationContextFromFileSystem(TestConstants.TESTING_REPO,
+                                                                             null);
+
+                    ServiceClient sender = new ServiceClient(configContext, null);
+
+                    EndpointReference targetEPR =
+                            new EndpointReference("http://" + NetworkUtils.getLocalHostname() + ":"
+                                                  + TestConstants.TESTING_PORT
+                                                  + "/soap/version/getVersion");
+
+                    Options options = new Options();
+                    options.setTo(targetEPR);
+                    options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+                    options.setUseSeparateListener(false);
+                    sender.setOptions(options);
+                    options.setAction("getVersion");
+                    OMElement result = sender.sendReceive(getTestPayload());
+                    String versionText = result.getFirstElement().getText();
+
+                    int i = versionText.indexOf("Hello I am WSO2 WSAS version service. My version is ");
+                    assertTrue(i != -1);
+                    System.err.println("##### Test passed");
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    fail("Exception occurred during startup " + e);
+                }
+            }
+        };
+        serverThread.start();
+        serverThread.join();
+        clientThread.start();
+        clientThread.join();
     }
 
     protected void tearDown() throws Exception {

Modified: branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/util/ServerUtils.java
==============================================================================
--- branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/util/ServerUtils.java	(original)
+++ branches/wsas/java/standalone-tomcat/java/modules/standalone-edition/test/org/wso2/wsas/util/ServerUtils.java	Wed Feb 28 00:44:47 2007
@@ -19,7 +19,6 @@
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
-import org.wso2.utils.ServerConfiguration;
 import org.wso2.utils.ServerException;
 import org.wso2.wsas.Main;
 
@@ -84,36 +83,19 @@
     }
 
     public void startServer() {
-
-        try {
-            initializeTestingServer(null);
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
+        initializeTestingServer();
     }
 
     /*
     Initializing WSO2 WSAS testing server
     */
-    private void initializeTestingServer(String wso2wsasConfigLocation)
-            throws InterruptedException {
-        if (wso2wsasConfigLocation == null) {
-            main = new Main();
-        } else {
-            ServerConfiguration.configurationXMLLocation = wso2wsasConfigLocation;
-            main = new Main();
-        }
-        main.setTestMode(true);
+    private void initializeTestingServer() {
+        main = new Main();
         main.startServer();
-        Thread.sleep(1000);
     }
 
     public void startServer(String serverConfigLocation) {
-        try {
-            initializeTestingServer(serverConfigLocation);
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
+        initializeTestingServer();
     }
 
     public void shutdown() throws ServerException {




More information about the Wsas-java-dev mailing list