You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2010/12/08 16:55:42 UTC
svn commit: r1043467 - in
/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src:
main/java/itest/scabindingmapper/ main/resources/META-INF/services/
test/java/itest/helloworld/ test/resources/
Author: antelder
Date: Wed Dec 8 15:55:42 2010
New Revision: 1043467
URL: http://svn.apache.org/viewvc?rev=1043467&view=rev
Log:
Add itest using an UnknownEndpointHandler. Also update tests to use port 8085
Added:
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyUnknownEndpointHandler.java (with props)
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.UnknownEndpointHandler
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/UnknownEndpointTestCase.java (with props)
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/clients.composite
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/services.composite
Modified:
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyMapper.java
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Mapper1TestCase.java
Modified: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyMapper.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyMapper.java?rev=1043467&r1=1043466&r2=1043467&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyMapper.java (original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyMapper.java Wed Dec 8 15:55:42 2010
@@ -51,7 +51,7 @@ public class MyMapper extends DefaultSCA
@Override
protected QName chooseBinding(RuntimeEndpointReference endpointReference) {
- if (endpointReference.getURI().endsWith("2")) {
+ if (endpointReference.getBinding().getURI().contains("Service2")) {
return JSONPBinding.TYPE;
} else {
return super.defaultMappedBinding;
Added: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyUnknownEndpointHandler.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyUnknownEndpointHandler.java?rev=1043467&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyUnknownEndpointHandler.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyUnknownEndpointHandler.java Wed Dec 8 15:55:42 2010
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 itest.scabindingmapper;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.impl.SCABindingFactoryImpl;
+import org.apache.tuscany.sca.runtime.UnknownEndpointHandler;
+
+public class MyUnknownEndpointHandler implements UnknownEndpointHandler {
+
+ @Override
+ public Binding handleUnknownEndpoint(EndpointReference endpointReference) {
+
+ if (endpointReference.getTargetEndpoint().getURI().endsWith("Service1")) {
+ SCABinding b = new SCABindingFactoryImpl().createSCABinding();
+ b.setURI("http://localhost:8085/Service1/Helloworld");
+ return b;
+
+ } else if (endpointReference.getTargetEndpoint().getURI().endsWith("Service2")) {
+ SCABinding b = new SCABindingFactoryImpl().createSCABinding();
+ b.setURI("http://localhost:8085/Service2/Helloworld");
+ return b;
+ }
+
+ return null;
+ }
+
+}
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyUnknownEndpointHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyUnknownEndpointHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.UnknownEndpointHandler
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.UnknownEndpointHandler?rev=1043467&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.UnknownEndpointHandler (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.UnknownEndpointHandler Wed Dec 8 15:55:42 2010
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+itest.scabindingmapper.MyUnknownEndpointHandler
+
+
Modified: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Mapper1TestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Mapper1TestCase.java?rev=1043467&r1=1043466&r2=1043467&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Mapper1TestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Mapper1TestCase.java Wed Dec 8 15:55:42 2010
@@ -25,14 +25,21 @@ import java.net.URL;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
public class Mapper1TestCase {
+ static {
+ org.apache.tuscany.sca.http.jetty.JettyServer.portDefault = 8085;
+ }
+
+ Node node;
+
@Test
public void testSCABindingFactory() throws IOException {
- Node node = NodeFactory.newInstance().createNode("test.composite", new String[]{"target/test-classes"}) ;
+ node = NodeFactory.newInstance().createNode("test.composite", new String[]{"target/test-classes"}) ;
node.start();
// test the service invocations work
@@ -43,10 +50,10 @@ public class Mapper1TestCase {
Assert.assertEquals("Hello Petra", helloworld.sayHello("Petra"));
// verify service1 is exposed as a WS endpoint and service2 is a jsonp endpoint
- URL wsService = new URL("http://localhost:8080/Service1/Helloworld?wsdl");
+ URL wsService = new URL("http://localhost:8085/Service1/Helloworld?wsdl");
Assert.assertTrue(getContent(wsService).contains("definitions name=\"HelloworldService\""));
- URL jsonpService = new URL("http://localhost:8080/Client2/Helloworld/sayHello?name=Petra");
+ URL jsonpService = new URL("http://localhost:8085/Client2/Helloworld/sayHello?name=Petra");
Assert.assertEquals("\"Hello Petra\"", getContent(jsonpService));
}
@@ -66,5 +73,10 @@ public class Mapper1TestCase {
}
}
}
+
+ @After
+ public void shutdown() {
+ node.stop();
+ }
}
Added: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/UnknownEndpointTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/UnknownEndpointTestCase.java?rev=1043467&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/UnknownEndpointTestCase.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/UnknownEndpointTestCase.java Wed Dec 8 15:55:42 2010
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 itest.helloworld;
+
+import java.io.IOException;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class UnknownEndpointTestCase {
+
+ static {
+ org.apache.tuscany.sca.http.jetty.JettyServer.portDefault = 8085;
+ }
+
+ Node servicesnode;
+ Node node;
+
+ @Test
+ public void testUnknownEndpoints() throws IOException, InterruptedException {
+ servicesnode = NodeFactory.newInstance().createNode("services.composite", new String[]{"target/test-classes"}) ;
+ servicesnode.start();
+ node = NodeFactory.newInstance().createNode("clients.composite", new String[]{"target/test-classes"}) ;
+ node.start();
+
+ // test the service invocations work
+ Helloworld helloworld = node.getService(Helloworld.class, "Client1");
+ Assert.assertEquals("Hello Petra", helloworld.sayHello("Petra"));
+
+ helloworld = node.getService(Helloworld.class, "Client2");
+ Assert.assertEquals("Hello Petra", helloworld.sayHello("Petra"));
+ }
+
+ @After
+ public void shutdown() throws InterruptedException {
+ node.stop();
+ servicesnode.stop();
+ }
+}
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/UnknownEndpointTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/UnknownEndpointTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/clients.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/clients.composite?rev=1043467&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/clients.composite (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/clients.composite Wed Dec 8 15:55:42 2010
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://Scopes"
+ name="clients">
+
+ <component name="Client1">
+ <implementation.java class="itest.helloworld.HelloworldClientImpl"/>
+ <reference name="ref" target="Service1" />
+ </component>
+
+ <component name="Client2">
+ <implementation.java class="itest.helloworld.HelloworldClientImpl"/>
+ <reference name="ref" target="Service2" />
+ </component>
+
+</composite>
Added: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/services.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/services.composite?rev=1043467&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/services.composite (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/services.composite Wed Dec 8 15:55:42 2010
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://Scopes"
+ name="services">
+
+ <component name="Service1">
+ <implementation.java class="itest.helloworld.HelloworldServiceImpl"/>
+ </component>
+
+ <component name="Service2">
+ <implementation.java class="itest.helloworld.HelloworldServiceImpl"/>
+ </component>
+</composite>