Author: cschneider
Date: Fri Jun 13 22:10:13 2014
New Revision: 1602532

URL: http://svn.apache.org/r1602532
Log:
ARIES-1210 - Switch twitter samples to pax exam 3

Removed:
    
aries/trunk/samples/twitter/twitter-itests/src/test/java/org/apache/aries/sample/twitter/itest/AbstractIntegrationTest.java
Modified:
    aries/trunk/samples/pom.xml
    aries/trunk/samples/twitter/pom.xml
    aries/trunk/samples/twitter/twitter-itests/pom.xml
    
aries/trunk/samples/twitter/twitter-itests/src/test/java/org/apache/aries/sample/twitter/itest/TwitterTest.java
    aries/trunk/samples/twitter/twitter-twitter4j/pom.xml

Modified: aries/trunk/samples/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/samples/pom.xml?rev=1602532&r1=1602531&r2=1602532&view=diff
==============================================================================
--- aries/trunk/samples/pom.xml (original)
+++ aries/trunk/samples/pom.xml Fri Jun 13 22:10:13 2014
@@ -160,7 +160,7 @@
         <serpVersion>1.13.1</serpVersion>
         <javaxServletVersion>1.2</javaxServletVersion>
 
-        <twitter4jVersion>2.0.8</twitter4jVersion>
+        <twitter4jVersion>2.0.10</twitter4jVersion>
 
         <aries.javadoc.exclude.packages>*</aries.javadoc.exclude.packages>
     </properties>

Modified: aries/trunk/samples/twitter/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/samples/twitter/pom.xml?rev=1602532&r1=1602531&r2=1602532&view=diff
==============================================================================
--- aries/trunk/samples/twitter/pom.xml (original)
+++ aries/trunk/samples/twitter/pom.xml Fri Jun 13 22:10:13 2014
@@ -29,6 +29,10 @@
     <artifactId>twitter</artifactId>
     <packaging>pom</packaging>
     
+    <properties>
+       <aries.skip.version.check>true</aries.skip.version.check>
+    </properties>
+    
     <dependencyManagement>
         <dependencies>
             <dependency>

Modified: aries/trunk/samples/twitter/twitter-itests/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/samples/twitter/twitter-itests/pom.xml?rev=1602532&r1=1602531&r2=1602532&view=diff
==============================================================================
--- aries/trunk/samples/twitter/twitter-itests/pom.xml (original)
+++ aries/trunk/samples/twitter/twitter-itests/pom.xml Fri Jun 13 22:10:13 2014
@@ -32,18 +32,18 @@
         Integration tests for the Twitter sample
     </description>
     
+    <properties>
+        <exam.version>3.4.0</exam.version>
+        <url.version>1.6.0</url.version>
+        <swissbox.version>1.7.0</swissbox.version>
+    </properties>
+    
     <dependencies>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
-            <scope>test</scope>
+               <dependency>
+            <groupId>org.eclipse</groupId>
+            <artifactId>org.eclipse.osgi</artifactId>
+            <version>3.8.0.v20120529-1548</version>
         </dependency>
-
-               <dependency>
-                       <groupId>org.apache.felix</groupId>
-                       <artifactId>org.apache.felix.configadmin</artifactId>
-                       <scope>test</scope>
-               </dependency>
                <dependency>
                        <groupId>org.apache.aries</groupId>
                        <artifactId>org.apache.aries.util</artifactId>
@@ -57,7 +57,6 @@
                <dependency>
                        <groupId>org.apache.aries.proxy</groupId>
                        <artifactId>org.apache.aries.proxy</artifactId>
-                       <version>1.0.0</version>
                        <scope>test</scope>
                </dependency>
                <dependency>
@@ -66,39 +65,6 @@
             <version>4.0</version>
                        <scope>test</scope>
                </dependency>
-               <dependency>
-                       <groupId>org.ops4j.pax.logging</groupId>
-                       <artifactId>pax-logging-api</artifactId>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.ops4j.pax.logging</groupId>
-                       <artifactId>pax-logging-service</artifactId>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.ops4j.pax.exam</groupId>
-                       <artifactId>pax-exam</artifactId>
-                        <version>1.2.4</version>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.ops4j.pax.exam</groupId>
-                       <artifactId>pax-exam-junit</artifactId>
-                        <version>1.2.4</version>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.ops4j.pax.exam</groupId>
-                       <artifactId>pax-exam-container-default</artifactId>
-                        <version>1.2.4</version>
-                       <scope>test</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.ops4j.pax.url</groupId>
-                       <artifactId>pax-url-mvn</artifactId>
-            <scope>test</scope>
-               </dependency>
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.bundlerepository</artifactId>
@@ -114,10 +80,10 @@
             <artifactId>org.apache.aries.application.utils</artifactId>
             <scope>test</scope>
         </dependency>
