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 13:06:07 UTC
svn commit: r1043371 - in
/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper: ./ src/
src/main/ src/main/java/ src/main/java/itest/
src/main/java/itest/scabindingmapper/ src/main/resources/
src/main/resources/META-INF/ src/main/resources/META-I...
Author: antelder
Date: Wed Dec 8 12:06:06 2010
New Revision: 1043371
URL: http://svn.apache.org/viewvc?rev=1043371&view=rev
Log:
Add an itest for changing the sca binding protocol on a per service basis
Added:
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/ (with props)
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/pom.xml (with props)
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyMapper.java (with props)
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/resources/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/resources/META-INF/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/resources/META-INF/services/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Helloworld.java (with props)
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldClientImpl.java (with props)
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldServiceImpl.java (with props)
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Mapper1TestCase.java (with props)
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/
tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/test.composite
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Dec 8 12:06:06 2010
@@ -0,0 +1,20 @@
+target
+work
+dojo
+*.iws
+*.ipr
+*.iml
+derby.log
+maven.log
+maven-eclipse.xml
+build.xml
+build-dependency.xml
+velocity.log*
+junit*.properties
+surefire*.properties
+.project
+.classpath
+.settings
+.deployables
+.wtpmodules
+.externalToolBuilders
Added: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/pom.xml?rev=1043371&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/pom.xml (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/pom.xml Wed Dec 8 12:06:06 2010
@@ -0,0 +1,61 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-scabindingmapper</artifactId>
+ <name>Apache Tuscany Async Integration Tests SCA Binding Mapper</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-base-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.19</version>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <plugins>
+ </plugins>
+ </build>
+</project>
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=1043371&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyMapper.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyMapper.java Wed Dec 8 12:06:06 2010
@@ -0,0 +1,70 @@
+/*
+ * 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 java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.jsonp.JSONPBinding;
+import org.apache.tuscany.sca.binding.sca.provider.DefaultSCABindingMapper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * A test SCABindingMapper to demonstrate changing the protocol on a per service basis.
+ * This uses JSONP if the service name ends with a "2" character.
+ * Uses a high ranking in the The meta-inf/services file to override the default mapper.
+ */
+public class MyMapper extends DefaultSCABindingMapper {
+
+ public MyMapper(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ super(registry, attributes);
+ }
+
+ @Override
+ protected QName chooseBinding(RuntimeEndpoint endpoint) {
+ if (endpoint.getComponent().getName().endsWith("2")) {
+ return JSONPBinding.TYPE;
+ } else {
+ return super.defaultMappedBinding;
+ }
+ }
+
+ @Override
+ protected QName chooseBinding(RuntimeEndpointReference endpointReference) {
+ if (endpointReference.getURI().endsWith("2")) {
+ return JSONPBinding.TYPE;
+ } else {
+ return super.defaultMappedBinding;
+ }
+ }
+
+ /*
+ * Probably others don't need to override this is they have a remotable endpoint registry, this itest
+ * doesn't so just fiddle the test
+ */
+ @Override
+ protected boolean isDistributed() {
+ return true;
+ }
+
+}
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/java/itest/scabindingmapper/MyMapper.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.binding.sca.provider.SCABindingMapper
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.binding.sca.provider.SCABindingMapper?rev=1043371&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.sca.provider.SCABindingMapper Wed Dec 8 12:06:06 2010
@@ -0,0 +1,18 @@
+# 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.MyMapper,ranking=4321
+
Added: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Helloworld.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Helloworld.java?rev=1043371&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Helloworld.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Helloworld.java Wed Dec 8 12:06:06 2010
@@ -0,0 +1,28 @@
+/*
+ * 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 org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+}
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Helloworld.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Helloworld.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldClientImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldClientImpl.java?rev=1043371&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldClientImpl.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldClientImpl.java Wed Dec 8 12:06:06 2010
@@ -0,0 +1,34 @@
+/*
+ * 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 org.oasisopen.sca.annotation.Reference;
+
+public class HelloworldClientImpl implements Helloworld{
+
+ @Reference
+ public Helloworld ref;
+
+ @Override
+ public String sayHello(String name) {
+ return ref.sayHello(name);
+ }
+
+}
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldClientImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldClientImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldServiceImpl.java?rev=1043371&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldServiceImpl.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldServiceImpl.java Wed Dec 8 12:06:06 2010
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+public class HelloworldServiceImpl implements Helloworld {
+
+ @Override
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/HelloworldServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=1043371&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Mapper1TestCase.java (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Mapper1TestCase.java Wed Dec 8 12:06:06 2010
@@ -0,0 +1,70 @@
+/*
+ * 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.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Mapper1TestCase {
+
+ @Test
+ public void testSCABindingFactory() throws IOException {
+ Node node = NodeFactory.newInstance().createNode("test.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"));
+
+ // verify service1 is exposed as a WS endpoint and service2 is a jsonp endpoint
+ URL wsService = new URL("http://localhost:8080/Service1/Helloworld?wsdl");
+ Assert.assertTrue(getContent(wsService).contains("definitions name=\"HelloworldService\""));
+
+ URL jsonpService = new URL("http://localhost:8080/Client2/Helloworld/sayHello?name=Petra");
+ Assert.assertEquals("\"Hello Petra\"", getContent(jsonpService));
+ }
+
+ private String getContent(URL url) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(url.openStream()));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+
+}
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Mapper1TestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/java/itest/helloworld/Mapper1TestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/test.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/test.composite?rev=1043371&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/test.composite (added)
+++ tuscany/sca-java-2.x/trunk/testing/itest/scabindingmapper/src/test/resources/test.composite Wed Dec 8 12:06:06 2010
@@ -0,0 +1,41 @@
+<?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="mappertest">
+
+ <component name="Client1">
+ <implementation.java class="itest.helloworld.HelloworldClientImpl"/>
+ <reference name="ref" target="Service1" />
+ </component>
+
+ <component name="Service1">
+ <implementation.java class="itest.helloworld.HelloworldServiceImpl"/>
+ </component>
+
+ <component name="Client2">
+ <implementation.java class="itest.helloworld.HelloworldClientImpl"/>
+ <reference name="ref" target="Service2" />
+ </component>
+
+ <component name="Service2">
+ <implementation.java class="itest.helloworld.HelloworldServiceImpl"/>
+ </component>
+</composite>