diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-10-31 10:30:29 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-10-31 10:30:29 +0000 |
commit | f3b9cd6311a0b7c8ce1af36057aefa6f00eed7e7 (patch) | |
tree | fecde555d6421a9361c9e89c0655d633c0f9fbc2 /sca-java-2.x/trunk/testing/itest | |
parent | 9e53a729acf513d54f0e2ed87e949e248b3cbeeb (diff) |
TUSCANY-3924 - ignore artifacts of the base class when a java implementation class extends a base class
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1195397 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/testing/itest')
7 files changed, 313 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/Annotated1CTCalcComponentImpl.java b/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/Annotated1CTCalcComponentImpl.java new file mode 100644 index 0000000000..d86c552c56 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/Annotated1CTCalcComponentImpl.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.ctcalc;
+
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CTCalcComponent.class)
+public class Annotated1CTCalcComponentImpl extends BaseCTCalcComponentImpl {
+
+ private String aPropertyPrivate;
+ protected String aPropertyProtected;
+ public String aPropertyPublic;
+ @Property
+ public String aPropertyAnnotated;
+
+ public String test(){
+ return "Annotated";
+ }
+}
diff --git a/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/AnnotatedCTCalcComponentImpl.java b/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/AnnotatedCTCalcComponentImpl.java new file mode 100644 index 0000000000..e9ea8129c9 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/AnnotatedCTCalcComponentImpl.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.ctcalc;
+
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(CTCalcComponent.class)
+public class AnnotatedCTCalcComponentImpl extends BaseCTCalcComponentImpl {
+
+ private String aPropertyPrivate;
+ protected String aPropertyProtected;
+ public String aPropertyPublic;
+
+ public String test(){
+ return "Annotated";
+ }
+}
diff --git a/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/BaseCTCalcComponentImpl.java b/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/BaseCTCalcComponentImpl.java new file mode 100644 index 0000000000..03fa878127 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/BaseCTCalcComponentImpl.java @@ -0,0 +1,54 @@ +/*
+ * 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.ctcalc;
+
+public class BaseCTCalcComponentImpl implements CTCalcComponent {
+
+ private String notAPropertyPrivate;
+ protected String notAPropertyProtected;
+ public String notAPropertyPublic;
+
+ public String getNotAPropertyPrivate() {
+ return notAPropertyPrivate;
+ }
+
+ public void setNotAPropertyPrivate(String notAPropertyPrivate) {
+ this.notAPropertyPrivate = notAPropertyPrivate;
+ }
+
+ public String getNotAPropertyProtected() {
+ return notAPropertyProtected;
+ }
+
+ public void setNotAPropertyProtected(String notAPropertyProtected) {
+ this.notAPropertyProtected = notAPropertyProtected;
+ }
+
+ public String getNotAPropertyPublic() {
+ return notAPropertyPublic;
+ }
+
+ public void setNotAPropertyPublic(String notAPropertyPublic) {
+ this.notAPropertyPublic = notAPropertyPublic;
+ }
+
+ public String test(){
+ return "XXX";
+ }
+}
diff --git a/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/CTCalcComponent.java b/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/CTCalcComponent.java new file mode 100644 index 0000000000..c5f17745fc --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/CTCalcComponent.java @@ -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.
+ */
+package org.apache.tuscany.sca.itest.ctcalc;
+
+public interface CTCalcComponent {
+ public String test();
+}
diff --git a/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/UnannotatedCTCalcComponentImpl.java b/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/UnannotatedCTCalcComponentImpl.java new file mode 100644 index 0000000000..aadfeebe1f --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/UnannotatedCTCalcComponentImpl.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.sca.itest.ctcalc;
+
+public class UnannotatedCTCalcComponentImpl extends BaseCTCalcComponentImpl {
+
+ private String aPropertyPrivate;
+ protected String aPropertyProtected;
+ public String aPropertyPublic;
+
+ public String test(){
+ return "Unannotated";
+ }
+}
diff --git a/sca-java-2.x/trunk/testing/itest/properties/src/main/resources/CTCalcTest.composite b/sca-java-2.x/trunk/testing/itest/properties/src/main/resources/CTCalcTest.composite new file mode 100644 index 0000000000..c242c78970 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/properties/src/main/resources/CTCalcTest.composite @@ -0,0 +1,36 @@ +<?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
+ * 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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ targetNamespace="http://foo"
+ name="CTCalcTest">
+
+ <component name="AnnotatedComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.ctcalc.AnnotatedCTCalcComponentImpl" />
+ </component>
+
+ <component name="UnannotatedComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.ctcalc.UnannotatedCTCalcComponentImpl" />
+ </component>
+
+ <component name="Annotated1Component">
+ <implementation.java class="org.apache.tuscany.sca.itest.ctcalc.Annotated1CTCalcComponentImpl" />
+ <property name="aPropertyAnnotated" value="xyz"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/trunk/testing/itest/properties/src/test/java/org/apache/tuscany/sca/itest/ctcalc/CTCalcTestCase.java b/sca-java-2.x/trunk/testing/itest/properties/src/test/java/org/apache/tuscany/sca/itest/ctcalc/CTCalcTestCase.java new file mode 100644 index 0000000000..bebae5296b --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/properties/src/test/java/org/apache/tuscany/sca/itest/ctcalc/CTCalcTestCase.java @@ -0,0 +1,100 @@ +/*
+ * 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.ctcalc;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Iterator;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * This tests how properties are calculated in the case where the implementation class extends another class. Two
+ * cases are considered where the implementation class has:
+ * - SCA annotations
+ * - No SCA annotations
+ *
+ * In particular we're checking that the artifacts of the base class are ignored in both cases.
+ *
+ */
+public class CTCalcTestCase {
+
+ private static Node node;
+
+ private static CTCalcComponent annotatedComponent;
+ private static CTCalcComponent unannotatedComponent;
+
+
+ /**
+ * Method annotated with
+ *
+ * @BeforeClass is used for one time set Up, it executes before every tests. This method is used to create a test
+ * Embedded SCA node, to start the SCA node and to get a reference to the 'outerABService' service
+ */
+ @BeforeClass
+ public static void init() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("CTCalcTest.composite");
+ node = NodeFactory.newInstance().createNode("CTCalcTest.composite", new Contribution("c1", location));
+ node.start();
+ annotatedComponent = node.getService(CTCalcComponent.class, "AnnotatedComponent");
+ unannotatedComponent = node.getService(CTCalcComponent.class, "UnannotatedComponent");
+ }
+
+ /**
+ * Method annotated with
+ *
+ * @AfterClass is used for one time Tear Down, it executes after every tests. This method is used to close the
+ * node, close any previously opened connections etc
+ */
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+
+ @Ignore("TODO - TUSCANY-3965")
+ @Test
+ public void testAnnotatedExtension() {
+ assertEquals("Annotated", annotatedComponent.test());
+ assertEquals(0, ((NodeImpl)node).getDomainComposite().getComponents().get(0).getProperties().size());
+ System.out.println(((NodeImpl)node).getDomainComposite().getComponents().get(0).getProperties());
+ }
+
+ @Test
+ public void testUnannotatedExtension() {
+ assertEquals("Unannotated", unannotatedComponent.test());
+ assertEquals(2, ((NodeImpl)node).getDomainComposite().getComponents().get(1).getProperties().size());
+ System.out.println(((NodeImpl)node).getDomainComposite().getComponents().get(1).getProperties());
+ }
+
+ @Test
+ public void testAnnotated1Extension() {
+ assertEquals("Annotated", annotatedComponent.test());
+ assertEquals(1, ((NodeImpl)node).getDomainComposite().getComponents().get(2).getProperties().size());
+ System.out.println(((NodeImpl)node).getDomainComposite().getComponents().get(2).getProperties());
+ }
+}
|