incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mahrw...@apache.org
Subject svn commit: r900127 - in /incubator/aries/trunk: testsupport/ testsupport/testsupport-unit/ testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/fixture/ web/ web/web-itests/ web/web-itests/.settings/ web/web-itests/src/ web/web-itests/...
Date Sun, 17 Jan 2010 12:40:18 GMT
Author: mahrwald
Date: Sun Jan 17 12:40:17 2010
New Revision: 900127

URL: http://svn.apache.org/viewvc?rev=900127&view=rev
Log:
ARIES-115 Add itest for webbundle url handler

Added:
    incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/fixture/
    incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/fixture/ArchiveFixture.java
    incubator/aries/trunk/web/web-itests/   (with props)
    incubator/aries/trunk/web/web-itests/.classpath
    incubator/aries/trunk/web/web-itests/.project
    incubator/aries/trunk/web/web-itests/.settings/
    incubator/aries/trunk/web/web-itests/.settings/org.eclipse.jdt.core.prefs
    incubator/aries/trunk/web/web-itests/.settings/org.maven.ide.eclipse.prefs
    incubator/aries/trunk/web/web-itests/pom.xml
    incubator/aries/trunk/web/web-itests/src/
    incubator/aries/trunk/web/web-itests/src/main/
    incubator/aries/trunk/web/web-itests/src/main/java/
    incubator/aries/trunk/web/web-itests/src/main/resources/
    incubator/aries/trunk/web/web-itests/src/test/
    incubator/aries/trunk/web/web-itests/src/test/java/
    incubator/aries/trunk/web/web-itests/src/test/java/org/
    incubator/aries/trunk/web/web-itests/src/test/java/org/apache/
    incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/
    incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/
    incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/converter/
    incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/converter/itest/
    incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/converter/itest/WabConverterITest.java
    incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/test/
    incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/test/TestClass.java
    incubator/aries/trunk/web/web-itests/src/test/resources/
Modified:
    incubator/aries/trunk/testsupport/pom.xml
    incubator/aries/trunk/testsupport/testsupport-unit/pom.xml
    incubator/aries/trunk/web/pom.xml

Modified: incubator/aries/trunk/testsupport/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/testsupport/pom.xml?rev=900127&r1=900126&r2=900127&view=diff
==============================================================================
--- incubator/aries/trunk/testsupport/pom.xml (original)
+++ incubator/aries/trunk/testsupport/pom.xml Sun Jan 17 12:40:17 2010
@@ -54,4 +54,25 @@
         <module>testsupport-unit</module>
     </modules>
 
+		<build>
+		    <pluginManagement>
+		        <plugins>
+		            <plugin>
+		                <groupId>org.apache.felix</groupId>
+		                <artifactId>maven-bundle-plugin</artifactId>
+		                <version>2.0.1</version>
+		            </plugin>
+		            <plugin>
+		                <groupId>org.apache.maven.plugins</groupId>
+		                <artifactId>maven-release-plugin</artifactId>
+		                <configuration>
+		                    <useReleaseProfile>false</useReleaseProfile>
+		                    <goals>deploy</goals>
+		                    <arguments>-Papache-release,deploy</arguments>
+		                </configuration>
+		            </plugin>
+		        </plugins>
+		    </pluginManagement>
+		</build>
+
 </project>

Modified: incubator/aries/trunk/testsupport/testsupport-unit/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/testsupport/testsupport-unit/pom.xml?rev=900127&r1=900126&r2=900127&view=diff
==============================================================================
--- incubator/aries/trunk/testsupport/testsupport-unit/pom.xml (original)
+++ incubator/aries/trunk/testsupport/testsupport-unit/pom.xml Sun Jan 17 12:40:17 2010
@@ -1,22 +1,21 @@
-<!--
- 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.
--->
-<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">
+
+  <!--
+    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.
+  -->
+<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>
@@ -26,23 +25,45 @@
   </parent>
 
   <artifactId>org.apache.aries.testsupport.unit</artifactId>
