synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sami...@apache.org
Subject svn commit: r383079 - in /incubator/synapse/trunk/java/modules/extensions: ./ src/META-INF/services/ src/org/apache/synapse/processors/mediatortypes/spring/ test/org/ test/org/apache/ test/org/apache/synapse/ test/org/apache/synapse/extensions/ test/or...
Date Sat, 04 Mar 2006 08:45:02 GMT
Author: saminda
Date: Sat Mar  4 00:45:00 2006
New Revision: 383079

URL: http://svn.apache.org/viewcvs?rev=383079&view=rev
Log:
Test case is added to SpringeMediatorProcessor/Configurator

Added:
    incubator/synapse/trunk/java/modules/extensions/src/META-INF/services/org.apache.synapse.xml.ProcessorConfigurator
      - copied, changed from r379348, incubator/synapse/trunk/java/modules/extensions/src/META-INF/services/org.apache.synapse.ProcessorConfigurator
    incubator/synapse/trunk/java/modules/extensions/test/org/
    incubator/synapse/trunk/java/modules/extensions/test/org/apache/
    incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/
    incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/
    incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/utils/
    incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/utils/Axis2EnvSetup.java
    incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/utils/SimpleSpringBean.java
    incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spi/
    incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spi/injection/
    incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spi/injection/SpringMediatorProcessorWithRuleTest.java
Removed:
    incubator/synapse/trunk/java/modules/extensions/src/META-INF/services/org.apache.synapse.ProcessorConfigurator
Modified:
    incubator/synapse/trunk/java/modules/extensions/maven.xml
    incubator/synapse/trunk/java/modules/extensions/project.xml
    incubator/synapse/trunk/java/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessorConfigurator.java

Modified: incubator/synapse/trunk/java/modules/extensions/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/extensions/maven.xml?rev=383079&r1=383078&r2=383079&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/extensions/maven.xml (original)
+++ incubator/synapse/trunk/java/modules/extensions/maven.xml Sat Mar  4 00:45:00 2006
@@ -11,31 +11,44 @@
     <!--<j:set var="dist.dir" value="target/dist"/>-->
     <j:set var="extensions.dir" value="target/extensions"/>
 
-    <postGoal name="test:test">
-        <j:if test="${context.getVariable('maven.test.skip') != 'true'}">
-            <attainGoal name="extensions"/>
-        </j:if>
+    <postGoal name="test:compile">
+        <mkdir dir="${extensions.dir}"/>
+        <attainGoal name="synapse_extensions"/>
+        <attainGoal name="extensions"/>
     </postGoal>
+    <goal name="synapse_extensions">
+        <j:set var="class_test.dir" value="target/test-classes"/>
+
+        <mkdir dir="target/synapse-repository"/>
+        <ant:copy todir="target/synapse-repository">
+            <ant:fileset dir="../core/target/synapse-repository">
+                <ant:include name="**/**"/>
+            </ant:fileset>
+        </ant:copy>
+        <ant:path id="classes_test.dir" location="${class_test.dir}"/>
+        <maven:addPath id="maven.dependency.classpath" refid="classes_test.dir"/>
+    </goal>
 
 
     <goal name="extensions">
-        <mkdir dir="${extensions.dir}/spring"/>
-        <mkdir dir="${extensions.dir}/spring/META-INF"/>
-        <ant:copy todir="${extensions.dir}/spring">
+        <mkdir dir="${extensions.dir}"/>
+        <mkdir dir="target/dist"/>
+        <mkdir dir="${extensions.dir}/META-INF"/>
+        <ant:copy todir="${extensions.dir}">
             <ant:fileset dir="target/classes">
-                <ant:include name="**/spring/**"/>
+                <ant:include name="**/**"/>
             </ant:fileset>
         </ant:copy>
-        <ant:copy todir="${extensions.dir}/spring/META-INF">
+        <ant:copy todir="${extensions.dir}/META-INF">
             <ant:fileset dir="src/META-INF">
-                <ant:include name="**"/>
+                <ant:include name="**/**"/>
             </ant:fileset>
         </ant:copy>
 
-        <jar jarfile="${extensions.dir}/spring_mediator.jar"
-             basedir="${extensions.dir}/spring">
-            <include name="**"/>
+        <jar jarfile="target/dist/extension_mediators.jar"
+             basedir="${extensions.dir}">
+            <include name="**/**"/>
         </jar>
