You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2006/03/11 00:57:25 UTC

svn commit: r384958 - in /incubator/tuscany/java/sca/container.java/src/test: java/org/apache/tuscany/container/java/integration/ resources/app1/

Author: jboynes
Date: Fri Mar 10 15:57:24 2006
New Revision: 384958

URL: http://svn.apache.org/viewcvs?rev=384958&view=rev
Log:
add integration test that mimics helloworld sample

Added:
    incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java   (with props)
    incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java   (with props)
    incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java   (with props)
    incubator/tuscany/java/sca/container.java/src/test/resources/app1/
    incubator/tuscany/java/sca/container.java/src/test/resources/app1/sca.module

Added: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java?rev=384958&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java (added)
+++ incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java Fri Mar 10 15:57:24 2006
@@ -0,0 +1,29 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.container.java.integration;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+    public String getGreetings(String name) {
+        return "Hello " + name;
+    }
+}

Propchange: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java?rev=384958&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java (added)
+++ incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java Fri Mar 10 15:57:24 2006
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.container.java.integration;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface HelloWorldService {
+    public String getGreetings(String name);
+}

Propchange: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java?rev=384958&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java (added)
+++ incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java Fri Mar 10 15:57:24 2006
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.container.java.integration;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import junit.framework.TestCase;
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ModuleContext;
+
+import org.apache.tuscany.core.client.TuscanyRuntime;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HelloWorldTestCase extends TestCase {
+    private ClassLoader oldCL;
+
+    public void testHelloWorld() throws Exception {
+        TuscanyRuntime tuscany = new TuscanyRuntime("test", null);
+        tuscany.start();
+        ModuleContext moduleContext = CurrentModuleContext.getContext();
+        assertNotNull(moduleContext);
+
+        HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorld");
+        assertNotNull(helloworldService);
+
+        String value = helloworldService .getGreetings("World");
+        assertEquals("Hello World", value);
+
+        tuscany.stop();
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        URL url = getClass().getResource("/app1/");
+        ClassLoader cl = new URLClassLoader(new URL[]{url}, getClass().getClassLoader());
+        oldCL = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(cl);
+    }
+
+    protected void tearDown() throws Exception {
+        Thread.currentThread().setContextClassLoader(oldCL);
+        super.tearDown();
+    }
+}

Propchange: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/java/sca/container.java/src/test/resources/app1/sca.module
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/test/resources/app1/sca.module?rev=384958&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/test/resources/app1/sca.module (added)
+++ incubator/tuscany/java/sca/container.java/src/test/resources/app1/sca.module Fri Mar 10 15:57:24 2006
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright (c) 2005 BEA Sytems Inc.
+  Copyright (c) 2005 International Business Machines
+
+  Licensed 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+        name="Helloworld">
+
+    <component name="HelloWorld">
+        <implementation.java class="org.apache.tuscany.container.java.integration.HelloWorldImpl"/>
+    </component>
+    
+</module>