cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r902847 - in /cxf/dosgi/trunk: ./ parent/ systests2/ systests2/src/ systests2/src/test/ systests2/src/test/java/ systests2/src/test/java/org/ systests2/src/test/java/org/apache/ systests2/src/test/java/org/apache/cxf/ systests2/src/test/jav...
Date Mon, 25 Jan 2010 15:49:31 GMT
Author: davidb
Date: Mon Jan 25 15:49:30 2010
New Revision: 902847

URL: http://svn.apache.org/viewvc?rev=902847&view=rev
Log:
The beginnings of a new system test suite.
Upgraded Junit dependency to 4.4
Upgraded EasyMock dependency to 2.4

The new system tests aren't part of the main build/test cycle yet.

Added:
    cxf/dosgi/trunk/systests2/
    cxf/dosgi/trunk/systests2/pom.xml   (with props)
    cxf/dosgi/trunk/systests2/src/
    cxf/dosgi/trunk/systests2/src/test/
    cxf/dosgi/trunk/systests2/src/test/java/
    cxf/dosgi/trunk/systests2/src/test/java/org/
    cxf/dosgi/trunk/systests2/src/test/java/org/apache/
    cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/
    cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/
    cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/
    cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/Streams.java
  (with props)
    cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/TestExportService.java
  (with props)
Modified:
    cxf/dosgi/trunk/parent/pom.xml
    cxf/dosgi/trunk/pom.xml

Modified: cxf/dosgi/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/parent/pom.xml?rev=902847&r1=902846&r2=902847&view=diff
==============================================================================
--- cxf/dosgi/trunk/parent/pom.xml (original)
+++ cxf/dosgi/trunk/parent/pom.xml Mon Jan 25 15:49:30 2010
@@ -48,19 +48,19 @@
             <dependency>
                 <groupId>junit</groupId>
                 <artifactId>junit</artifactId>
-                <version>4.2</version>
+                <version>4.4</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.easymock</groupId>
                 <artifactId>easymock</artifactId>
-                <version>2.2</version>
+                <version>2.4</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.easymock</groupId>
                 <artifactId>easymockclassextension</artifactId>
-                <version>2.2</version>
+                <version>2.4</version>
                 <scope>test</scope>
             </dependency>
        </dependencies>

Modified: cxf/dosgi/trunk/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/pom.xml?rev=902847&r1=902846&r2=902847&view=diff
==============================================================================
--- cxf/dosgi/trunk/pom.xml (original)
+++ cxf/dosgi/trunk/pom.xml Mon Jan 25 15:49:30 2010
@@ -110,7 +110,6 @@
         <module>discovery</module>
         <module>samples</module>
         <module>distribution</module>
-    <!--    <module>systests</module>-->
     </modules>
 
     <profiles>

