aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tjwat...@apache.org
Subject svn commit: r1606837 [27/27] - in /aries/branches/subsystemsR6: ./ application/ application/application-api/ application/application-bundle/ application/application-converters/ application/application-default-local-platform/ application/application-dep...
Date Mon, 30 Jun 2014 16:55:06 GMT
Modified: aries/branches/subsystemsR6/web/web-itests/src/test/java/org/apache/aries/web/converter/itest/WabConverterITest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/web/web-itests/src/test/java/org/apache/aries/web/converter/itest/WabConverterITest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/web/web-itests/src/test/java/org/apache/aries/web/converter/itest/WabConverterITest.java
(original)
+++ aries/branches/subsystemsR6/web/web-itests/src/test/java/org/apache/aries/web/converter/itest/WabConverterITest.java
Mon Jun 30 16:54:57 2014
@@ -19,228 +19,123 @@ package org.apache.aries.web.converter.i
 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.composite;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 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 static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.Dictionary;
-import java.util.List;
 
+import javax.inject.Inject;
+
+import org.apache.aries.itest.AbstractIntegrationTest;
 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.Configuration;
 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.junit.PaxExam;
 import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
 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.service.url.URLStreamHandlerService;
-import org.osgi.util.tracker.ServiceTracker;
-
-@RunWith(JUnit4TestRunner.class)
-public class WabConverterITest {
-  public static final long DEFAULT_TIMEOUT = 60000;
-
-  @Inject
-  protected BundleContext bundleContext;
-  
-  private List<ServiceTracker> srs;
-
-  @Before
-  public void setUp() throws Exception {
-    srs = new ArrayList<ServiceTracker>();
-    
-    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);
-    fout.close();
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    new File("test.war").delete();
-    for (ServiceTracker st : srs) {
-        if (st != null) {
-            st.close();
-        }  
-    }
-  }
-
-  @Test
-  public void getStarted() throws Exception {
-    
-    File testWar = new File("test.war");
-    String baseUrl = "webbundle:" + testWar.toURI().toURL().toExternalForm() ;
-
-    assertTrue("Time out waiting for webbundle URL handler", waitForURLHandler(baseUrl));
-    
-    Bundle converted = bundleContext.installBundle(baseUrl + "?Bundle-SymbolicName=test.war.bundle&Web-ContextPath=foo");
-    
-    assertNotNull(converted);
-    Dictionary<String,String> man = converted.getHeaders();
-    
-    assertEquals("test.war.bundle", man.get(Constants.BUNDLE_SYMBOLICNAME)); 
-    assertEquals("/foo", man.get("Web-ContextPath"));
-    assertTrue(man.get(Constants.IMPORT_PACKAGE).contains("javax.naming"));
-  }
-
-  private boolean waitForURLHandler(String url) {
-      int maxRepetition = 100;
-      for (int i = 0; i < maxRepetition; i++) {
-          try {
-              new URL(url);
-              return true;
-          } catch (MalformedURLException e) {
-              try {
-                  Thread.sleep(100);
-              } catch (InterruptedException ee) {
-                  return false;
-              }
-          }
-      }
-      return false;
-  }
-
-  @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.ow2.asm", "asm-all"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
-        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"),
-       
-
-        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();
-      
-      // add tracker to the list of trackers we close at tear down
-      srs.add(tracker);
-      
-      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);
-    }
-  }
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class WabConverterITest extends AbstractIntegrationTest {
+	@Inject
+	protected BundleContext bundleContext;
+
+	private void createTestWar(File warFile) throws IOException {
+		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(warFile);
+		testWar.writeOut(fout);
+		fout.close();
+	}
+
+	@Test
+	public void getStarted() throws Exception {
+		File testWar = File.createTempFile("test", ".war");
+		createTestWar(testWar);
+		String baseUrl = "webbundle:"
+				+ testWar.toURI().toURL().toExternalForm();
+		assertTrue("Time out waiting for webbundle URL handler",
+				waitForURLHandler(baseUrl));
+
+		Bundle converted = bundleContext.installBundle(baseUrl
+				+ "?Bundle-SymbolicName=test.war.bundle&Web-ContextPath=foo");
+
+		assertNotNull(converted);
+		Dictionary<String, String> man = converted.getHeaders();
+
+		assertEquals("test.war.bundle", man.get(Constants.BUNDLE_SYMBOLICNAME));
+		assertEquals("/foo", man.get("Web-ContextPath"));
+		assertTrue(man.get(Constants.IMPORT_PACKAGE).contains("javax.naming"));
+		new File("test.war").delete();
+	}
+
+	private boolean waitForURLHandler(String url) {
+		int maxRepetition = 100;
+		for (int i = 0; i < maxRepetition; i++) {
+			try {
+				new URL(url);
+				return true;
+			} catch (MalformedURLException e) {
+				try {
+					Thread.sleep(100);
+				} catch (InterruptedException ee) {
+					return false;
+				}
+			}
+		}
+		return false;
+	}
+
+	public Option baseOptions() {
+		String localRepo = getLocalRepo();
+		return composite(
+				junitBundles(),
+				systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+				when(localRepo != null).useOptions(
+						vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)));
+	}
+
+	@Configuration
+	public Option[] configuration() {
+		return options(
+				// bootDelegation(),
+				baseOptions(),
+				mavenBundle("org.osgi", "org.osgi.compendium"),
+				mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+
+				// Bundles
+				mavenBundle("org.apache.aries.web", "org.apache.aries.web.urlhandler"),
+				mavenBundle("org.apache.aries", "org.apache.aries.util"),
+				mavenBundle("org.ow2.asm", "asm-debug-all"),
+				mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+				mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+				mavenBundle("org.apache.aries.testsupport",	"org.apache.aries.testsupport.unit"));
+	}
+
+	private MavenArtifactProvisionOption mavenBundle(String groupId,
+			String artifactId) {
+		return CoreOptions.mavenBundle().groupId(groupId)
+				.artifactId(artifactId).versionAsInProject();
+	}
+
 }

