Author: kwilliams
Date: Thu May 1 13:34:32 2008
New Revision: 652653
URL: http://svn.apache.org/viewvc?rev=652653&view=rev
Log:
Applying Gilbert's patch for TUSCANY-2284
Added:
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AnotherAService.java
(with props)
Modified:
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/resources/property.composite
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java
Modified:
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java?rev=652653&r1=652652&r2=652653&view=diff
==============================================================================
---
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java
(original)
+++
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java
Thu May 1 13:34:32 2008
@@ -61,12 +61,6 @@
public int getP12BInt();
- public String getP13();
-
- public String getP14();
-
- public boolean getP14SetterIsCalled();
-
public String getP15();
public String getP16();
@@ -85,5 +79,4 @@
public int getP21Size();
- public String getP22();
}
Added:
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AnotherAService.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AnotherAService.java?rev=652653&view=auto
==============================================================================
---
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AnotherAService.java
(added)
+++
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AnotherAService.java
Thu May 1 13:34:32 2008
@@ -0,0 +1,48 @@
+/*
+ * 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.javaapi.annotations.property;
+
+/**
+ * Simple Service
+ */
+public interface AnotherAService {
+
+ public String getName();
+
+ public String getP13();
+
+ public String getP14();
+
+ public String getP22();
+
+ public String getP23();
+
+ public String getP24();
+
+ public String getP25();
+
+ public boolean getP14SetterIsCalled();
+
+ public boolean getP23SetterIsCalled();
+
+ public boolean getP24SetterIsCalled();
+
+ public boolean getP25SetterIsCalled();
+
+}
Propchange:
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AnotherAService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AnotherAService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java?rev=652653&r1=652652&r2=652653&view=diff
==============================================================================
---
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java
(original)
+++
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java
Thu May 1 13:34:32 2008
@@ -56,12 +56,6 @@
public AObject p12; // complex Java type
injected via constructor parameter
- public String p13; // injected via field
and un-annotated
-
- public String p14; // injected via setter
and un-annotated
-
- public boolean p14SetterIsCalled = false;
-
@Property(name="pFifteen")
protected String p15; // injected via field with
different name
@@ -80,8 +74,6 @@
@Property(required=false)
public Integer[] p21; // an array and injected via
field
- protected String p22; // unannotated protected field should
not be injected
-
public String getName() {
return "AService";
}
@@ -119,11 +111,6 @@
this.p10 = p10;
}
- public void setP14(String p14) {
- p14SetterIsCalled = true;
- this.p14 = p14;
- }
-
@Property(name="pSixteen")
public void setP16(String p16) {
this.p16 = p16;
@@ -211,18 +198,6 @@
return p12.bInt;
}
- public String getP13() {
- return p13;
- }
-
- public String getP14() {
- return p14;
- }
-
- public boolean getP14SetterIsCalled() {
- return p14SetterIsCalled;
- }
-
public String getP15() {
return p15;
}
@@ -259,9 +234,7 @@
return p21.length;
}
- public String getP22() {
- return p22;
- }
}
+
Modified:
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java?rev=652653&r1=652652&r2=652653&view=diff
==============================================================================
---
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java
(original)
+++
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java
Thu May 1 13:34:32 2008
@@ -19,103 +19,55 @@
package org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl;
-import org.apache.tuscany.sca.vtest.javaapi.annotations.property.AService;
+import
org.apache.tuscany.sca.vtest.javaapi.annotations.property.AnotherAService;
import org.osoa.sca.annotations.Service;
[EMAIL PROTECTED](AService.class)
-public class AnotherAServiceImpl implements AService {
[EMAIL PROTECTED](AnotherAService.class)
+public class AnotherAServiceImpl implements AnotherAService {
- public String p13; // injected via field and un-annotated
+ public String p13; // injected via field and un-annotated
- public String p14; // injected via setter and un-annotated
-
- public boolean p14SetterIsCalled = false;
+ public String p14; // injected via setter and un-annotated
protected String p22; // unannotated protected field should not
be injected
+ protected String p23; // un-annotated protected and
has protected setter
+
+ protected String p24; // un-annotated protected field
and has public setter
+
+ private String p25; // un-annotated private
field and has public setter
+
+ public boolean p14SetterIsCalled = false;
+
+ public boolean p23SetterIsCalled = false;
+
+ public boolean p24SetterIsCalled = false;
+
+ public boolean p25SetterIsCalled = false;
+
+
public String getName() {
return "AService";
}
- public AnotherAServiceImpl() {
- super();
- }
-
public void setP14(String p14) {
p14SetterIsCalled = true;
this.p14 = p14;
}
-
- public String getP1() {
- return null;
- }
-
- public String getP2() {
- return null;
- }
-
- public String getP3() {
- return null;
- }
-
- public String getP4() {
- return null;
- }
-
- public String getP5() {
- return null;
- }
-
- public String getP6() {
- return null;
- }
-
- public String getP7AString() {
- return null;
- }
-
- public int getP7BInt() {
- return -1;
- }
-
- public String getP8AString() {
- return null;
- }
-
- public int getP8BInt() {
- return -1;
- }
-
- public String getP9AString() {
- return null;
- }
- public int getP9BInt() {
- return -1;
- }
-
- public String getP10AString() {
- return null;
+ protected void setP23(String p23) {
+ p23SetterIsCalled = true;
+ this.p23 = p23;
}
- public int getP10BInt() {
- return -1;
+ public void setP24(String p24) {
+ p24SetterIsCalled = true;
+ this.p24 = p24;
}
- public String getP11AString() {
- return null;
- }
-
- public int getP11BInt() {
- return -1;
- }
-
- public String getP12AString() {
- return null;
- }
-
- public int getP12BInt() {
- return -1;
+ public void setP25(String p25) {
+ p25SetterIsCalled = true;
+ this.p25 = p25;
}
public String getP13() {
@@ -126,47 +78,39 @@
return p14;
}
- public boolean getP14SetterIsCalled() {
- return p14SetterIsCalled;
- }
-
- public String getP15() {
- return null;
- }
-
- public String getP16() {
- return null;
+ public String getP22() {
+ return p22;
}
- public String getP17() {
- return null;
+ public String getP23() {
+ return p23;
}
- public String getP18() {
- return null;
+ public String getP24() {
+ return p24;
}
- public int getP19Size() {
- return -1;
+ public String getP25() {
+ return p25;
}
- public String getP20(int i) {
- return null;
+ public boolean getP14SetterIsCalled() {
+ return p14SetterIsCalled;
}
+
- public int getP20Size() {
- return -1;
+ public boolean getP23SetterIsCalled() {
+ return p23SetterIsCalled;
}
+
- public int getP21(int i) {
- return -1;
+ public boolean getP24SetterIsCalled() {
+ return p24SetterIsCalled;
}
+
- public int getP21Size() {
- return -1;
+ public boolean getP25SetterIsCalled() {
+ return p25SetterIsCalled;
}
- public String getP22() {
- return p22;
- }
}
Modified:
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/resources/property.composite
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/resources/property.composite?rev=652653&r1=652652&r2=652653&view=diff
==============================================================================
---
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/resources/property.composite
(original)
+++
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/resources/property.composite
Thu May 1 13:34:32 2008
@@ -65,8 +65,6 @@
<bInt>12</bInt>
</AObject>
</property>
- <property name="p13">p13</property>
- <property name="p14">p14</property>
<property name="pFifteen">p15</property>
<property name="pSixteen">p16</property>
<property name="p19" many="true"></property>
@@ -138,5 +136,8 @@
<property name="p13">p13</property>
<property name="p14">p14</property>
<property name="p22">p22</property>
+ <property name="p23">p23</property>
+ <property name="p24">p24</property>
+ <property name="p25">p25</property>
</component>
</composite>
Modified:
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java?rev=652653&r1=652652&r2=652653&view=diff
==============================================================================
---
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java
(original)
+++
incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java
Thu May 1 13:34:32 2008
@@ -25,9 +25,11 @@
import org.apache.tuscany.sca.host.embedded.SCADomain;
import org.apache.tuscany.sca.vtest.javaapi.annotations.property.AService;
import org.apache.tuscany.sca.vtest.javaapi.annotations.property.CService;
+import
org.apache.tuscany.sca.vtest.javaapi.annotations.property.AnotherAService;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.Ignore;
/**
* This test class tests the Property annotation described in section 1.2.3
@@ -44,6 +46,7 @@
protected static CService cService4 = null;
protected static CService cService5 = null;
protected static CService cService6 = null;
+ protected static AnotherAService anotherAService = null;
@BeforeClass
public static void init() throws Exception {
@@ -57,6 +60,7 @@
cService4 = domain.getService(CService.class, "CComponent4");
cService5 = domain.getService(CService.class, "CComponent5");
cService6 = domain.getService(CService.class, "CComponent6");
+ anotherAService = domain.getService(AnotherAService.class,
"AnotherAComponent");
} catch (Exception ex) {
ex.printStackTrace();
}
@@ -124,11 +128,10 @@
* the case where there is no "@Property" annotation, the name of the
* property is the same as the name of the field or setter.<br>
* <p>
- * p13 - injected via field and un-annotated
+ * p13 is an un-annotated public field which should be injected via
field<br>
*/
@Test
public void atProperty2() throws Exception {
- AService anotherAService = domain.getService(AService.class,
"AnotherAComponent");
Assert.assertEquals("p13", anotherAService.getP13());
}
@@ -137,11 +140,10 @@
* Where there is both a setter method and a field for a property, the
* setter method is used.<br>
* <p>
- * p14 - injected via setter and un-annotated
+ * p14 is an un-annotated public field, it should be injected via public
setter<br>
*/
@Test
public void atProperty3() throws Exception {
- AService anotherAService = domain.getService(AService.class,
"AnotherAComponent");
Assert.assertEquals("p14", anotherAService.getP14());
Assert.assertTrue(anotherAService.getP14SetterIsCalled());
}
@@ -262,11 +264,36 @@
* field. In the case where there is no "@Property" annotation, the name
of the property is the same as the
* name of the field or setter.
* <p>
- * p22 - unannotated protected field which should not be injected
+ * p22 is unannotated protected field which should not be injected
+ * p23 is un-annotated protected which should not be injected via
protected setter<br>
*/
@Test
+ @Ignore
+ // JIRA-2289 - p23 failed
public void atProperty7() throws Exception {
- AService anotherAService = domain.getService(AService.class,
"AnotherAComponent");
Assert.assertNull(anotherAService.getP22());
+ Assert.assertNull(anotherAService.getP23());
+ Assert.assertFalse(anotherAService.getP23SetterIsCalled());
}
+
+ /**
+ * Lines 1349 to 1352:<br>
+ * 1.8.13. "@Property"<br>
+ * ...<br>
+ * Properties may also be injected via public setter methods even when the
"@Property" annotation is not
+ * present. However, the "@Property" annotation must be used in order to
inject a property onto a non-public
+ * field. In the case where there is no "@Property" annotation, the name
of the property is the same as the
+ * name of the field or setter.
+ * <p>
+ * p24 is un-annotated protected field which should be injected via public
setter<br>
+ * p25 is un-annotated private field which should be injected via public
setter<br>
+ */
+ @Test
+ public void atProperty8() throws Exception {
+ Assert.assertEquals("p24", anotherAService.getP24());
+ Assert.assertTrue(anotherAService.getP24SetterIsCalled());
+ Assert.assertEquals("p25", anotherAService.getP25());
+ Assert.assertTrue(anotherAService.getP25SetterIsCalled());
+ }
+
}