diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /sandbox/SPI/implementation-script/src |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
44 files changed, 1404 insertions, 0 deletions
diff --git a/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementation.java b/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementation.java new file mode 100644 index 0000000000..dab22e00f9 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementation.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.implementation.script; + +import org.apache.tuscany.assembly.Implementation; +import org.apache.tuscany.assembly.impl.ComponentTypeImpl; + +/** + * Represents a Script implementation. + */ +public class ScriptImplementation extends ComponentTypeImpl implements Implementation { + + private String scriptName; + private String scriptSrc; + private String scriptLanguage; + + public ScriptImplementation() { + setUnresolved(true); + } + + public String getScriptName() { + return scriptName; + } + + public String getScriptLanguage() { + return scriptLanguage; + } + + public String getScriptSrc() { + return scriptSrc; + } + + public void setScriptSrc(String scriptSrc) { + this.scriptSrc = scriptSrc; + } + + public void setScriptLanguage(String scriptLanguage) { + this.scriptLanguage = scriptLanguage; + } + + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + setURI(scriptName); // TODO: hack to enable getting componentType name + } +} diff --git a/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementationActivator.java b/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementationActivator.java new file mode 100644 index 0000000000..f7112d2ed0 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptImplementationActivator.java @@ -0,0 +1,49 @@ +/* + * 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.implementation.script; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.assembly.xml.Constants; +import org.apache.tuscany.spi.implementation.ImplementationActivator; +import org.apache.tuscany.spi.implementation.InvokerFactory; +import org.apache.tuscany.spi.implementation.XMLSCDLProcessor; + +public class ScriptImplementationActivator implements ImplementationActivator<ScriptImplementation>{ + + private static final QName IMPLEMENTATION_SCRIPT_QNAME = new QName(Constants.SCA10_NS, "implementation.script"); + + public Class getImplementationClass() { + return ScriptImplementation.class; + } + + public InvokerFactory getInvokerFactory(ScriptImplementation impl) { + return new ScriptInvokerFactory(impl); + } + + public QName getModelQName() { + return IMPLEMENTATION_SCRIPT_QNAME; + } + + public XMLSCDLProcessor getSCDLProcessor() { + return new ScriptXMLSCDLProcessor(); + } + +} diff --git a/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptInvoker.java b/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptInvoker.java new file mode 100644 index 0000000000..bfcee1d6a4 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptInvoker.java @@ -0,0 +1,48 @@ +/* + * 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.implementation.script; + +import javax.script.Invocable; +import javax.script.ScriptException; + +import org.apache.tuscany.interfacedef.Operation; +import org.apache.tuscany.spi.implementation.Invoker; + +public class ScriptInvoker implements Invoker { + + private String operationName; + + public ScriptInvoker(ScriptImplementation impl, Operation operation) { + this.operationName = operation.getName(); + } + + public Object invoke(Object instance, Object[] args) { + try { + + Invocable scriptEngine = (Invocable)instance; + + return scriptEngine.invokeFunction(operationName, args); + + } catch (ScriptException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptInvokerFactory.java b/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptInvokerFactory.java new file mode 100644 index 0000000000..b2afe4a8f3 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptInvokerFactory.java @@ -0,0 +1,74 @@ +/* + * 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.implementation.script; + +import java.io.StringReader; +import java.util.Map; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; + +import org.apache.tuscany.interfacedef.Operation; +import org.apache.tuscany.spi.ObjectCreationException; +import org.apache.tuscany.spi.implementation.Invoker; +import org.apache.tuscany.spi.implementation.InvokerFactory; + +public class ScriptInvokerFactory implements InvokerFactory { + + private ScriptImplementation impl; + + public ScriptInvokerFactory(ScriptImplementation impl) { + this.impl = impl; + } + + public Invoker createInvoker(Operation operation) { + return new ScriptInvoker(impl, operation); + } + + public Object getInstance(Map<String, Object> references, Map<String, Object> properties) { + try { + ScriptEngineManager manager = new ScriptEngineManager(); + + for (String referenceName : references.keySet()) { + Object reference = references.get(referenceName); + manager.put(referenceName, reference); + } + + for (String propertyName : properties.keySet()) { + Object propertyValue = properties.get(propertyName); + manager.put(propertyName, propertyValue); + } + + ScriptEngine engine = manager.getEngineByExtension(impl.getScriptLanguage()); + if (engine == null) { + throw new ObjectCreationException("no script engine found for language: " + impl.getScriptLanguage()); + } + + engine.eval(new StringReader(impl.getScriptSrc())); + + return engine; + + } catch (ScriptException e) { + throw new ObjectCreationException(e); + } + } + +} diff --git a/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptXMLSCDLProcessor.java b/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptXMLSCDLProcessor.java new file mode 100644 index 0000000000..56dc885fe8 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/main/java/org/apache/tuscany/implementation/script/ScriptXMLSCDLProcessor.java @@ -0,0 +1,94 @@ +/* + * 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.implementation.script; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URL; + +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.assembly.Implementation; +import org.apache.tuscany.spi.implementation.XMLSCDLProcessor; + +public class ScriptXMLSCDLProcessor implements XMLSCDLProcessor { + + private static final String SCRIPT = "script"; + private static final String LANGUAGE = "language"; + + public void read(Implementation impl, XMLStreamReader reader) { + ScriptImplementation scriptImplementation = (ScriptImplementation)impl; + + String scriptName = reader.getAttributeValue(null, SCRIPT); + scriptImplementation.setScriptName(scriptName); + + String scriptLanguage = reader.getAttributeValue(null, LANGUAGE); + if (scriptLanguage == null || scriptLanguage.length() < 1) { + int i = scriptName.lastIndexOf('.'); + scriptLanguage = scriptName.substring(i+1); + } + scriptImplementation.setScriptLanguage(scriptLanguage); + + scriptImplementation.setScriptSrc(readScript(scriptImplementation.getScriptName())); + } + + public void write(Implementation impl, XMLStreamWriter writer) { + } + + protected String readScript(String scriptName) { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL scriptSrcUrl = cl.getResource(scriptName); + if (scriptSrcUrl == null) { + throw new RuntimeException("No script: " + scriptName); + } + + InputStream is; + try { + is = scriptSrcUrl.openStream(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + try { + + Reader reader = new InputStreamReader(is, "UTF-8"); + char[] buffer = new char[1024]; + StringBuilder source = new StringBuilder(); + int count; + while ((count = reader.read(buffer)) > 0) { + source.append(buffer, 0, count); + } + + return source.toString(); + + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + is.close(); + } catch (IOException e) { + // ignore + } + } + } +} diff --git a/sandbox/SPI/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.spi.implementation.ImplementationActivator b/sandbox/SPI/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.spi.implementation.ImplementationActivator new file mode 100644 index 0000000000..6db2e89f3a --- /dev/null +++ b/sandbox/SPI/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.spi.implementation.ImplementationActivator @@ -0,0 +1,3 @@ +# Implementation class for the Script ImplementationActivator
+org.apache.tuscany.implementation.script.ScriptImplementationActivator
+
diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/AbstractSCATestCase.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/AbstractSCATestCase.java new file mode 100644 index 0000000000..f320e4be4e --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/AbstractSCATestCase.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.implementation.script.itests; + +import junit.framework.TestCase; + +import org.apache.tuscany.host.embedded.SCARuntime; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; + +public abstract class AbstractSCATestCase<T> extends TestCase { + + protected T service; + + protected void setUp() throws Exception { + SCARuntime.start(getCompositeName()); + ComponentContext context = SCARuntime.getComponentContext("ClientComponent"); + ServiceReference<T> serviceReference = context.createSelfReference(getServiceClass()); + service = serviceReference.getService(); + } + + abstract protected Class getServiceClass(); + + protected void tearDown() throws Exception { + SCARuntime.stop(); + } + + protected String getCompositeName() { + String className = this.getClass().getName(); + return className.substring(0, className.length() - 8).replace('.', '/') + ".composite"; + } + +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/AbstractHelloWorldTestCase.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/AbstractHelloWorldTestCase.java new file mode 100644 index 0000000000..98adb1f830 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/AbstractHelloWorldTestCase.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.implementation.script.itests.helloworld; + +import org.apache.tuscany.implementation.script.itests.AbstractSCATestCase; + +public abstract class AbstractHelloWorldTestCase extends AbstractSCATestCase<HelloWorld> { + + public void testCalculator() throws Exception { + assertEquals("Hello petra", service.sayHello("petra")); + } + + @Override + protected Class<HelloWorld> getServiceClass() { + return HelloWorld.class; + } +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/GroovyHelloWorldTestCase.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/GroovyHelloWorldTestCase.java new file mode 100644 index 0000000000..671bba61ca --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/GroovyHelloWorldTestCase.java @@ -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. + */ + +package org.apache.tuscany.implementation.script.itests.helloworld; + + +public class GroovyHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/HelloWorld.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/HelloWorld.java new file mode 100644 index 0000000000..510b20c21c --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/HelloWorld.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.implementation.script.itests.helloworld; + +public interface HelloWorld { + + public String sayHello(String s); + +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/HelloWorldProxy.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/HelloWorldProxy.java new file mode 100644 index 0000000000..5ab737ec60 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/HelloWorldProxy.java @@ -0,0 +1,33 @@ +/* + * 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.implementation.script.itests.helloworld; + +import org.osoa.sca.annotations.Reference; + +public class HelloWorldProxy implements HelloWorld { + + @Reference + public HelloWorld delegate; + + public String sayHello(String s) { + return delegate.sayHello(s); + } + +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JRubyHelloWorldTestCase.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JRubyHelloWorldTestCase.java new file mode 100644 index 0000000000..566a62999e --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JRubyHelloWorldTestCase.java @@ -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. + */ + +package org.apache.tuscany.implementation.script.itests.helloworld; + + +public class JRubyHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JavaScriptHelloWorldTestCase.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JavaScriptHelloWorldTestCase.java new file mode 100644 index 0000000000..506421de18 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JavaScriptHelloWorldTestCase.java @@ -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. + */ + +package org.apache.tuscany.implementation.script.itests.helloworld; + + +public class JavaScriptHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java new file mode 100644 index 0000000000..55296464f7 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java @@ -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. + */ + +package org.apache.tuscany.implementation.script.itests.helloworld; + + +public class JythonHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/AbstractHelloWorldTestCase.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/AbstractHelloWorldTestCase.java new file mode 100644 index 0000000000..2f249254d3 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/AbstractHelloWorldTestCase.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.implementation.script.itests.properties; + +import org.apache.tuscany.implementation.script.itests.AbstractSCATestCase; + +public abstract class AbstractHelloWorldTestCase extends AbstractSCATestCase<HelloWorld> { + + public void testCalculator() throws Exception { + assertEquals("Hello petra from Tuscany", service.sayHello("petra")); + } + + @Override + protected Class<HelloWorld> getServiceClass() { + return HelloWorld.class; + } +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/GroovyHelloWorldTestCase.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/GroovyHelloWorldTestCase.java new file mode 100644 index 0000000000..8a15074dbc --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/GroovyHelloWorldTestCase.java @@ -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. + */ + +package org.apache.tuscany.implementation.script.itests.properties; + + +public class GroovyHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/HelloWorld.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/HelloWorld.java new file mode 100644 index 0000000000..26033681f3 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/HelloWorld.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.implementation.script.itests.properties; + +public interface HelloWorld { + + public String sayHello(String s); + +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/HelloWorldProxy.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/HelloWorldProxy.java new file mode 100644 index 0000000000..3d315b45ea --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/HelloWorldProxy.java @@ -0,0 +1,33 @@ +/* + * 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.implementation.script.itests.properties; + +import org.osoa.sca.annotations.Reference; + +public class HelloWorldProxy implements HelloWorld { + + @Reference + public HelloWorld delegate; + + public String sayHello(String s) { + return delegate.sayHello(s); + } + +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/JRubyHelloWorldTestCaseFIXME.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/JRubyHelloWorldTestCaseFIXME.java new file mode 100644 index 0000000000..6755501bca --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/JRubyHelloWorldTestCaseFIXME.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.implementation.script.itests.properties; + +public class JRubyHelloWorldTestCaseFIXME extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name + + // this doesn't work as the property doesn't seem to get set in the JRuby + // script. It could be I've a typo somewhere, or a bug in the jruby script + // engine. + +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/JavaScriptHelloWorldTestCase.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/JavaScriptHelloWorldTestCase.java new file mode 100644 index 0000000000..c42f7e2151 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/JavaScriptHelloWorldTestCase.java @@ -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. + */ + +package org.apache.tuscany.implementation.script.itests.properties; + + +public class JavaScriptHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/JythonHelloWorldTestCase.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/JythonHelloWorldTestCase.java new file mode 100644 index 0000000000..c1dd6ce4a7 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/properties/JythonHelloWorldTestCase.java @@ -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. + */ + +package org.apache.tuscany.implementation.script.itests.properties; + + +public class JythonHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/references/HelloWorldTarget.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/references/HelloWorldTarget.java new file mode 100644 index 0000000000..bc35df0670 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/references/HelloWorldTarget.java @@ -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. + */ + +package org.apache.tuscany.implementation.script.itests.references; + +import org.apache.tuscany.implementation.script.itests.helloworld.HelloWorld; + +public class HelloWorldTarget implements HelloWorld { + + public String sayHello(String s) { + return "Hello " + s; + } + +} diff --git a/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/references/JavaScriptReferenceTestCase.java b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/references/JavaScriptReferenceTestCase.java new file mode 100644 index 0000000000..654e309350 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/java/org/apache/tuscany/implementation/script/itests/references/JavaScriptReferenceTestCase.java @@ -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. + */ +package org.apache.tuscany.implementation.script.itests.references; + +import org.apache.tuscany.implementation.script.itests.helloworld.AbstractHelloWorldTestCase; + +public class JavaScriptReferenceTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/GroovyHelloWorld.composite b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/GroovyHelloWorld.composite new file mode 100644 index 0000000000..c52db94bff --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/GroovyHelloWorld.composite @@ -0,0 +1,32 @@ +<?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"
+ name="GroovyHelloWorld">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.script script="org/apache/tuscany/implementation/script/itests/helloworld/helloworld.groovy"/>
+ </component>
+
+</composite>
diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JRubyHelloWorld.composite b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JRubyHelloWorld.composite new file mode 100644 index 0000000000..2fc2948d0a --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JRubyHelloWorld.composite @@ -0,0 +1,32 @@ +<?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"
+ name="JRubyHelloWorld">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.script script="org/apache/tuscany/implementation/script/itests/helloworld/helloworld.rb"/>
+ </component>
+
+</composite>
diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JavaScriptHelloWorld.composite b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JavaScriptHelloWorld.composite new file mode 100644 index 0000000000..489feeab96 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JavaScriptHelloWorld.composite @@ -0,0 +1,32 @@ +<?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"
+ name="JavaScriptHelloWorld">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.script script="org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js"/>
+ </component>
+
+</composite>
diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorld.composite b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorld.composite new file mode 100644 index 0000000000..70c40d908c --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/JythonHelloWorld.composite @@ -0,0 +1,32 @@ +<?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"
+ name="JythonHelloWorld">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.script script="org/apache/tuscany/implementation/script/itests/helloworld/helloworld.py"/>
+ </component>
+
+</composite>
diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType new file mode 100644 index 0000000000..99a18538d8 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.componentType @@ -0,0 +1,30 @@ +<?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:wsdli="http://www.w3.org/2006/01/wsdl-instance" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <service name="HelloWorldService"> + <interface.java interface="org.apache.tuscany.implementation.script.itests.helloworld.HelloWorld" /> + </service> + +</componentType> +
\ No newline at end of file diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.groovy b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.groovy new file mode 100644 index 0000000000..9f89bd373e --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.groovy @@ -0,0 +1,22 @@ +/*
+ * 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.
+ */
+
+def sayHello(s) {
+ return "Hello " + s
+}
\ No newline at end of file diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js new file mode 100644 index 0000000000..eac2ab283f --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.js @@ -0,0 +1,23 @@ +/* + * 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; +}
\ No newline at end of file diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.py b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.py new file mode 100644 index 0000000000..f5dd0f8fcf --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.py @@ -0,0 +1,20 @@ +# 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. +# + +def sayHello(s): + return 'Hello ' + s
\ No newline at end of file diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.rb b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.rb new file mode 100644 index 0000000000..cd2d3bcaea --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/helloworld/helloworld.rb @@ -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.
+#
+
+def sayHello(s)
+ return "Hello " + s
+end
\ No newline at end of file diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/GroovyHelloWorld.composite b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/GroovyHelloWorld.composite new file mode 100644 index 0000000000..35abb780fa --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/GroovyHelloWorld.composite @@ -0,0 +1,32 @@ +<?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"
+ name="GroovyProperties">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.properties.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.script script="org/apache/tuscany/implementation/script/itests/properties/helloworld.groovy"/>
+ </component>
+
+</composite>
diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/JRubyHelloWorld.composite b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/JRubyHelloWorld.composite new file mode 100644 index 0000000000..bd4661b7a3 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/JRubyHelloWorld.composite @@ -0,0 +1,32 @@ +<?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"
+ name="JRubyProperties">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.properties.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent" />
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.script script="org/apache/tuscany/implementation/script/itests/properties/helloworld.rb"/>
+ </component>
+
+</composite>
diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/JavaScriptHelloWorld.composite b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/JavaScriptHelloWorld.composite new file mode 100644 index 0000000000..adf04cbcc0 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/JavaScriptHelloWorld.composite @@ -0,0 +1,32 @@ +<?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"
+ name="JavaScriptProperties">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.properties.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.script script="org/apache/tuscany/implementation/script/itests/properties/helloworld.js"/>
+ </component>
+
+</composite>
diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/JythonHelloWorld.composite b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/JythonHelloWorld.composite new file mode 100644 index 0000000000..633f20e8f0 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/JythonHelloWorld.composite @@ -0,0 +1,32 @@ +<?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"
+ name="JythonProperties">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.properties.HelloWorldProxy"/>
+ <reference name="delegate" target="HelloWorldComponent"></reference>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.script script="org/apache/tuscany/implementation/script/itests/properties/helloworld.py"/>
+ </component>
+
+</composite>
diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.componentType b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.componentType new file mode 100644 index 0000000000..de4669ddea --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.componentType @@ -0,0 +1,32 @@ +<?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:wsdli="http://www.w3.org/2006/01/wsdl-instance" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <service name="HelloWorldService"> + <interface.java interface="org.apache.tuscany.implementation.script.itests.helloworld.HelloWorld" /> + </service> + + <property name="greeter" type="xsd:string">Tuscany</property> + +</componentType> +
\ No newline at end of file diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.groovy b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.groovy new file mode 100644 index 0000000000..a7eb446d37 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.groovy @@ -0,0 +1,22 @@ +/*
+ * 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.
+ */
+
+def sayHello(s) {
+ return "Hello " + s + " from " + greeter
+}
\ No newline at end of file diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.js b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.js new file mode 100644 index 0000000000..64df3ebbef --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.js @@ -0,0 +1,23 @@ +/* + * 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 + " from " + greeter; +}
\ No newline at end of file diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.py b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.py new file mode 100644 index 0000000000..868cfa9eeb --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.py @@ -0,0 +1,20 @@ +# 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. +# + +def sayHello(s): + return 'Hello ' + s + ' from ' + greeter
\ No newline at end of file diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.rb b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.rb new file mode 100644 index 0000000000..2844f8b8d9 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/properties/helloworld.rb @@ -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.
+#
+
+def sayHello(s)
+ return "Hello " + s + " from " + $greeter
+end
\ No newline at end of file diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/references/JavaScriptReference.composite b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/references/JavaScriptReference.composite new file mode 100644 index 0000000000..00bbac878e --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/references/JavaScriptReference.composite @@ -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"
+ name="JavaScriptReference">
+
+ <component name="ClientComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.helloworld.HelloWorldProxy"/>
+ <reference name="delegate" target="ReferenceComponent"></reference>
+ </component>
+
+ <component name="ReferenceComponent">
+ <implementation.script script="org/apache/tuscany/implementation/script/itests/references/reference.js"/>
+ <reference name="ref" target="TargetComponent" />
+ </component>
+
+ <component name="TargetComponent">
+ <implementation.java class="org.apache.tuscany.implementation.script.itests.references.HelloWorldTarget"/>
+ </component>
+
+</composite>
diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/references/reference.componentType b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/references/reference.componentType new file mode 100644 index 0000000000..71be1baf73 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/references/reference.componentType @@ -0,0 +1,31 @@ +<?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:wsdli="http://www.w3.org/2006/01/wsdl-instance"> + + <service name="HelloWorldService"> + <interface.java interface="org.apache.tuscany.implementation.script.itests.helloworld.HelloWorld" /> + </service> + + <reference name="ref"> + <interface.java interface="org.apache.tuscany.implementation.script.itests.helloworld.HelloWorld" /> + </reference> + +</componentType> +
\ No newline at end of file diff --git a/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/references/reference.js b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/references/reference.js new file mode 100644 index 0000000000..ad0a932d26 --- /dev/null +++ b/sandbox/SPI/implementation-script/src/test/resources/org/apache/tuscany/implementation/script/itests/references/reference.js @@ -0,0 +1,22 @@ +/* + * 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 ref.sayHello(s); +}
\ No newline at end of file |