diff options
Diffstat (limited to 'sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld')
4 files changed, 148 insertions, 0 deletions
diff --git a/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/AbstractHelloWorldTestCase.java b/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/AbstractHelloWorldTestCase.java new file mode 100644 index 0000000000..b2f821668f --- /dev/null +++ b/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/AbstractHelloWorldTestCase.java @@ -0,0 +1,42 @@ +/* + * 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.spring.itests.helloworld; + +import org.apache.tuscany.implementation.spring.itests.AbstractSCATestCase; + +/** + * Basic "hello world" style test case for testing Spring component implementation + * @author MikeEdwards + * + */ +public abstract class AbstractHelloWorldTestCase extends AbstractSCATestCase<HelloWorld> { + + /** + * Calls the hello world service and checks that it gives the right response... + */ + public void testCalculator() throws Exception { + assertEquals("Hello petra", service.sayHello("petra")); + } + + @Override + protected Class<HelloWorld> getServiceClass() { + return HelloWorld.class; + } +} diff --git a/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorld.java b/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorld.java new file mode 100644 index 0000000000..a743880378 --- /dev/null +++ b/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorld.java @@ -0,0 +1,32 @@ +/* + * 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.spring.itests.helloworld; + +/** + * Interface for the "hello world" service - predictably simple with a single operation + * "sayHello" + * @author MikeEdwards + * + */ +public interface HelloWorld { + + public String sayHello(String s); + +} diff --git a/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorldProxy.java b/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorldProxy.java new file mode 100644 index 0000000000..305c245ea3 --- /dev/null +++ b/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/HelloWorldProxy.java @@ -0,0 +1,42 @@ +/* + * 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.spring.itests.helloworld; + +import org.osoa.sca.annotations.Reference; + +/** + * A simple proxy Java class which implements the HelloWorld interface but which uses + * a reference "delegate" to actually provide the HelloWorld service + * @author MikeEdwards + * + */ +public class HelloWorldProxy implements HelloWorld { + + // Here is the reference "delegate" - it implements the HelloWorld interface... + @Reference + public HelloWorld delegate; + + public String sayHello(String s) { + // Simply call the reference to satisfy the service request... + System.out.println("HelloWorldProxy - calling sayHello"); + return delegate.sayHello(s); + } + +} diff --git a/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/SpringHelloWorldTestCase.java b/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/SpringHelloWorldTestCase.java new file mode 100644 index 0000000000..9d0c52322b --- /dev/null +++ b/sandbox/implementation-spring2/src/test/java/org/apache/tuscany/implementation/spring/itests/helloworld/SpringHelloWorldTestCase.java @@ -0,0 +1,32 @@ +/* + * 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.spring.itests.helloworld; + +/** + * A basic test case of: + * 1) A composite containing a component with a Spring implementation + * 2) The composite has a component with a Java POJO implementation which uses the + * Spring implementation to satisfy a reference + * + * @author MikeEdwards + */ +public class SpringHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} |