diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:08:11 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:08:11 +0000 |
commit | 0cc8ed2208c9d04057bcb00859490290e3aa948c (patch) | |
tree | 0087418cfdfc40a85fc250a9c36cb8ddc0ebb5db /sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src | |
parent | e0ff67c0b32813ea48734c770a5ffc1952644e29 (diff) |
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835129 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src')
12 files changed, 437 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/META-INF/sca/SpringDelegationHelloWorld-context.xml b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/META-INF/sca/SpringDelegationHelloWorld-context.xml new file mode 100644 index 0000000000..7068224183 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/META-INF/sca/SpringDelegationHelloWorld-context.xml @@ -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. +--> +<!-- Application context for the SpringHelloWorld testcase --> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:sca="http://www.springframework.org/schema/sca" + xsi:schemaLocation=" +http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd +http://www.springframework.org/schema/sca http://www.springframework.org/schema/sca/spring-sca.xsd"> + + <bean id="delegateBean" + class="org.apache.tuscany.sca.itest.spring.TestHelloWorldBean" lazy-init="true"> + </bean> + + <bean id="testBean" + class="org.apache.tuscany.sca.itest.spring.TestHelloWorldDelegatorBean" lazy-init="true"> + <property name="delegate"><ref bean="delegateBean"/></property> + </bean> + +</beans>
\ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/META-INF/sca/SpringHelloWorld-context.xml b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/META-INF/sca/SpringHelloWorld-context.xml new file mode 100644 index 0000000000..3b87979ab2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/META-INF/sca/SpringHelloWorld-context.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<!-- Application context for the SpringHelloWorld testcase --> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:sca="http://www.springframework.org/schema/sca" + xsi:schemaLocation=" +http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd +http://www.springframework.org/schema/sca http://www.springframework.org/schema/sca/spring-sca.xsd"> + + <bean id="testBean" class="org.apache.tuscany.sca.itest.spring.TestHelloWorldBean" lazy-init="true"> + </bean> + +</beans>
\ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite new file mode 100644 index 0000000000..70b2d5fdab --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.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="SpringHelloWorld"> + + <component name="ClientComponent"> + <implementation.java class="org.apache.tuscany.sca.itest.spring.HelloWorldProxy"/> + <reference name="delegate" target="HelloWorldComponent"/> + </component> + + <component name="HelloWorldComponent"> + <implementation.spring location="META-INF/sca/SpringDelegationHelloWorld-context.xml"/> + </component> + +</composite> diff --git a/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite new file mode 100644 index 0000000000..bab9ecb528 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.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="SpringHelloWorld"> + + <component name="ClientComponent"> + <implementation.java class="org.apache.tuscany.sca.itest.spring.HelloWorldProxy"/> + <reference name="delegate" target="HelloWorldComponent"/> + </component> + + <component name="HelloWorldComponent"> + <implementation.spring location="META-INF/sca/SpringHelloWorld-context.xml"/> + </component> + +</composite> diff --git a/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java new file mode 100644 index 0000000000..634e3d34af --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java @@ -0,0 +1,40 @@ +/* + * 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.sca.itest.spring; + + +/** + * Basic "hello world" style test case for testing Spring component implementation + * + */ +public abstract class AbstractHelloWorldTestCase extends AbstractSCATestCase<HelloWorld> { + + /** + * Calls the hello world service and checks that it gives the right response... + */ + public void testHello() throws Exception { + assertEquals("Hello petra", service.sayHello("petra")); + } + + @Override + protected Class<HelloWorld> getServiceClass() { + return HelloWorld.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java new file mode 100644 index 0000000000..e0b1a79c95 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java @@ -0,0 +1,51 @@ +/* + * 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.sca.itest.spring; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public abstract class AbstractSCATestCase<T> extends TestCase { + + protected SCADomain domain; + protected T service; + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance(getCompositeName()); + service = (T)domain.getService(getServiceClass(), "ClientComponent"); + } + + abstract protected Class getServiceClass(); + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + + protected String getCompositeName() { + String className = this.getClass().getName(); + String compositeName = className.substring(0, className.length() - 8).replace('.', '/') + ".composite"; + System.out.println("Using composite: " + compositeName); + return compositeName; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java new file mode 100644 index 0000000000..3957e49bf3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.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.sca.itest.spring; + +import org.osoa.sca.annotations.Remotable; + +/** + * Interface for the "hello world" service - predictably simple with a single operation + * "sayHello" + * + */ +@Remotable +public interface HelloWorld { + + public String sayHello(String s); + +} diff --git a/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java new file mode 100644 index 0000000000..d75d19295d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java @@ -0,0 +1,41 @@ +/* + * 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.sca.itest.spring; + +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 + * + */ +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/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java new file mode 100644 index 0000000000..4088691ccd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java @@ -0,0 +1,31 @@ +/* + * 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.sca.itest.spring; + +/** + * 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 + * + */ +public class SpringDelegationHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java new file mode 100644 index 0000000000..840bf59b73 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/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.sca.itest.spring; + +/** + * 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 + * 3) The Spring component delegates function to a second spring bean + * + */ +public class SpringHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java new file mode 100644 index 0000000000..fa7967c964 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java @@ -0,0 +1,36 @@ +/* + * 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.sca.itest.spring; + +/** + * A simple test Spring bean which provides the HelloWorld service + * + */ + +public class TestHelloWorldBean implements HelloWorld { + + static String hello = "Hello "; + + // Classic "Hello xxx" response to any input message + public String sayHello(String message) { + System.out.println("TestHelloWorldBean - sayHello called"); + return (hello + message); + } + +} // end class TestHelloWorldBean diff --git a/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java new file mode 100644 index 0000000000..b57cc7f366 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.3.2/itest/spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java @@ -0,0 +1,40 @@ +/* + * 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.sca.itest.spring; + +/** + * A simple test Spring bean which delgates to another bean + * + */ + +public class TestHelloWorldDelegatorBean implements HelloWorld { + + HelloWorld delegate; + + public void setDelegate(HelloWorld delegate) { + this.delegate = delegate; + } + + // Classic "Hello xxx" response to any input message + public String sayHello(String message) { + System.out.println("TestHelloWorldDelegatorBean - sayHello called"); + return delegate.sayHello(message); + } + +} |