You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/12/15 00:39:22 UTC
svn commit: r604331 - in /servicemix/smx4/runtime/trunk/testing/support/src:
main/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTest.java
test/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTestTest.java
Author: gnodet
Date: Fri Dec 14 15:39:05 2007
New Revision: 604331
URL: http://svn.apache.org/viewvc?rev=604331&view=rev
Log:
Fix maven snapshot resolution
Modified:
servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTest.java
servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTestTest.java
Modified: 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=604331&r1=604330&r2=604331&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTest.java (original)
+++ servicemix/smx4/runtime/trunk/testing/support/src/main/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTest.java Fri Dec 14 15:39:05 2007
@@ -27,11 +27,15 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.FileSystemResource;
import org.springframework.osgi.internal.util.concurrent.Counter;
import org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests;
-import org.springframework.osgi.test.platform.Platforms;
+import org.springframework.osgi.test.provisioning.ArtifactLocator;
import org.springframework.osgi.util.OsgiFilterUtils;
import org.springframework.osgi.util.OsgiListenerUtils;
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
public class AbstractIntegrationTest extends AbstractConfigurableBundleCreatorTests {
@@ -98,6 +102,28 @@
bundle.start();
}
+ protected Resource locateBundle(String bundleId) {
+ Assert.hasText(bundleId, "bundleId should not be empty");
+
+ // parse the String
+ String[] artifactId = StringUtils.commaDelimitedListToStringArray(bundleId);
+
+ Assert.isTrue(artifactId.length >= 3, "the CSV string " + bundleId + " contains too few values");
+ // TODO: add a smarter mechanism which can handle 1 or 2 values CSVs
+ for (int i = 0; i < artifactId.length; i++) {
+ artifactId[i] = StringUtils.trimWhitespace(artifactId[i]);
+ }
+
+ File f;
+ if (artifactId.length == 3) {
+ f = localMavenBundle(artifactId[0], artifactId[1], artifactId[2], null, ArtifactLocator.DEFAULT_ARTIFACT_TYPE);
+ } else {
+ f = localMavenBundle(artifactId[0], artifactId[1], artifactId[2], null, artifactId[3]);
+ }
+ return new FileSystemResource(f);
+ }
+
+
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));
@@ -106,14 +132,7 @@
location.append('/');
location.append(artifact);
location.append('/');
- /*
- if (isSnapshot(version)) {
- location.append("SNAPSHOT");
- } else {
- location.append(version);
- }
- */
- location.append(version);
+ location.append(getSnapshot(version));
location.append('/');
location.append(artifact);
location.append('-');
@@ -128,8 +147,19 @@
return new File(repositoryHome, location.toString());
}
+ protected static String getSnapshot(String version) {
+ if (isTimestamped(version)) {
+ return version.substring(0, version.lastIndexOf('-', version.lastIndexOf('-') - 1)) + "-SNAPSHOT";
+ }
+ return version;
+ }
+
+ protected static boolean isTimestamped(String version) {
+ return version.matches(".+-\\d\\d\\d\\d\\d\\d\\d\\d\\.\\d\\d\\d\\d\\d\\d-\\d+");
+ }
+
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)");
+ return version.matches(".+-SNAPSHOT");
}
public <T> T getOsgiService(Class<T> type) {
Modified: 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=604331&r1=604330&r2=604331&view=diff
==============================================================================
--- servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTestTest.java (original)
+++ servicemix/smx4/runtime/trunk/testing/support/src/test/java/org/apache/servicemix/runtime/testing/support/AbstractIntegrationTestTest.java Fri Dec 14 15:39:05 2007
@@ -16,15 +16,19 @@
*/
package org.apache.servicemix.runtime.testing.support;
-import org.junit.Test;import static org.junit.Assert.assertTrue;import static org.junit.Assert.assertFalse;
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;import static org.junit.Assert.assertEquals;
public class AbstractIntegrationTestTest {
@Test
public void testSnapshotVersion() {
- assertTrue(AbstractIntegrationTest.isSnapshot("0.9.0-20070713.230317-1"));
- assertTrue(AbstractIntegrationTest.isSnapshot("0.9.0-SNAPSHOT"));
+ assertTrue(AbstractIntegrationTest.isTimestamped("0.9.0-20070713.230317-1"));
+ assertTrue(AbstractIntegrationTest.isSnapshot("0.9.0-SNAPSHOT"));
assertFalse(AbstractIntegrationTest.isSnapshot("0.9.0"));
+ assertEquals("0.9.0-SNAPSHOT", AbstractIntegrationTest.getSnapshot("0.9.0-20070713.230317-1"));
+ assertEquals("0.9.0", "0.9.0");
}
}