-        
         <dependency>
             <groupId>org.apache.aries.testsupport</groupId>
             <artifactId>org.apache.aries.testsupport.unit</artifactId>
+            <version>2.0.0-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
 
@@ -126,49 +92,41 @@
             
<artifactId>org.apache.aries.application.runtime.itest.interfaces</artifactId>
             <scope>test</scope>
         </dependency>
-        
         <dependency>
             <groupId>org.apache.aries.application</groupId>
             <artifactId>org.apache.aries.application.management</artifactId>
             <scope>test</scope>
         </dependency>
-        
         <dependency>
                <groupId>org.apache.aries.application</groupId>
                
<artifactId>org.apache.aries.application.runtime.framework</artifactId>
                <scope>test</scope>
         </dependency>
-        
         <dependency>
                <groupId>org.apache.aries.application</groupId>
                
<artifactId>org.apache.aries.application.runtime.framework.management</artifactId>
                <scope>test</scope>
         </dependency>
-        
         <dependency>
                <groupId>org.apache.aries.application</groupId>
                
<artifactId>org.apache.aries.application.runtime.repository</artifactId>
                <scope>test</scope>
         </dependency>
-        
         <dependency>
                <groupId>org.apache.aries.application</groupId>
                
<artifactId>org.apache.aries.application.runtime.isolated</artifactId>
                <scope>test</scope>
         </dependency>
-        
         <dependency>
                <groupId>org.apache.aries.application</groupId>
                <artifactId>org.apache.aries.application.runtime</artifactId>
                <scope>test</scope>
         </dependency>
-        
         <dependency>
             <groupId>org.apache.aries.application</groupId>
             <artifactId>org.apache.aries.application.resolver.obr</artifactId>
             <scope>test</scope>
         </dependency>
-       
         <dependency>
             <groupId>org.apache.aries.application</groupId>
             <artifactId>org.apache.aries.application.resolver.noop</artifactId>
@@ -190,12 +148,6 @@
                <scope>test</scope>
         </dependency>
         <dependency>
-               <groupId>org.eclipse</groupId>
-               <artifactId>osgi</artifactId>
-                <version>3.5.0.v20090520</version>
-               <scope>test</scope>
-        </dependency>
-        <dependency>
           <groupId>org.apache.aries.samples.twitter</groupId>
           <artifactId>org.apache.aries.samples.twitter.eba</artifactId>
           <scope>test</scope>
@@ -204,16 +156,86 @@
         <dependency>
             <groupId>org.apache.aries.samples.twitter</groupId>
             <artifactId>org.apache.aries.samples.twitter.twitter4j</artifactId>
+            <exclusions>
+               <exclusion>
+                       <artifactId>nlog4j</artifactId>
+                       <groupId>org.slf4j</groupId>
+               </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.aries.samples.twitter</groupId>
             <artifactId>org.apache.aries.samples.twitter.bundle</artifactId>
         </dependency>