-        <ant:delete dir="${extensions.dir}/spring"/>
+        <ant:delete dir="${extensions.dir}"/>
     </goal>
 </project>

Modified: incubator/synapse/trunk/java/modules/extensions/project.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/extensions/project.xml?rev=383079&r1=383078&r2=383079&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/extensions/project.xml (original)
+++ incubator/synapse/trunk/java/modules/extensions/project.xml Sat Mar  4 00:45:00 2006
@@ -184,5 +184,28 @@
             </properties>
         </dependency>
     </dependencies>
+
+    <build>
+        <nagEmailAddress>synapse-dev@ws.apache.org</nagEmailAddress>
+        <sourceDirectory>src</sourceDirectory>
+        <unitTestSourceDirectory>test</unitTestSourceDirectory>
+        <unitTest>
+            <includes>
+                <include>**/*Test.java</include>
+            </includes>
+            <!--<excludes>-->
+                <!--<exclude>**/*Test.java</exclude>-->
+            <!--</excludes>-->
+            <resources>
+                <resource>
+                    <directory>src</directory>
+                    <includes>
+                        <include>**/org.apache.synapse.xml.ProcessorConfigurator</include>
+                    </includes>
+                </resource>
+            </resources>
+        </unitTest>
+
+    </build>
 </project>
 

Copied: incubator/synapse/trunk/java/modules/extensions/src/META-INF/services/org.apache.synapse.xml.ProcessorConfigurator
(from r379348, incubator/synapse/trunk/java/modules/extensions/src/META-INF/services/org.apache.synapse.ProcessorConfigurator)
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/extensions/src/META-INF/services/org.apache.synapse.xml.ProcessorConfigurator?p2=incubator/synapse/trunk/java/modules/extensions/src/META-INF/services/org.apache.synapse.xml.ProcessorConfigurator&p1=incubator/synapse/trunk/java/modules/extensions/src/META-INF/services/org.apache.synapse.ProcessorConfigurator&r1=379348&r2=383079&rev=383079&view=diff
==============================================================================
    (empty)

Modified: incubator/synapse/trunk/java/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessorConfigurator.java?rev=383079&r1=383078&r2=383079&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessorConfigurator.java
(original)
+++ incubator/synapse/trunk/java/modules/extensions/src/org/apache/synapse/processors/mediatortypes/spring/SpringMediatorProcessorConfigurator.java
Sat Mar  4 00:45:00 2006
@@ -63,8 +63,10 @@
 				}
 			}
 			if (beans==null) throw new SynapseException("<beans> element not found in "+el.toString());
-			xsw.setDefaultNamespace(beans.getNamespace().getName());
-			beans.serialize(xsw);
+            if (beans.getNamespace() != null)
+                xsw.setDefaultNamespace(beans.getNamespace().getName());
+
+            beans.serialize(xsw);
 		} catch (Exception e) {
 			throw new SynapseException(e);
 		} 

Added: incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/utils/Axis2EnvSetup.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/utils/Axis2EnvSetup.java?rev=383079&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/utils/Axis2EnvSetup.java
(added)
+++ incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/utils/Axis2EnvSetup.java
Sat Mar  4 00:45:00 2006
@@ -0,0 +1,79 @@
+package org.apache.synapse.extensions.utils;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.om.OMFactory;
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMDocument;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.InOutAxisOperation;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.synapse.axis2.SynapseMessageReceiver;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import java.io.ByteArrayInputStream;
+
+/**
+ * Utils for extensions
+ */
+public class Axis2EnvSetup {
+    public static MessageContext axis2Deployment(String testingRepository)
+            throws AxisFault {
+        ConfigurationContextFactory conFac = new ConfigurationContextFactory();
+        ConfigurationContext configCtx = conFac
+                .createConfigurationContextFromFileSystem(testingRepository);
+        MessageContext msgCtx = new MessageContext();
+        msgCtx.setConfigurationContext(configCtx);
+        msgCtx.setEnvelope(testEnvSetup());
+        msgCtx.setServerSide(true);
+
+        AxisConfiguration axisConfiguration = msgCtx.getConfigurationContext()
+                .getAxisConfiguration();
+        AxisService service = new AxisService("se");
+        msgCtx.setAxisService(service);
+        service.setClassLoader(axisConfiguration.getServiceClassLoader());
+        AxisOperation axisOp = new InOutAxisOperation(
+                new QName("op"));
+        msgCtx.setAxisOperation(axisOp);
+        axisOp.setMessageReceiver(new SynapseMessageReceiver());
+        service.addOperation(axisOp);
+        axisConfiguration.addService(service);
+        msgCtx.setTo(
+                new EndpointReference("/axis2/services/" + "se" + "/" + "op"));
+        msgCtx.setSoapAction("op");
+        return msgCtx;
+    }
+
+    private static SOAPEnvelope testEnvSetup() {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        SOAPEnvelope env = OMAbstractFactory.getSOAP11Factory()
+                .getDefaultEnvelope();
+        OMDocument doc = fac.createOMDocument();
+        doc.addChild(env);
+        OMElement ele = fac.createOMElement("text", "urn:text-body", "ns");
+        env.getBody().addChild(ele);
+        return env;
+    }
+
+    public static OMElement getSynapseConfigElement(String synapseXml)
+            throws XMLStreamException {
+        XMLStreamReader parser = XMLInputFactory.newInstance()
+                .createXMLStreamReader(
+                        new ByteArrayInputStream(synapseXml.getBytes()));
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        StAXOMBuilder staxBuilder = new StAXOMBuilder(fac, parser);
+        OMElement config = staxBuilder.getDocumentElement();
+        return config;
+
+    }
+}

