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/15 21:58:58 UTC
svn commit: r538293 - 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: Tue May 15 12:58:56 2007
New Revision: 538293
URL: http://svn.apache.org/viewvc?view=rev&rev=538293
Log:
Simplest tes of ComponentContext.getService via a defined reference
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
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=538293
==============================================================================
--- 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 Tue May 15 12:58:56 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=538293
==============================================================================
--- 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 Tue May 15 12:58:56 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=538293
==============================================================================
--- 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 Tue May 15 12:58:56 2007
@@ -0,0 +1,49 @@
+/*
+ * 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.BasicService;
+import org.apache.tuscany.sca.test.spec.MathService;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(BasicService.class)
+public class BasicServiceImpl implements BasicService {
+
+ @Context
+ protected ComponentContext context;
+
+ //The reference anntation is used in lieu of a component type definition
+ //This makes the call to getService redundant since the reference is injected
+ //but it serves the purpose to demonstrate that getService is working.
+ @Reference
+ protected MathService mathServiceReference;
+
+ public int negate(int theInt) {
+ return -theInt;
+ }
+
+ public int delegateNegate(int theInt) {
+ mathServiceReference = context.getService(MathService.class, "mathServiceReference");
+ return mathServiceReference.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=538293
==============================================================================
--- 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 Tue May 15 12:58:56 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=538293
==============================================================================
--- 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 Tue May 15 12:58:56 2007
@@ -0,0 +1,30 @@
+<?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"/>
+ <reference name="mathServiceReference" target="MathServiceComponent"/>
+ </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=538293
==============================================================================
--- 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 Tue May 15 12:58:56 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="MathServiceComponent">
+ <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=538293&r1=538292&r2=538293
==============================================================================
--- 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 Tue May 15 12:58:56 2007
@@ -19,37 +19,35 @@
package org.apache.tuscany.sca.test.spec;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import org.apache.tuscany.sca.host.embedded.SCADomain;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
public class ComponentContextTestCase {
-
- static SCADomain domain;
+
+ private SCADomain domain;
@Test
- public void getServiceReference() {
-
- //FIXME this does not test ComponentContext, we'll need a component impl
- // to test it
- MyService myService = domain.getService(MyService.class, "MyService");
-
- assertNotNull(myService);
- assertEquals("RTP", myService.getLocation());
- assertEquals("2006", myService.getYear());
+ public void simpleLocate() {
+ BasicService service = domain.getService(BasicService.class, "BasicServiceComponent");
+ assertEquals(-99, service.negate(99));
+ }
+ @Test
+ public void delegateViaDefinedReference() {
+ BasicService service = domain.getService(BasicService.class, "BasicServiceComponent");
+ assertEquals(-99, service.delegateNegate(99));
}
- @BeforeClass
- public static void init() throws Exception {
- domain = SCADomain.newInstance("CompositeTest.composite");
+ @Before
+ public void init() throws Exception {
+ domain = SCADomain.newInstance("sca://local", ".", "BasicService.composite", "MathService.composite");
}
- @AfterClass
- public static void destroy() throws Exception {
+ @After
+ public void destroy() throws Exception {
domain.close();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org