diff options
Diffstat (limited to 'branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany')
16 files changed, 0 insertions, 1119 deletions
diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainBeanTestCase.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainBeanTestCase.java deleted file mode 100644 index 9252b114a1..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainBeanTestCase.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.host.embedded.test.extension.TestService; -import org.osoa.sca.ServiceReference; - - - -/** - * Test creation of an SCADomainBean and invocation of a service. - * - * @version $Rev$ $Date$ - */ -public class SCADomainBeanTestCase extends TestCase { - - private SCADomainBean domain; - - @Override - protected void setUp() throws Exception { - domain = new SCADomainBean(); - domain.setDeployableComposites("test.composite"); - } - - public void testInvoke() throws Exception { - ServiceReference<TestService> serviceReference = domain.getServiceReference(TestService.class, "TestServiceComponent"); - assertNotNull(serviceReference); - TestService service = serviceReference.getService(); - String result = service.ping("Bob"); - assertEquals("Hello Bob", result); - } - - @Override - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainTestCase.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainTestCase.java deleted file mode 100644 index c52c16d8e1..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainTestCase.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.host.embedded.test.extension.TestService; -import org.osoa.sca.ServiceReference; - - - -/** - * Test SCADomain.newInstance and invocation of a service. - * - * @version $Rev$ $Date$ - */ -public class SCADomainTestCase extends TestCase { - - private SCADomain domain; - - @Override - protected void setUp() throws Exception { - domain = SCADomain.newInstance("test.composite"); - } - - public void testInvoke() throws Exception { - ServiceReference<TestService> serviceReference = domain.getServiceReference(TestService.class, "TestServiceComponent"); - assertNotNull(serviceReference); - TestService service = serviceReference.getService(); - String result = service.ping("Bob"); - assertEquals("Hello Bob", result); - } - - @Override - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainZipsTestCaseFIXME.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainZipsTestCaseFIXME.java deleted file mode 100644 index 8b0bd5fd73..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainZipsTestCaseFIXME.java +++ /dev/null @@ -1,51 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.host.embedded;
-
-import junit.framework.TestCase;
-import sample.Helloworld;
-
-
-
-/**
- * Test SCADomain.newInstance and invocation of a service.
- *
- * @version $Rev: 608205 $ $Date: 2008-01-02 20:29:05 +0000 (Wed, 02 Jan 2008) $
- */
-public class SCADomainZipsTestCaseFIXME extends TestCase {
-
- private SCADomain domain;
-
- @Override
- protected void setUp() throws Exception {
- domain = SCADomain.newInstance("myDomain", "src/test/resources/helloworld.jar", "META-INF/sca-deployables/Helloworld.composite" );
- }
-
- public void testInvoke() throws Exception {
- Helloworld service = domain.getService(Helloworld.class, "HelloworldComponent");
- assertEquals("Hello Petra", service.sayHello("Petra"));
- }
-
- @Override
- protected void tearDown() throws Exception {
- domain.close();
- }
-
-}
diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java deleted file mode 100644 index fd5398c8e6..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/DefaultSCADomainTestCase.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.impl; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.host.embedded.management.ComponentManager; -import org.apache.tuscany.sca.host.embedded.test.extension.TestService; - - -/** - * Test creation of DefaultSCADomain. - * - * @version $Rev$ $Date$ - */ -public class DefaultSCADomainTestCase extends TestCase { - private DefaultSCADomain domain; - - @Override - protected void setUp() throws Exception { - domain = new DefaultSCADomain(getClass().getClassLoader(), getClass().getClassLoader(), - "http://localhost", "./target/test-classes", "test.composite"); - } - - public void testStart() throws Exception { - TestService service = domain.getService(TestService.class, "TestServiceComponent"); - assertNotNull(service); - } - - public void testComponentManager() throws Exception { - ComponentManager componentManager = domain.getComponentManager(); - assertEquals(1, componentManager.getComponentNames().size()); - assertEquals("TestServiceComponent", componentManager.getComponentNames().iterator().next()); - assertNotNull(componentManager.getComponent("TestServiceComponent")); - - assertTrue(componentManager.isComponentStarted("TestServiceComponent")); - componentManager.stopComponent("TestServiceComponent"); - assertFalse(componentManager.isComponentStarted("TestServiceComponent")); - } - - @Override - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java deleted file mode 100644 index 2a59635a19..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.impl; - -import java.net.URL; - -import javax.xml.namespace.QName; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.contribution.service.ContributionService; -import org.apache.tuscany.sca.host.embedded.management.ComponentListener; -import org.apache.tuscany.sca.host.embedded.management.ComponentManager; -import org.apache.tuscany.sca.host.embedded.test.extension.TestService; - -/** - * Test creation of an EmbeddedSCADomain and invocation of a service. - * - * @version $Rev$ $Date$ - */ -public class EmbeddedSCADomainTestCase extends TestCase { - private EmbeddedSCADomain domain; - - @Override - protected void setUp() throws Exception { - - // Create a test embedded SCA domain - domain = new EmbeddedSCADomain(getClass().getClassLoader(), "http://localhost"); - } - - public void testDomain() throws Exception { - // Start the domain - domain.start(); - - // Determine my class loader and my test SCA contribution location - ClassLoader myClassLoader = getClass().getClassLoader(); - String url = myClassLoader.getResource("test.txt").toString(); - url = url.substring(0, url.length()-8); - - // Contribute the SCA contribution - TestModelResolver myResolver = new TestModelResolver(myClassLoader); - ContributionService contributionService = domain.getContributionService(); - Contribution contribution = contributionService.contribute("http://test/contribution", new URL(url), myResolver, false); - assertNotNull(contribution); - - // Decide which SCA composite I want to deploy - Composite myComposite = myResolver.getComposite(new QName("http://test", "test")); - - // Add the deployable composite to the domain - domain.getDomainComposite().getIncludes().add(myComposite); - - - domain.buildComposite(myComposite); - - // Start the composite - domain.getCompositeActivator().activate(myComposite); - domain.getCompositeActivator().start(myComposite); - - // At this point the domain contains my contribution, my composite and - // it's started, my application code can start using it - - // Get the TestServiceComponent service - TestService service = domain.getService(TestService.class, "TestServiceComponent"); - - // Invoke the service - String result = service.ping("Bob"); - assertEquals("Hello Bob", result); - - // Stop my composite - domain.getCompositeActivator().stop(myComposite); - domain.getCompositeActivator().deactivate(myComposite); - - // Remove my composite - domain.getDomainComposite().getIncludes().remove(myComposite); - - // Remove my contribution - contributionService.remove("http://test/contribution"); - - // Stop the domain - domain.stop(); - } - - public void testComponentManager() throws Exception { - // Start the domain - domain.start(); - - // Determine my class loader and my test SCA contribution location - ClassLoader myClassLoader = getClass().getClassLoader(); - String url = myClassLoader.getResource("test.txt").toString(); - url = url.substring(0, url.length()-8); - - // Contribute the SCA contribution - TestModelResolver myResolver = new TestModelResolver(myClassLoader); - ContributionService contributionService = domain.getContributionService(); - Contribution contribution = contributionService.contribute("http://test/contribution", new URL(url), myResolver, false); - assertNotNull(contribution); - - // Decide which SCA composite I want to deploy - Composite myComposite = myResolver.getComposite(new QName("http://test", "test")); - - // Add the deployable composite to the domain - domain.getDomainComposite().getIncludes().add(myComposite); - - domain.buildComposite(myComposite); - - // Start the composite - domain.getCompositeActivator().activate(myComposite); - domain.getCompositeActivator().start(myComposite); - - // At this point the domain contains my contribution, my composite and - // it's started, my application code can start using it - - ComponentManager componentManager = domain.getComponentManager(); - assertEquals(1, componentManager.getComponentNames().size()); - assertEquals("TestServiceComponent", componentManager.getComponentNames().iterator().next()); - - Component component = componentManager.getComponent("TestServiceComponent"); - assertNotNull(component); - assertEquals("TestServiceComponent", component.getName()); - - MyComponentListener cl = new MyComponentListener(); - componentManager.addComponentListener(cl); - - assertTrue(componentManager.isComponentStarted("TestServiceComponent")); - - assertFalse(cl.stopCalled); - componentManager.stopComponent("TestServiceComponent"); - assertTrue(cl.stopCalled); - assertFalse(componentManager.isComponentStarted("TestServiceComponent")); - - assertFalse(cl.startCalled); - componentManager.startComponent("TestServiceComponent"); - assertTrue(cl.startCalled); - assertTrue(componentManager.isComponentStarted("TestServiceComponent")); - - // Stop my composite - domain.getCompositeActivator().stop(myComposite); - domain.getCompositeActivator().deactivate(myComposite); - - // Remove my composite - domain.getDomainComposite().getIncludes().remove(myComposite); - - // Remove my contribution - contributionService.remove("http://test/contribution"); - - // Stop the domain - domain.stop(); - } - - class MyComponentListener implements ComponentListener { - boolean startCalled; - boolean stopCalled; - - public void componentStarted(String componentName) { - startCalled = true; - } - - public void componentStopped(String componentName) { - stopCalled = true; - } - - } - - @Override - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/TestModelResolver.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/TestModelResolver.java deleted file mode 100644 index 1cfe5ed5d8..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/TestModelResolver.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.impl; - -import java.lang.ref.WeakReference; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.contribution.resolver.ClassReference; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; - - -/** - * A test model resolver, based on a map. - * - * @version $Rev$ $Date$ - */ -public class TestModelResolver implements ModelResolver { - private static final long serialVersionUID = -7826976465762296634L; - - private Map<Object, Object> map = new HashMap<Object, Object>(); - private WeakReference<ClassLoader> classLoader; - - private Map<QName, Composite> composites = new HashMap<QName, Composite>(); - - public TestModelResolver(ClassLoader classLoader) { - this.classLoader = new WeakReference<ClassLoader>(classLoader); - } - - public <T> T resolveModel(Class<T> modelClass, T unresolved) { - Object resolved = map.get(unresolved); - if (resolved != null) { - - // Return the resolved object - return modelClass.cast(resolved); - - } else if (unresolved instanceof ClassReference) { - - // Load a class on demand - ClassReference classReference = (ClassReference)unresolved; - Class<?> clazz; - try { - clazz = Class.forName(classReference.getClassName(), true, classLoader.get()); - } catch (ClassNotFoundException e) { - - // Return the unresolved object - return unresolved; - } - - // Store a new ClassReference wrapping the loaded class - resolved = new ClassReference(clazz); - map.put(resolved, resolved); - - // Return the resolved ClassReference - return modelClass.cast(resolved); - - } else { - - // Return the unresolved object - return unresolved; - } - } - - public void addModel(Object resolved) { - map.put(resolved, resolved); - if (resolved instanceof Composite) { - Composite composite = (Composite)resolved; - composites.put(composite.getName(), composite); - } - } - - public Object removeModel(Object resolved) { - if (resolved instanceof Composite) { - Composite composite = (Composite)resolved; - composites.remove(composite.getName()); - } - return map.remove(resolved); - } - - public Composite getComposite(QName qname) { - return composites.get(qname); - } - -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/DefaultTestImplementationFactory.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/DefaultTestImplementationFactory.java deleted file mode 100644 index 86e0cb6a8a..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/DefaultTestImplementationFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.test.extension; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.host.embedded.test.extension.impl.TestImplementationImpl; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; - - -/** - * Default factory for the test implementation model. - * - * @version $Rev$ $Date$ - */ -public class DefaultTestImplementationFactory implements TestImplementationFactory { - - private AssemblyFactory assemblyFactory; - private JavaInterfaceFactory javaFactory; - - public DefaultTestImplementationFactory(AssemblyFactory assemblyFactory, - JavaInterfaceFactory javaFactory) { - this.assemblyFactory = assemblyFactory; - this.javaFactory = javaFactory; - } - - public TestImplementation createTestImplementation() { - return new TestImplementationImpl(assemblyFactory, javaFactory); - } - -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestImplementation.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestImplementation.java deleted file mode 100644 index d9f1228307..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestImplementation.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.host.embedded.test.extension; - -import org.apache.tuscany.sca.assembly.Implementation; - -/** - * The model representing a test implementation in an SCA assembly model. - * - * @version $Rev$ $Date$ - */ -public interface TestImplementation extends Implementation { - - /** - * Returns the greeting string that can be configured on test implementations. - * - * @return the greeting string that can be configured on test implementations - */ - String getGreeting(); - - /** - * Sets the greeting string that can be configured on test implementations. - * - * @param greeting the greeting string that can be configured on test implementations - */ - void setGreeting(String greeting); - -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestImplementationFactory.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestImplementationFactory.java deleted file mode 100644 index 9200d850bb..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestImplementationFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.test.extension; - - -/** - * A factory for the test implementation model. - * - * @version $Rev$ $Date$ - */ -public interface TestImplementationFactory { - - /** - * Creates a new test implementation. - * - * @return - */ - TestImplementation createTestImplementation(); - -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestService.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestService.java deleted file mode 100644 index 4adec91151..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/TestService.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.host.embedded.test.extension; - -/** - * Service interface for test component implementations. - * - * @version $Rev$ $Date$ - */ -public interface TestService { - - String ping(String name); - -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationImpl.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationImpl.java deleted file mode 100644 index 083b01167f..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.host.embedded.test.extension.impl; - -import java.util.Collections; -import java.util.List; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ConstrainingType; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.host.embedded.test.extension.TestService; -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementation; -import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; - - -/** - * The model representing a test implementation in an SCA assembly model. - * - * @version $Rev$ $Date$ - */ -public class TestImplementationImpl implements TestImplementation { - - private Service testService; - private String greeting; - - /** - * Constructs a new test implementation. - */ - public TestImplementationImpl(AssemblyFactory assemblyFactory, - JavaInterfaceFactory javaFactory) { - - // Test implementations always provide a single service exposing - // the TestService interface, and have no references and properties - testService = assemblyFactory.createService(); - testService.setName("Test"); - JavaInterface javaInterface; - try { - javaInterface = javaFactory.createJavaInterface(TestService.class); - } catch (InvalidInterfaceException e) { - throw new IllegalArgumentException(e); - } - JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); - interfaceContract.setInterface(javaInterface); - testService.setInterfaceContract(interfaceContract); - } - - public String getGreeting() { - return greeting; - } - - public void setGreeting(String greeting) { - this.greeting = greeting; - } - - public ConstrainingType getConstrainingType() { - // The test implementation does not support constrainingTypes - return null; - } - - public List<Property> getProperties() { - // The test implementation does not support properties - return Collections.emptyList(); - } - - public List<Service> getServices() { - // The test implementation provides a single fixed Test service - return Collections.singletonList(testService); - } - - public List<Reference> getReferences() { - // The test implementation does not support properties - return Collections.emptyList(); - } - - public String getURI() { - // The test implementation does not have a URI - return null; - } - - public void setConstrainingType(ConstrainingType constrainingType) { - // The test implementation does not support constrainingTypes - } - - public void setURI(String uri) { - // The test implementation does not have a URI - } - - public boolean isUnresolved() { - // The test implementation is always resolved - return false; - } - - public void setUnresolved(boolean unresolved) { - // The test implementation is always resolved - } -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationProcessor.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationProcessor.java deleted file mode 100644 index 73feffad50..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/impl/TestImplementationProcessor.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.host.embedded.test.extension.impl; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementation; -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementationFactory; - - - -/** - * Implements a StAX artifact processor for test implementations. - * - * @version $Rev$ $Date$ - */ -public class TestImplementationProcessor implements StAXArtifactProcessor<TestImplementation> { - private static final QName IMPLEMENTATION_TEST = new QName("http://test/extension", "implementation.test"); - - private TestImplementationFactory testFactory; - - public TestImplementationProcessor(TestImplementationFactory testFactory) { - this.testFactory = testFactory; - } - - public QName getArtifactType() { - // Returns the QName of the XML element processed by this processor - return IMPLEMENTATION_TEST; - } - - public Class<TestImplementation> getModelType() { - // Returns the type of model processed by this processor - return TestImplementation.class; - } - - public TestImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - - // Read an <implementation.test> element - - // Read the message attribute. - String message = reader.getAttributeValue(null, "greeting"); - - // Create and initialize the test implementation model - TestImplementation implementation = testFactory.createTestImplementation(); - implementation.setGreeting(message); - - // Skip to end element - while (reader.hasNext()) { - if (reader.next() == END_ELEMENT && IMPLEMENTATION_TEST.equals(reader.getName())) { - break; - } - } - - return implementation; - } - - public void resolve(TestImplementation impl, ModelResolver resolver) throws ContributionResolveException { - } - - public void write(TestImplementation implementation, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { - - writer.writeStartElement(IMPLEMENTATION_TEST.getNamespaceURI(), IMPLEMENTATION_TEST.getLocalPart()); - - if (implementation.getGreeting() != null) { - writer.writeAttribute("greeting", implementation.getGreeting()); - } - - writer.writeEndElement(); - } -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/module/TestModuleActivator.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/module/TestModuleActivator.java deleted file mode 100644 index f6f077e99b..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/module/TestModuleActivator.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.test.extension.module; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModuleActivator; -import org.apache.tuscany.sca.host.embedded.test.extension.DefaultTestImplementationFactory; -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementationFactory; -import org.apache.tuscany.sca.host.embedded.test.extension.impl.TestImplementationProcessor; -import org.apache.tuscany.sca.host.embedded.test.extension.provider.TestImplementationProviderFactory; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; - - - -/** - * Implements a module activator for the test implementation extension module. - * - * @version $Rev$ $Date$ - */ -public class TestModuleActivator implements ModuleActivator { - - public void start(ExtensionPointRegistry registry) { - - // Create the test implementation factory - ModelFactoryExtensionPoint modelFactories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class); - AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); - JavaInterfaceFactory javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); - TestImplementationFactory testFactory = new DefaultTestImplementationFactory(assemblyFactory, javaFactory); - modelFactories.addFactory(testFactory); - - // Add the test implementation extension to the StAXArtifactProcessor - // extension point - StAXArtifactProcessorExtensionPoint processors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); - TestImplementationProcessor implementationArtifactProcessor = new TestImplementationProcessor(testFactory); - processors.addArtifactProcessor(implementationArtifactProcessor); - - // Add the test provider factory to the ProviderFactory extension point - ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class); - providerFactories.addProviderFactory(new TestImplementationProviderFactory()); - } - - public void stop(ExtensionPointRegistry registry) { - } -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProvider.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProvider.java deleted file mode 100644 index 1d27e08fee..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProvider.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.host.embedded.test.extension.provider; - -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementation; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - - -/** - * Implementation provider for test implementations. - * - * @version $Rev$ $Date$ - */ -public class TestImplementationProvider implements ImplementationProvider { - - private RuntimeComponent component; - private TestImplementation implementation; - - /** - * Constructs a new test implementation provider. - */ - public TestImplementationProvider(RuntimeComponent component, TestImplementation implementation) { - this.component = component; - this.implementation = implementation; - } - - public Invoker createInvoker(RuntimeComponentService service, Operation operation) { - TestInvoker invoker = new TestInvoker(operation, implementation.getGreeting()); - return invoker; - } - - public boolean supportsOneWayInvocation() { - return false; - } - - public void start() { - System.out.println("Starting " + component.getName()); - } - - public void stop() { - System.out.println("Stopping " + component.getName()); - } - -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProviderFactory.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProviderFactory.java deleted file mode 100644 index 15d3618fdd..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestImplementationProviderFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.host.embedded.test.extension.provider; - -import org.apache.tuscany.sca.host.embedded.test.extension.TestImplementation; -import org.apache.tuscany.sca.provider.ImplementationProvider; -import org.apache.tuscany.sca.provider.ImplementationProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; - - -/** - * The model representing a test implementation in an SCA assembly model. - * - * @version $Rev$ $Date$ - */ -public class TestImplementationProviderFactory implements ImplementationProviderFactory<TestImplementation> { - - /** - * Constructs a new test implementation provider factory. - */ - public TestImplementationProviderFactory() { - } - - public ImplementationProvider createImplementationProvider(RuntimeComponent component, TestImplementation implementation) { - return new TestImplementationProvider(component, implementation); - } - - public Class<TestImplementation> getModelType() { - return TestImplementation.class; - } -} diff --git a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestInvoker.java b/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestInvoker.java deleted file mode 100644 index d49179dec0..0000000000 --- a/branches/sca-java-1.x/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/test/extension/provider/TestInvoker.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.host.embedded.test.extension.provider; - -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; - - -/** - * Implements an invoker for test component implementations. - * - * The target invoker is responsible for handling operation invocations. - * - * @version $Rev$ $Date$ - */ -public class TestInvoker implements Invoker { - private Operation operation; - private String greeting; - - public TestInvoker(Operation operation, String greeting) { - this.operation = operation; - this.greeting = greeting; - } - - public Message invoke(Message msg) { - Object[] args = msg.getBody(); - if (operation.getName().equals("ping")) { - msg.setBody(greeting + " " + args[0]); - } else { - msg.setFaultBody(new Exception("Operation " + operation.getName() + " is not supported")); - } - return msg; - } -} |