-  <packaging>jar</packaging>
+  <packaging>bundle</packaging>
   <name>Apache Aries Unit Test Support</name>
   <description>
       This bundle provides unit test support.
   </description>
-  
+
   <dependencies>
-      <dependency>
-          <groupId>junit</groupId>
-          <artifactId>junit</artifactId>
-          <scope>provided</scope>
-      </dependency>
-      <dependency>
-          <groupId>org.osgi</groupId>
-          <artifactId>org.osgi.core</artifactId>
-          <scope>provided</scope>
-      </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Export-Package>
+              org.apache.aries.unittest.fixture
+            </Export-Package>
+            <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))
+            </_versionpolicy>
+            <_removeheaders>Ignore-Package,Include-Resource,Private-Package,Bundle-DocURL
+            </_removeheaders>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
 </project>

Added: incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/fixture/ArchiveFixture.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/fixture/ArchiveFixture.java?rev=900127&view=auto
==============================================================================
--- incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/fixture/ArchiveFixture.java
(added)
+++ incubator/aries/trunk/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/fixture/ArchiveFixture.java
Sun Jan 17 12:40:17 2010
@@ -0,0 +1,472 @@
+/**
+ *  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.aries.unittest.fixture;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.osgi.framework.Constants;
+
+/**
+ * Utility class for creating archive-based fixtures such as EBA archives, jar files etc.
+ * This class provides a flow based api for defining such fixtures. For example, a simple
EBA archive could 
+ * be defined as such:
+ * 
+ * <code>
+ * ArchiveFixtures.ZipFixture zip = ArchiveFixtures.newZip()
+ *   .jar("test.jar")
+ *     .manifest()
+ *       .symbolicName("com.ibm.test")
+ *       .version("2.0.0")
+ *     .end()
+ *     .file("random.txt", "Some text")
+ *   .end();
+ * </code>
+ * 
+ * This defines a zip archive containing a single jar file (hence no application manifest).
The jar file itself has
+ * a manifest and a text file.
+ * 
+ * To actually create the physical archive use the <code>writeOut</code> method
on the archive fixture.
+ */
+public class ArchiveFixture
+{
+  /**
+   * Create a new zip file fixture
+   * @return
+   */
+  public static ZipFixture newZip() {
+    return new ZipFixture(null);
+  }
+  
+  /**
+   * Create a new jar file fixture
+   * @return
+   */
+  public static JarFixture newJar() {
+    return new JarFixture(null);
+  }
+  
+  /**
+   * Utility to copy an InputStream into an OutputStream. Closes the InputStream afterwards.
+   * @param in
+   * @param out
+   * @throws IOException
+   */
+  private static void copy(InputStream in, OutputStream out) throws IOException
+  {
+    try {
+      int len;
+      byte[] b = new byte[1024];
+      while ((len = in.read(b)) != -1)
+        out.write(b,0,len);
+    }
+    finally {
+      in.close();
+    }
+  }
+
+  /**
+   * Base interface for every fixture.
+   */
+  public interface Fixture {
+    /**
+     * Write the physical representation of the fixture to the given OutputStream
+     * @param out
+     * @throws IOException
+     */
+    void writeOut(OutputStream out) throws IOException;
+  }
+  
+  /**
+   * Abstract base class for fixtures. Archive fixtures are by nature hierarchical.
+   */
+  public static abstract class AbstractFixture implements Fixture {
+    private ZipFixture parent;
+    
+    protected AbstractFixture(ZipFixture parent) {
+      this.parent = parent;
+    }
+    
+    /**
+     * Ends the current flow target and returns the parent flow target. For example, in the
+     * following code snippet the <code>end</code> after <code>.version("2.0.0")</code>
marks
+     * the end of the manifest. Commands after that relate to the parent jar file of the
manifest.
+     * 
+     * <code>
+     * ArchiveFixtures.ZipFixture zip = ArchiveFixtures.newZip()
+     *   .jar("test.jar")
+     *     .manifest()
+     *       .symbolicName("com.ibm.test")
+     *       .version("2.0.0")
+     *     .end()
+     *     .file("random.txt", "Some text")
+     *   .end();
+     * </code>
+     * @return
+     */
+    public ZipFixture end() {
+      return parent;
+    }
+  }
+
+  /**
+   * Simple fixture for text files.
+   */
+  public static class FileFixture extends AbstractFixture {
+    private StringBuffer text = new StringBuffer();
+    
+    protected FileFixture(ZipFixture parent) {
+      super(parent);
+    }
+    
+    /**
+     * Add a line to the file fixture. The EOL character is added automatically.
+     * @param line
+     * @return
+     */
+    public FileFixture line(String line) {
+      text.append(line);
+      text.append("\n");
+      return this;
+    }
+    
+    public void writeOut(OutputStream out) throws IOException {
+      out.write(text.toString().getBytes());
+    }
+  }
+  
+  public static class IStreamFixture extends AbstractFixture {
+    private byte[] bytes;
+    
+    protected IStreamFixture(ZipFixture parent, InputStream input) throws IOException {
+      super(parent);
+
+      ByteArrayOutputStream output = new ByteArrayOutputStream();
+      try {
+        copy(input, output);
+      } finally {
+        output.close();
+      }
+      
+      bytes = output.toByteArray();
+    }
+
+    public void writeOut(OutputStream out) throws IOException {
+      copy(new ByteArrayInputStream(bytes), out);
+    }
+  }
+  
+  /**
+   * Fixture for (bundle) manifests. By default, they contain the lines
+   * 
+   * <code>
+   * Manifest-Version: 1
+   * Bundle-ManifestVersion: 2
+   * </code>
+   */
+  public static class ManifestFixture extends AbstractFixture {
+    private Manifest mf;
+    
+    protected Manifest getManifest()
+    {
+      return mf;
+    }
+    
+    protected ManifestFixture(ZipFixture parent) {
+      super(parent);
+      mf = new Manifest();
+      mf.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1");
+      mf.getMainAttributes().putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
+    }
+    
+    /**
+     * Set the symbolic name of the bundle
+     * @param name
+     * @return
+     */
+    public ManifestFixture symbolicName(String name)
+    {
+      mf.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, name);
+      return this;
+    }
+    
+    /**
+     * Set the version of the bundle
+     * @param version
+     * @return
+     */
+    public ManifestFixture version(String version)
+    {
+      mf.getMainAttributes().putValue(Constants.BUNDLE_VERSION, version);
+      return this;
+    }
+    
+    /**
+     * Add a custom attribute to the manifest. Use the more specific methods for symbolic
name and version.
+     * @param name
+     * @param value
+     * @return
+     */
+    public ManifestFixture attribute(String name, String value)
+    {
+      mf.getMainAttributes().putValue(name, value);
+      return this;
+    }
+    
+    public void writeOut(OutputStream out) throws IOException
+    {
+      mf.write(out);
+    }
+  }
+
+  /**
+   * Fixture for a jar archive. It offers the same functionality as zip fixtures.
+   * The main difference is that in a jar archive the manifest will be output as the first
file,
+   * regardless of when it is added.
+   */
+  public static class JarFixture extends ZipFixture {
+    private ManifestFixture mfFixture;
+    
+    protected JarFixture(ZipFixture parent) {
+      super(parent);
+    }
+    
+    @Override
+    public ManifestFixture manifest()
+    {
+      if (mfFixture != null)
+        throw new IllegalStateException("Only one manifest allowed, you dummy ;)");
+      
+      mfFixture = new ManifestFixture(this);
+      return mfFixture;
+    }
+    
+    @Override
+    public void writeOut(OutputStream out) throws IOException
+    {
+      if (bytes == null) {
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        JarOutputStream jout;
+        if (mfFixture != null)
+          jout = new JarOutputStream(bout, mfFixture.getManifest());
+        else
+          jout = new JarOutputStream(bout);
+        
+        try {
+          writeAllEntries(jout);
+        } finally {
+          jout.close();
+        }
+        
+        bytes = bout.toByteArray();
+      }
+      
+      ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
+      copy(bin, out);
+    }
+  }
+  
+  /**
+   * Base fixture for any kind of zip archive. Zip archives can contain any number of child
archives 
+   * given by an archive type and a path. The order in which these child archives are added
is important
+   * because it will be the order in which they are added to the zip.
+   */
+  public static class ZipFixture extends AbstractFixture {
+    protected static class ChildFixture {
+      public String path;
+      public Fixture fixture;
+      
+      public ChildFixture(String path, Fixture fixture)
+      {
+        this.path = path;
+        this.fixture = fixture;
+      }
+    }
+    
+    protected List<ChildFixture> children = new ArrayList<ChildFixture>();
+    protected byte[] bytes = null;
+    
+    protected ZipFixture(ZipFixture parent) {
+      super(parent);
+    }
+        
+    /**
+     * Create a child zip fixture at the given target.
+     * @param path
+     * @return
+     */
+    public ZipFixture zip(String path) {
+      ZipFixture res = new ZipFixture(this);
+      children.add(new ChildFixture(path, res));
+      
+      return res;
+    }
+    
+    /**
+     * Create a child jar fixture at the given path.
+     * @param path
+     * @return
+     */
+    public ZipFixture jar(String path) {
+      JarFixture res = new JarFixture(this);
+      children.add(new ChildFixture(path, res));
+      
+      return res;
+    }
+    
+    /**
+     * Create a complete child file fixture at the given path and with the content.
+     * Note: this will return the current zip fixture and not the file fixture.
+     * 
+     * @param path
+     * @param content
+     * @return
+     */
+    public ZipFixture file(String path, String content) 
+    {
+      return file(path).line(content).end();
+    }
+    
+    /**
+     * Create an empty file fixture at the given path.
+     * 
+     * @param path
+     * @return
+     */
+    public FileFixture file(String path)
+    {
+      FileFixture res = new FileFixture(this);
+      children.add(new ChildFixture(path, res));
+      
+      return res;
+    }
+    
+    /**
+     * Create a binary file with the content from the input stream
+     * @param path
+     * @param input
+     * @return
+     */
+    public ZipFixture binary(String path, InputStream input) throws IOException {
+      IStreamFixture child = new IStreamFixture(this, input);
+      children.add(new ChildFixture(path, child));
+      
+      return this;
+    }
+    
+    /**
+     * Create a binary file that is populated from content on the classloader
+     * @param path
+     * @param resourcePath Path that the resource can be found in the current classloader
+     * @return
+     */
+    public ZipFixture binary(String path, String resourcePath) throws IOException {
+      return binary(path, getClass().getClassLoader().getResourceAsStream(resourcePath));
+    }
+    
+    /**
+     * Create a manifest fixture at the given path.
+     * @return
+     */
+    public ManifestFixture manifest()
+    {
+      ManifestFixture res = new ManifestFixture(this);
+      children.add(new ChildFixture("META-INF/MANIFEST.MF", res));
+      
+      return res;
+    }
+    
+    /**
+     * Ensure that the necessary directory entries for the entry are available
+     * in the zip file. Newly created entries are added to the set of directories.
+     * 
+     * @param zout
+     * @param entry
+     * @param existingDirs
+     * @throws IOException
+     */
+    private void mkDirs(ZipOutputStream zout, String entry, Set<String> existingDirs)
throws IOException
+    {
+      String[] parts = entry.split("/");
+      String dirName = "";
+      for (int i=0;i<parts.length-1;i++) {
+        dirName += parts[i] + "/";
+        if (!!!existingDirs.contains(dirName)) {
+          ZipEntry ze = new ZipEntry(dirName);
+          zout.putNextEntry(ze);
+          zout.closeEntry();
+          
+          existingDirs.add(dirName);
+        }
+      }
+    }
+    
+    /**
+     * Add all entries to the ZipOutputStream
+     * @param zout
+     * @throws IOException
+     */
+    protected void writeAllEntries(ZipOutputStream zout) throws IOException
+    {
+      Set<String> dirs = new HashSet<String>();
+      
+      for (ChildFixture child : children) {
+        mkDirs(zout, child.path, dirs);
+        
+        ZipEntry ze = new ZipEntry(child.path);
+        zout.putNextEntry(ze);
+        child.fixture.writeOut(zout);
+        zout.closeEntry();
+      }      
+    }
+    
+    public void writeOut(OutputStream out) throws IOException 
+    {
+      /*
+       * For better reuse this method delegate the writing to writeAllEntries, which
+       * can be reused by the JarFixture.
+       */
+      if (bytes == null) {
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        ZipOutputStream zout = new ZipOutputStream(bout);
+        try {
+          writeAllEntries(zout);
+        } finally {
+          zout.close();
+        }
+        
+        bytes = bout.toByteArray();
+      }
+
+      ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
+      copy(bin, out);
+    }
+  }
+
+}

