diff options
Diffstat (limited to '')
33 files changed, 2346 insertions, 0 deletions
diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldService.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..e0b1ab2303 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldService.java @@ -0,0 +1,27 @@ +/* + * 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 helloworld; + +import org.apache.axiom.om.OMElement; + +public interface HelloWorldService { + + String sayHello(String s); + OMElement sayE4XHello(OMElement xmlObject); +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..ac17e29eb0 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/helloworld/HelloWorldServiceImpl.java @@ -0,0 +1,55 @@ +/* + * 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 helloworld; + +import java.io.ByteArrayInputStream; + +import javax.xml.stream.XMLStreamReader; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.om.util.StAXUtils; + +public class HelloWorldServiceImpl implements HelloWorldService { + + public OMElement sayE4XHello(OMElement xmlObject) { + + String helloString = "<hel:getGreetingsResponse xmlns:hel=\"http://helloworld\">" + + "<hel:getGreetingsReturn>Hello from Java Implementation to </hel:getGreetingsReturn>NoString</hel:getGreetingsResponse>"; + + try { + String inputValue = xmlObject.getFirstElement().getText(); + + XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(helloString.getBytes())); + + StAXOMBuilder staxOMBuilder = new StAXOMBuilder(OMAbstractFactory.getOMFactory(), xmlReader); + OMElement response = staxOMBuilder.getDocumentElement(); + response.getFirstElement().setText(response.getFirstElement().getText() + inputValue); + + return response; + } catch (Exception e) { + return null; + } + } + + public String sayHello(String s) { + return "Hello " + s; + } +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/JavaScriptImplementationLoaderTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/JavaScriptImplementationLoaderTestCase.java new file mode 100644 index 0000000000..b7f081bb70 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/JavaScriptImplementationLoaderTestCase.java @@ -0,0 +1,107 @@ +/* + * 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 org.apache.tuscany.container.javascript; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.spi.component.CompositeComponent; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.loader.MissingResourceException; + +import junit.framework.TestCase; +import static org.easymock.EasyMock.expect; +import static org.easymock.classextension.EasyMock.createMock; +import static org.easymock.classextension.EasyMock.replay; +import static org.easymock.classextension.EasyMock.verify; + +/** + * Tests for JavaScriptImplementationLoader + */ +public class JavaScriptImplementationLoaderTestCase extends TestCase { + private CompositeComponent parent; + + private XMLStreamReader reader; + + private DeploymentContext deploymentContext; + + private ClassLoader classLoader; + + private LoaderRegistry registry; + + private JavaScriptImplementationLoader loader; + + public void testNoScriptAttribute() throws LoaderException, XMLStreamException { + expect(reader.getAttributeValue(null, "script")).andReturn(null); + replay(reader); + replay(deploymentContext); + + try { + loader.load(parent, reader, deploymentContext); + fail(); + } catch (MissingResourceException e) { + // ok + } + verify(reader); + verify(deploymentContext); + } + + public void testNoScriptPresent() throws LoaderException, XMLStreamException { + expect(reader.getAttributeValue(null, "script")).andReturn("foo.groovy"); + expect(deploymentContext.getClassLoader()).andReturn(classLoader); + + replay(reader); + replay(deploymentContext); + + JavaScriptImplementationLoader mockLoader = new JavaScriptImplementationLoader(registry) { + protected String loadSource(ClassLoader cl, String resource) throws LoaderException { + assertSame(classLoader, cl); + assertEquals("foo.groovy", resource); + throw new MissingResourceException(resource); + } + }; + try { + mockLoader.load(parent, reader, deploymentContext); + fail(); + } catch (MissingResourceException e) { + assertEquals("foo.groovy", e.getMessage()); + } + verify(reader); + verify(deploymentContext); + } + + public void testLoadScript() throws LoaderException { + String script = + loader.loadSource(getClass().getClassLoader(), "org/apache/tuscany/container/javascript/mock/test.js"); + assertEquals("//Test Script", script); + } + + protected void setUp() throws Exception { + super.setUp(); + registry = createMock(LoaderRegistry.class); + loader = new JavaScriptImplementationLoader(registry); + + parent = createMock(CompositeComponent.class); + reader = createMock(XMLStreamReader.class); + deploymentContext = createMock(DeploymentContext.class); + classLoader = createMock(ClassLoader.class); + } +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/PropertyTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/PropertyTestCase.java new file mode 100644 index 0000000000..7287d7833f --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/PropertyTestCase.java @@ -0,0 +1,65 @@ +/* + * 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 org.apache.tuscany.container.javascript; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import junit.framework.TestCase; + +import org.apache.tuscany.container.javascript.mock.Greeting; +import org.apache.tuscany.container.javascript.rhino.RhinoScript; +import org.apache.tuscany.core.component.scope.ModuleScopeContainer; +import org.apache.tuscany.spi.wire.WireService; +import org.apache.tuscany.test.ArtifactFactory; + +/** + * Tests for component properties + */ +public class PropertyTestCase extends TestCase { + + private static final String SCRIPT = "function greet(name){ return property; }"; + + private RhinoScript implClass; + + /** + * Tests injecting a simple property type on a Javascript implementation instance + */ + public void testPropertyInjection() throws Exception { + /*ModuleScopeContainer scope = new ModuleScopeContainer(null); + scope.start(); + List<Class<?>> services = new ArrayList<Class<?>>(); + services.add(Greeting.class); + Map<String, Object> properties = new HashMap<String, Object>(); + properties.put("property", "bar"); + WireService wireService = ArtifactFactory.createWireService(); + JavaScriptComponent<Greeting> context = new JavaScriptComponent<Greeting>("source", implClass, services, properties, null, scope, wireService, null); + scope.register(context); + Greeting greeting = context.getServiceInstance(); + assertEquals("bar", greeting.greet("foo")); + scope.stop();*/ + } + + protected void setUp() throws Exception { + super.setUp(); + implClass = new RhinoScript("test", SCRIPT); + } +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/RhinoScriptIntrospectorTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/RhinoScriptIntrospectorTestCase.java new file mode 100644 index 0000000000..3a51a8f619 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/RhinoScriptIntrospectorTestCase.java @@ -0,0 +1,114 @@ +/* + * 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 org.apache.tuscany.container.javascript; + +import java.io.IOException; +import java.net.URL; +import java.util.Map; +import javax.wsdl.WSDLException; +import javax.xml.namespace.QName; + +import org.apache.tuscany.spi.idl.InvalidServiceContractException; +import org.apache.tuscany.spi.idl.java.JavaServiceContract; +import org.apache.tuscany.spi.loader.MissingResourceException; +import org.apache.tuscany.spi.model.ComponentType; +import org.apache.tuscany.spi.model.ServiceContract; +import org.apache.tuscany.spi.model.ServiceDefinition; + +import helloworld.HelloWorldService; +import junit.framework.TestCase; +import org.apache.tuscany.container.javascript.rhino.RhinoSCAConfig; +import org.apache.tuscany.container.javascript.rhino.RhinoScript; +import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl; +import org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl; +import org.apache.tuscany.idl.wsdl.WSDLServiceContract; +import org.apache.tuscany.idl.wsdl.XMLSchemaRegistryImpl; + +public class RhinoScriptIntrospectorTestCase extends TestCase { + + private static final WSDLDefinitionRegistryImpl.Monitor NULL_MONITOR = new WSDLDefinitionRegistryImpl.Monitor() { + public void readingWSDL(String namespace, URL location) { + } + + public void cachingDefinition(String namespace, URL location) { + } + }; + + public void testJavaInterface() throws MissingResourceException, InvalidServiceContractException { + RhinoScript rs = + new RhinoScript("javaInterfaceTest", "SCA = { javaInterface : 'helloworld.HelloWorldService',};", + null, getClass().getClassLoader()); + RhinoSCAConfig scaConfig = new RhinoSCAConfig(rs.getScriptScope()); + JavaScriptIntrospector introspector = + new JavaScriptIntrospector(null, new JavaInterfaceProcessorRegistryImpl()); + ComponentType comonentType = introspector.introspectScript(scaConfig, rs.getClassLoader()); + assertNotNull(comonentType); + Map services = comonentType.getServices(); + assertEquals(1, services.size()); + ServiceDefinition serviceDefinition = (ServiceDefinition) services.values().iterator().next(); + ServiceContract serviceContract = serviceDefinition.getServiceContract(); + assertTrue(serviceContract instanceof JavaServiceContract); + JavaServiceContract javaServiceContract = (JavaServiceContract) serviceContract; + assertEquals(HelloWorldService.class, javaServiceContract.getInterfaceClass()); + } + + public void testWSDLLocation() throws WSDLException { +// RhinoScript rs = new RhinoScript("wsdlLocation", +// "SCA = { wsdlLocation : 'src/test/resources/org/apache/tuscany/container/javascript/rhino/helloworld.wsdl',};", null, getClass() +// .getClassLoader()); +// RhinoSCAConfig scaConfig = new RhinoSCAConfig(rs.getScriptScope()); +// JavaScriptIntrospector introspector = new JavaScriptIntrospector(null); +// ComponentType comonentType = introspector.introspectScript(scaConfig, rs.getClassLoader()); +// assertNotNull(comonentType); +// Map services = comonentType.getServices(); +// assertEquals(1, services.size()); +// ServiceDefinition serviceDefinition = (ServiceDefinition) services.values().iterator().next(); +// ServiceContract serviceContract = serviceDefinition.getServiceContract(); +// assertTrue(serviceContract instanceof WSDLServiceContract); +// WSDLServiceContract wsdlServiceContract = (WSDLServiceContract) serviceContract; +// assertEquals(new QName("http://helloworld", "HelloWorld"), wsdlServiceContract.getPortType().getQName()); + } + + public void testWSDLPortType() throws WSDLException, IOException, MissingResourceException, + InvalidServiceContractException { + RhinoScript rs = new RhinoScript("wsdlPortType", + "SCA = { wsdlPortType : 'HelloWorld', wsdlNamespace : 'http://helloworld',};", null, + getClass().getClassLoader()); + RhinoSCAConfig scaConfig = new RhinoSCAConfig(rs.getScriptScope()); + + WSDLDefinitionRegistryImpl wsdlReg = new WSDLDefinitionRegistryImpl(); + wsdlReg.setSchemaRegistry(new XMLSchemaRegistryImpl()); + wsdlReg.setMonitor(NULL_MONITOR); + URL wsdlURL = + getClass().getClassLoader().getResource("org/apache/tuscany/container/javascript/rhino/helloworld.wsdl"); + wsdlReg.loadDefinition("http://helloworld", wsdlURL); + + JavaScriptIntrospector introspector = + new JavaScriptIntrospector(wsdlReg, new JavaInterfaceProcessorRegistryImpl()); + ComponentType comonentType = introspector.introspectScript(scaConfig, rs.getClassLoader()); + assertNotNull(comonentType); + Map services = comonentType.getServices(); + assertEquals(1, services.size()); + ServiceDefinition serviceDefinition = (ServiceDefinition) services.values().iterator().next(); + ServiceContract serviceContract = serviceDefinition.getServiceContract(); + assertTrue(serviceContract instanceof WSDLServiceContract); + WSDLServiceContract wsdlServiceContract = (WSDLServiceContract) serviceContract; + assertEquals(new QName("http://helloworld", "HelloWorld"), wsdlServiceContract.getPortType().getQName()); + } +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/ScriptInvokeTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/ScriptInvokeTestCase.java new file mode 100644 index 0000000000..94835591df --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/ScriptInvokeTestCase.java @@ -0,0 +1,61 @@ +/* + * 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 org.apache.tuscany.container.javascript; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.container.javascript.mock.Greeting; +import org.apache.tuscany.container.javascript.rhino.RhinoScript; +import org.apache.tuscany.core.component.scope.ModuleScopeContainer; +import org.apache.tuscany.test.ArtifactFactory; + +/** + * Tests for invoker JavaScriptComponents + */ +public class ScriptInvokeTestCase extends TestCase { + + private static final String SCRIPT = "function greet(name) { return name }"; + + private RhinoScript rhinoScript; + + /** + * Tests the invocation of a Groovy "script" as opposed to a class + */ + public void testBasicScriptInvocation() throws Exception { +// ModuleScopeContainer scope = new ModuleScopeContainer(null); +// scope.start(); +// List<Class<?>> services = new ArrayList<Class<?>>(); +// services.add(Greeting.class); +// JavaScriptComponent<Greeting> context = new JavaScriptComponent<Greeting>("source", rhinoScript, services, new HashMap<String, Object>(), +// null, scope, ArtifactFactory.createWireService(), null); +// scope.register(context); +// Greeting object = (Greeting) context.getServiceInstance(); +// assertEquals("foo", object.greet("foo")); +// scope.stop(); + } + + protected void setUp() throws Exception { + super.setUp(); + rhinoScript = new RhinoScript("test", SCRIPT); + } +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/WireTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/WireTestCase.java new file mode 100644 index 0000000000..8bf7f8e74a --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/WireTestCase.java @@ -0,0 +1,161 @@ +/* + * 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 org.apache.tuscany.container.javascript; + +import static org.easymock.EasyMock.reportMatcher; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.container.javascript.mock.Greeting; +import org.apache.tuscany.container.javascript.rhino.RhinoScript; +import org.apache.tuscany.core.component.scope.ModuleScopeContainer; +import org.apache.tuscany.spi.model.Operation; +import org.apache.tuscany.spi.wire.InboundInvocationChain; +import org.apache.tuscany.spi.wire.InboundWire; +import org.apache.tuscany.spi.wire.Message; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.test.ArtifactFactory; +import org.easymock.IArgumentMatcher; + +/** + * Tests for JavaScript component wiring + */ +public class WireTestCase extends TestCase { + + private static final String SCRIPT = + " function setWire(ref){" + + " wire = ref;" + " }" + + " " + + " function greet(name){" + + " return wire.greet(name); " + + " }"; + + private static final String SCRIPT2 = + " function greet(name){" + + " return name; " + + " }"; + + private RhinoScript implClass1; + + private RhinoScript implClass2; + + /** + * Tests a basic invocation down a source wire + */ + public void testReferenceWireInvocation() throws Exception { +// ModuleScopeContainer scope = new ModuleScopeContainer(null); +// scope.start(); +// +// List<Class<?>> services = new ArrayList<Class<?>>(); +// services.add(Greeting.class); +// JavaScriptComponent<Greeting> context = new JavaScriptComponent<Greeting>("source", implClass1, services, properties, null, scope, +// ArtifactFactory.createWireService(), null); +// OutboundWire wire = ArtifactFactory.createOutboundWire("wire", Greeting.class); +// ArtifactFactory.terminateWire(wire); +// +// TargetInvoker invoker = createMock(TargetInvoker.class); +// expect(invoker.isCacheable()).andReturn(false); +// Message response = new MessageImpl(); +// response.setBody("foo"); +// expect(invoker.invoke(eqMessage())).andReturn(response); +// replay(invoker); +// +// for (OutboundInvocationChain chain : wire.getInvocationChains().values()) { +// chain.setTargetInvoker(invoker); +// } +// scope.register(context); +// context.addOutboundWire(wire); +// Greeting greeting = context.getServiceInstance(); +// assertEquals("foo", greeting.greet("foo")); +// verify(invoker); +// +// scope.stop(); + } + + // todo this could be generalized and moved to test module + public static Message eqMessage() { + reportMatcher(new IArgumentMatcher() { + public boolean matches(Object object) { + if (!(object instanceof Message)) { + return false; + } + final Message msg = (Message) object; + Object[] body = (Object[]) msg.getBody(); + return "foo".equals(body[0]); + } + + public void appendTo(StringBuffer stringBuffer) { + } + }); + return null; + } + + /** + * Tests a basic invocation to a target + */ + public void testTargetInvocation() throws Exception { + ModuleScopeContainer scope = new ModuleScopeContainer(null); + scope.start(); + List<Class<?>> services = new ArrayList<Class<?>>(); + services.add(Greeting.class); + JavaScriptComponent context = + new JavaScriptComponent("source", implClass2, new HashMap<String, Object>(), services, null, scope, + ArtifactFactory.createWireService(), null); + scope.register(context); + Operation<Type> operation = new Operation<Type>("greet", null, null, null, false, null); + TargetInvoker invoker = context.createTargetInvoker(null, operation); + assertEquals("foo", invoker.invokeTarget(new String[]{"foo"})); + scope.stop(); + } + + /** + * Tests a basic invocation down a target wire + */ + public void testTargetWireInvocation() throws Exception { + ModuleScopeContainer scope = new ModuleScopeContainer(null); + scope.start(); + List<Class<?>> services = new ArrayList<Class<?>>(); + services.add(Greeting.class); + JavaScriptComponent context = + new JavaScriptComponent("source", implClass2, new HashMap<String, Object>(), services, null, scope, + ArtifactFactory.createWireService(), null); + scope.register(context); + + InboundWire wire = ArtifactFactory.createInboundWire("Greeting", Greeting.class); + ArtifactFactory.terminateWire(wire); + for (InboundInvocationChain chain : wire.getInvocationChains().values()) { + chain.setTargetInvoker(context.createTargetInvoker(null, chain.getOperation())); + } + context.addInboundWire(wire); + Greeting greeting = (Greeting) context.getServiceInstance("Greeting"); + assertEquals("foo", greeting.greet("foo")); + scope.stop(); + } + + protected void setUp() throws Exception { + super.setUp(); + implClass1 = new RhinoScript("script1", SCRIPT); + implClass2 = new RhinoScript("script2", SCRIPT2); + } +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/HelloWorldTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/HelloWorldTestCase.java new file mode 100644 index 0000000000..3db49618e2 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/HelloWorldTestCase.java @@ -0,0 +1,104 @@ +/* + * 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 org.apache.tuscany.container.javascript.function; + +import helloworld.HelloWorldService; + +import java.io.ByteArrayInputStream; +import java.net.URL; + +import javax.xml.stream.XMLStreamReader; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.om.util.StAXUtils; +import org.apache.tuscany.test.SCATestCase; +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * This shows how to test the HelloWorld service component. + */ +public class HelloWorldTestCase extends SCATestCase { + + private CompositeContext context; + + protected void setUp() throws Exception { + URL base = getClass().getResource("/META-INF/sca/js.system.scdl"); + addExtension("JavaScriptContainer", new URL(base, "default.scdl")); + setApplicationSCDL(getClass().getResource("helloworld.scdl")); + super.setUp(); + + context = CurrentCompositeContext.getContext(); + } + + public void testHelloWorld() throws Exception { + HelloWorldService helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldComponent"); + assertEquals(helloWorldService.sayHello("petra"), "Hello petra"); + } + + public void testIntrospectedHelloWorld() throws Exception { + HelloWorldService introspectableService = context.locateService(HelloWorldService.class, "IntrospectableHelloWorldComponent"); + assertEquals(introspectableService.sayHello("petra"), "Hello petra"); + } + + public void testE4XImplInvocation() throws Exception { + HelloWorldService e4xHelloWorldService = context.locateService(HelloWorldService.class, "HelloWorldComponentE4X"); + String xmlInput = "<hel:getGreetings xmlns:hel=\"http://helloworld\"> " + + "<hel:name>TuscanyWorld</hel:name> " + + "</hel:getGreetings>"; + + XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader( + new ByteArrayInputStream(xmlInput.getBytes())); + StAXOMBuilder staxOMBuilder = new StAXOMBuilder(OMAbstractFactory.getOMFactory(), xmlReader); + Object response = e4xHelloWorldService.sayE4XHello(staxOMBuilder.getDocumentElement()); + assertNotNull(response); + assertTrue(response instanceof OMElement); + assertEquals("e4xHello TuscanyWorld", ((OMElement)response).getFirstElement().getText()); + //System.out.println(response); + } + + public void testE4XRefInvocation() throws Exception + { + HelloWorldService e4xHelloWorldService = context.locateService(HelloWorldService.class, "HelloWorldComponentE4X"); + + String initialInput = "JavaClient"; + String jsAddition = " thro e4x reference"; + String endSvcImplResponse = "Hello from Java Implementation to "; + + Object response = e4xHelloWorldService.sayHello(initialInput); + assertNotNull(response); + assertTrue(response instanceof String); + assertEquals(endSvcImplResponse + initialInput + jsAddition, response.toString()); + //System.out.println(response); + } + + public void testHelloWorldProperty() throws Exception { + HelloWorldService helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldProperty"); + assertEquals(helloWorldService.sayHello("petra"), "Kia ora petra"); + System.out.println(helloWorldService.sayHello("petra")); + } + + public void testHelloWorldPropertyDefault() throws Exception { + HelloWorldService helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldPropertyDefault"); + assertEquals(helloWorldService.sayHello("petra"), "Hi petra"); + } + +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/ScopeTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/ScopeTestCase.java new file mode 100644 index 0000000000..b823939e6c --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/function/ScopeTestCase.java @@ -0,0 +1,65 @@ +/* + * 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 org.apache.tuscany.container.javascript.function; + +import java.net.URL; + +import helloworld.HelloWorldService; + +import org.apache.tuscany.test.SCATestCase; +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * This shows how to test the HelloWorld service component. + */ +public class ScopeTestCase extends SCATestCase { + + private CompositeContext context; + + protected void setUp() throws Exception { + URL base = getClass().getResource("/META-INF/sca/js.system.scdl"); + addExtension("JavaScriptContainer", new URL(base, "default.scdl")); + setApplicationSCDL(getClass().getResource("scopeTest.scdl")); + super.setUp(); + + context = CurrentCompositeContext.getContext(); + } + +// Composite scope not implemented in core yet +// public void testComposite() throws Exception { +// HelloWorldService composoteScopeService = context.locateService(HelloWorldService.class, "ComposoteScopeService"); +// assertEquals("1", composoteScopeService.sayHello("")); +// assertEquals("2", composoteScopeService.sayHello("")); +// } + + public void testStateless() throws Exception { + HelloWorldService statelessService = context.locateService(HelloWorldService.class, "StatelessComponent"); + assertEquals("1", statelessService.sayHello("")); + // stateless gives a new instance for each request + assertEquals("1", statelessService.sayHello("")); + } + +// Request scope not implemented in core yet +// public void testRequestState() throws Exception { +// HelloWorldService requestService = context.locateService(HelloWorldService.class, "RequestComponent"); +// assertEquals("1", requestService.sayHello("")); +// assertEquals("1", requestService.sayHello("")); +// } +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/mock/Greeting.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/mock/Greeting.java new file mode 100644 index 0000000000..e300f73469 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/mock/Greeting.java @@ -0,0 +1,26 @@ +/* + * 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 org.apache.tuscany.container.javascript.mock; + +public interface Greeting { + + String setWire(Greeting ref); + + String greet(String name); +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/Foo.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/Foo.java new file mode 100644 index 0000000000..397501a23b --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/Foo.java @@ -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 org.apache.tuscany.container.javascript.rhino; + +class Foo { + private String s; + + public Foo() { + } + + public String getS() { + return s; + } + + public void setS(String s) { + this.s = s; + } +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoFunctionInvokerTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoFunctionInvokerTestCase.java new file mode 100644 index 0000000000..dad61659f3 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoFunctionInvokerTestCase.java @@ -0,0 +1,174 @@ +/* + * 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 org.apache.tuscany.container.javascript.rhino; + +import java.io.IOException; + +import junit.framework.TestCase; + +import org.apache.axiom.om.OMElement; +import org.apache.xmlbeans.XmlException; +import org.apache.xmlbeans.XmlObject; + +/** + * Tests for the RhinoFunctionInvoker + */ +public class RhinoFunctionInvokerTestCase extends TestCase { + + public RhinoFunctionInvokerTestCase() { + } + + protected void setUp() throws Exception { + super.setUp(); + } + + public void testNoArgsInvoke() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getPetra"); + assertNotNull(invoker); + assertEquals("petra", invoker.invoke(null)); + } + + public void testOneArgInvoke() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getS(s) {return s;}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getS"); + assertNotNull(invoker); + assertEquals("petra", invoker.invoke(new Object[] { "petra" })); + } + + public void testMultiArgsInvoke() { + RhinoScript rhinoScript = new RhinoScript("foo", "function concat(x, y) {return x + y}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("concat"); + assertNotNull(invoker); + assertEquals("petrasue", invoker.invoke(new Object[] { "petra", "sue" })); + } + + public void testNoResponseInvoke() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getNull() {}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getNull"); + assertNotNull(invoker); + assertEquals(null, invoker.invoke(new Object[0])); + } + + public void testNullResponseInvoke() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getNull() {return null;}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getNull"); + assertNotNull(invoker); + assertEquals(null, invoker.invoke(new Object[0])); + } + + public void testResponseTypeDefaultString() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getTrue() {return true;}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getTrue"); + assertNotNull(invoker); + Object o = invoker.invoke(new Object[0]); + assertTrue(o instanceof String); + assertEquals("true", o); + } + + public void testResponseTypeBoolean() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getTrue() {return true;}"); + //rhinoScript.setResponseClass("getTrue", Boolean.class); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getTrue", Boolean.class); + assertNotNull(invoker); + assertTrue((Boolean) invoker.invoke(new Object[0])); + } + + public void testResponseTypeStringArray() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getAs() {var as = new Array(1);as[0]='petra';return as;}"); + //rhinoScript.setResponseClass("getAs", new String[0].getClass()); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getAs", new String[0].getClass()); + assertNotNull(invoker); + Object o = invoker.invoke(new Object[0]); + assertNotNull(o); + assertTrue(o.getClass().isArray()); + assertEquals("petra", ((Object[]) o)[0]); + } + + public void testResponseTypeBooleanArray() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getBs() {var bs = new Array(1);bs[0]=true;return bs;}"); + rhinoScript.setResponseClass("getBs", new Boolean[0].getClass()); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getBs", new Boolean[0].getClass()); + assertNotNull(invoker); + Object o = invoker.invoke(new Object[0]); + assertNotNull(o); + assertTrue(o.getClass().isArray()); + assertTrue(((Boolean[]) o)[0]); + } + + public void testRequestCustomType() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getFooS(foo) {return foo.getS();}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getFooS"); + assertNotNull(invoker); + + Foo foo = new Foo(); + foo.setS("petra"); + Object o = invoker.invoke(new Object[] { foo }); + assertEquals(foo.getS(), o); + } + + public void testResponseCustomType() { + RhinoScript rhinoScript = new RhinoScript("foo", + "importClass(Packages.org.apache.tuscany.container.javascript.rhino.Foo);function getFoo(s) {var foo = new Foo(); foo.setS(s);return foo;}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getFoo"); + assertNotNull(invoker); + + Object o = invoker.invoke(new Object[] { "petra" }); + assertNotNull(o); + assertEquals("petra", ((Foo) o).getS()); + } + + public void testXMLRequest() throws XmlException, IOException { + RhinoScript rhinoScript = new RhinoScript("foo", "function isXML(x) {return 'xml' == (typeof x);}"); + //rhinoScript.setResponseClass("isXML", Boolean.class); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("isXML", Boolean.class); + assertNotNull(invoker); + + Object xml = XmlObject.Factory.parse("<a><b/></a>"); + assertTrue((Boolean) invoker.invoke(new Object[] { xml })); + + Object notXML = "notXML"; + assertFalse((Boolean) invoker.invoke(new Object[] { notXML })); + } + + public void testXMLResponse() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getXML(s) {return <a> { s } </a>;}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getXML"); + assertNotNull(invoker); + + Object xml = invoker.invoke(new Object[] { "petra" }); + assertNotNull(xml); + assertTrue(xml instanceof OMElement); + assertEquals("<a>petra</a>", ((OMElement) xml).toString()); + } + +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoSCAConfigTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoSCAConfigTestCase.java new file mode 100644 index 0000000000..cddaa9c46f --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoSCAConfigTestCase.java @@ -0,0 +1,116 @@ +/* + * 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 org.apache.tuscany.container.javascript.rhino; + +import junit.framework.TestCase; + +import org.apache.tuscany.spi.model.Scope; + +public class RhinoSCAConfigTestCase extends TestCase { + + public void testJavaInteface() { + RhinoScript rs = new RhinoScript("javaInterface", "SCA = { javaInterface : 'Test' }"); + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + assertTrue(scaConfig.hasSCAConfig()); + assertEquals("Test", scaConfig.getJavaInterface()); + } + + public void testWSDLLocation() { + RhinoScript rs = new RhinoScript("wsdlLocation", "SCA = { wsdlLocation : 'Test' }"); + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + assertTrue(scaConfig.hasSCAConfig()); + assertEquals("Test", scaConfig.getWSDLLocation()); + } + + public void testWSDLNamespace() { + RhinoScript rs = new RhinoScript("wsdlNamespace", "SCA = { wsdlNamespace : 'Test' }"); + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + assertTrue(scaConfig.hasSCAConfig()); + assertEquals("Test", scaConfig.getWSDLNamespace()); + } + + public void testWSDLPortType() { + RhinoScript rs = new RhinoScript("wsdlPortType", "SCA = { wsdlPortType : 'Test' }"); + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + assertTrue(scaConfig.hasSCAConfig()); + assertEquals("Test", scaConfig.getWSDLPortType()); + } + + public void testScopeStateless() { + RhinoScript rs = new RhinoScript("testScopeStateless", "SCA = { scope : 'stateless', javaInterface : 'helloworld.HelloWorldService'}"); + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + assertTrue(scaConfig.hasSCAConfig()); + assertEquals(Scope.STATELESS, scaConfig.getScope()); + } + + public void testScopeComposite() { + RhinoScript rs = new RhinoScript("testScopeComposite", "SCA = { scope : 'composite', javaInterface : 'helloworld.HelloWorldService'}"); + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + assertTrue(scaConfig.hasSCAConfig()); + assertEquals(Scope.MODULE, scaConfig.getScope()); // TODO + } + + public void testScopeConversational() { + RhinoScript rs = new RhinoScript("testScopeConversational", "SCA = { scope : 'conversational', javaInterface : 'helloworld.HelloWorldService'}"); + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + assertTrue(scaConfig.hasSCAConfig()); + assertEquals(Scope.SESSION, scaConfig.getScope()); + } + + public void testScopeRequest() { + RhinoScript rs = new RhinoScript("testScopeRequest", "SCA = { scope : 'request', javaInterface : 'helloworld.HelloWorldService'}"); + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + assertTrue(scaConfig.hasSCAConfig()); + assertEquals(Scope.REQUEST, scaConfig.getScope()); + } + + public void testBadScope() { + RhinoScript rs = new RhinoScript("testScopeStateless", "SCA = { scope : 'rubbish', javaInterface : 'helloworld.HelloWorldService'}"); + try { + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + fail("expecting bad scope exception: " + scaConfig); + } catch (IllegalArgumentException e) { + } + } + + public void testNoConfig() { + RhinoScript rs = new RhinoScript("javaInterface", ""); + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + assertTrue(!scaConfig.hasSCAConfig()); + } + + public void testNoService() { + RhinoScript rs = new RhinoScript("javaInterface", "SCA = {}"); + try { + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + fail("expecting no service exception: " + scaConfig); + } catch (IllegalArgumentException e) { + } + } + + public void testDupicateInteface() { + RhinoScript rs = new RhinoScript("javaInterface", "SCA = { javaInterface : 'Test', wsdlLocation : 'Test' }"); + try { + RhinoSCAConfig scaConfig = rs.getSCAConfig(); + fail("expecting multiple service exception: " + scaConfig); + } catch (IllegalArgumentException e) { + } + } + +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptInstanceTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptInstanceTestCase.java new file mode 100644 index 0000000000..76d6c7c49d --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptInstanceTestCase.java @@ -0,0 +1,50 @@ +/* + * 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 org.apache.tuscany.container.javascript.rhino; + +import junit.framework.TestCase; + +/** + * Tests for the RhinoScriptInstance + */ +public class RhinoScriptInstanceTestCase extends TestCase { + + public RhinoScriptInstanceTestCase() { + + } + + protected void setUp() throws Exception { + super.setUp(); + } + + public void testInvokeFunction() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + assertEquals("petra", instance.invokeFunction("getPetra", new Object[0])); + } + + public void testCreateRhinoFunctionInvoker() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getPetra"); + assertNotNull(invoker); + assertEquals("petra", invoker.invoke(new Object[0])); + } + +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptTestCase.java new file mode 100644 index 0000000000..ab684c39ce --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/rhino/RhinoScriptTestCase.java @@ -0,0 +1,83 @@ +/* + * 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 org.apache.tuscany.container.javascript.rhino; + +import java.util.HashMap; +import java.util.Map; + +import junit.framework.TestCase; + +/** + * Tests for the RhinoScript + */ +public class RhinoScriptTestCase extends TestCase { + + public RhinoScriptTestCase() { + + } + + protected void setUp() throws Exception { + super.setUp(); + } + + public void testSimpleConstructor() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + assertEquals("petra", instance.invokeFunction("getPetra", new Object[0])); + } + + public void testFullConstructor() { + ClassLoader cl = getClass().getClassLoader(); + Map<String, Object> contexts = new HashMap<String, Object>(); + contexts.put("name", "petra"); + RhinoScript rhinoScript = new RhinoScript("foo", "function getName() {return name;}", contexts, cl); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + assertEquals("petra", instance.invokeFunction("getName", new Object[0])); + } + + public void testCreateInstance() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + assertNotNull(instance); + } + + public void testCreateInstanceWithContext() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getName() {return name;}"); + Map<String, Object> contexts = new HashMap<String, Object>(); + contexts.put("name", "petra"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(contexts); + assertEquals("petra", instance.invokeFunction("getName", new Object[0])); + } + + public void testDefaultResponseType() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getX() {return 42;}"); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + assertEquals("42", instance.invokeFunction("getX", new Object[0])); + } + + public void testSetResponseType() { + RhinoScript rhinoScript = new RhinoScript("foo", "function getX() {return 42;}"); + rhinoScript.setResponseClass("getX", Integer.class); + RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(); + Object x = instance.invokeFunction("getX", new Object[0], Integer.class); + assertTrue(x instanceof Integer); + assertEquals(new Integer(42), x); + } + +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDGeneratorTestCase.java b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDGeneratorTestCase.java new file mode 100644 index 0000000000..15752bdaa1 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/java/org/apache/tuscany/container/javascript/utils/xmlfromxsd/XMLfromXSDGeneratorTestCase.java @@ -0,0 +1,129 @@ +/* + * 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 org.apache.tuscany.container.javascript.utils.xmlfromxsd; + +import junit.framework.TestCase; + +public class XMLfromXSDGeneratorTestCase extends TestCase { + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + /*public void testXMLInstance_SDO_based_1() + { + String[] arguments = new String[] { "-xsd", "sequences.xsd", + "-st", "MixedQuote", + "-stn", "http://www.example.com/sequences", + "-o", "target/xmlFromxsd-source", + "-of", "sequences_sdo.xml" + }; + + XMLfromXSDGenerator.main(arguments); + //File file = new File("target/java2wsdl-source/CustomerValue.wsdl"); + //assertTrue(file.exists() && file.isFile()); + } + + public void testXMLInstance_SDO_based_2() + { + try + { + XMLfromXSDConfiguration config = new XMLfromXSDConfiguration(); + config.setXsdFileName("interopdoc.wsdl"); + config.setSchemaTypeName("ComplexDocument"); + config.setSchemaTypeNamespaceURI("http://soapinterop.org/"); + config.setXmlOutputLocation("target/xmlFromxsd-source"); + config.setXmlFileName("interopdoc_sdo.xml"); + + XMLGeneratorFactory.getInstance().createGenerator(XMLGenerator.SDO_BASED).generateXML(config); + //XMLGeneratorFactory.getInstance().createGenerator(XMLGenerator.XMLBEANS_BASED).generateXML(config); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + + public void testXMLInstance_SDO_based_3() + { + try + { + XMLfromXSDConfiguration config = new XMLfromXSDConfiguration(); + config.setXsdFileName("helloworld.wsdl"); + //config.setSchemaTypeName("getGreetings"); + config.setSchemaTypeName("ComplexGreetings"); + config.setSchemaTypeNamespaceURI("http://helloworldaxis.samples.tuscany.apache.org"); + config.setXmlOutputLocation("target/xmlFromxsd-source"); + config.setXmlFileName("helloworld_sdo.xml"); + + XMLGeneratorFactory.getInstance().createGenerator(XMLGenerator.SDO_BASED).generateXML(config); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + }*/ + + public void testXMLInstance_XB_based_1() { + String[] arguments = new String[] { "-xsd", "src/test/resources/sequences.xsd", "-st", "mixedStockQuote", "-stn", + "http://www.example.com/sequences", "-o", "target/xmlFromxsd-source", "-of", "sequences_xb.xml" }; + + XMLfromXSDGenerator.generatorType = XMLGenerator.XMLBEANS_BASED; + XMLfromXSDGenerator.main(arguments); + /* + * File file = new File("target/java2wsdl-source/CustomerValue.wsdl"); assertTrue(file.exists() && file.isFile()); + */ + } + + public void testXMLInstance_XB_based_2() { + try { + XMLfromXSDConfiguration config = new XMLfromXSDConfiguration(); + config.setXsdFileName("interopdoc.wsdl"); + config.setSchemaTypeName("ComplexDocument"); + config.setSchemaTypeNamespaceURI("http://soapinterop.org/"); + config.setXmlOutputLocation("target/xmlFromxsd-source"); + config.setXmlFileName("interopdoc_xb.xml"); + + XMLGeneratorFactory.getInstance().createGenerator(XMLGenerator.XMLBEANS_BASED).generateXML(config); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void testXMLInstance_XB_based_3() { + try { + XMLfromXSDConfiguration config = new XMLfromXSDConfiguration(); + config.setXsdFileName("org/apache/tuscany/container/javascript/rhino/helloworld.wsdl"); + // config.setXsdFileName("helloworld.wsdl"); + config.setSchemaTypeName("getGreetings"); + // config.setSchemaTypeName("ComplexGreetings"); + config.setSchemaTypeNamespaceURI("http://helloworld"); + config.setXmlOutputLocation("target/xmlFromxsd-source"); + config.setXmlFileName("helloworld_xb.xml"); + + XMLGeneratorFactory.getInstance().createGenerator(XMLGenerator.XMLBEANS_BASED).generateXML(config); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/AccountService.wsdl b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/AccountService.wsdl new file mode 100644 index 0000000000..2a56a3c496 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/AccountService.wsdl @@ -0,0 +1,242 @@ +<?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. + --> +<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:tns="http://www.bigbank.com/Account/" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:account="http://www.bigbank.com/Account/" + targetNamespace="http://www.bigbank.com/Account/" + name="AccountService"> + + <wsdl:types> + <xsd:schema targetNamespace="http://www.bigbank.com/Account/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:account="http://www.bigbank.com/Account/" + xmlns:sdojava="commonj.sdo/java" + sdojava:package="org.apache.tuscany.samples.bigbank.account"> + + <xsd:element name="getAccountReportWrapped0"> + <xsd:complexType> + <xsd:sequence> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="getAccountReportWrapped0Response"> + <xsd:complexType> + <xsd:sequence> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:element name="getAccountReportWrapped1"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="customerID" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="getAccountReportWrapped1Response"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="accountReport" type="account:AccountReport"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:element name="getAccountReportWrappedN"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="customerID" type="xsd:string"/> + <xsd:element name="customerID2" type="xsd:int"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="getAccountReportWrappedNResponse"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="accountReport" type="account:AccountReport"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:element name="getAccountReportBare0" type="xsd:string"/> + <xsd:element name="getAccountReportBare0Response" type="xsd:int"/> + + <xsd:element name="getAccountReportBare1Simple" type="xsd:string"/> + <xsd:element name="getAccountReportBare1SimpleResponse" type="xsd:int"/> + + <xsd:element name="getAccountReportBare1Complex" type="account:AccountRequest"/> + <xsd:element name="getAccountReportBare1ComplexResponse" type="account:AccountReport"/> + + <xsd:complexType name="AccountRequest"> + <xsd:sequence> + <xsd:element name="customerID" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="AccountReport"> + <xsd:sequence> + <xsd:element name="accountSummaries" type="account:AccountSummary" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + <xsd:complexType name="AccountSummary"> + <xsd:attribute name="accountNumber" type="xsd:string"/> + <xsd:attribute name="accountType" type="xsd:string"/> + <xsd:attribute name="balance" type="xsd:float"/> + </xsd:complexType> + + </xsd:schema> + </wsdl:types> + + <wsdl:message name="getAccountReportWrapped0Request"> + <wsdl:part element="account:getAccountReportWrapped0" name="getAccountReportWrapped0Request"/> + </wsdl:message> + <wsdl:message name="getAccountReportWrapped0Response"> + <wsdl:part element="account:getAccountReportWrapped0Response" name="getAccountReportWrapped0Response"/> + </wsdl:message> + + <wsdl:message name="getAccountReportWrapped1Request"> + <wsdl:part element="account:getAccountReportWrapped1" name="getAccountReportWrapped1Request"/> + </wsdl:message> + <wsdl:message name="getAccountReportWrapped1Response"> + <wsdl:part element="account:getAccountReportWrapped1Response" name="getAccountReportWrapped1Response"/> + </wsdl:message> + + <wsdl:message name="getAccountReportWrappedNRequest"> + <wsdl:part element="account:getAccountReportWrappedN" name="getAccountReportWrappedNRequest"/> + </wsdl:message> + <wsdl:message name="getAccountReportWrappedNResponse"> + <wsdl:part element="account:getAccountReportWrappedNResponse" name="getAccountReportWrappedNResponse"/> + </wsdl:message> + + <wsdl:message name="getAccountReportBare0Request"> + </wsdl:message> + <wsdl:message name="getAccountReportBare0Response"> + </wsdl:message> + + <wsdl:message name="getAccountReportBare1SimpleRequest"> + <wsdl:part element="account:getAccountReportBare1Simple" name="getAccountReportBare1SimpleRequest"/> + </wsdl:message> + <wsdl:message name="getAccountReportBare1SimpleResponse"> + <wsdl:part element="account:getAccountReportBare1SimpleResponse" name="getAccountReportBare1SimpleResponse"/> + </wsdl:message> + + <wsdl:message name="getAccountReportBare1ComplexRequest"> + <wsdl:part element="account:getAccountReportBare1Complex" name="getAccountReportBare1ComplexRequest"/> + </wsdl:message> + <wsdl:message name="getAccountReportBare1ComplexResponse"> + <wsdl:part element="account:getAccountReportBare1ComplexResponse" name="getAccountReportBare1ComplexResponse"/> + </wsdl:message> + + <wsdl:portType name="Account_Service"> + <wsdl:operation name="getAccountReportWrapped0"> + <wsdl:input message="tns:getAccountReportWrapped0Request"/> + <wsdl:output message="tns:getAccountReportWrapped0Response"/> + </wsdl:operation> + <wsdl:operation name="getAccountReportWrapped1"> + <wsdl:input message="tns:getAccountReportWrapped1Request"/> + <wsdl:output message="tns:getAccountReportWrapped1Response"/> + </wsdl:operation> + <wsdl:operation name="getAccountReportWrappedN"> + <wsdl:input message="tns:getAccountReportWrappedNRequest"/> + <wsdl:output message="tns:getAccountReportWrappedNResponse"/> + </wsdl:operation> + <wsdl:operation name="getAccountReportBare0"> + <wsdl:input message="tns:getAccountReportBare0Request"/> + <wsdl:output message="tns:getAccountReportBare0Response"/> + </wsdl:operation> + <wsdl:operation name="getAccountReportBare1Simple"> + <wsdl:input message="tns:getAccountReportBare1SimpleRequest"/> + <wsdl:output message="tns:getAccountReportBare1SimpleResponse"/> + </wsdl:operation> + <wsdl:operation name="getAccountReportBare1Complex"> + <wsdl:input message="tns:getAccountReportBare1ComplexRequest"/> + <wsdl:output message="tns:getAccountReportBare1ComplexResponse"/> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="AccountServiceSOAP" type="tns:Account_Service"> + <soap:binding style="document" + transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getAccountReportWrapped0"> + <soap:operation + soapAction="http://www.bigbank.com/Account/getAccountReportWrapped0"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="getAccountReportWrapped1"> + <soap:operation + soapAction="http://www.bigbank.com/Account/getAccountReportWrapped1"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="getAccountReportWrappedN"> + <soap:operation + soapAction="http://www.bigbank.com/Account/getAccountReportWrappedN"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="getAccountReportBare0"> + <soap:operation + soapAction="http://www.bigbank.com/Account/getAccountReportBare0"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="getAccountReportBare1Simple"> + <soap:operation + soapAction="http://www.bigbank.com/Account/getAccountReportBare1Simple"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="getAccountReportBare1Complex"> + <soap:operation + soapAction="http://www.bigbank.com/Account/getAccountReportBare1Complex"/> + <wsdl:input> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="AccountService"> + <wsdl:port binding="tns:AccountServiceSOAP" + name="AccountServiceSOAP"> + <soap:address location="http://localhost:8080/sample-account/services/AccountService"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/interopdoc.wsdl b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/interopdoc.wsdl new file mode 100644 index 0000000000..820c26ca34 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/interopdoc.wsdl @@ -0,0 +1,180 @@ +<?xml version="1.0"?> +<!-- + * 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. + --> +<definitions name="InteropTestDoc" targetNamespace="http://soapinterop.org/" + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://soapinterop.org/" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> + + <types> + + <xsd:schema elementFormDefault="qualified" targetNamespace="http://soapinterop.org/" xmlns:interop="http://soapinterop.org/"> + + <xsd:element name="SingleTag"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="SingleTag" type="interop:SingleTag"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:complexType name="SingleTag"/> + <xsd:element name="SingleTagResponse"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="SingleTag" type="interop:SingleTag"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="SimpleDocument"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="SimpleDocument" type="interop:SimpleDocument"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:complexType name="SimpleDocument"> + <xsd:simpleContent> + <xsd:extension base="xsd:string"/> + </xsd:simpleContent> + </xsd:complexType> + <xsd:element name="SimpleDocumentResponse"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="SimpleDocument" type="interop:SimpleDocument"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="ComplexDocument"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="ComplexDocument" type="interop:ComplexDocument"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:complexType name="ComplexDocument"> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="simpleDoc" type="interop:ArrayOfSimpleDocument"/> + <xsd:element minOccurs="0" maxOccurs="1" name="child" type="interop:ChildDocument"/> + </xsd:sequence> + <xsd:attribute name="AnAttribute" type="xsd:string"/> + </xsd:complexType> + <xsd:complexType name="ArrayOfSimpleDocument"> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="unbounded" name="SimpleDocument" nillable="true" type="interop:SimpleDocument"/> + </xsd:sequence> + </xsd:complexType> + <xsd:complexType name="ChildDocument"> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="childSimpleDoc" type="interop:ArrayOfSimpleDocument"/> + </xsd:sequence> + </xsd:complexType> + <xsd:element name="ComplexDocumentResponse"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="ComplexDocument" type="interop:ComplexDocument"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + </xsd:schema> + + </types> + + <message name="SingleTagSoapIn"> + <part name="parameters" element="tns:SingleTag"/> + </message> + <message name="SingleTagSoapOut"> + <part name="outputDoc" element="tns:SingleTagResponse"/> + </message> + <message name="SimpleDocumentSoapIn"> + <part name="parameters" element="tns:SimpleDocument"/> + </message> + <message name="SimpleDocumentSoapOut"> + <part name="outputDoc" element="tns:SimpleDocumentResponse"/> + </message> + <message name="ComplexDocumentSoapIn"> + <part name="parameters" element="tns:ComplexDocument"/> + </message> + <message name="ComplexDocumentSoapOut"> + <part name="outputDoc" element="tns:ComplexDocumentResponse"/> + </message> + + <portType name="DocTestPortType"> + + <operation name="SingleTag"> + <input message="tns:SingleTagSoapIn"/> + <output message="tns:SingleTagSoapOut"/> + </operation> + <operation name="SimpleDocument"> + <input message="tns:SimpleDocumentSoapIn"/> + <output message="tns:SimpleDocumentSoapOut"/> + </operation> + <operation name="ComplexDocument"> + <input message="tns:ComplexDocumentSoapIn"/> + <output message="tns:ComplexDocumentSoapOut"/> + </operation> + + </portType> + + <binding name="doc_test_binding" type="tns:DocTestPortType"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + + <operation name="SingleTag"> + <soap:operation soapAction="http://soapinterop.org/SingleTag"/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + + <operation name="SimpleDocument"> + <soap:operation soapAction="http://soapinterop.org/SimpleDocument"/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + + <operation name="ComplexDocument"> + <soap:operation soapAction="http://soapinterop.org/ComplexDocument"/> + <input> + <soap:body use="literal"/> + </input> + <output> + <soap:body use="literal"/> + </output> + </operation> + </binding> + + <service name="interopDocSvc"> + + <port name="interopDocPort" binding="tns:doc_test_binding"> + <soap:address location="http://www.whitemesa.net/interopdoc"/> + </port> + + </service> + +</definitions> diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.componentType b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.componentType new file mode 100644 index 0000000000..bd1e9445c1 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.componentType @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * 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. +--> + +<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <service name="HelloWorldService"> + <interface.java interface="helloworld.HelloWorldService"/> + </service> +</componentType> diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.js b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.js new file mode 100644 index 0000000000..520153329e --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/HelloWorld.js @@ -0,0 +1,21 @@ +/* + * 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. + */ +function sayHello(s) { + return "Hello " + s; +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/IntrospectableHelloWorld.js b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/IntrospectableHelloWorld.js new file mode 100644 index 0000000000..2f6b7e0675 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/IntrospectableHelloWorld.js @@ -0,0 +1,25 @@ +/* + * 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. + */ +SCA = { + 'javaInterface' : 'helloworld.HelloWorldService' +} + +function sayHello(s) { + return "Hello " + s; +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/compositeScope.js b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/compositeScope.js new file mode 100644 index 0000000000..4684b89e66 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/compositeScope.js @@ -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. + */ +SCA = { + scope : 'composite', + javaInterface : 'helloworld.HelloWorldService' +} + +x = 0; + +function sayHello(s) { + x = x + 1; + return x; +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.componentType b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.componentType new file mode 100644 index 0000000000..8f2d906f58 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.componentType @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * 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. +--> + +<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <service name="HelloWorldService"> +<!-- <interface.wsdl interface="http://integration.rhino.container.tuscany.apache.org#HelloWorld"/> --> + <interface.java interface="helloworld.HelloWorldService"/> + </service> + + <reference name="extHelloWorldService"> + <interface.java interface="helloworld.HelloWorldService"/> + </reference> + + +</componentType> diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.js b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.js new file mode 100644 index 0000000000..3e9c00fcb9 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/e4x.js @@ -0,0 +1,45 @@ +/* + * 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. + */ + +function sayE4XHello(xmlIn) { + + var greeting = "e4xHello " + xmlIn..*::name; + var xmlOut = getXmlObject("http://helloworld","getGreetingsResponse"); + + var ns = new Namespace("http://helloworld"); + xmlOut.ns::getGreetingsReturn = greeting; + + return xmlOut; +} + + + + function sayHello(name) { + //create XML Request Object + var xmlIn = getXmlObject("http://helloworld","getGreetings"); + var ns = new Namespace("http://helloworld"); + xmlIn.ns::name = name + " thro e4x reference"; + + //invoke service thro service reference and obtain XML Response + var xmlOut = extHelloWorldService.sayE4XHello(xmlIn); + + //extract the content of response XML and return as string + var greeting = "" + xmlOut..*::getGreetingsReturn; + return greeting; +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/helloworld.scdl b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/helloworld.scdl new file mode 100644 index 0000000000..c3c4f5c669 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/helloworld.scdl @@ -0,0 +1,50 @@ +<?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://www.osoa.org/xmlns/sca/1.0" + xmlns:js="http://incubator.apache.org/tuscany/xmlns/container/js/1.0-incubator-M2" + + name="HelloWorldComposite"> + + <component name="HelloWorldComponent"> + <js:implementation.js script="org/apache/tuscany/container/javascript/function/HelloWorld.js"/> + </component> + + <component name="IntrospectableHelloWorldComponent"> + <js:implementation.js script="org/apache/tuscany/container/javascript/function/IntrospectableHelloWorld.js"/> + </component> + + <component name="HelloWorldComponentE4X"> + <js:implementation.js script="org/apache/tuscany/container/javascript/function/e4x.js"/> + <reference name="extHelloWorldService" target="HelloWorldJavaReference">HelloWorldJavaReference</reference> + </component> + + <component name="HelloWorldJavaReference"> + <implementation.java class="helloworld.HelloWorldServiceImpl"/> + </component> + + <component name="HelloWorldProperty"> + <js:implementation.js script="org/apache/tuscany/container/javascript/function/propertyTest.js"/> + <property name="GREETING">Kia ora</property> + </component> + + <component name="HelloWorldPropertyDefault"> + <js:implementation.js script="org/apache/tuscany/container/javascript/function/propertyTest.js"/> + </component> +</composite> diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.componentType b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.componentType new file mode 100644 index 0000000000..8e46971ea3 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.componentType @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+
+ <property name="GREETING" type="xsd:string">Hi</property>
+
+</componentType>
diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.js b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.js new file mode 100644 index 0000000000..96e21d0c75 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/propertyTest.js @@ -0,0 +1,21 @@ +/*
+ * 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.
+ */
+function sayHello(s) {
+ return GREETING + ' ' + s;
+}
diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/requestScope.js b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/requestScope.js new file mode 100644 index 0000000000..bf8f840b91 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/requestScope.js @@ -0,0 +1,30 @@ +/* + * 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. + */ + +SCA = { + scope : 'request', + javaInterface : 'helloworld.HelloWorldService' +} + +x = 0; + +function sayHello(s) { + x = x + 1; + return x; +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/scopeTest.scdl b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/scopeTest.scdl new file mode 100644 index 0000000000..3754d69da1 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/scopeTest.scdl @@ -0,0 +1,37 @@ +<?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://www.osoa.org/xmlns/sca/1.0" + xmlns:js="http://incubator.apache.org/tuscany/xmlns/container/js/1.0-incubator-M2" + + name="HelloWorldComposite"> + + <component name="StatelessComponent"> + <js:implementation.js script="org/apache/tuscany/container/javascript/function/statelessScope.js"/> + </component> + + <!-- component name="RequestComponent"> + <js:implementation.js script="org/apache/tuscany/container/javascript/function/requestScope.js"/> + </component --> + + <!-- component name="CompositeScopeComponent"> + <js:implementation.js script="org/apache/tuscany/container/javascript/function/compositeScope.js"/> + </component --> + +</composite> diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/statelessScope.js b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/statelessScope.js new file mode 100644 index 0000000000..21f5104859 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/function/statelessScope.js @@ -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. + */ +SCA = { + scope : 'stateless', + javaInterface : 'helloworld.HelloWorldService' +} + +x = 0; + +function sayHello(s) { + x = x + 1; + return x; +} diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/mock/test.js b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/mock/test.js new file mode 100644 index 0000000000..ef2694b475 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/mock/test.js @@ -0,0 +1 @@ +//Test Script
\ No newline at end of file diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/rhino/helloworld.wsdl b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/rhino/helloworld.wsdl new file mode 100644 index 0000000000..67067f044a --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/org/apache/tuscany/container/javascript/rhino/helloworld.wsdl @@ -0,0 +1,78 @@ +<?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. + --> +<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="helloworld"> + + <wsdl:types> + <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema"> + + <element name="getGreetings"> + <complexType> + <sequence> + <element name="name" type="xsd:string"/> + </sequence> + </complexType> + </element> + + <element name="getGreetingsResponse"> + <complexType> + <sequence> + <element name="getGreetingsReturn" type="xsd:string"/> + </sequence> + </complexType> + </element> + </schema> + </wsdl:types> + + <wsdl:message name="getGreetingsRequest"> + <wsdl:part element="tns:getGreetings" name="parameters"/> + </wsdl:message> + + <wsdl:message name="getGreetingsResponse"> + <wsdl:part element="tns:getGreetingsResponse" name="parameters"/> + </wsdl:message> + + <wsdl:portType name="HelloWorld"> + <wsdl:operation name="getGreetings"> + <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/> + <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getGreetings"> + <wsdlsoap:operation soapAction=""/> + <wsdl:input name="getGreetingsRequest"> + <wsdlsoap:body use="literal"/> + </wsdl:input> + <wsdl:output name="getGreetingsResponse"> + <wsdlsoap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="HelloWorldService"> + <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort"> + <wsdlsoap:address location="http://localhost:8080/sample-helloworldws/services/HelloWorldWebService"/> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/sequences.xsd b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/sequences.xsd new file mode 100644 index 0000000000..a565f3fa65 --- /dev/null +++ b/branches/sca-java-M2/sca/services/containers/container.javascript/src/test/resources/sequences.xsd @@ -0,0 +1,100 @@ +<?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. + --> +<xsd:schema xmlns:seq="http://www.example.com/sequences" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.example.com/sequences"> + + <xsd:element name="mixedStockQuote" type="seq:MixedQuote" /> + <xsd:element name="rc" type="seq:RepeatingChoice" /> + <xsd:element name="mrc" type="seq:MixedRepeatingChoice" /> + <xsd:element name="rc2" type="seq:TwoRCs" /> + <xsd:element name="mrc2" type="seq:TwoRCsMixed" /> + + + + <xsd:complexType mixed="true" name="MixedQuote"> + <xsd:sequence> + <xsd:element name="symbol" type="xsd:string" /> + <xsd:element name="companyName" type="xsd:string" /> + <xsd:element name="price" type="xsd:decimal" /> + <xsd:element name="open1" type="xsd:decimal" /> + <xsd:element name="high" type="xsd:decimal" /> + <xsd:element name="low" type="xsd:decimal" /> + <xsd:element name="volume" type="xsd:double" /> + <xsd:element name="change1" type="xsd:double" /> + <xsd:element maxOccurs="unbounded" minOccurs="0" + name="quotes" type="seq:MixedQuote" /> + </xsd:sequence> + </xsd:complexType> + + + <xsd:complexType name="RepeatingChoice"> + <xsd:choice maxOccurs="unbounded" minOccurs="0"> + <xsd:element name="a" type="xsd:string" /> + <xsd:element name="b" type="xsd:int" /> + </xsd:choice> + </xsd:complexType> + + + <xsd:complexType mixed="true" name="MixedRepeatingChoice"> + <xsd:choice maxOccurs="unbounded" minOccurs="0"> + <xsd:element name="a" type="xsd:string" /> + <xsd:element name="b" type="xsd:int" /> + </xsd:choice> + </xsd:complexType> + + + <xsd:complexType name="TwoRCs"> + <xsd:sequence> + + <xsd:choice maxOccurs="unbounded" minOccurs="0"> + <xsd:element name="a" type="xsd:string" /> + <xsd:element name="b" type="xsd:int" /> + </xsd:choice> + + <xsd:element name="split" type="xsd:string" /> + + <xsd:choice maxOccurs="unbounded" minOccurs="0"> + <xsd:element name="y" type="xsd:string" /> + <xsd:element name="z" type="xsd:int" /> + </xsd:choice> + + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType mixed="true" name="TwoRCsMixed"> + <xsd:sequence> + + <xsd:choice maxOccurs="unbounded" minOccurs="0"> + <xsd:element name="a" type="xsd:string" /> + <xsd:element name="b" type="xsd:int" /> + </xsd:choice> + + <xsd:element name="split" type="xsd:string" /> + + <xsd:choice maxOccurs="unbounded" minOccurs="0"> + <xsd:element name="y" type="xsd:string" /> + <xsd:element name="z" type="xsd:int" /> + </xsd:choice> + + </xsd:sequence> + </xsd:complexType> + +</xsd:schema> |