summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-10-31 10:30:29 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-10-31 10:30:29 +0000
commitf3b9cd6311a0b7c8ce1af36057aefa6f00eed7e7 (patch)
treefecde555d6421a9361c9e89c0655d633c0f9fbc2
parent9e53a729acf513d54f0e2ed87e949e248b3cbeeb (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
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java6
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java6
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java9
-rw-r--r--sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/Annotated1CTCalcComponentImpl.java36
-rw-r--r--sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/AnnotatedCTCalcComponentImpl.java34
-rw-r--r--sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/BaseCTCalcComponentImpl.java54
-rw-r--r--sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/CTCalcComponent.java23
-rw-r--r--sca-java-2.x/trunk/testing/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ctcalc/UnannotatedCTCalcComponentImpl.java30
-rw-r--r--sca-java-2.x/trunk/testing/itest/properties/src/main/resources/CTCalcTest.composite36
-rw-r--r--sca-java-2.x/trunk/testing/itest/properties/src/test/java/org/apache/tuscany/sca/itest/ctcalc/CTCalcTestCase.java100
10 files changed, 326 insertions, 8 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java
index e993cdd382..a289a58091 100644
--- a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java
+++ b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java
@@ -25,9 +25,9 @@ package org.apache.tuscany.sca.implementation.java.util;
*/
public class Bean1 extends SuperBean {
- public static final int ALL_BEAN1_FIELDS = 6 + ALL_SUPER_FIELDS;
- public static final int ALL_BEAN1_PUBLIC_PROTECTED_FIELDS = 5 + ALL_SUPER_PUBLIC_PROTECTED_FIELDS;
- public static final int ALL_BEAN1_METHODS = 4 + ALL_SUPER_METHODS - 1;
+ public static final int ALL_BEAN1_FIELDS = 6; //TUSCANY-3924 + ALL_SUPER_FIELDS;
+ public static final int ALL_BEAN1_PUBLIC_PROTECTED_FIELDS = 5; //TUSCANY-3924 + ALL_SUPER_PUBLIC_PROTECTED_FIELDS;
+ public static final int ALL_BEAN1_METHODS = 4; //TUSCANY-3924 + ALL_SUPER_METHODS - 1;
public String field3;
protected String field2;
private String field1;
diff --git a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
index 9624865dcc..dfb3c77966 100644
--- a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
+++ b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.Set;
import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -46,7 +47,7 @@ public class JavaIntrospectionHelperTestCase {
@Test
public void testBean1AllPublicProtectedFields() throws Exception {
Set<Field> beanFields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(Bean1.class, true);
- assertEquals(4, beanFields.size()); //Bean1.ALL_BEAN1_PUBLIC_PROTECTED_FIELDS
+ assertEquals(2, beanFields.size()); //Bean1.ALL_BEAN1_PUBLIC_PROTECTED_FIELDS
}
@Test
@@ -75,7 +76,8 @@ public class JavaIntrospectionHelperTestCase {
throw new Exception("Override never invoked");
}
}
-
+
+ @Ignore("TUSCANY-3924")
@Test
public void testNoOverrideMethod() throws Exception {
Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class, true);
diff --git a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java
index a04ad3721a..f67ebe793c 100644
--- a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java
+++ b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java
@@ -83,7 +83,8 @@ public final class JavaIntrospectionHelper {
if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) {
return fields;
}
- fields = getAllPublicAndProtectedFields(clazz.getSuperclass(), fields, validating);
+ // TUSCANY-3924 - don't consider inherited fields
+ //fields = getAllPublicAndProtectedFields(clazz.getSuperclass(), fields, validating);
Field[] declaredFields = null;
@@ -136,7 +137,8 @@ public final class JavaIntrospectionHelper {
return fields;
}
- fields = getInjectableFields(clazz.getSuperclass(), fields, validating);
+ // TUSCANY-3924 - don't consider inherited fields
+ //fields = getInjectableFields(clazz.getSuperclass(), fields, validating);
Field[] declaredFields = null;
@@ -235,7 +237,8 @@ public final class JavaIntrospectionHelper {
}
// evaluate class hierarchy - this is done last to track inherited
// methods
- methods = getAllUniqueMethods(pClass.getSuperclass(), methods, validating);
+ // TUSCANY-3924 - don't consider inherited fields
+ //methods = getAllUniqueMethods(pClass.getSuperclass(), methods, validating);
return methods;
}
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());
+ }
+}