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 2008/10/09 17:23:48 UTC
svn commit: r703181 - in /servicemix/smx4/kernel/trunk:
main/src/main/java/org/apache/servicemix/kernel/main/ testing/support/
testing/support/src/main/java/org/apache/servicemix/kernel/testing/support/
testing/support/src/main/resources/org/apache/ser...
Author: gnodet
Date: Thu Oct 9 08:23:47 2008
New Revision: 703181
URL: http://svn.apache.org/viewvc?rev=703181&view=rev
Log:
SMX4KNL-120: The ServiceMix Kernel testing platform should use the servicemix kernel main jar instead of the felix one
Modified:
servicemix/smx4/kernel/trunk/main/src/main/java/org/apache/servicemix/kernel/main/Main.java
servicemix/smx4/kernel/trunk/testing/support/pom.xml
servicemix/smx4/kernel/trunk/testing/support/src/main/java/org/apache/servicemix/kernel/testing/support/SmxKernelPlatform.java
servicemix/smx4/kernel/trunk/testing/support/src/main/resources/org/apache/servicemix/kernel/testing/support/felix.config.properties
servicemix/smx4/kernel/trunk/testing/support/src/test/java/org/apache/servicemix/kernel/testing/support/AbstractIntegrationTestTest.java
Modified: servicemix/smx4/kernel/trunk/main/src/main/java/org/apache/servicemix/kernel/main/Main.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/main/src/main/java/org/apache/servicemix/kernel/main/Main.java?rev=703181&r1=703180&r2=703181&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/main/src/main/java/org/apache/servicemix/kernel/main/Main.java (original)
+++ servicemix/smx4/kernel/trunk/main/src/main/java/org/apache/servicemix/kernel/main/Main.java Thu Oct 9 08:23:47 2008
@@ -936,7 +936,7 @@
* @throws IllegalArgumentException If there was a syntax error in the
* property placeholder syntax or a recursive variable reference.
*/
- private static String substVars(String val, String currentKey,
+ public static String substVars(String val, String currentKey,
Map<String, String> cycleMap, Properties configProps)
throws IllegalArgumentException {
// If there is currently no cycle map, then create
Modified: servicemix/smx4/kernel/trunk/testing/support/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/testing/support/pom.xml?rev=703181&r1=703180&r2=703181&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/testing/support/pom.xml (original)
+++ servicemix/smx4/kernel/trunk/testing/support/pom.xml Thu Oct 9 08:23:47 2008
@@ -35,8 +35,8 @@
<dependencies>
<dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
+ <groupId>org.apache.servicemix.kernel</groupId>
+ <artifactId>org.apache.servicemix.kernel.main</artifactId>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
@@ -44,14 +44,6 @@
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.main</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.configadmin</artifactId>
</dependency>
<dependency>
@@ -100,7 +92,12 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
- <Import-Package>org.apache.felix*;resolution:=optional,*</Import-Package>
+ <Import-Package>
+ org.apache.felix*;resolution:=optional,
+ org.apache.servicemix.kernel.main;resolution:=optional,
+ org.apache.servicemix.kernel.main.spi;resolution:=optional;version="1.0.0",
+ *
+ </Import-Package>
<Export-Package>${pom.artifactId}</Export-Package>
</instructions>
</configuration>
Modified: servicemix/smx4/kernel/trunk/testing/support/src/main/java/org/apache/servicemix/kernel/testing/support/SmxKernelPlatform.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/testing/support/src/main/java/org/apache/servicemix/kernel/testing/support/SmxKernelPlatform.java?rev=703181&r1=703180&r2=703181&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/testing/support/src/main/java/org/apache/servicemix/kernel/testing/support/SmxKernelPlatform.java (original)
+++ servicemix/smx4/kernel/trunk/testing/support/src/main/java/org/apache/servicemix/kernel/testing/support/SmxKernelPlatform.java Thu Oct 9 08:23:47 2008
@@ -28,6 +28,8 @@
import java.net.MalformedURLException;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.FileNotFoundException;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
import java.security.AccessController;
@@ -36,13 +38,16 @@
import org.springframework.osgi.test.platform.FelixPlatform;
import org.springframework.osgi.test.platform.OsgiPlatform;
import org.springframework.util.ClassUtils;
-import org.apache.felix.main.Main;
import org.apache.felix.framework.Felix;
+import org.apache.felix.framework.util.CompoundEnumeration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.kernel.main.Main;
+import org.apache.servicemix.kernel.main.spi.MainService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Bundle;
-import sun.misc.CompoundEnumeration;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.ServiceRegistration;
public class SmxKernelPlatform implements OsgiPlatform {
@@ -142,10 +147,33 @@
//System.out.println(jars);
ClassLoader classLoader = new GuardClassLoader(toURLs(jars.toArray(new String[jars.size()])), additionalPackages);
+ BundleActivator activator = new BundleActivator() {
+ private ServiceRegistration registration;
+
+ public void start(BundleContext context) {
+ registration = context.registerService(MainService.class.getName(), new MainService() {
+ public String[] getArgs() {
+ return new String[0];
+ }
+ public int getExitCode() {
+ return 0;
+ }
+ public void setExitCode(int exitCode) {
+ }
+ }, null);
+ }
+
+ public void stop(BundleContext context) {
+ registration.unregister();
+ }
+ };
+ List<BundleActivator> activations = new ArrayList<BundleActivator>();
+ activations.add(activator);
+
Thread.currentThread().setContextClassLoader(classLoader);
Class cl = classLoader.loadClass(Felix.class.getName());
Constructor cns = cl.getConstructor(Map.class, List.class);
- platform = cns.newInstance(getConfigurationProperties(), null);
+ platform = cns.newInstance(getConfigurationProperties(), activations);
platform.getClass().getMethod("start").invoke(platform);
Bundle systemBundle = (Bundle) platform;
@@ -233,7 +261,33 @@
System.getProperties().setProperty(FELIX_CONFIG_PROPERTY, url.toExternalForm());
// load config.properties (use Felix's Main for resolving placeholders)
- return Main.loadConfigProperties();
+ Properties props = new Properties();
+ InputStream is = null;
+ try {
+ is = url.openConnection().getInputStream();
+ props.load(is);
+ is.close();
+ }
+ catch (FileNotFoundException ex) {
+ // Ignore file not found.
+ }
+ catch (Exception ex) {
+ System.err.println("Main: Error loading system properties from " + url);
+ System.err.println("Main: " + ex);
+ try {
+ if (is != null) is.close();
+ }
+ catch (IOException ex2) {
+ // Nothing we can do.
+ }
+ return null;
+ }
+ // Perform variable substitution for system properties.
+ for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
+ String name = (String) e.nextElement();
+ props.setProperty(name, Main.substVars(props.getProperty(name), name, null, props));
+ }
+ return props;
}
/**
Modified: servicemix/smx4/kernel/trunk/testing/support/src/main/resources/org/apache/servicemix/kernel/testing/support/felix.config.properties
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/testing/support/src/main/resources/org/apache/servicemix/kernel/testing/support/felix.config.properties?rev=703181&r1=703180&r2=703181&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/testing/support/src/main/resources/org/apache/servicemix/kernel/testing/support/felix.config.properties (original)
+++ servicemix/smx4/kernel/trunk/testing/support/src/main/resources/org/apache/servicemix/kernel/testing/support/felix.config.properties Thu Oct 9 08:23:47 2008
@@ -24,7 +24,8 @@
org.osgi.service.packageadmin; version=1.2.0, \
org.osgi.service.startlevel; version=1.1.0, \
org.osgi.service.url; version=1.0.0, \
- org.apache.servicemix.kernel.main.spi, \
+ org.apache.servicemix.kernel.main.spi; version=1.0.0, \
+ org.apache.servicemix.kernel.jaas.boot, \
${jre-${java.specification.version}}
org.osgi.framework.bootdelegation=sun.*,com.sun.management*,com.sun.org.apache.*
Modified: servicemix/smx4/kernel/trunk/testing/support/src/test/java/org/apache/servicemix/kernel/testing/support/AbstractIntegrationTestTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/testing/support/src/test/java/org/apache/servicemix/kernel/testing/support/AbstractIntegrationTestTest.java?rev=703181&r1=703180&r2=703181&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/testing/support/src/test/java/org/apache/servicemix/kernel/testing/support/AbstractIntegrationTestTest.java (original)
+++ servicemix/smx4/kernel/trunk/testing/support/src/test/java/org/apache/servicemix/kernel/testing/support/AbstractIntegrationTestTest.java Thu Oct 9 08:23:47 2008
@@ -18,7 +18,8 @@
import org.junit.Test;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertEquals;
public class AbstractIntegrationTestTest {