servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r604234 - in /servicemix/smx4/runtime/trunk: ./ gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/ testing/ testing/depends-maven-plugin/ testing/depends-maven-plugin/src/main/java/org/apache/servicemix/tooling/depends/ tes...
Date Fri, 14 Dec 2007 17:12:51 GMT
Author: gnodet
Date: Fri Dec 14 09:12:49 2007
New Revision: 604234

URL: http://svn.apache.org/viewvc?rev=604234&view=rev
Log:
Add testing support

Added:
    servicemix/smx4/runtime/trunk/testing/support/   (with props)
    servicemix/smx4/runtime/trunk/testing/support/pom.xml
    servicemix/smx4/runtime/trunk/testing/support/src/
    servicemix/smx4/runtime/trunk/testing/support/src/main/
    servicemix/smx4/runtime/trunk/testing/support/src/main/java/
    servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/
    servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/
    servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/
    servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/runtime/
    servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/runtime/testing/
    servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/runtime/testing/support/
    servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTest.java
    servicemix/smx4/runtime/trunk/testing/support/src/main/resources/
    servicemix/smx4/runtime/trunk/testing/support/src/test/
    servicemix/smx4/runtime/trunk/testing/support/src/test/java/
    servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/
    servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/
    servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/
    servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/runtime/
    servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/runtime/testing/
    servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/runtime/testing/support/
    servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTestTest.java
Modified:
    servicemix/smx4/runtime/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java
    servicemix/smx4/runtime/trunk/pom.xml
    servicemix/smx4/runtime/trunk/testing/   (props changed)
    servicemix/smx4/runtime/trunk/testing/depends-maven-plugin/pom.xml
    servicemix/smx4/runtime/trunk/testing/depends-maven-plugin/src/main/java/org/apache/servicemix/tooling/depends/GenerateDependsFileMojo.java
    servicemix/smx4/runtime/trunk/testing/pom.xml

Modified: servicemix/smx4/runtime/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java?rev=604234&r1=604233&r2=604234&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java
(original)
+++ servicemix/smx4/runtime/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java
Fri Dec 14 09:12:49 2007
@@ -40,7 +40,7 @@
  * Time: 3:47:24 PM
  * To change this template use File | Settings | File Templates.
  */