Modified: incubator/aries/trunk/web/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/web/pom.xml?rev=900127&r1=900126&r2=900127&view=diff
==============================================================================
--- incubator/aries/trunk/web/pom.xml (original)
+++ incubator/aries/trunk/web/pom.xml Sun Jan 17 12:40:17 2010
@@ -33,6 +33,7 @@
 
     <modules>
         <module>web-urlhandler</module>
+        <module>web-itests</module>
     </modules>
 
     <dependencyManagement>

Propchange: incubator/aries/trunk/web/web-itests/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Jan 17 12:40:17 2010
@@ -0,0 +1 @@
+target

Added: incubator/aries/trunk/web/web-itests/.classpath
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/web/web-itests/.classpath?rev=900127&view=auto
==============================================================================
--- incubator/aries/trunk/web/web-itests/.classpath (added)
+++ incubator/aries/trunk/web/web-itests/.classpath Sun Jan 17 12:40:17 2010
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: incubator/aries/trunk/web/web-itests/.project
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/web/web-itests/.project?rev=900127&view=auto
==============================================================================
--- incubator/aries/trunk/web/web-itests/.project (added)
+++ incubator/aries/trunk/web/web-itests/.project Sun Jan 17 12:40:17 2010
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>web-itests</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: incubator/aries/trunk/web/web-itests/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/web/web-itests/.settings/org.eclipse.jdt.core.prefs?rev=900127&view=auto
==============================================================================
--- incubator/aries/trunk/web/web-itests/.settings/org.eclipse.jdt.core.prefs (added)
+++ incubator/aries/trunk/web/web-itests/.settings/org.eclipse.jdt.core.prefs Sun Jan 17 12:40:17
2010
@@ -0,0 +1,5 @@
+#Sun Jan 17 12:26:12 GMT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5

