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 2008/03/27 07:30:37 UTC

svn commit: r641711 - in /incubator/tuscany/java/sca/vtest/java-api/src: main/java/org/ main/java/org/apache/ main/java/org/apache/tuscany/ main/java/org/apache/tuscany/sca/ main/java/org/apache/tuscany/sca/vtest/ main/java/org/apache/tuscany/sca/vtest...

Author: kwilliams
Date: Wed Mar 26 23:30:33 2008
New Revision: 641711

URL: http://svn.apache.org/viewvc?rev=641711&view=rev
Log:
Adding first test against java-api spec

Added:
    incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/
    incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/
    incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/
    incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/
    incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/
    incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/
    incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java   (with props)
    incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/BService.java   (with props)
    incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/
    incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java   (with props)
    incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/BServiceImpl.java   (with props)
    incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite   (with props)
Modified:
    incubator/tuscany/java/sca/vtest/java-api/src/test/java/org/apache/tuscany/sca/vtest/javaapi/JavaApiTestCase.java

Added: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java?rev=641711&view=auto
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java (added)
+++ incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java Wed Mar 26 23:30:33 2008
@@ -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.vtest.javaapi;
+
+
+/**
+ * Simple Service that uses another Service
+ */
+public interface AService {
+
+    public String getName();
+
+    public String getDelegateName();
+
+}

Propchange: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/AService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/BService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/BService.java?rev=641711&view=auto
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/BService.java (added)
+++ incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/BService.java Wed Mar 26 23:30:33 2008
@@ -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.vtest.javaapi;
+
+
+/**
+ * Simple Service used by another service
+ */
+public interface BService {
+
+    String getName();
+
+}

Propchange: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/BService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/BService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java?rev=641711&view=auto
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java (added)
+++ incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java Wed Mar 26 23:30:33 2008
@@ -0,0 +1,41 @@
+/*
+ * 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.vtest.javaapi.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.AService;
+import org.apache.tuscany.sca.vtest.javaapi.BService;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(AService.class)
+public class AServiceImpl implements AService {
+    
+    @Reference
+    protected BService delegate;
+
+    public String getName() {
+        return "AService";
+    }
+
+    public String getDelegateName() {
+        return delegate.getName();
+    }
+
+}

Propchange: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/AServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/BServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/BServiceImpl.java?rev=641711&view=auto
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/BServiceImpl.java (added)
+++ incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/BServiceImpl.java Wed Mar 26 23:30:33 2008
@@ -0,0 +1,32 @@
+/*
+ * 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.vtest.javaapi.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.BService;
+import org.osoa.sca.annotations.Service;
+
+@Service(BService.class)
+public class BServiceImpl implements BService {
+
+    public String getName() {
+        return "BService";
+    }
+
+}

Propchange: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/BServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/vtest/java-api/src/main/java/org/apache/tuscany/sca/vtest/javaapi/impl/BServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite?rev=641711&view=auto
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite (added)
+++ incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite Wed Mar 26 23:30:33 2008
@@ -0,0 +1,33 @@
+<?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"
+	targetNamespace="http://java-api-tests"
+	name="AB-Composite">
+ 	      
+    <component name="AComponent">
+	    <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.impl.AServiceImpl"/>
+        <reference name="delegate" target="BComponent"/>		
+    </component>   
+    
+    <component name="BComponent">
+        <implementation.java class="org.apache.tuscany.sca.vtest.javaapi.impl.BServiceImpl"/>
+    </component>     
+    
+</composite>

Propchange: incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/vtest/java-api/src/main/resources/ab.composite
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/tuscany/java/sca/vtest/java-api/src/test/java/org/apache/tuscany/sca/vtest/javaapi/JavaApiTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/src/test/java/org/apache/tuscany/sca/vtest/javaapi/JavaApiTestCase.java?rev=641711&r1=641710&r2=641711&view=diff
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/src/test/java/org/apache/tuscany/sca/vtest/javaapi/JavaApiTestCase.java (original)
+++ incubator/tuscany/java/sca/vtest/java-api/src/test/java/org/apache/tuscany/sca/vtest/javaapi/JavaApiTestCase.java Wed Mar 26 23:30:33 2008
@@ -19,41 +19,74 @@
 
 package org.apache.tuscany.sca.vtest.javaapi;
 
+import static org.junit.Assert.fail;
 import junit.framework.Assert;
 
+import org.apache.tuscany.sca.host.embedded.SCADomain;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
  * 
  */
 public class JavaApiTestCase {
-    
+
+    protected static SCADomain domain;
+    protected static AService a;
+    protected static String compositeName = "ab.composite";
+
     @BeforeClass
     public static void init() throws Exception {
-             
         try {
             System.out.println("Setting up");
-                        
-        } catch(Exception ex){
+            domain = SCADomain.newInstance(compositeName);
+            a = domain.getService(AService.class, "AComponent");
+        } catch (Exception ex) {
             ex.printStackTrace();
-        }  
-        
-   }
+        }
+    }
 
     @AfterClass
     public static void destroy() throws Exception {
 
-        System.out.println("Clean up");
+        System.out.println("Cleaning up");
+        if (domain != null)
+            domain.close();
+
+    }
 
+    @Test
+    public void firstTest() throws Exception {
+        Assert.assertTrue(true);
     }
-    
+
     @Test
-    public void testStartWithNoNodeContributions() throws Exception { 
+    @Ignore
+    public void bogusComponentName() throws Exception {
+        SCADomain tempDomain = SCADomain.newInstance(compositeName);
+        try {
+            AService a = tempDomain.getService(AService.class, "AReallyBogusComponentName");
+            if (a == null)
+                fail("Should have thrown an exception rather than return null");
+            else
+                fail("Should have thrown an exception rather than return a proxy");
+        } finally {
+            if (tempDomain != null)
+                tempDomain.close();
+        }
 
-                  Assert.assertTrue(true);
     }
-    
-    
+
+    @Test
+    public void accessAService() throws Exception {
+        Assert.assertEquals("AService", a.getName());
+    }
+
+    @Test
+    public void atReference() throws Exception {
+        Assert.assertEquals("BService", a.getDelegateName());
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org