Added: incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/utils/SimpleSpringBean.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/utils/SimpleSpringBean.java?rev=383079&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/utils/SimpleSpringBean.java
(added)
+++ incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/extensions/utils/SimpleSpringBean.java
Sat Mar  4 00:45:00 2006
@@ -0,0 +1,47 @@
+package org.apache.synapse.extensions.utils;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.SynapseMessage;
+import junit.framework.TestCase;
+/*
+ * Copyright 2004,2005 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 SimpleSpringBean implements Mediator {
+    public String getEpr() {
+        return epr;
+    }
+
+    public void setEpr(String epr) {
+        this.epr = epr;
+    }
+
+    public String getIp() {
+        return ip;
+    }
+
+    public void setIp(String ip) {
+        this.ip = ip;
+    }
+
+    private String epr;
+    private String ip;
+
+    public boolean mediate(SynapseMessage smc) {
+        TestCase.assertNotNull(getIp());
+        TestCase.assertNotNull(getEpr());
+        return true;
+    }
+}

Added: incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spi/injection/SpringMediatorProcessorWithRuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spi/injection/SpringMediatorProcessorWithRuleTest.java?rev=383079&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spi/injection/SpringMediatorProcessorWithRuleTest.java
(added)
+++ incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spi/injection/SpringMediatorProcessorWithRuleTest.java
Sat Mar  4 00:45:00 2006
@@ -0,0 +1,58 @@
+package org.apache.synapse.spi.injection;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.extensions.utils.Axis2EnvSetup;
+import org.apache.synapse.axis2.Axis2SynapseEnvironment;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+import junit.framework.TestCase;
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (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 SpringMediatorProcessorWithRuleTest extends TestCase {
+    private MessageContext msgCtx;
+        private SynapseEnvironment env;
+        private String synapsexml =
+                "<synapse xmlns=\"http://ws.apache.org/ns/synapse\" xmlns:spring=\"http://ws.apache.org/ns/synapse/spring\">\n"
+
+                        "<spring:springmediator bean=\"unit_test_spring_bean\" >\n"
+
+                        "    <beans xmlns=\"\">\n" +
+                        "          <bean id=\"unit_test_spring_bean\" class=\"org.apache.synapse.extensions.utils.SimpleSpringBean\"
>\n"+
+                        "              <property name=\"epr\">\n"+
+                        "                   <value>127.0.0.1:8008/axis2/services/MyService</value>\n"+
+                        "              </property>\n"+
+                        "              <property name=\"ip\">\n"+
+                        "                   <value>192.168.1.245</value>\n"+
+                        "              </property>\n"+
+                        "           </bean>\n"+
+                        "    </beans>\n" +
+                        "</spring:springmediator>\n"+
+                        "</synapse>";
+        public void setUp() throws Exception {
+            msgCtx = Axis2EnvSetup.axis2Deployment("target/synapse-repository");
+            OMElement config =Axis2EnvSetup.getSynapseConfigElement(synapsexml);
+            env = new Axis2SynapseEnvironment(config,
+                    Thread.currentThread().getContextClassLoader());
+        }
+
+        public void testSpringProcessor() throws Exception {
+
+            SynapseMessage smc = new Axis2SynapseMessage(msgCtx);
+            env.injectMessage(smc);
+
+        }
+
+}



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


Mime
View raw message