Added: incubator/aries/trunk/web/web-itests/.settings/org.maven.ide.eclipse.prefs
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/web/web-itests/.settings/org.maven.ide.eclipse.prefs?rev=900127&view=auto
==============================================================================
--- incubator/aries/trunk/web/web-itests/.settings/org.maven.ide.eclipse.prefs (added)
+++ incubator/aries/trunk/web/web-itests/.settings/org.maven.ide.eclipse.prefs Sun Jan 17
12:40:17 2010
@@ -0,0 +1,9 @@
+#Sun Jan 17 12:26:12 GMT 2010
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1

Added: incubator/aries/trunk/web/web-itests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/web/web-itests/pom.xml?rev=900127&view=auto
==============================================================================
--- incubator/aries/trunk/web/web-itests/pom.xml (added)
+++ incubator/aries/trunk/web/web-itests/pom.xml Sun Jan 17 12:40:17 2010
@@ -0,0 +1,172 @@
+  <!--
+    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.
+  -->
+<project>
+  <parent>
+    <artifactId>web</artifactId>
+    <groupId>org.apache.aries.web</groupId>
+    <version>1.0.0-incubating-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>org.apache.aries.web.itests</artifactId>
+  <packaging>jar</packaging>
+  <name>Apache Aries Web integration tests</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>asm</groupId>
+      <artifactId>asm-all</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.aries.testsupport</groupId>
+      <artifactId>org.apache.aries.testsupport.unit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <version>4.2.0</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.aries.blueprint</groupId>
+      <artifactId>org.apache.aries.blueprint.sample</artifactId>
+      <version>${version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.configadmin</artifactId>
+      <version>1.2.4</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.aries</groupId>
+      <artifactId>org.apache.aries.util</artifactId>
+      <version>${version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.aries.blueprint</groupId>
+      <artifactId>org.apache.aries.blueprint</artifactId>
+      <version>${version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.logging</groupId>
+      <artifactId>pax-logging-api</artifactId>
+      <version>1.4</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.logging</groupId>
+      <artifactId>pax-logging-service</artifactId>
+      <version>1.4</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam</artifactId>
+      <version>1.1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-junit</artifactId>
+      <version>1.1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-container-default</artifactId>
+      <version>1.1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.swissbox</groupId>
+      <artifactId>pax-swissbox-tinybundles</artifactId>
+      <version>1.2.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.url</groupId>
+      <artifactId>pax-url-mvn</artifactId>
+      <version>1.0.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.aries.web</groupId>
+      <artifactId>org.apache.aries.web.urlhandler</artifactId>
+      <version>${version}</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.servicemix.tooling</groupId>
+        <artifactId>depends-maven-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+            <id>generate-depends-file</id>
+            <goals>
+              <goal>generate-depends-file</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>ci-build-profile</id>
+      <activation>
+        <property>
+          <name>maven.repo.local</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <!--
+                when the local repo location has been specified, we need
+                to pass on this information to PAX mvn url
+              -->
+              <argLine>-Dorg.ops4j.pax.url.mvn.localRepository=${maven.repo.local}
+              </argLine>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>

Added: incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/converter/itest/WabConverterITest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/converter/itest/WabConverterITest.java?rev=900127&view=auto
==============================================================================
--- incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/converter/itest/WabConverterITest.java
(added)
+++ incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/converter/itest/WabConverterITest.java
Sun Jan 17 12:40:17 2010
@@ -0,0 +1,209 @@
+/**
+ *  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.aries.web.converter.itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
+import static org.ops4j.pax.exam.OptionUtils.combine;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Dictionary;
+
+import org.apache.aries.unittest.fixture.ArchiveFixture;
+import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
+import org.junit.After;
+import org.junit.Before;
+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.JUnit4TestRunner;
+import org.ops4j.pax.exam.options.BootDelegationOption;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.Version;
+import org.osgi.util.tracker.ServiceTracker;
+
+@RunWith(JUnit4TestRunner.class)
+public class WabConverterITest {
+  public static final long DEFAULT_TIMEOUT = 30000;
+
+  @Inject
+  protected BundleContext bundleContext;
+
+  @Before
+  public void setUp() throws Exception {
+    ZipFixture testWar = ArchiveFixture.newJar()
+      .binary("WEB-INF/classes/org/apache/aries/web/test/TestClass.class", 
+        getClass().getClassLoader().getResourceAsStream("org/apache/aries/web/test/TestClass.class"));
+    
+    FileOutputStream fout = new FileOutputStream("test.war");
+    testWar.writeOut(fout);
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    new File("test.war").delete();
+  }
+
+  
+  @Test
+  public void getStarted() throws Exception {    
+    Bundle warConverter = getBundle("org.apache.aries.web.urlhandler");
+    assertEquals(Bundle.ACTIVE, warConverter.getState());
+    
+    File testWar = new File("test.war");
+    Bundle converted = bundleContext.installBundle("webbundle:"+testWar.toURL().toExternalForm()

+        + "?Bundle-SymbolicName=test.war.bundle");
+    
+    assertNotNull(converted);
+    Dictionary<String,String> man = converted.getHeaders();
+    
+    assertEquals("test.war.bundle", man.get(Constants.BUNDLE_SYMBOLICNAME));   
+    assertTrue(man.get(Constants.IMPORT_PACKAGE).contains("javax.naming"));
+  }
+
+  @org.ops4j.pax.exam.junit.Configuration
+  public static Option[] configuration() {
+    Option[] options = options(
+        bootDelegation(),
+        
+        // Log
+        mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+        mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+        // Felix Config Admin
+        mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+        // Felix mvn url handler
+        mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+        // this is how you set the default log level when using pax
+        // logging (logProfile)
+        systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+        // Bundles
+        mavenBundle("org.apache.aries.web","org.apache.aries.web.urlhandler"),
+        mavenBundle("org.apache.aries", "org.apache.aries.util"),
+        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"), 
+        mavenBundle("org.osgi", "org.osgi.compendium"),
+        mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
+        mavenBundle("asm","asm-all"),
+
+        equinox().version("3.5.0"));
+    options = updateOptions(options);
+    return options;
+  }
+  
+  
+  protected Bundle getBundle(String symbolicName) {
+    return getBundle(symbolicName, null);
+  }
+
+  protected Bundle getBundle(String bundleSymbolicName, String version) {
+    Bundle result = null;
+    for (Bundle b : bundleContext.getBundles()) {
+      if (b.getSymbolicName().equals(bundleSymbolicName)) {
+        if (version == null
+            || b.getVersion().equals(Version.parseVersion(version))) {
+          result = b;
+          break;
+        }
+      }
+    }
+    return result;
+  }
+
+  public static BootDelegationOption bootDelegation() {
+    return new BootDelegationOption("org.apache.aries.unittest.fixture");
+  }
+  
+  public static MavenArtifactProvisionOption mavenBundle(String groupId,
+      String artifactId) {
+    return CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId)
+        .versionAsInProject();
+  }
+
+  protected static Option[] updateOptions(Option[] options) {
+    // We need to add pax-exam-junit here when running with the ibm
+    // jdk to avoid the following exception during the test run:
+    // ClassNotFoundException: org.ops4j.pax.exam.junit.Configuration
+    if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
+      Option[] ibmOptions = options(wrappedBundle(mavenBundle(
+          "org.ops4j.pax.exam", "pax-exam-junit")));
+      options = combine(ibmOptions, options);
+    }
+
+    return options;
+  }
+
+  protected <T> T getOsgiService(Class<T> type, long timeout) {
+    return getOsgiService(type, null, timeout);
+  }
+
+  protected <T> T getOsgiService(Class<T> type) {
+    return getOsgiService(type, null, DEFAULT_TIMEOUT);
+  }
+  
+  protected <T> T getOsgiService(Class<T> type, String filter, long timeout)
{
+    return getOsgiService(null, type, filter, timeout);
+  }
+
+  protected <T> T getOsgiService(BundleContext bc, Class<T> type,
+      String filter, long timeout) {
+    ServiceTracker tracker = null;
+    try {
+      String flt;
+      if (filter != null) {
+        if (filter.startsWith("(")) {
+          flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")"
+              + filter + ")";
+        } else {
+          flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")("
+              + filter + "))";
+        }
+      } else {
+        flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
+      }
+      Filter osgiFilter = FrameworkUtil.createFilter(flt);
+      tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter,
+          null);
+      tracker.open();
+      // Note that the tracker is not closed to keep the reference
+      // This is buggy, has the service reference may change i think
+      Object svc = type.cast(tracker.waitForService(timeout));
+      if (svc == null) {
+        throw new RuntimeException("Gave up waiting for service " + flt);
+      }
+      return type.cast(svc);
+    } catch (InvalidSyntaxException e) {
+      throw new IllegalArgumentException("Invalid filter", e);
+    } catch (InterruptedException e) {
+      throw new RuntimeException(e);
+    }
+  }
+}

Added: incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/test/TestClass.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/test/TestClass.java?rev=900127&view=auto
==============================================================================
--- incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/test/TestClass.java
(added)
+++ incubator/aries/trunk/web/web-itests/src/test/java/org/apache/aries/web/test/TestClass.java
Sun Jan 17 12:40:17 2010
@@ -0,0 +1,28 @@
+/**
+ *  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.aries.web.test;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class TestClass {
+  private InitialContext ctx;
+  
+  public TestClass() throws NamingException {
+    ctx = new InitialContext();
+  }
+}



Mime
View raw message