Author: slaws
Date: Mon Jan 26 13:01:49 2009
New Revision: 737683

URL: http://svn.apache.org/viewvc?rev=737683&view=rev
Log:
Add some exception handling so that the JUnit test takes account of exceptions 
thrown in the "in-composite" client. Also exploit the common ant script.

Modified:
    tuscany/java/sca/samples/implementation-java-calculator/build.xml
    tuscany/java/sca/samples/implementation-java-calculator/pom.xml
    
tuscany/java/sca/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java
    
tuscany/java/sca/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java

Modified: tuscany/java/sca/samples/implementation-java-calculator/build.xml
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/samples/implementation-java-calculator/build.xml?rev=737683&r1=737682&r2=737683&view=diff
==============================================================================
--- tuscany/java/sca/samples/implementation-java-calculator/build.xml (original)
+++ tuscany/java/sca/samples/implementation-java-calculator/build.xml Mon Jan 
26 13:01:49 2009
@@ -16,26 +16,15 @@
  * specific language governing permissions and limitations
  * under the License.    
 -->
+       
 <project name="implementation-java-calculator" default="run-jse"> <!-- could 
dertmine the same name autmatically -->
+       <import file="../build-common.xml"/>
+       
     <property name="sample.name" value="${ant.project.name}"/>
        <property name="sample.root" value="."/>
     <property name="sample.jar" 
value="${sample.root}/target/sample-${sample.name}.jar" />
-       <available file="../../distribution/pom.xml" 
property="running.in.development"/>
        
-       <target name="set-development" if="running.in.development">
-               <property name="distro.root" 
value="../../distribution/all/target"/>
-       </target>
-       
-       <target name="set-distribution" unless="running.in.development">
-               <property name="distro.root" value="../.."/>
-       </target>
-                       
-    <target name="init" depends="set-development, set-distribution" >
-       
-        <mkdir dir="${sample.root}/target/classes"/>
-    </target>
-       
-    <target name="compile" depends="init">
+    <target name="compile" depends="common-init">
         <javac srcdir="${sample.root}/src/main/java"
                destdir="${sample.root}/target/classes"
                debug="on"
@@ -60,7 +49,7 @@
         <java 
jar="${distro.root}/modules/tuscany-node-launcher-2.0-SNAPSHOT.jar"
               fork="true"
                  inputstring="q">
-            <jvmarg 
value="-Djava.util.logging.config.file=${sample.root}../../logging.properties"/>
+            <jvmarg 
value="-Djava.util.logging.config.file=${sample.root}/../../logging.properties"/>
             <arg value="Calculator.composite"/> 
                 <!-- would be good to have the node launcher run the first 
deployable 
                      composite if this is not specified so I don't have to put 
it here -->

Modified: tuscany/java/sca/samples/implementation-java-calculator/pom.xml
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/samples/implementation-java-calculator/pom.xml?rev=737683&r1=737682&r2=737683&view=diff
==============================================================================
--- tuscany/java/sca/samples/implementation-java-calculator/pom.xml (original)
+++ tuscany/java/sca/samples/implementation-java-calculator/pom.xml Mon Jan 26 
13:01:49 2009
@@ -62,14 +62,6 @@
     <build>
        <finalName>${artifactId}</finalName>
        <plugins>
-           <plugin>
-               <groupId>org.apache.maven.plugins</groupId>
-               <artifactId>maven-surefire-plugin</artifactId>
-               <configuration>
-                   <skip>true</skip>
-               </configuration>
-           </plugin>
-           
               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-antrun-plugin</artifactId>

Modified: 
tuscany/java/sca/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java?rev=737683&r1=737682&r2=737683&view=diff
==============================================================================
--- 
tuscany/java/sca/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java
 (original)
+++ 
tuscany/java/sca/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java
 Mon Jan 26 13:01:49 2009
@@ -19,6 +19,7 @@
 
 package calculator;
 
+import org.osoa.sca.ServiceRuntimeException;
 import org.osoa.sca.annotations.EagerInit;
 import org.osoa.sca.annotations.Init;
 import org.osoa.sca.annotations.Reference;

Modified: 
tuscany/java/sca/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java?rev=737683&r1=737682&r2=737683&view=diff
==============================================================================
--- 
tuscany/java/sca/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java
 (original)
+++ 
tuscany/java/sca/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java
 Mon Jan 26 13:01:49 2009
@@ -23,6 +23,7 @@
 import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper;
 import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
 import org.junit.AfterClass;
+import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -32,7 +33,8 @@
 public class CalculatorTestCase {
 
     private static NodeLauncher launcher;
-    private static Node node;   
+    private static Node node;  
+    private static String status = "Sample Success";
     
     public static void main(String[] args) throws Exception {
        setUpBeforeClass();
@@ -44,8 +46,13 @@
         launcher = NodeLauncher.newInstance();
         String location = 
ContributionLocationHelper.getContributionLocation(CalculatorClient.class);
         node = launcher.createNode("Calculator.composite", new 
Contribution("test", location));
-        System.out.println("SCA Node API ClassLoader: " + 
node.getClass().getClassLoader());
-        node.start();
+        
+        try {
+            node.start();
+        } catch (Exception ex) {
+            status = ex.toString();
+            System.out.println(status);
+        }
     }
 
     @AfterClass
@@ -60,6 +67,7 @@
     }
 
     @Test
-    public void testDummy() throws Exception {
+    public void testSample() throws Exception {
+        Assert.assertEquals("Sample Success", status);
     }
 }


Reply via email to