You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by kw...@apache.org on 2007/05/02 22:48:05 UTC
svn commit: r534611 - in /incubator/tuscany/java/sca/itest/spec-api/src:
main/java/org/apache/tuscany/sca/test/spec/
main/java/org/apache/tuscany/sca/test/spec/impl/ main/resources/
test/java/org/apache/tuscany/sca/test/spec/
Author: kwilliams
Date: Wed May 2 13:48:04 2007
New Revision: 534611
URL: http://svn.apache.org/viewvc?view=rev&rev=534611
Log:
Adding dynamic service locate test and moving to Junit 4 idioms
Added:
incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/BasicService.java (with props)
incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MathService.java (with props)
incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/BasicServiceImpl.java (with props)
incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MathServiceImpl.java (with props)
incubator/tuscany/java/sca/itest/spec-api/src/main/resources/BasicService.composite
incubator/tuscany/java/sca/itest/spec-api/src/main/resources/MathService.composite
incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ServiceLocateTest.java (with props)
Modified:
incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java
Added: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/BasicService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/BasicService.java?view=auto&rev=534611
==============================================================================
--- incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/BasicService.java (added)
+++ incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/BasicService.java Wed May 2 13:48:04 2007
@@ -0,0 +1,26 @@
+/*
+ * 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.test.spec;
+
+public interface BasicService {
+
+ int negate(int theInt);
+ int delegateNegate(int theInt);
+
+}
Propchange: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/BasicService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/BasicService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MathService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MathService.java?view=auto&rev=534611
==============================================================================
--- incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MathService.java (added)
+++ incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MathService.java Wed May 2 13:48:04 2007
@@ -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.test.spec;
+
+public interface MathService {
+
+ int negate(int theInt);
+
+}
Propchange: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MathService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/MathService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/BasicServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/BasicServiceImpl.java?view=auto&rev=534611
==============================================================================
--- incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/BasicServiceImpl.java (added)
+++ incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/BasicServiceImpl.java Wed May 2 13:48:04 2007
@@ -0,0 +1,45 @@
+/*
+ * 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.test.spec.impl;
+
+import org.apache.tuscany.host.embedded.SCARuntime;
+import org.apache.tuscany.sca.test.spec.BasicService;
+import org.apache.tuscany.sca.test.spec.MathService;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Service;
+
+@Service(BasicService.class)
+public class BasicServiceImpl implements BasicService {
+
+ public int negate(int theInt) {
+ return -theInt;
+ }
+
+ public int delegateNegate(int theInt) {
+
+ SCARuntime.start("BasicService.composite");
+ ComponentContext context = SCARuntime.getComponentContext("MathServiceComponent");
+ ServiceReference<MathService> service = context.createSelfReference(MathService.class);
+ MathService mathService = service.getService();
+
+ return mathService.negate(theInt);
+
+ }
+}
Propchange: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/BasicServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/BasicServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MathServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MathServiceImpl.java?view=auto&rev=534611
==============================================================================
--- incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MathServiceImpl.java (added)
+++ incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MathServiceImpl.java Wed May 2 13:48:04 2007
@@ -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.test.spec.impl;
+
+import org.apache.tuscany.sca.test.spec.MathService;
+import org.osoa.sca.annotations.Service;
+
+@Service(MathService.class)
+public class MathServiceImpl implements MathService {
+
+ public int negate(int theInt) {
+ return -theInt;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MathServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/spec-api/src/main/java/org/apache/tuscany/sca/test/spec/impl/MathServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/itest/spec-api/src/main/resources/BasicService.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/spec-api/src/main/resources/BasicService.composite?view=auto&rev=534611
==============================================================================
--- incubator/tuscany/java/sca/itest/spec-api/src/main/resources/BasicService.composite (added)
+++ incubator/tuscany/java/sca/itest/spec-api/src/main/resources/BasicService.composite Wed May 2 13:48:04 2007
@@ -0,0 +1,29 @@
+<?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
+ * "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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:foo="http://foo"
+ targetNamespace="http://foo"
+ name="BasicServiceComposite">
+
+ <component name="BasicServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.test.spec.impl.BasicServiceImpl"/>
+ </component>
+
+</composite>
Added: incubator/tuscany/java/sca/itest/spec-api/src/main/resources/MathService.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/spec-api/src/main/resources/MathService.composite?view=auto&rev=534611
==============================================================================
--- incubator/tuscany/java/sca/itest/spec-api/src/main/resources/MathService.composite (added)
+++ incubator/tuscany/java/sca/itest/spec-api/src/main/resources/MathService.composite Wed May 2 13:48:04 2007
@@ -0,0 +1,29 @@
+<?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
+ * "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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:foo="http://foo"
+ targetNamespace="http://foo"
+ name="MathServiceComposite">
+
+ <component name="MathComponent">
+ <implementation.java class="org.apache.tuscany.sca.test.spec.impl.MathServiceImpl"/>
+ </component>
+
+</composite>
Modified: incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java?view=diff&rev=534611&r1=534610&r2=534611
==============================================================================
--- incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java Wed May 2 13:48:04 2007
@@ -18,31 +18,37 @@
*/
package org.apache.tuscany.sca.test.spec;
-import junit.framework.TestCase;
-
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import org.apache.tuscany.host.embedded.SCARuntime;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.osoa.sca.ComponentContext;
import org.osoa.sca.ServiceReference;
-public class ComponentContextTestCase extends TestCase {
+public class ComponentContextTestCase {
+
+ @Test
+ public void createSelfReference() {
- public void testCreateSelfReference() {
-
- ComponentContext context = SCARuntime.getComponentContext("MyService");
+ ComponentContext context = SCARuntime.getComponentContext("MyService");
ServiceReference<MyService> service = context.createSelfReference(MyService.class, "MyService");
MyService myService = service.getService();
-
+
assertNotNull(myService);
assertEquals("RTP", myService.getLocation());
assertEquals("2006", myService.getYear());
-
+
}
- protected void setUp() throws Exception {
- SCARuntime.start("CompositeTest.composite");
- }
+ @BeforeClass
+ public static void init() throws Exception {
+ SCARuntime.start("CompositeTest.composite");
+ }
- protected void tearDown() throws Exception {
- SCARuntime.stop();
+ @AfterClass
+ public static void destroy() throws Exception {
+ SCARuntime.stop();
}
}
Added: incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ServiceLocateTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ServiceLocateTest.java?view=auto&rev=534611
==============================================================================
--- incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ServiceLocateTest.java (added)
+++ incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ServiceLocateTest.java Wed May 2 13:48:04 2007
@@ -0,0 +1,65 @@
+/*
+ * 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.test.spec;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.host.embedded.SCARuntime;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+
+public class ServiceLocateTest {
+
+ ComponentContext context;
+ BasicService basicService;
+
+ @Test
+ public void negate() {
+
+ assertEquals(-99, basicService.negate(99));
+
+ }
+
+ @Ignore
+ @Test
+ public void delegateNegate() {
+
+ assertEquals(-99, basicService.delegateNegate(99));
+
+ }
+
+ @Before
+ public void init() throws Exception {
+
+ SCARuntime.start("BasicService.composite");
+ context = SCARuntime.getComponentContext("BasicServiceComponent");
+ ServiceReference<BasicService> service = context.createSelfReference(BasicService.class);
+ basicService = service.getService();
+
+ }
+
+ @After
+ public void destroy() throws Exception {
+ SCARuntime.stop();
+ }
+}
Propchange: incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ServiceLocateTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ServiceLocateTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org