Author: gnodet
Date: Wed May 17 09:12:12 2006
New Revision: 407298
URL: http://svn.apache.org/viewvc?rev=407298&view=rev
Log:
Add a module containing integration tests (mainly tests involving several standard JBI components)
Added:
incubator/servicemix/trunk/servicemix-itests/
incubator/servicemix/trunk/servicemix-itests/pom.xml
incubator/servicemix/trunk/servicemix-itests/src/
incubator/servicemix/trunk/servicemix-itests/src/test/
incubator/servicemix/trunk/servicemix-itests/src/test/java/
incubator/servicemix/trunk/servicemix-itests/src/test/java/org/
incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/
incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/
incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/
incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/Jsr181HttpTest.java
incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/WSNComponentTest.java
incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/beans/
incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/beans/Echo.java
incubator/servicemix/trunk/servicemix-itests/src/test/resources/
incubator/servicemix/trunk/servicemix-itests/src/test/resources/org/
incubator/servicemix/trunk/servicemix-itests/src/test/resources/org/apache/
incubator/servicemix/trunk/servicemix-itests/src/test/resources/org/apache/servicemix/
incubator/servicemix/trunk/servicemix-itests/src/test/resources/org/apache/servicemix/itests/
incubator/servicemix/trunk/servicemix-itests/src/test/resources/org/apache/servicemix/itests/jsr181http.xml
Added: incubator/servicemix/trunk/servicemix-itests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-itests/pom.xml?rev=407298&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-itests/pom.xml (added)
+++ incubator/servicemix/trunk/servicemix-itests/pom.xml Wed May 17 09:12:12 2006
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 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.
+-->
+<!-- $Rev: 356052 $ $Date: 2005-12-11 14:41:20 -0800 (dim., 11 déc. 2005) $ -->
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>servicemix-itests</artifactId>
+ <packaging>jar</packaging>
+ <name>ServiceMix :: ITests</name>
+ <description>Integration tests</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>servicemix-http</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>servicemix-jsr181</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>servicemix-wsn2005</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>servicemix-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added: incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/Jsr181HttpTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/Jsr181HttpTest.java?rev=407298&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/Jsr181HttpTest.java
(added)
+++ incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/Jsr181HttpTest.java
Wed May 17 09:12:12 2006
@@ -0,0 +1,26 @@
+package org.apache.servicemix.itests;
+
+import java.io.StringWriter;
+
+import javax.wsdl.Definition;
+import javax.wsdl.factory.WSDLFactory;
+
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class Jsr181HttpTest extends SpringTestSupport {
+
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ return new ClassPathXmlApplicationContext("org/apache/servicemix/itests/jsr181http.xml");
+ }
+
+ public void test() throws Exception {
+ WSDLFactory wsdlFactory = WSDLFactory.newInstance();
+ Definition def = wsdlFactory.newWSDLReader().readWSDL("http://localhost:8194/Service/?wsdl");
+ StringWriter writer = new StringWriter();
+ wsdlFactory.newWSDLWriter().writeWSDL(def, writer);
+ System.err.println(writer.toString());
+ }
+
+}
Added: incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/WSNComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/WSNComponentTest.java?rev=407298&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/WSNComponentTest.java
(added)
+++ incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/WSNComponentTest.java
Wed May 17 09:12:12 2006
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2005-2006 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.servicemix.itests;
+
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.servicemix.http.HttpEndpoint;
+import org.apache.servicemix.http.HttpSpringComponent;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.soap.SoapHelper;
+import org.apache.servicemix.tck.ReceiverComponent;
+import org.apache.servicemix.wsn.client.NotificationBroker;
+import org.apache.servicemix.wsn.component.WSNComponent;
+import org.w3._2005._08.addressing.AttributedURIType;
+import org.w3._2005._08.addressing.EndpointReferenceType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+public class WSNComponentTest extends TestCase {
+
+ public static QName NOTIFICATION_BROKER = new QName("http://servicemix.org/wsnotification",
"NotificationBroker");
+
+ private JBIContainer jbi;
+ private BrokerService jmsBroker;
+ private NotificationBroker wsnBroker;
+ private WSNComponent wsnComponent;
+
+ protected void setUp() throws Exception {
+ jmsBroker = new BrokerService();
+ jmsBroker.setPersistent(false);
+ jmsBroker.addConnector("vm://localhost");
+ jmsBroker.start();
+
+ jbi = new JBIContainer();
+ jbi.setEmbedded(true);
+ jbi.init();
+ jbi.start();
+
+ wsnComponent = new WSNComponent();
+ wsnComponent.setConnectionFactory(new ActiveMQConnectionFactory("vm://localhost"));
+ ActivationSpec as = new ActivationSpec();
+ as.setComponentName("servicemix-wsn2005");
+ as.setComponent(wsnComponent);
+ jbi.activateComponent(as);
+
+ wsnBroker = new NotificationBroker(jbi);
+ }
+
+ protected void tearDown() throws Exception {
+ if (jbi != null) {
+ jbi.shutDown();
+ }
+ if (jmsBroker != null) {
+ jmsBroker.stop();
+ }
+ }
+
+ public void testDynamicSubscription() throws Exception {
+ HttpSpringComponent httpComponent = new HttpSpringComponent();
+
+ HttpEndpoint httpWSNBroker = new HttpEndpoint();
+ httpWSNBroker.setService(new QName("http://servicemix.org/wsnotification", "NotificationBroker"));
+ httpWSNBroker.setEndpoint("Broker");
+ httpWSNBroker.setRoleAsString("consumer");
+ httpWSNBroker.setLocationURI("http://localhost:8192/WSNBroker/");
+ httpWSNBroker.setSoap(true);
+
+ HttpEndpoint httpReceiver = new HttpEndpoint();
+ httpReceiver.setService(new QName("receiver"));
+ httpReceiver.setEndpoint("endpoint");
+ httpReceiver.setLocationURI("http://localhost:8192/Receiver/");
+ httpReceiver.setDefaultMep(SoapHelper.IN_ONLY);
+ httpReceiver.setSoap(true);
+
+ httpComponent.setEndpoints(new HttpEndpoint[] { httpWSNBroker, httpReceiver });
+ jbi.activateComponent(new ActivationSpec("servicemix-http", httpComponent));
+
+ ReceiverComponent receiver = new ReceiverComponent();
+ receiver.setService(new QName("receiver"));
+ receiver.setEndpoint("endpoint");
+ jbi.activateComponent(new ActivationSpec("receiver", receiver));
+
+ EndpointReferenceType epr = new EndpointReferenceType();
+ epr.setAddress(new AttributedURIType());
+ epr.getAddress().setValue("http://localhost:8192/Receiver/?http.soap=true");
+ wsnBroker.subscribe(epr, "myTopic", null);
+ wsnBroker.notify("myTopic", parse("<hello>world</hello>"));
+
+ receiver.getMessageList().assertMessagesReceived(1);
+ }
+
+ private Element parse(String txt) throws Exception {
+ DocumentBuilder builder = new SourceTransformer().createDocumentBuilder();
+ InputSource is = new InputSource(new StringReader(txt));
+ Document doc = builder.parse(is);
+ return doc.getDocumentElement();
+ }
+
+}
Added: incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/beans/Echo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/beans/Echo.java?rev=407298&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/beans/Echo.java
(added)
+++ incubator/servicemix/trunk/servicemix-itests/src/test/java/org/apache/servicemix/itests/beans/Echo.java
Wed May 17 09:12:12 2006
@@ -0,0 +1,13 @@
+package org.apache.servicemix.itests.beans;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+@WebService
+public class Echo {
+
+ @WebMethod
+ public String echo(String msg) {
+ return "Hello: " + msg;
+ }
+}
Added: incubator/servicemix/trunk/servicemix-itests/src/test/resources/org/apache/servicemix/itests/jsr181http.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-itests/src/test/resources/org/apache/servicemix/itests/jsr181http.xml?rev=407298&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-itests/src/test/resources/org/apache/servicemix/itests/jsr181http.xml
(added)
+++ incubator/servicemix/trunk/servicemix-itests/src/test/resources/org/apache/servicemix/itests/jsr181http.xml
Wed May 17 09:12:12 2006
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+ xmlns:jsr181="http://servicemix.apache.org/jsr181/1.0"
+ xmlns:http="http://servicemix.apache.org/http/1.0"
+ xmlns:test="http://servicemix.org/test/">
+
+ <sm:container id="jbi" embedded="true" >
+ <sm:activationSpecs>
+
+ <sm:activationSpec>
+ <sm:component>
+ <jsr181:component>
+ <jsr181:endpoints>
+ <jsr181:endpoint
+ pojoClass="org.apache.servicemix.itests.beans.Echo"
+ service="test:Hello"
+ endpoint="testService" />
+ </jsr181:endpoints>
+ </jsr181:component>
+ </sm:component>
+ </sm:activationSpec>
+
+ <sm:activationSpec>
+ <sm:component>
+ <http:component>
+ <http:endpoints>
+ <http:endpoint
+ service="test:Hello"
+ endpoint="testService"
+ role="consumer"
+ defaultOperation="echo"
+ locationURI="http://localhost:8194/Service/"
+ defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
+ soap="true" />
+ </http:endpoints>
+ </http:component>
+ </sm:component>
+ </sm:activationSpec>
+
+ </sm:activationSpecs>
+ </sm:container>
+</beans>
|