Added: cxf/dosgi/trunk/systests2/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/pom.xml?rev=902847&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/pom.xml (added)
+++ cxf/dosgi/trunk/systests2/pom.xml Mon Jan 25 15:49:30 2010
@@ -0,0 +1,116 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.cxf.dosgi</groupId>
+        <artifactId>cxf-dosgi-ri-parent</artifactId>
+        <version>1.2-SNAPSHOT</version>
+        <relativePath>../parent/pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.cxf.dosgi.systests</groupId>
+    <artifactId>cxf-dosgi-ri-systests2</artifactId>
+    <version>1.2-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <name>Distributed OSGi System Tests 2</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <version>1.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit</artifactId>
+            <version>1.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-default</artifactId>
+            <version>1.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>4.1.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf.dosgi</groupId>
+            <artifactId>cxf-dosgi-ri-singlebundle-distribution</artifactId>
+            <version>${pom.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf.dosgi.samples</groupId>
+            <artifactId>cxf-dosgi-ri-samples-greeter-impl</artifactId>
+            <version>${pom.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf.dosgi.samples</groupId>
+            <artifactId>cxf-dosgi-ri-samples-greeter-interface</artifactId>
+            <version>${pom.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency> 
+    </dependencies>
+
+    <build>
+        <plugins>
+            <!-- use pax exam maven plugin -->
+
+            <!--
+            Note: settings and dependencies for the final osgi runtime (TESTS) are just used
in TestCases
+            that annotated with this:
+            @RunWith( MavenConfiguredJUnit4TestRunner.class )
+
+            All other testcases will use their own settings/provisioning inside @Configure
Methods.
+            -->
+            <plugin>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>maven-paxexam-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>generate-config</id>
+                        <goals>
+                            <goal>generate-config</goal>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <options>
+                        <platform>equinox</platform>
+                        <profiles>log</profiles>
+                    </options>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
+

Propchange: cxf/dosgi/trunk/systests2/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/systests2/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/dosgi/trunk/systests2/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/Streams.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/Streams.java?rev=902847&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/Streams.java
(added)
+++ cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/Streams.java
Mon Jan 25 15:49:30 2010
@@ -0,0 +1,39 @@
+package org.apache.cxf.dosgi.systests2.common;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class Streams {
+    private Streams() {}
+    
+    public static void pump(InputStream is, OutputStream os) throws IOException {       

+        byte[] bytes = new byte[8192];
+
+        int length = 0;
+        int offset = 0;
+
+        while ((length = is.read(bytes, offset, bytes.length - offset)) != -1) {
+            offset += length;
+
+            if (offset == bytes.length) {
+                os.write(bytes, 0, bytes.length);
+                offset = 0;
+            }
+        }
+        if (offset != 0) {
+            os.write(bytes, 0, offset);
+        }
+    }
+    
+    public static byte [] suck(InputStream is) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            pump(is, baos);
+            return baos.toByteArray();
+        } finally {
+            is.close();
+        }
+    }
+}

Propchange: cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/Streams.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/Streams.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/TestExportService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/TestExportService.java?rev=902847&view=auto
==============================================================================
--- cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/TestExportService.java
(added)
+++ cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/TestExportService.java
Mon Jan 25 15:49:30 2010
@@ -0,0 +1,160 @@
+/** 
+ * 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.cxf.dosgi.systests2.common;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.net.URL;
+import java.util.Map;
+import java.util.concurrent.TimeoutException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.dosgi.samples.greeter.GreeterData;
+import org.apache.cxf.dosgi.samples.greeter.GreeterException;
+import org.apache.cxf.dosgi.samples.greeter.GreeterService;
+import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestExportService {
+    @Inject
+    BundleContext bundleContext = null;
+
+    @Configuration
+    public static Option[] configure() {
+        return CoreOptions.options(
+//                // this just adds all what you write here to java vm argumenents of the
(new) osgi process.
+//                vmOption( "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"
),
+//                // this is necessary to let junit runner not timout the remote process
before attaching debugger
+//                // setting timeout to 0 means wait as long as the remote service comes
available.
+//                waitForFrameworkStartup(),
+                
+                CoreOptions.mavenBundle().groupId("org.osgi").artifactId("org.osgi.compendium").versionAsInProject(),
+                CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi").artifactId("cxf-dosgi-ri-singlebundle-distribution").versionAsInProject(),
+                CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject(),
+                CoreOptions.mavenBundle().groupId("org.apache.cxf.dosgi.samples").artifactId("cxf-dosgi-ri-samples-greeter-impl").versionAsInProject()
+        );
+    }
+    
+    @Test
+    public void testCreateEndpoint() throws Exception {
+        for( Bundle b : bundleContext.getBundles() )
+        {
+            System.out.println( "Bundle " + b.getBundleId() + " : " + b.getSymbolicName()
);
+        }        
+
+        waitPort(9090);
+        URL wsdlURL = new URL("http://localhost:9090/greeter?wsdl");
+        
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        dbf.setValidating(false);
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        Document doc = db.parse(wsdlURL.openStream());
+        Element el = doc.getDocumentElement();
+        Assert.assertEquals("definitions", el.getLocalName());
+        Assert.assertEquals("http://schemas.xmlsoap.org/wsdl/", el.getNamespaceURI());
+        Assert.assertEquals("GreeterService", el.getAttribute("name"));
+        
+        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
       
+        try {
+            ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
+            factory.setServiceClass(GreeterService.class);
+            factory.setAddress("http://localhost:9090/greeter");
+            factory.getServiceFactory().setDataBinding(new AegisDatabinding());
+            GreeterService client = (GreeterService)factory.create();
+            Map<GreetingPhrase, String> greetings = client.greetMe("Fred");
+            Assert.assertEquals("Fred", greetings.get(new GreetingPhrase("Hello")));
+            
+            try {
+                class GreeterDataImpl implements GreeterData {
+                    private String name;
+                    private int age;
+                    private boolean exception;
+
+                    GreeterDataImpl(String n, int a, boolean ex) {
+                        name = n;
+                        age = a;
+                        exception = ex;
+                    }
+                    
+                    public String getName() {
+                        return name;
+                    }
+
+                    public int getAge() {
+                        return age;
+                    }
+
+                    public boolean isException() {
+                        return exception;
+                    }                
+                }
+                
+                GreeterData gd = new GreeterDataImpl("Stranger", 11, true);
+                client.greetMe(gd);
+                Assert.fail("GreeterException has to be thrown");
+            } catch (GreeterException ex) {
+                Assert.assertEquals("Wrong exception message", 
+                             "GreeterService can not greet Stranger", 
+                             ex.toString());
+            } 
+        } finally {
+            Thread.currentThread().setContextClassLoader(contextLoader);            
+        }
+    }
+
+    private void waitPort(int port) throws Exception {
+        for (int i = 0; i < 10; i++) {
+            Socket s = null;
+            try {
+                s = new Socket((String) null, port);
+                // yep, its available
+                return;
+            } catch (IOException e) {
+                // wait 
+            } finally {
+                if (s != null) {
+                    try {
+                        s.close();
+                    } catch (IOException e) {}
+                }
+            }
+            Thread.sleep(1000);            
+        }
+        throw new TimeoutException();
+    }
+}

Propchange: cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/TestExportService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/systests2/src/test/java/org/apache/cxf/dosgi/systests2/common/TestExportService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message