You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/03/28 01:33:22 UTC
svn commit: r523114 - in
/incubator/tuscany/sandbox/rfeng/runtime/embedded/src:
main/java/org/apache/tuscany/runtime/embedded/ test/java/calculator/
test/java/org/apache/tuscany/api/ test/resources/
Author: rfeng
Date: Tue Mar 27 16:33:21 2007
New Revision: 523114
URL: http://svn.apache.org/viewvc?view=rev&rev=523114
Log:
Add a test client
Added:
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorClient.java (with props)
Modified:
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/system.composite
Modified: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java?view=diff&rev=523114&r1=523113&r2=523114
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java (original)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java Tue Mar 27 16:33:21 2007
@@ -87,11 +87,17 @@
public Component start() throws Exception {
initialize();
+ ScopeRegistry scopeRegistry = getScopeRegistry();
+ container = scopeRegistry.getScopeContainer(Scope.COMPOSITE);
+
+ /*
int i = 0;
for (URL ext : runtimeInfo.getExtensionSCDLs()) {
URI uri = URI.create("/extensions/extension" + (i++));
deployExtension(null, uri, ext, runtimeInfo.getClassLoader());
}
+ */
+
CompositeImplementation impl = new CompositeImplementation();
impl.setScdlLocation(applicationScdl);
impl.setClassLoader(runtimeInfo.getClassLoader());
@@ -102,8 +108,6 @@
for (Component component : components) {
component.start();
}
- ScopeRegistry scopeRegistry = getScopeRegistry();
- container = scopeRegistry.getScopeContainer(Scope.COMPOSITE);
container.startContext(DEFAULT_COMPOSITE, DEFAULT_COMPOSITE);
getWorkContext().setIdentifier(Scope.COMPOSITE, DEFAULT_COMPOSITE);
WorkContext workContext = new SimpleWorkContext();
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorClient.java?view=auto&rev=523114
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorClient.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorClient.java Tue Mar 27 16:33:21 2007
@@ -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 calculator;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CalculatorClient {
+
+ public CalculatorClient() {
+ super();
+ }
+
+ public static void main(String[] args) {
+ // Start the embedded SCA runtime
+ SCARuntime.start();
+
+ // Look up the ComponentContext by name
+ ComponentContext context = SCARuntime.getComponentContext("CalculatorServiceComponent");
+ ServiceReference<CalculatorService> self = context.createSelfReference(CalculatorService.class);
+ CalculatorService calculatorService = self.getService();
+ System.out.println("1.0 x 2.0 = " + calculatorService.multiply(1.0, 2.0));
+ AddService addService = context.getService(AddService.class, "addService");
+ System.out.println("1.0 + 2.0 = " + addService.add(1.0, 2.0));
+
+ // Stop the SCA embedded runtime
+ SCARuntime.stop();
+ }
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorClient.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorClient.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java?view=diff&rev=523114&r1=523113&r2=523114
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java (original)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java Tue Mar 27 16:33:21 2007
@@ -19,17 +19,13 @@
package org.apache.tuscany.api;
-import java.net.URI;
-
import junit.framework.TestCase;
-import org.apache.tuscany.runtime.embedded.SimpleRuntime;
-import org.apache.tuscany.runtime.embedded.SimpleRuntimeImpl;
-import org.apache.tuscany.runtime.embedded.SimpleRuntimeInfo;
-import org.apache.tuscany.runtime.embedded.SimpleRuntimeInfoImpl;
import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
import calculator.AddService;
+import calculator.CalculatorService;
/**
* @version $Rev$ $Date$
@@ -45,6 +41,8 @@
public void testStart() throws Exception {
ComponentContext context = SCARuntime.getComponentContext("CalculatorServiceComponent");
assertNotNull(context);
+ ServiceReference<CalculatorService> self = context.createSelfReference(CalculatorService.class);
+ assertEquals(2.0, self.getService().multiply(1.0, 2.0));
AddService service = context.getService(AddService.class, "addService");
assertEquals(3.0, service.add(1.0, 2.0));
}
Modified: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/system.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/system.composite?view=diff&rev=523114&r1=523113&r2=523114
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/system.composite (original)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/system.composite Tue Mar 27 16:33:21 2007
@@ -286,16 +286,6 @@
</component>
-->
- <!-- WorkScheduler service -->
- <component name="workManager">
- <system:implementation.system class="org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager" />
- <property name="poolSize">10</property>
- </component>
-
- <component name="workSchCompositeContextImplTestCaseeduler">
- <system:implementation.system class="org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler" />
- </component>
-
<component name="policyBuilderRegistry">
<system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl" />
</component>
@@ -343,10 +333,6 @@
class="org.apache.tuscany.runtime.standalone.host.implementation.launched.LaunchedComponentBuilder"/>
</component>
-->
-
- <component name="wiringExceptionFormatter">
- <system:implementation.system class="org.apache.tuscany.core.builder.WiringExceptionFormatter" />
- </component>
<component name="wiringExceptionFormatter">
<system:implementation.system class="org.apache.tuscany.core.builder.WiringExceptionFormatter" />
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org