You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2007/04/25 19:50:50 UTC

svn commit: r532422 [2/2] - in /webservices/axis2/trunk/java/modules/kernel: src/org/apache/axis2/context/ src/org/apache/axis2/deployment/ src/org/apache/axis2/deployment/repository/util/ src/org/apache/axis2/deployment/util/ src/org/apache/axis2/desc...

Added: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/CustomDeployerTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/CustomDeployerTest.java?view=auto&rev=532422
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/CustomDeployerTest.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/CustomDeployerTest.java Wed Apr 25 10:50:48 2007
@@ -0,0 +1,44 @@
+package org.apache.axis2.deployment;
+
+import junit.framework.TestCase;
+import org.apache.axis2.AbstractTestCase;
+import org.apache.axis2.deployment.deployers.CustomDeployer;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.engine.AxisConfiguration;
+
+/*
+* Copyright 2007 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 CustomDeployerTest extends TestCase {
+    public void testCustomDeployer() throws Exception {
+        String filename =
+                AbstractTestCase.basedir + "/test-resources/deployment/CustomDeployerRepo";
+        AxisConfiguration axisConfig = ConfigurationContextFactory
+                .createConfigurationContextFromFileSystem(filename)
+                .getAxisConfiguration();
+
+        // OK, let's see what we've got here...
+        assertTrue("Init was not called", CustomDeployer.initCalled);
+        assertEquals("Wrong directory", "widgets", CustomDeployer.directory);
+        assertEquals("Wrong extension", "svc", CustomDeployer.extension);
+        assertEquals("Wrong number of deployed items", 2, CustomDeployer.deployedItems);
+        assertTrue("George wasn't found", CustomDeployer.georgeDeployed);
+        assertTrue("Mary wasn't found", CustomDeployer.maryDeployed);
+
+        assertEquals("Parameter not set correctly",
+                     CustomDeployer.PARAM_VAL,
+                     axisConfig.getParameterValue(CustomDeployer.PARAM_NAME));
+    }
+}

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java?view=diff&rev=532422&r1=532421&r2=532422
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java Wed Apr 25 10:50:48 2007
@@ -22,17 +22,13 @@
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.phaseresolver.PhaseException;
 
 import javax.xml.stream.XMLStreamException;
 
 public class DeploymentTotalTest extends TestCase {
     AxisConfiguration er;
 
-    public void testparseService1() throws PhaseException,
-            DeploymentException,
-            AxisFault,
-            XMLStreamException {
+    public void testparseService1() throws AxisFault, XMLStreamException {
         String filename = AbstractTestCase.basedir + "/target/test-resources/deployment";
         er = ConfigurationContextFactory
                 .createConfigurationContextFromFileSystem(filename, filename + "/axis2.xml")

Added: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/deployers/CustomDeployer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/deployers/CustomDeployer.java?view=auto&rev=532422
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/deployers/CustomDeployer.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/deployers/CustomDeployer.java Wed Apr 25 10:50:48 2007
@@ -0,0 +1,126 @@
+package org.apache.axis2.deployment.deployers;
+
+import org.apache.axis2.deployment.Deployer;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.repository.util.DeploymentFileData;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.FileInputStream;
+
+/*
+* Copyright 2007 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.
+*/
+
+/**
+ * A custom Deployer instance for testing.  This coordinates with the CustomDeployerTest and
+ * the CustomDeployerRepo/ repository in test-resources/.  It's going to be set up to deploy
+ * "svc" files, both in the services/ directory and in the widgets/ directory.  After the
+ * config is complete, we should have 2 deployed items, and should have found both "Mary" and
+ * "George" (see the repo for test data).  We use static fields to keep all this information
+ * in a way that the test can access it.
+ */
+public class CustomDeployer implements Deployer {
+    protected static final Log log = LogFactory.getLog(CustomDeployer.class);
+
+    /** Has init() been called? */
+    public static boolean initCalled;
+    /** This is set to the last argument to setDirectory() */
+    public static String directory;
+    /** This is set to the last argument to setExtension() */
+    public static String extension;
+    /** The count of deployed items */
+    public static int deployedItems;
+    /** Set to true if "George" has been deployed */
+    public static boolean georgeDeployed;
+    /** Set to true if "Mary" has been deployed */
+    public static boolean maryDeployed;
+
+    public static final String PARAM_NAME = "customDeployerParam";
+    public static final String PARAM_VAL = "customDeployer parameter value";
+
+    /**
+     * Initialize the Deployer
+     *
+     * @param configCtx our ConfigurationContext
+     */
+    public void init(ConfigurationContext configCtx) {
+        initCalled = true;
+
+        // Set a property on the AxisConfig just to make sure we end up with the right one
+        try {
+            configCtx.getAxisConfiguration().addParameter(PARAM_NAME, PARAM_VAL);
+        } catch (AxisFault axisFault) {
+            // Two comments - 1) why the heck does addParameter throw AxisFault?
+            //                2) why doesn't init() throw AxisFault?
+        }
+    }
+
+    /**
+     * Process a file and add it to the configuration
+     *
+     * @param deploymentFileData the DeploymentFileData object to deploy
+     * @throws org.apache.axis2.deployment.DeploymentException
+     *          if there is a problem
+     */
+    public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException {
+        log.info("Deploying - " + deploymentFileData.getName());
+        try {
+            FileInputStream fis = new FileInputStream(deploymentFileData.getFile());
+            int x= fis.available();
+            byte b[]= new byte[x];
+            fis.read(b);
+            String content = new String(b);
+            if (content.indexOf("George") > -1) georgeDeployed = true;
+            if (content.indexOf("Mary") > -1) maryDeployed = true;
+            deployedItems++;
+        } catch (Exception e) {
+            throw new DeploymentException(e);
+        }
+    }
+
+    /**
+     * Set the directory
+     *
+     * @param directory directory name
+     */
+    public void setDirectory(String directory) {
+        CustomDeployer.directory = directory;
+    }
+
+    /**
+     * Set the extension to look for TODO: Support multiple extensions?
+     *
+     * @param extension the file extension associated with this Deployer
+     */
+    public void setExtension(String extension) {
+        CustomDeployer.extension = extension;
+    }
+
+    /**
+     * Remove a given file from the configuration
+     *
+     * @param fileName name of item to remove
+     * @throws org.apache.axis2.deployment.DeploymentException
+     *          if there is a problem
+     */
+    public void unDeploy(String fileName) throws DeploymentException {
+        // Undeploy
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org