+        
+        <!-- pax exam -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-native</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-aether</artifactId>
+            <version>${url.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <version>0.9.29</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>0.9.29</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.tinybundles</groupId>
+            <artifactId>tinybundles</artifactId>
+            <version>2.0.0</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>org.osgi.core</artifactId>
+                    <groupId>org.osgi</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
         <plugins>
-            <plugin>
+                       <plugin>
                 <groupId>org.apache.servicemix.tooling</groupId>
                 <artifactId>depends-maven-plugin</artifactId>
                 <version>1.2</version>
@@ -223,9 +245,6 @@
                         <goals>
                             <goal>generate-depends-file</goal>
                         </goals>
-                        <configuration>
-                            
<outputFile>${project.build.directory}/test-classes/META-INF/maven/dependencies.properties</outputFile>
-                        </configuration>
                     </execution>
                 </executions>
             </plugin>
@@ -234,14 +253,6 @@
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
                     <forkMode>pertest</forkMode>
-                    <excludes>
-                        <exclude>**/*$*</exclude>
-                        <exclude>**/Abstract*.java</exclude>
-                    </excludes>
-                    <includes>
-                        <include>**/Test*.java</include>
-                        <include>**/*Test.java</include>
-                    </includes>
                 </configuration>
             </plugin>
         </plugins>
@@ -261,6 +272,7 @@
                         <groupId>org.apache.maven.plugins</groupId>
                         <artifactId>maven-surefire-plugin</artifactId>
                         <configuration>
+                            <forkMode>pertest</forkMode>
                             <!--
                                 when the local repo location has been 
specified, we need to pass
                                 on this information to PAX mvn url

Modified: 
aries/trunk/samples/twitter/twitter-itests/src/test/java/org/apache/aries/sample/twitter/itest/TwitterTest.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/samples/twitter/twitter-itests/src/test/java/org/apache/aries/sample/twitter/itest/TwitterTest.java?rev=1602532&r1=1602531&r2=1602532&view=diff
==============================================================================
--- 
aries/trunk/samples/twitter/twitter-itests/src/test/java/org/apache/aries/sample/twitter/itest/TwitterTest.java
 (original)
+++ 
aries/trunk/samples/twitter/twitter-itests/src/test/java/org/apache/aries/sample/twitter/itest/TwitterTest.java
 Fri Jun 13 22:10:13 2014
@@ -17,151 +17,188 @@
  * under the License.
  */
 package org.apache.aries.sample.twitter.itest;
-import static junit.framework.Assert.assertEquals;
+
+import static org.junit.Assert.assertEquals;
 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.maven;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
+import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
 
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import javax.inject.Inject;
+
 import org.apache.aries.application.DeploymentContent;
 import org.apache.aries.application.DeploymentMetadata;
 import org.apache.aries.application.management.AriesApplication;
 import org.apache.aries.application.management.AriesApplicationContext;
 import org.apache.aries.application.management.AriesApplicationManager;
 import org.apache.aries.application.utils.AppConstants;
+import org.apache.aries.itest.AbstractIntegrationTest;
 import org.apache.felix.bundlerepository.Repository;
 import org.apache.felix.bundlerepository.RepositoryAdmin;
 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.Option;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-@RunWith(JUnit4TestRunner.class)
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
+
+@RunWith(PaxExam.class)
 public class TwitterTest extends AbstractIntegrationTest 
 {
-  public static final String CORE_BUNDLE_BY_VALUE = "core.bundle.by.value";
-  public static final String CORE_BUNDLE_BY_REFERENCE = 
"core.bundle.by.reference";
-  public static final String TRANSITIVE_BUNDLE_BY_VALUE = 
"transitive.bundle.by.value";
-  public static final String TRANSITIVE_BUNDLE_BY_REFERENCE = 
"transitive.bundle.by.reference";
-  public static final String USE_BUNDLE_BY_REFERENCE = 
"use.bundle.by.reference";
-  public static final String REPO_BUNDLE = "aries.bundle1";
-  public static final String 
HELLO_WORLD_CLIENT_BUNDLE="hello.world.client.bundle";
-  public static final String 
HELLO_WORLD_SERVICE_BUNDLE1="hello.world.service.bundle1";
-  public static final String 
HELLO_WORLD_SERVICE_BUNDLE2="hello.world.service.bundle2";
-  
-  //Test for JIRA-461 which currently fails.
-  @Test
-  public void testTwitter() throws Exception
-  {
-    // provision against the local runtime
-    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, 
"false");
-    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
-    Repository[] repos = repositoryAdmin.listRepositories();
-    for (Repository repo : repos) {
-      repositoryAdmin.removeRepository(repo.getURI());
-    }
-
-    
-    // Use the superclasses' getUrlToEba() method instead of the pax-exam 
mavenBundle() method because pax-exam is running in a
-    // diffference bundle which doesn't have visibility to the 
META-INF/maven/dependencies.properties file used to figure out the
-    // version of the maven artifact.
-    URL twitterEbaUrl = getUrlToEba("org.apache.aries.samples.twitter",
-        "org.apache.aries.samples.twitter.eba");
-    URL twitterCommonLangJar_url = getUrlToBundle("commons-lang", 
"commons-lang");
-    URL twitterJar_url = getUrlToBundle("org.apache.aries.samples.twitter", 
"org.apache.aries.samples.twitter.twitter4j");
-   
-    // add the repository xml to the repository admin
-    StringBuilder repositoryXML = new StringBuilder();
-    BufferedReader reader = new BufferedReader(new 
InputStreamReader(this.getClass().getResourceAsStream("/obr/twitter/TwitterRepository.xml")));
-    String line;
-    while ((line = reader.readLine()) != null) {
-      repositoryXML.append(line);
-      repositoryXML.append("\r\n");
-    }
-  //replace the jar file url with the real url related to the environment
-    String repo = repositoryXML.toString().replaceAll("commons.lang.location", 
twitterCommonLangJar_url.toExternalForm());
-    repo = repo.replaceAll("twitter4j.location", 
twitterJar_url.toExternalForm());
-    
-    FileWriter writer = new FileWriter("twitterRepo.xml");
-    writer.write(repo);
-    writer.close();
-    repositoryAdmin.addRepository(new File("twitterRepo.xml").toURI().toURL());
-    AriesApplicationManager manager = 
getOsgiService(AriesApplicationManager.class);
-    AriesApplication app = manager.createApplication(twitterEbaUrl);
-    app = manager.resolve(app);
-    DeploymentMetadata depMeta = app.getDeploymentMetadata();
-    List<DeploymentContent> provision = 
depMeta.getApplicationProvisionBundles();
-    Collection<DeploymentContent> useBundles = depMeta.getDeployedUseBundle();
-    Collection<DeploymentContent> appContent = 
depMeta.getApplicationDeploymentContents();
-    // We cannot be sure whether there are two or three provision bundles 
pulled in by Felix OBR as there is an outstanding defect
-    // https://issues.apache.org/jira/browse/FELIX-2672
-    // The workaround is to check we get the two bundles we are looking for, 
instead of insisting on just having two bundles.
-    
-    List<String> provisionBundleSymbolicNames = new ArrayList<String>();
-    for (DeploymentContent dep : provision) {
-       provisionBundleSymbolicNames.add(dep.getContentName());
-    }
-    String provision_bundle1 = "org.apache.commons.lang";
-    String provision_bundle2 = "twitter4j";
-    assertTrue("Bundle " + provision_bundle1 + " not found.", 
provisionBundleSymbolicNames.contains(provision_bundle1));
-    assertTrue("Bundle " + provision_bundle2 + " not found.", 
provisionBundleSymbolicNames.contains(provision_bundle2));
-    assertEquals(useBundles.toString(), 0, useBundles.size());
-    assertEquals(appContent.toString(), 1, appContent.size());
-    AriesApplicationContext ctx = manager.install(app);
-    ctx.start();
-  }
-  
-  @org.ops4j.pax.exam.junit.Configuration
-  public static Option[] configuration() {
-    Option[] options = testOptions(
-        // 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.application", 
"org.apache.aries.application.api"),
-        mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.utils"),
-        mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.management"),
-        mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.default.local.platform"),
-        mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.runtime"),
-        mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.resolver.obr"),
-        mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.deployment.management"),
-        mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.modeller"),
-        mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
-        mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.runtime.itest.interfaces"),
-        mavenBundle("org.apache.aries", "org.apache.aries.util"),
-        mavenBundle("org.apache.aries.blueprint", 
"org.apache.aries.blueprint"),
-        mavenBundle("org.ow2.asm", "asm-all"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
-        mavenBundle("org.osgi", "org.osgi.compendium"),
-        mavenBundle("org.apache.aries.testsupport", 
"org.apache.aries.testsupport.unit"),
-        /* For debugging, uncomment the next two lines  */
-        /*vmOption 
("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5010"),
-        waitForFrameworkStartup(),  */
-//        vmOption 
("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5010"),
-        /* For debugging, add these imports:
-        import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
-        import static 
org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
-        */
-
-        equinox().version("3.5.0"));
-    return options;
-  }
+       public static final String CORE_BUNDLE_BY_VALUE = 
"core.bundle.by.value";
+       public static final String CORE_BUNDLE_BY_REFERENCE = 
"core.bundle.by.reference";
+       public static final String TRANSITIVE_BUNDLE_BY_VALUE = 
"transitive.bundle.by.value";
+       public static final String TRANSITIVE_BUNDLE_BY_REFERENCE = 
"transitive.bundle.by.reference";
+       public static final String USE_BUNDLE_BY_REFERENCE = 
"use.bundle.by.reference";
+       public static final String REPO_BUNDLE = "aries.bundle1";
+       public static final String 
HELLO_WORLD_CLIENT_BUNDLE="hello.world.client.bundle";
+       public static final String 
HELLO_WORLD_SERVICE_BUNDLE1="hello.world.service.bundle1";
+       public static final String 
HELLO_WORLD_SERVICE_BUNDLE2="hello.world.service.bundle2";
+
+       @Inject
+       RepositoryAdmin repositoryAdmin;
+
+       @Inject
+       AriesApplicationManager manager;
+
+       /**
+        * Test for ARIES-461
+        * Application that bring in dependency bundles from a bundle 
repository doesn't deploy
+        * 
+        * @throws Exception
+        */
+       @Test
+       public void testTwitter() throws Exception
+       {
+               // provision against the local runtime
+               
System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
+
+               deleteRepos();
+
+               MavenArtifactUrlReference twitterEbaUrl = 
maven("org.apache.aries.samples.twitter", 
"org.apache.aries.samples.twitter.eba").versionAsInProject().type("eba");
+               MavenArtifactUrlReference twitterCommonLangJar = 
maven("commons-lang", "commons-lang").versionAsInProject();
+               MavenArtifactUrlReference twitterJar = 
maven("org.apache.aries.samples.twitter", 
"org.apache.aries.samples.twitter.twitter4j").versionAsInProject();
+
+               // add the repository xml to the repository admin
+               String repositoryXML = 
getRepoContent("/obr/twitter/TwitterRepository.xml");
+               // replace the jar file url with the real url related to the 
environment
+               String repo = repositoryXML
+                               .replaceAll("commons.lang.location", 
twitterCommonLangJar.getURL())
+                               .replaceAll("twitter4j.location", 
twitterJar.getURL());
+
+               URL url = getRepoUrl(repo);
+               repositoryAdmin.addRepository(url);
+
+               AriesApplication app = manager.createApplication(new 
URL(twitterEbaUrl.getURL()));
+               app = manager.resolve(app);
+               DeploymentMetadata depMeta = app.getDeploymentMetadata();
+               List<DeploymentContent> provision = 
depMeta.getApplicationProvisionBundles();
+               Collection<DeploymentContent> useBundles = 
depMeta.getDeployedUseBundle();
+               Collection<DeploymentContent> appContent = 
depMeta.getApplicationDeploymentContents();
+               // We cannot be sure whether there are two or three provision 
bundles pulled in by Felix OBR as there is an outstanding defect
+               // https://issues.apache.org/jira/browse/FELIX-2672
+               // The workaround is to check we get the two bundles we are 
looking for, instead of insisting on just having two bundles.
+
+               List<String> provisionBundleSymbolicNames = new 
ArrayList<String>();
+               for (DeploymentContent dep : provision) {
+                       provisionBundleSymbolicNames.add(dep.getContentName());
+               }
+               String provision_bundle1 = "org.apache.commons.lang";
+               String provision_bundle2 = "twitter4j";
+               assertTrue("Bundle " + provision_bundle1 + " not found.", 
provisionBundleSymbolicNames.contains(provision_bundle1));
+               assertTrue("Bundle " + provision_bundle2 + " not found.", 
provisionBundleSymbolicNames.contains(provision_bundle2));
+               assertEquals(useBundles.toString(), 0, useBundles.size());
+               assertEquals(appContent.toString(), 1, appContent.size());
+               AriesApplicationContext ctx = manager.install(app);
+               ctx.start();
+       }
+
+       private URL getRepoUrl(String repo) throws IOException,
+                       MalformedURLException {
+               File repoFile = File.createTempFile("twitterRepo", "xml");
+               FileWriter writer = new FileWriter(repoFile);
+               writer.write(repo);
+               writer.close();
+               return repoFile.toURI().toURL();
+       }
+
+       private void deleteRepos() {
+               Repository[] repos = repositoryAdmin.listRepositories();
+               for (Repository repo : repos) {
+                       repositoryAdmin.removeRepository(repo.getURI());
+               }
+       }
+
+       private String getRepoContent(String path) throws IOException {
+               StringBuilder repositoryXML = new StringBuilder();
+               InputStream resourceAsStream = 
this.getClass().getResourceAsStream(path);
+               BufferedReader reader = new BufferedReader(new 
InputStreamReader(resourceAsStream));
+               String line;
+               while ((line = reader.readLine()) != null) {
+                       repositoryXML.append(line);
+                       repositoryXML.append("\r\n");
+               }
+               return repositoryXML.toString();
+       }
+
+       protected Option baseOptions() {
+               String localRepo = System.getProperty("maven.repo.local");
+
+               if (localRepo == null) {
+                       localRepo = 
System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+               }
+               return composite(
+                               junitBundles(),
+                               mavenBundle("org.ops4j.pax.logging", 
"pax-logging-api", "1.7.2"),
+                               mavenBundle("org.ops4j.pax.logging", 
"pax-logging-service", "1.7.2"),
+                               mavenBundle("org.apache.aries.testsupport", 
"org.apache.aries.testsupport.unit").versionAsInProject(),
+                               // this is how you set the default log level 
when using pax
+                               // logging (logProfile)
+                               
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 CoreOptions.options(
+                               baseOptions(),
+                               mavenBundle("org.osgi", 
"org.osgi.compendium").versionAsInProject(),
+                               mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.api").versionAsInProject(),
+                               mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.utils").versionAsInProject(),
+                               mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.management").versionAsInProject(),
+                               mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.default.local.platform").versionAsInProject(),
+                               mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.runtime").versionAsInProject(),
+                               mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.resolver.obr").versionAsInProject(),
+                               mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.deployment.management").versionAsInProject(),
+                               mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.modeller").versionAsInProject(),
+                               mavenBundle("org.apache.felix", 
"org.apache.felix.bundlerepository").versionAsInProject(),
+                               mavenBundle("org.apache.aries.application", 
"org.apache.aries.application.runtime.itest.interfaces").versionAsInProject(),
+                               mavenBundle("org.apache.aries", 
"org.apache.aries.util").versionAsInProject(),
+                               mavenBundle("org.apache.aries.blueprint", 
"org.apache.aries.blueprint").versionAsInProject(),
+                               mavenBundle("org.ow2.asm", 
"asm-all").versionAsInProject(),
+                               mavenBundle("org.apache.aries.proxy", 
"org.apache.aries.proxy").versionAsInProject(),
+                               mavenBundle("org.apache.aries.samples.twitter", 
"org.apache.aries.samples.twitter.twitter4j").versionAsInProject()
+
+                               // For debugging
+                               //vmOption 
("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5010"),
+                               );
+       }
 }

Modified: aries/trunk/samples/twitter/twitter-twitter4j/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/samples/twitter/twitter-twitter4j/pom.xml?rev=1602532&r1=1602531&r2=1602532&view=diff
==============================================================================
--- aries/trunk/samples/twitter/twitter-twitter4j/pom.xml (original)
+++ aries/trunk/samples/twitter/twitter-twitter4j/pom.xml Fri Jun 13 22:10:13 
2014
@@ -35,34 +35,21 @@
             <artifactId>twitter4j</artifactId>
         </dependency>
        </dependencies>
-    <build>
-        <plugins>
-            <plugin>
-                       <groupId>org.apache.felix</groupId>
-              <artifactId>maven-bundle-plugin</artifactId>
-              <version>1.4.0</version>
-              <extensions>true</extensions>
-              <configuration>
-                  <instructions>
-                      
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                      <Bundle-Name>${project.name}</Bundle-Name>
-                      <Bundle-Version>${project.version}</Bundle-Version>
-                                         
<Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>      
-                                         
<Import-Package>com.sun.syndication.feed.synd;resolution:=optional,com.sun.syndication.io;resolution:=optional,javax.crypto,javax.crypto.spec,javax.xml.parsers,javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.stream,org.slf4j,org.w3c.dom,org.xml.sax,twitter4j;version="2.0.8"</Import-Package>
-                                         
<Export-Package>twitter4j;version=2.0.8</Export-Package>
-                      <executions>
-                        <execution>
-                          <id>bundle-manifest</id>
-                          <phase>process-classes</phase>
-                                                 <goals>    
-                                                       <goal>manifest</goal>
-                                                 </goals>              
-                        </execution>
-                      </executions>
-                  </instructions>
-              </configuration>
-            </plugin>
-        </plugins>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <version>2.3.5</version>
+                               <extensions>true</extensions>
+                               <configuration>
+                                       <instructions>
+                                               
<Import-Package>dalvik.system;resolution:=optional,*</Import-Package>
+                                               
<Export-Package>!twitter4j.examples,*</Export-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
     </build>
 
 </project>


Reply via email to