Modified: aries/branches/subsystemsR6/web/web-urlhandler/pom.xml
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/web/web-urlhandler/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/web/web-urlhandler/pom.xml (original)
+++ aries/branches/subsystemsR6/web/web-urlhandler/pom.xml Mon Jun 30 16:54:57 2014
@@ -1,3 +1,4 @@
+<?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
@@ -17,13 +18,15 @@
  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>
         <groupId>org.apache.aries</groupId>
-        <artifactId>java5-parent</artifactId>
-        <version>1.0.0</version>
-        <relativePath />
+        <artifactId>parent</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
     </parent>
-    <modelVersion>4.0.0</modelVersion>
 
     <groupId>org.apache.aries.web</groupId>
     <artifactId>org.apache.aries.web.urlhandler</artifactId>
@@ -31,23 +34,23 @@
     <version>1.0.1-SNAPSHOT</version>
     <name>Apache Aries Web Url handler</name>
 
-     <scm>
-         <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/web/web-urlhandler</connection>
-         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/web/web-urlhandler</developerConnection>
-         <url>http://svn.apache.org/viewvc/aries/trunk/web/web-urlhandler</url>
-     </scm>
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/web/web-urlhandler</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/web/web-urlhandler</developerConnection>
+        <url>http://svn.apache.org/viewvc/aries/trunk/web/web-urlhandler</url>
+    </scm>
 
-	<properties>
+    <properties>
         <!-- Export package versions are maintained in packageinfo files -->
-
-		<aries.osgi.export.pkg>
-			org.apache.aries.web.converter;provide:=true
-		</aries.osgi.export.pkg>
-		<aries.osgi.private.pkg>
-			org.apache.aries.web.converter.impl,
-			org.apache.aries.web.url
-		</aries.osgi.private.pkg>
-	</properties>
+        <aries.osgi.export.pkg>
+            org.apache.aries.web.converter;provide:=true
+        </aries.osgi.export.pkg>
+        <aries.osgi.private.pkg>
+            org.apache.aries.web.converter.impl,
+            org.apache.aries.web.url
+        </aries.osgi.private.pkg>
+        <lastReleaseVersion>1.0.0</lastReleaseVersion>
+    </properties>
 
     <dependencies>
         <dependency>
@@ -61,9 +64,9 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-           <groupId>org.ow2.asm</groupId>
-            <artifactId>asm-all</artifactId>
-            <version>4.0</version>
+            <groupId>org.ow2.asm</groupId>
+            <artifactId>asm-debug-all</artifactId>
+            <version>5.0.3</version>
         </dependency>
         <dependency>
             <groupId>org.apache.aries.testsupport</groupId>
@@ -72,12 +75,12 @@
             <version>1.0.0</version>
         </dependency>
     </dependencies>
+
     <build>
         <plugins>
             <plugin>
                 <groupId>org.apache.aries.versioning</groupId>
                 <artifactId>org.apache.aries.versioning.plugin</artifactId>
-                <version>0.1.0</version>
                 <executions>
                     <execution>
                         <id>default-verify</id>
@@ -85,9 +88,6 @@
                         <goals>
                             <goal>version-check</goal>
                         </goals>
-                        <configuration>
-                            <oldArtifact>org.apache.aries.web:org.apache.aries.web.urlhandler:1.0.0</oldArtifact>
-                        </configuration>
                     </execution>
                 </executions>
             </plugin>



Mime
View raw message