-public class SpringCommandRegistry extends DefaultCommandRegistry implements LayoutManager
{
+    public class SpringCommandRegistry extends DefaultCommandRegistry implements LayoutManager
{
 
     public static final String SEPARATOR = ":";
 

Modified: servicemix/smx4/runtime/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/pom.xml?rev=604234&r1=604233&r2=604234&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/pom.xml Fri Dec 14 09:12:49 2007
@@ -37,9 +37,9 @@
   <modules>
     <module>bundles</module>
     <module>main</module>
-    <module>gshell</module>
     <module>filemonitor</module>
     <module>testing</module>
+    <module>gshell</module>
     <module>assembly</module>
   </modules>
 
@@ -78,7 +78,7 @@
       <jline.version>0.9.93</jline.version>
       <log4j.version>1.2.14</log4j.version>
       <mina.version>1.1.6-r602102</mina.version>
-      <pax.logging.version>0.9.9-SNAPSHOT</pax.logging.version>
+      <pax.logging.version>0.9.8</pax.logging.version>
       <spring.osgi.version>1.0-m3</spring.osgi.version>
       <spring.version>2.5</spring.version>
       <xstream.version>1.2.2</xstream.version>
@@ -146,6 +146,11 @@
       <dependency>
           <groupId>org.springframework</groupId>
           <artifactId>spring-context</artifactId>
+          <version>${spring.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.springframework</groupId>
+          <artifactId>spring-test</artifactId>
           <version>${spring.version}</version>
       </dependency>
       <dependency>

Propchange: servicemix/smx4/runtime/trunk/testing/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Dec 14 09:12:49 2007
@@ -0,0 +1,8 @@
+target
+*.iml
+*.ipr
+*.iws
+.classpath
+.project
+.settings
+eclipse-classes

Modified: servicemix/smx4/runtime/trunk/testing/depends-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/testing/depends-maven-plugin/pom.xml?rev=604234&r1=604233&r2=604234&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/testing/depends-maven-plugin/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/testing/depends-maven-plugin/pom.xml Fri Dec 14 09:12:49
2007
@@ -1,50 +1,49 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-    <!--
-
-        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.
-    -->
-
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <groupId>org.apache.servicemix.tooling</groupId>
-        <artifactId>tooling</artifactId>
-        <version>4.0-SNAPSHOT</version>
-    </parent>
-
-    <groupId>org.apache.servicemix.tooling</groupId>
-    <artifactId>depends-maven-plugin</artifactId>
-    <packaging>maven-plugin</packaging>
-    <version>4.0-SNAPSHOT</version>
-    <name>ServiceMix Tooing Depends plugin</name>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.maven</groupId>
-            <artifactId>maven-plugin-api</artifactId>
-            <version>2.0.1</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.maven</groupId>
-            <artifactId>maven-project</artifactId>
-            <version>2.0.1</version>
-        </dependency>
-    </dependencies>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.servicemix.runtime.testing</groupId>
+        <artifactId>testing</artifactId>
+        <version>0.1-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.apache.servicemix.runtime.testing</groupId>
+    <artifactId>depends-maven-plugin</artifactId>
+    <packaging>maven-plugin</packaging>
+    <name>ServiceMix Runtime :: Testing - Depends plugin</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <version>2.0.8</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-project</artifactId>
+            <version>2.0.8</version>
+        </dependency>
+    </dependencies>
+
+</project>

Modified: servicemix/smx4/runtime/trunk/testing/depends-maven-plugin/src/main/java/org/apache/servicemix/tooling/depends/GenerateDependsFileMojo.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/testing/depends-maven-plugin/src/main/java/org/apache/servicemix/tooling/depends/GenerateDependsFileMojo.java?rev=604234&r1=604233&r2=604234&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/testing/depends-maven-plugin/src/main/java/org/apache/servicemix/tooling/depends/GenerateDependsFileMojo.java
(original)
+++ servicemix/smx4/runtime/trunk/testing/depends-maven-plugin/src/main/java/org/apache/servicemix/tooling/depends/GenerateDependsFileMojo.java
Fri Dec 14 09:12:49 2007
@@ -21,9 +21,21 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactCollector;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.DefaultArtifactCollector;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -36,7 +48,7 @@
  * @version $Id: $
  * @goal generate-depends-file
  * @phase generate-resources
- * @requiresDependencyResolution runtime
+ * @requiresDependencyResolution test
  * @description Generates the dependencies properties file
  */
 public class GenerateDependsFileMojo extends AbstractMojo {
@@ -53,6 +65,13 @@
     protected MavenProject project;
 
     /**
+     *
+     * @parameter expression='true'
+     * @required
+     */
+    protected boolean recursive;
+
+    /**
      * The file to generate
      *
      * @parameter default-value="${project.build.directory}/classes/META-INF/maven/dependencies.properties"
@@ -60,15 +79,88 @@
     
     private File outputFile;
 
+    /**
+     * @parameter default-value="${localRepository}"
+     */
+    protected ArtifactRepository localRepo;
+
+    /**
+     * @parameter default-value="${project.remoteArtifactRepositories}"
+     */
+    protected List remoteRepos;
+
+    /**
+     * @component
+     */
+    protected ArtifactMetadataSource artifactMetadataSource;
+
+    /**
+     * @component
+     */
+    protected ArtifactResolver resolver;
+
+    protected ArtifactCollector collector = new DefaultArtifactCollector();
+
+    /**
+     * @component
+     */
+    protected ArtifactFactory factory;
+
     public void execute() throws MojoExecutionException, MojoFailureException {
         OutputStream out = null;
         try {
             outputFile.getParentFile().mkdirs();
             out = new FileOutputStream(outputFile);
             PrintStream printer = new PrintStream(out);
-            populateProperties(printer);
-            getLog().info("Created: " + outputFile);
 
+            List<Dependency> dependencies;
+            if (!recursive) {
+                dependencies = project.getDependencies();
+            } else {
+                Set<Artifact> artifacts = project.getArtifacts();
+                dependencies = new ArrayList<Dependency>();
+                for (Artifact a : artifacts) {
+                    Dependency dep = new Dependency();
+                    dep.setGroupId(a.getGroupId());
+                    dep.setArtifactId(a.getArtifactId());
+                    dep.setVersion(a.getVersion());
+                    dep.setClassifier(a.getClassifier());
+                    dep.setType(a.getType());
+                    dep.setScope(a.getScope());
+                    dependencies.add(dep);
+                }
+            }
+            Collections.sort(dependencies, new Comparator<Dependency>() {
+                public int compare(Dependency o1, Dependency o2) {
+                    int result = o1.getGroupId().compareTo( o2.getGroupId() );
+                    if ( result == 0 ) {
+                        result = o1.getArtifactId().compareTo( o2.getArtifactId() );
+                        if ( result == 0 ) {
+                            result = o1.getType().compareTo( o2.getType() );
+                            if ( result == 0 ) {
+                                if ( o1.getClassifier() == null ) {
+                                    if ( o2.getClassifier() != null ) {
+                                        result = 1;
+                                    }
+                                } else {
+                                    if ( o2.getClassifier() != null ) {
+                                        result = o1.getClassifier().compareTo( o2.getClassifier()
);
+                                    } else {
+                                        result = -1;
+                                    }
+                                }
+                                if ( result == 0 ) {
+                                    // We don't consider the version range in the comparison,
just the resolved version
+                                    result = o1.getVersion().compareTo( o2.getVersion() );
+                                }
+                            }
+                        }
+                    }
+                    return result;
+                }
+            });
+            populateProperties(printer, dependencies);
+            getLog().info("Created: " + outputFile);
         } catch (Exception e) {
             throw new MojoExecutionException(
                     "Unable to create dependencies file: " + e, e);
@@ -83,7 +175,7 @@
         }
     }
 
-    protected void populateProperties(PrintStream out) {
+    protected void populateProperties(PrintStream out, List<Dependency> dependencies)
{
         out.println("# Project dependencies generated by the Apache ServiceMix Maven Plugin");
         out.println("# Generated at: " + new Date());
         out.println();
@@ -96,7 +188,8 @@
         out.println("# dependencies");
         out.println();
 
-        Iterator iterator = project.getDependencies().iterator();
+        Iterator iterator = dependencies.iterator();
+
         while (iterator.hasNext()) {
             Dependency dependency = (Dependency) iterator.next();
             String prefix = dependency.getGroupId() + SEPARATOR + dependency.getArtifactId()
+ SEPARATOR;
@@ -112,4 +205,5 @@
             getLog().debug("Dependency: " + dependency + " classifier: " + classifier + "
type: " + dependency.getType());
         }
     }
+
 }

Modified: servicemix/smx4/runtime/trunk/testing/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/testing/pom.xml?rev=604234&r1=604233&r2=604234&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/testing/pom.xml (original)
+++ servicemix/smx4/runtime/trunk/testing/pom.xml Fri Dec 14 09:12:49 2007
@@ -34,6 +34,8 @@
     <name>ServiceMix Runtime :: Testing</name>
 
     <modules>
+        <module>depends-maven-plugin</module>
+        <module>support</module>
     </modules>
 
 </project>

Propchange: servicemix/smx4/runtime/trunk/testing/support/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Dec 14 09:12:49 2007
@@ -0,0 +1,8 @@
+target
+*.iml
+*.ipr
+*.iws
+.classpath
+.project
+.settings
+eclipse-classes

Added: servicemix/smx4/runtime/trunk/testing/support/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/testing/support/pom.xml?rev=604234&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/testing/support/pom.xml (added)
+++ servicemix/smx4/runtime/trunk/testing/support/pom.xml Fri Dec 14 09:12:49 2007
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <!--
+
+      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.
+  -->
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+      <groupId>org.apache.servicemix.runtime.testing</groupId>
+      <artifactId>testing</artifactId>
+      <version>0.1-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.servicemix.runtime.testing</groupId>
+  <artifactId>org.apache.servicemix.runtime.testing.support</artifactId>
+  <packaging>bundle</packaging>
+  <name>ServiceMix Runtime :: Testing - Support</name>
+
+  <dependencies>
+      <dependency>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.osgi.core</artifactId>
+          <version>${felix.osgi.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.osgi.compendium</artifactId>
+          <version>${felix.compendium.version}</version>
+          <exclusions>
+	         <exclusion>
+	              <groupId>org.apache.felix</groupId>
+    	          <artifactId>javax.servlet</artifactId>
+             </exclusion>
+	         <exclusion>
+	              <groupId>org.apache.felix</groupId>
+    	          <artifactId>org.osgi.foundation</artifactId>
+             </exclusion>
+	      </exclusions>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.apache.felix.framework</artifactId>
+          <version>${felix.framework.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.apache.felix.main</artifactId>
+          <version>${felix.framework.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.apache.felix.configadmin</artifactId>
+          <version>${felix.configadmin.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.ops4j.pax.logging</groupId>
+          <artifactId>pax-logging-api</artifactId>
+          <version>${pax.logging.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.ops4j.pax.logging</groupId>
+          <artifactId>pax-logging-service</artifactId>
+          <version>${pax.logging.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.springframework.osgi</groupId>
+          <artifactId>spring-osgi-test</artifactId>
+          <version>${spring.osgi.version}</version>
+          <exclusions>
+              <exclusion>
+                  <groupId>org.springframework.osgi</groupId>
+                  <artifactId>asm.osgi</artifactId>
+              </exclusion>
+          </exclusions>
+      </dependency>
+      <dependency>
+          <groupId>org.springframework.osgi</groupId>
+          <artifactId>spring-osgi-extender</artifactId>
+          <version>${spring.osgi.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.springframework.osgi</groupId>
+          <artifactId>spring-osgi-annotation</artifactId>
+          <version>${spring.osgi.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-servlet_2.5_spec</artifactId>
+          <version>${geronimo.servlet.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+          <version>${geronimo.stax.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.servicemix.bundles</groupId>
+          <artifactId>org.apache.servicemix.bundles.aopalliance-${aopalliance.version}</artifactId>
+          <version>0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.servicemix.bundles</groupId>
+          <artifactId>org.apache.servicemix.bundles.asm-${asm.version}</artifactId>
+          <version>0.1-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.servicemix.bundles</groupId>
+          <artifactId>org.apache.servicemix.bundles.junit-${junit.version}</artifactId>
+          <version>0.1-SNAPSHOT</version>
+      </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Export-Package>${pom.artifactId}</Export-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Added: servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTest.java?rev=604234&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTest.java
(added)
+++ servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTest.java
Fri Dec 14 09:12:49 2007
@@ -0,0 +1,198 @@
+/*
+ * 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.servicemix.runtime.testing.support;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.log4j.PropertyConfigurator;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.springframework.osgi.internal.test.platform.FelixPlatform;
+import org.springframework.osgi.internal.util.concurrent.Counter;
+import org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests;
+import org.springframework.osgi.test.platform.OsgiPlatform;
+import org.springframework.osgi.util.OsgiFilterUtils;
+import org.springframework.osgi.util.OsgiListenerUtils;
+
+public class AbstractIntegrationTest extends AbstractConfigurableBundleCreatorTests {
+
+    static {
+        try {
+            System.setProperty("bundles.configuration.location", new File("src/test/conf").getAbsolutePath());
+            PropertyConfigurator.configure("target/test-classes/log4j.properties");
+        } catch (Throwable t) {}
+    }
+
+    private Properties dependencies;
+
+
+    protected OsgiPlatform createPlatform() {
+        return new FelixPlatform();
+    }
+
+    protected String getBundle(String groupId, String artifactId) {
+        return groupId + "," + artifactId + "," + getBundleVersion(groupId, artifactId);
+    }
+
+    protected String getBundleVersion(String groupId, String artifactId) {
+        if (dependencies == null) {
+            try {
+                File f = new File(System.getProperty("basedir"), "target/classes/META-INF/maven/dependencies.properties");
+                Properties prop = new Properties();
+                prop.load(new FileInputStream(f));
+                dependencies = prop;
+            } catch (IOException e) {
+                throw new IllegalStateException("Unable to load dependencies informations",
e);
+            }
+        }
+        String version = dependencies.getProperty(groupId + "/" + artifactId + "/version");
+        if (version == null) {
+            throw new IllegalStateException("Unable to find dependency information for: "
+ groupId + "/" + artifactId + "/version");
+        }
+        return version;
+    }
+
+    protected String[] getTestFrameworkBundlesNames() {
+        return new String[] {
+            getBundle("org.apache.geronimo.specs", "geronimo-servlet_2.5_spec"),
+            getBundle("org.apache.felix", "org.osgi.compendium"),
+            getBundle("org.apache.felix", "org.apache.felix.configadmin"),
+            getBundle("org.ops4j.pax.logging", "pax-logging-api"),
+            getBundle("org.ops4j.pax.logging", "pax-logging-service"),
+            getBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.aopalliance-1.0"),
+            getBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.asm-2.2.3"),
+            getBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.junit-4.4"),
+            getBundle("org.springframework", "spring-beans"),
+            getBundle("org.springframework", "spring-core"),
+            getBundle("org.springframework", "spring-context"),
+            getBundle("org.springframework", "spring-aop"),
+            getBundle("org.springframework", "spring-test"),
+            getBundle("org.springframework.osgi", "spring-osgi-core"),
+            getBundle("org.springframework.osgi", "spring-osgi-io"),
+            getBundle("org.springframework.osgi", "spring-osgi-extender"),
+            getBundle("org.springframework.osgi", "spring-osgi-test"),
+            getBundle("org.springframework.osgi", "spring-osgi-annotation"),
+		};
+    }
+
+    protected void installBundle(String groupId, String artifactId, String classifier, String
type) throws Exception {
+        String version = getBundleVersion(groupId, artifactId);
+        File loc = localMavenBundle(groupId, artifactId, version, classifier, type);
+        Bundle bundle = bundleContext.installBundle(loc.toURI().toString());
+        bundle.start();
+    }
+
+    protected File localMavenBundle(String groupId, String artifact, String version, String
classifier, String type) {
+        String defaultHome = new File(new File(System.getProperty("user.home")), ".m2/repository").getAbsolutePath();
+        File repositoryHome = new File(System.getProperty("localRepository", defaultHome));
+
+        StringBuffer location = new StringBuffer(groupId.replace('.', '/'));
+        location.append('/');
+        location.append(artifact);
+        location.append('/');
+        /*
+        if (isSnapshot(version)) {
+            location.append("SNAPSHOT");
+        } else {
+            location.append(version);
+        }
+        */
+        location.append(version);
+        location.append('/');
+        location.append(artifact);
+        location.append('-');
+        location.append(version);
+        if (classifier != null) {
+            location.append('-');
+            location.append(classifier);
+        }
+        location.append(".");
+        location.append(type);
+
+        return new File(repositoryHome, location.toString());
+    }
+
+    protected static boolean isSnapshot(String version) {
+        return version.matches(".+-(\\d\\d\\d\\d\\d\\d\\d\\d\\.\\d\\d\\d\\d\\d\\d-\\d+|SNAPSHOT)");
+    }
+
+    public <T> T getOsgiService(Class<T> type) {
+        return getOsgiService(type, DEFAULT_WAIT_TIME);
+    }
+
+    public <T> T getOsgiService(Class<T> type, long timeout) {
+        // translate from seconds to miliseconds
+        long time = timeout * 1000;
+
+        // use the counter to make sure the threads block
+        final Counter counter = new Counter("waitForOsgiService on bnd=" + type.getName());
+
+        counter.increment();
+
+        final List<T> services = new ArrayList<T>();
+
+        ServiceListener listener = new ServiceListener() {
+            public void serviceChanged(ServiceEvent event) {
+                if (event.getType() == ServiceEvent.REGISTERED) {
+                    services.add((T) bundleContext.getService(event.getServiceReference()));
+                    counter.decrement();
+                }
+            }
+        };
+
+        String filter = OsgiFilterUtils.unifyFilter(type.getName(), null);
+        OsgiListenerUtils.addServiceListener(bundleContext, listener, filter);
+
+        if (logger.isDebugEnabled())
+            logger.debug("start waiting for OSGi service=" + type.getName());
+
+        try {
+            if (counter.waitForZero(time)) {
+                logger.warn("waiting for OSGi service=" + type.getName() + " timed out");
+                throw new RuntimeException("Gave up waiting for OSGi service '" + type.getName()
+ "' to be created");
+            }
+            else if (logger.isDebugEnabled()) {
+                logger.debug("found OSGi service=" + type.getName());
+            }
+            return services.get(0);
+        }
+        finally {
+            // inform waiting thread
+            bundleContext.removeServiceListener(listener);
+        }
+    }
+
+    protected void checkBundleStarted(String name) {
+        assertNotNull(bundleContext);
+        for (int i = 0; i < bundleContext.getBundles().length; i++) {
+            Bundle b = bundleContext.getBundles()[i];
+            if (b.getSymbolicName().equals(name)) {
+                assertEquals("Bundle '" + name + "' is not active", Bundle.ACTIVE, b.getState());
+                return;
+            }
+        }
+        fail("Bundle '" + name + "' not found");
+    }
+
+
+}
\ No newline at end of file

Added: servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTestTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTestTest.java?rev=604234&view=auto
==============================================================================
--- servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTestTest.java
(added)
+++ servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTestTest.java
Fri Dec 14 09:12:49 2007
@@ -0,0 +1,30 @@
+/*
+ * 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.servicemix.runtime.testing.support;
+
+import org.junit.Test;import static org.junit.Assert.assertTrue;import static org.junit.Assert.assertFalse;
+
+public class AbstractIntegrationTestTest {
+
+    @Test
+    public void testSnapshotVersion() {
+        assertTrue(AbstractIntegrationTest.isSnapshot("0.9.0-20070713.230317-1"));
+        assertTrue(AbstractIntegrationTest.isSnapshot("0.9.0-SNAPSHOT"));        
+        assertFalse(AbstractIntegrationTest.isSnapshot("0.9.0"));
+    }
+
+}



Mime
View raw message