You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by na...@apache.org on 2011/08/21 13:55:43 UTC
svn commit: r1159968 - in /tuscany/sca-java-1.x/trunk/itest/services/src:
main/java/org/apache/tuscany/sca/itest/services/ main/resources/
test/java/org/apache/tuscany/sca/itest/services/
Author: nash
Date: Sun Aug 21 11:55:43 2011
New Revision: 1159968
URL: http://svn.apache.org/viewvc?rev=1159968&view=rev
Log:
TUSCANY-2735: Add tests for generic types
Added:
tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsService.java
tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceClient.java
tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceClientImpl.java
tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceImpl.java
tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SuperGenericsService.java
tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SuperGenericsServiceImpl.java
Modified:
tuscany/sca-java-1.x/trunk/itest/services/src/main/resources/ServicesTest.composite
tuscany/sca-java-1.x/trunk/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java
Added: tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsService.java?rev=1159968&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsService.java (added)
+++ tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsService.java Sun Aug 21 11:55:43 2011
@@ -0,0 +1,25 @@
+/*
+ * 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.services;
+
+public interface SubGenericsService extends SuperGenericsService<String> {
+
+ void print();
+}
Added: tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceClient.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceClient.java?rev=1159968&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceClient.java (added)
+++ tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceClient.java Sun Aug 21 11:55:43 2011
@@ -0,0 +1,27 @@
+/*
+ * 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.services;
+
+public interface SubGenericsServiceClient<T> {
+
+ void print();
+
+ T doIt(T anything);
+}
Added: tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceClientImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceClientImpl.java?rev=1159968&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceClientImpl.java (added)
+++ tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceClientImpl.java Sun Aug 21 11:55:43 2011
@@ -0,0 +1,51 @@
+/*
+ * 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.services;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(SubGenericsServiceClient.class)
+public class SubGenericsServiceClientImpl implements SubGenericsServiceClient<String> {
+
+ private SubGenericsService subGenericsService;
+
+ public String doIt(String anything) {
+ return subGenericsService.doIt(anything);
+ }
+
+ public void print() {
+ subGenericsService.print();
+
+ }
+
+ public SubGenericsService getSubGenericsService() {
+ return subGenericsService;
+ }
+
+ @Reference
+ public void setSubGenericsService(SubGenericsService subGenericsService) {
+ this.subGenericsService = subGenericsService;
+ }
+
+
+
+
+}
Added: tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceImpl.java?rev=1159968&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceImpl.java (added)
+++ tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SubGenericsServiceImpl.java Sun Aug 21 11:55:43 2011
@@ -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.itest.services;
+
+
+public class SubGenericsServiceImpl extends SuperGenericsServiceImpl<String>
+ implements SubGenericsService{
+
+ public void print(){
+ System.out.println("I am print.");
+ }
+}
Added: tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SuperGenericsService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SuperGenericsService.java?rev=1159968&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SuperGenericsService.java (added)
+++ tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SuperGenericsService.java Sun Aug 21 11:55:43 2011
@@ -0,0 +1,28 @@
+/*
+ * 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.services;
+
+/**
+ * The interface for SuperGenericsService.
+ *
+ */
+public interface SuperGenericsService<T> {
+
+ T doIt(T anything);
+}
Added: tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SuperGenericsServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SuperGenericsServiceImpl.java?rev=1159968&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SuperGenericsServiceImpl.java (added)
+++ tuscany/sca-java-1.x/trunk/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/SuperGenericsServiceImpl.java Sun Aug 21 11:55:43 2011
@@ -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.itest.services;
+
+
+public abstract class SuperGenericsServiceImpl<T> implements SuperGenericsService<T>{
+
+ public T doIt(T anything){
+ return anything;
+ }
+
+}
Modified: tuscany/sca-java-1.x/trunk/itest/services/src/main/resources/ServicesTest.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/services/src/main/resources/ServicesTest.composite?rev=1159968&r1=1159967&r2=1159968&view=diff
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/services/src/main/resources/ServicesTest.composite (original)
+++ tuscany/sca-java-1.x/trunk/itest/services/src/main/resources/ServicesTest.composite Sun Aug 21 11:55:43 2011
@@ -66,5 +66,16 @@
<interface.java interface="org.apache.tuscany.sca.itest.services.D1Component" />
</service>
</component>
+
+ <!-- Component used to implement SubGenericsService -->
+ <component name="SubGenericsServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.services.SubGenericsServiceImpl"/>
+ </component>
+
+ <!-- A SubGenericsServiceClientImpl component that uses SCA binding to invoke SubGenericsService service -->
+ <component name="SubGenericsServiceClientSCAComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.services.SubGenericsServiceClientImpl" />
+ <reference name="subGenericsService" target="SubGenericsServiceComponent"/>
+ </component>
</composite>
\ No newline at end of file
Modified: tuscany/sca-java-1.x/trunk/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java?rev=1159968&r1=1159967&r2=1159968&view=diff
==============================================================================
--- tuscany/sca-java-1.x/trunk/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java (original)
+++ tuscany/sca-java-1.x/trunk/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java Sun Aug 21 11:55:43 2011
@@ -99,6 +99,22 @@ public class ServicesTestCase {
}
+ @Test
+ public void testSCASubGenericsServiceDoIt() throws Exception{
+ @SuppressWarnings("unchecked")
+ SubGenericsServiceClient<String> subGenericsServiceClient = domain.getService(SubGenericsServiceClient.class, "SubGenericsServiceClientSCAComponent");
+ String actual = "noting";
+ String expected = subGenericsServiceClient.doIt(actual);
+ Assert.assertEquals(actual, expected);
+ }
+
+ @Test
+ public void testSCASubGenericsServicePrint() throws Exception{
+ @SuppressWarnings("unchecked")
+ SubGenericsServiceClient<String> subGenericsServiceClient = domain.getService(SubGenericsServiceClient.class, "SubGenericsServiceClientSCAComponent");
+ subGenericsServiceClient.print();
+ }
+
public static void main(String[] args) throws Exception {
ServicesTestCase.init();
ServicesTestCase tester = new ServicesTestCase();
@@ -106,6 +122,8 @@ public class ServicesTestCase {
tester.testBService();
tester.testCService();
tester.testDService();
+ tester.testSCASubGenericsServiceDoIt();
+ tester.testSCASubGenericsServicePrint();
ServicesTestCase.destroy();
}
}