From fc1d68b406b368d20a263386ac6ca1776b12d8ff Mon Sep 17 00:00:00 2001 From: kwilliams Date: Tue, 1 Jul 2008 19:00:22 +0000 Subject: First test for Assembly Model component section git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@673173 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/vtest/assembly/component/pom.xml | 49 +++++++++++++++ .../sca/vtest/assembly/component/AService.java | 31 ++++++++++ .../sca/vtest/assembly/component/BService.java | 29 +++++++++ .../assembly/component/impl/AServiceImpl.java | 49 +++++++++++++++ .../assembly/component/impl/BServiceImpl.java | 40 +++++++++++++ .../src/main/resources/component.composite | 41 +++++++++++++ .../assembly/component/ComponentTestCase.java | 70 ++++++++++++++++++++++ java/sca/vtest/assembly/pom.xml | 1 + 8 files changed, 310 insertions(+) create mode 100644 java/sca/vtest/assembly/component/pom.xml create mode 100644 java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/AService.java create mode 100644 java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/BService.java create mode 100644 java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/AServiceImpl.java create mode 100644 java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/BServiceImpl.java create mode 100644 java/sca/vtest/assembly/component/src/main/resources/component.composite create mode 100644 java/sca/vtest/assembly/component/src/test/java/org/apache/tuscany/sca/vtest/assembly/component/ComponentTestCase.java (limited to 'java/sca/vtest/assembly') diff --git a/java/sca/vtest/assembly/component/pom.xml b/java/sca/vtest/assembly/component/pom.xml new file mode 100644 index 0000000000..cf38e7ab8e --- /dev/null +++ b/java/sca/vtest/assembly/component/pom.xml @@ -0,0 +1,49 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + vtest-assembly + 1.4-SNAPSHOT + ../pom.xml + + vtest-assembly-component + + Apache Tuscany SCA Assembly Verification Tests - Component + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + + + diff --git a/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/AService.java b/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/AService.java new file mode 100644 index 0000000000..592020c180 --- /dev/null +++ b/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/AService.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.vtest.assembly.component; + +/** + * Simple Remotable Service + */ +public interface AService { + + public String getState(); + public String getBProperty(); + public String getB2Property(); + + +} diff --git a/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/BService.java b/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/BService.java new file mode 100644 index 0000000000..0d95c8e4b8 --- /dev/null +++ b/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/BService.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.sca.vtest.assembly.component; + +/** + * Simple Service + */ +public interface BService { + + public String getState(); + public String getSomeProperty(); + +} diff --git a/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/AServiceImpl.java b/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/AServiceImpl.java new file mode 100644 index 0000000000..8c0d08d052 --- /dev/null +++ b/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/AServiceImpl.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.sca.vtest.assembly.component.impl; + +import org.apache.tuscany.sca.vtest.assembly.component.AService; +import org.apache.tuscany.sca.vtest.assembly.component.BService; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +@Service(AService.class) +public class AServiceImpl implements AService { + + @Reference + protected BService b; + + @Reference + protected BService b2; + + public String getState() { + return b.getState(); + } + + public String getBProperty() { + return b.getSomeProperty(); + } + + public String getB2Property() { + return b2.getSomeProperty(); + } + +} + diff --git a/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/BServiceImpl.java b/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/BServiceImpl.java new file mode 100644 index 0000000000..ad0406daaf --- /dev/null +++ b/java/sca/vtest/assembly/component/src/main/java/org/apache/tuscany/sca/vtest/assembly/component/impl/BServiceImpl.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.vtest.assembly.component.impl; + +import org.apache.tuscany.sca.vtest.assembly.component.BService; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Service; + +@Service(BService.class) +public class BServiceImpl implements BService { + + @Property + protected String someProperty; + + public String getState() { + return "SomeStateFromB"; + } + + public String getSomeProperty() { + return someProperty; + } + +} diff --git a/java/sca/vtest/assembly/component/src/main/resources/component.composite b/java/sca/vtest/assembly/component/src/main/resources/component.composite new file mode 100644 index 0000000000..bb452feac9 --- /dev/null +++ b/java/sca/vtest/assembly/component/src/main/resources/component.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + some b component value + + + + + some b2 component value + + + diff --git a/java/sca/vtest/assembly/component/src/test/java/org/apache/tuscany/sca/vtest/assembly/component/ComponentTestCase.java b/java/sca/vtest/assembly/component/src/test/java/org/apache/tuscany/sca/vtest/assembly/component/ComponentTestCase.java new file mode 100644 index 0000000000..7788e69381 --- /dev/null +++ b/java/sca/vtest/assembly/component/src/test/java/org/apache/tuscany/sca/vtest/assembly/component/ComponentTestCase.java @@ -0,0 +1,70 @@ +/* + * 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.vtest.assembly.component; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + */ +public class ComponentTestCase { + + protected static String compositeName = "component.composite"; + protected static AService aService = null; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + aService = ServiceFinder.getService(AService.class, "AComponent/AService"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + + } + + /** + * Lines 92-94: + *

+ * Components are configured instances of implementations. Components + * provide and consume services. More than one component can use and + * configure the same implementation, where each component configures the + * implementation differently. + */ + @Test + public void component1() throws Exception { + Assert.assertEquals("some b component value", aService.getBProperty()); + Assert.assertEquals("some b2 component value", aService.getB2Property()); + } + +} diff --git a/java/sca/vtest/assembly/pom.xml b/java/sca/vtest/assembly/pom.xml index 8d77631536..9a907402bf 100644 --- a/java/sca/vtest/assembly/pom.xml +++ b/java/sca/vtest/assembly/pom.xml @@ -61,6 +61,7 @@ ctypefile + component -- cgit v1.2.3