[jboss-osgi-commits] JBoss-OSGI SVN: r101149 - in projects/jboss-osgi/projects: testing and 21 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Fri Feb 19 05:43:05 EST 2010
Author: thomas.diesler at jboss.com
Date: 2010-02-19 05:43:03 -0500 (Fri, 19 Feb 2010)
New Revision: 101149
Added:
projects/jboss-osgi/projects/testing/
projects/jboss-osgi/projects/testing/trunk/
projects/jboss-osgi/projects/testing/trunk/.classpath
projects/jboss-osgi/projects/testing/trunk/.project
projects/jboss-osgi/projects/testing/trunk/.settings/
projects/jboss-osgi/projects/testing/trunk/.settings/org.eclipse.jdt.core.prefs
projects/jboss-osgi/projects/testing/trunk/.settings/org.maven.ide.eclipse.prefs
projects/jboss-osgi/projects/testing/trunk/pom.xml
projects/jboss-osgi/projects/testing/trunk/scripts/
projects/jboss-osgi/projects/testing/trunk/scripts/antrun-test-jars.xml
projects/jboss-osgi/projects/testing/trunk/scripts/assembly-bundles.xml
projects/jboss-osgi/projects/testing/trunk/src/
projects/jboss-osgi/projects/testing/trunk/src/main/
projects/jboss-osgi/projects/testing/trunk/src/main/java/
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/husky/
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/husky/internal/
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/husky/runtime/
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/husky/runtime/junit/
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/husky/runtime/osgi/
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiServiceReference.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedServiceReference.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/MainDeployerClient.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteFramework.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteFrameworkException.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteServiceReference.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/package.html
projects/jboss-osgi/projects/testing/trunk/src/test/
projects/jboss-osgi/projects/testing/trunk/src/test/java/
projects/jboss-osgi/projects/testing/trunk/src/test/java/org/
projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/
projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/
projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/osgi/
projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/osgi/husky/
projects/jboss-osgi/projects/testing/trunk/src/test/java/org/jboss/test/osgi/husky/context/
projects/jboss-osgi/projects/testing/trunk/src/test/resources/
projects/jboss-osgi/projects/testing/trunk/src/test/resources/context/
projects/jboss-osgi/projects/testing/trunk/src/test/resources/jboss-osgi-framework.properties
projects/jboss-osgi/projects/testing/trunk/src/test/resources/log4j.xml
Log:
split husky and testing
Property changes on: projects/jboss-osgi/projects/testing/trunk
___________________________________________________________________
Name: svn:ignore
+ target
Name: svn:mergeinfo
+
Added: projects/jboss-osgi/projects/testing/trunk/.classpath
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/.classpath (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/.classpath 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: projects/jboss-osgi/projects/testing/trunk/.project
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/.project (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/.project 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jboss-osgi-husky</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: projects/jboss-osgi/projects/testing/trunk/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/.settings/org.eclipse.jdt.core.prefs 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,6 @@
+#Fri Feb 19 11:02:56 CET 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.5
Added: projects/jboss-osgi/projects/testing/trunk/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/.settings/org.maven.ide.eclipse.prefs 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,9 @@
+#Fri May 15 00:24:21 CEST 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
Added: projects/jboss-osgi/projects/testing/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/pom.xml (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/pom.xml 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+ <!-- ====================================================================== -->
+ <!-- -->
+ <!-- JBoss, JUnit testing for OSGi bundles -->
+ <!-- -->
+ <!-- Distributable under LGPL license. -->
+ <!-- See terms of license at http://www.gnu.org. -->
+ <!-- -->
+ <!-- ====================================================================== -->
+
+ <!-- $Id$ -->
+
+<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>
+
+ <name>JBossOSGi - Testing</name>
+ <description>JBoss OSGi Test Support</description>
+
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-testing</artifactId>
+ <packaging>jar</packaging>
+
+ <version>1.0.0-SNAPSHOT</version>
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-parent</artifactId>
+ <version>1.0.5-SNAPSHOT</version>
+ </parent>
+
+ <!-- Subversion -->
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/testing/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-osgi/projects/testing/trunk</developerConnection>
+ <url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
+ </scm>
+
+ <!-- Properties -->
+ <properties>
+ <version.apache.aries.jmx>1.0.0-incubating-SNAPSHOT</version.apache.aries.jmx>
+ <version.apache.felix.log>1.0.0</version.apache.felix.log>
+ <version.jboss.osgi.jmx>1.0.4-SNAPSHOT</version.jboss.osgi.jmx>
+ <version.jboss.osgi.runtime.felix>2.0.2.SP1-SNAPSHOT</version.jboss.osgi.runtime.felix>
+ <version.osgi>4.2.0</version.osgi>
+ </properties>
+
+ <!-- Dependencies -->
+ <dependencies>
+ <dependency>
+ <groupId>biz.aQute</groupId>
+ <artifactId>bnd</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-jmx</artifactId>
+ <version>${version.jboss.osgi.jmx}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <!-- Provided Dependencies -->
+ <dependency>
+ <groupId>org.apache.aries.jmx</groupId>
+ <artifactId>org.apache.aries.jmx</artifactId>
+ <version>${version.apache.aries.jmx}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.log</artifactId>
+ <version>${version.apache.felix.log}</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- OSGi Dependencies -->
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${version.osgi}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>${version.osgi}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>org.jboss.osgi.runtime</groupId>
+ <artifactId>jboss-osgi-runtime-felix</artifactId>
+ <version>${version.jboss.osgi.runtime.felix}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <quiet>true</quiet>
+ <excludePackageNames>*.internal</excludePackageNames>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>bundles</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>directory-single</goal>
+ </goals>
+ <configuration>
+ <finalName>test-libs</finalName>
+ <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>scripts/assembly-bundles.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build-test-jars</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
+ <property name="artifactId" value="${artifactId}" />
+ <property name="tests.output.dir" value="${project.build.directory}" />
+ <property name="build.artifact" value="${project.build.finalName}" />
+ <ant antfile="scripts/antrun-test-jars.xml" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>${surefire.jpda.args}</argLine>
+ <systemProperties>
+ <property>
+ <name>java.protocol.handler.pkgs</name>
+ <value>org.jboss.net.protocol|org.jboss.virtual.protocol</value>
+ </property>
+ <property>
+ <name>log4j.output.dir</name>
+ <value>${project.build.directory}</value>
+ </property>
+ <property>
+ <name>test.archive.directory</name>
+ <value>${project.build.directory}/test-libs</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- Profiles -->
+ <profiles>
+
+ <!--
+ Name: jpda
+ Descr: Enable JPDA remote debuging
+ -->
+ <profile>
+ <id>jpda</id>
+ <activation>
+ <property>
+ <name>jpda</name>
+ </property>
+ </activation>
+ <properties>
+ <surefire.jpda.args>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</surefire.jpda.args>
+ </properties>
+ </profile>
+
+ </profiles>
+
+</project>
Property changes on: projects/jboss-osgi/projects/testing/trunk/pom.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/scripts/antrun-test-jars.xml (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/scripts/antrun-test-jars.xml 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ============================================================ -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- ============================================================ -->
+
+<!-- $Id$ -->
+
+<project default="build-test-jars">
+
+ <description>OSGi test archive builder</description>
+
+ <!-- ================================================================== -->
+ <!-- Init -->
+ <!-- ================================================================== -->
+
+ <target name="init">
+
+ <!-- Property override when not called from maven -->
+ <property name="maven.runtime.classpath" value="/usr/java/bnd.jar" />
+ <property name="tests.output.dir" value="${basedir}/../target" />
+
+ <mkdir dir="${tests.output.dir}/test-libs" />
+ <property name="tests.classes.dir" value="${tests.output.dir}/test-classes" />
+ <property name="tests.resources.dir" value="${tests.output.dir}/test-classes" />
+
+ <taskdef resource="aQute/bnd/ant/taskdef.properties">
+ <classpath>
+ <pathelement path="${maven.runtime.classpath}" />
+ </classpath>
+ </taskdef>
+
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Building -->
+ <!-- ================================================================== -->
+
+ <target name="build-test-jars" depends="init" description="Build the test deployments">
+
+ <!-- Please add alphabetically -->
+
+ <!-- simple -->
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-simple.jar" files="${tests.resources.dir}/simple/example-simple.bnd" />
+
+ <!-- Please add alphabetically -->
+
+ </target>
+
+</project>
Property changes on: projects/jboss-osgi/projects/testing/trunk/scripts/antrun-test-jars.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/scripts/assembly-bundles.xml (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/scripts/assembly-bundles.xml 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,41 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+
+ <id>deploy-artifacts</id>
+ <formats>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <!-- Dependency Sets -->
+ <dependencySets>
+
+ <!-- bundle -->
+ <dependencySet>
+ <outputDirectory>bundles</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <includes>
+ <include>*:jboss-osgi-common-core:jar</include>
+ <include>*:jboss-osgi-common:jar</include>
+ <include>*:jboss-osgi-jmx:jar</include>
+ <include>*:jboss-osgi-jndi:jar</include>
+ </includes>
+ <useStrictFiltering>true</useStrictFiltering>
+ <scope>compile</scope>
+ <unpack>false</unpack>
+ </dependencySet>
+ <dependencySet>
+ <outputDirectory>bundles</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <includes>
+ <include>*:org.apache.aries.jmx:jar</include>
+ <include>*:org.apache.felix.log:jar</include>
+ <include>*:org.osgi.compendium:jar</include>
+ </includes>
+ <useStrictFiltering>true</useStrictFiltering>
+ <scope>provided</scope>
+ <unpack>false</unpack>
+ </dependencySet>
+
+ </dependencySets>
+</assembly>
Property changes on: projects/jboss-osgi/projects/testing/trunk/scripts/assembly-bundles.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Dictionary;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
+
+/**
+ * An abstraction of an OSGi {@link Bundle}.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public abstract class OSGiBundle
+{
+ /**
+ * Get the runtime associated with this bundle.
+ */
+ public abstract OSGiRuntime getRuntime();
+
+ /**
+ * Returns this bundle's unique identifier.
+ */
+ public abstract long getBundleId();
+
+ /**
+ * Returns the symbolic name of this bundle as specified by its Bundle-SymbolicName manifest header.
+ */
+ public abstract String getSymbolicName();
+
+ /**
+ * Returns the version of this bundle.
+ */
+ public abstract Version getVersion();
+
+ /**
+ * Returns this bundle's location.
+ */
+ public abstract String getLocation();
+
+ /**
+ * Returns this bundle's Manifest headers and values.
+ */
+ public abstract Dictionary<String, String> getHeaders();
+
+ /**
+ * Returns this bundle's Manifest headers and values localized to the specified locale.
+ */
+ public abstract Dictionary<String, String> getHeaders(String locale);
+
+ /**
+ * Returns this bundle's current state.
+ */
+ public abstract int getState();
+
+ /**
+ * Returns the value of the specified property.
+ */
+ public abstract String getProperty(String key);
+
+ /**
+ * Creates a File object for a file in the persistent storage area provided for the bundle by the Framework.
+ */
+ public abstract File getDataFile(String filename);
+
+ /**
+ * Loads the specified class using this bundle's class loader.
+ *
+ * @param name The name of the class to load
+ * @return The OSGiBundle that is wired to this bundle class loader and contains the class.
+ * @throws ClassNotFoundException If no such class can be found or if this bundle is a fragment bundle
+ */
+ public abstract OSGiBundle loadClass(String name) throws ClassNotFoundException;
+
+ /**
+ * Returns a URL to the entry at the specified path in this bundle.
+ *
+ * @param name The path name of the entry
+ * @return A URL to the entry, or null if no entry could be found
+ */
+ public abstract URL getEntry(String path);
+
+ /**
+ * Find the specified resource from this bundle's class loader.
+ * @param name The name of the resource.
+ * @return A URL to the named resource, or null if the resource could not be found
+ */
+ public abstract URL getResource(String name);
+
+ /**
+ * Starts this bundle.
+ */
+ public abstract void start() throws BundleException;
+
+ /**
+ * Stops this bundle.
+ */
+ public abstract void stop() throws BundleException;
+
+ /**
+ * Uninstalls this bundle.
+ */
+ public abstract void uninstall() throws BundleException;
+
+ /**
+ * Return true if symbolic name and version are equal
+ */
+ public boolean equals(Object obj)
+ {
+ if ((obj instanceof OSGiBundle) == false)
+ return false;
+
+ OSGiBundle other = (OSGiBundle)obj;
+
+ boolean isEqual = getSymbolicName().equals(other.getSymbolicName());
+ isEqual = isEqual && getVersion().equals(other.getVersion());
+ return isEqual;
+ }
+
+ /**
+ * Returns the hash code for this bundle.
+ */
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ /**
+ * Returns the string representation of this bundle
+ */
+ public String toString()
+ {
+ return "[" + getSymbolicName() + "," + getVersion() + "]";
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiBundle.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing;
+
+//$Id$
+
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An abstraction of the OSGi {@link PackageAdmin} service.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public interface OSGiPackageAdmin
+{
+ /**
+ * Forces the update (replacement) or removal of packages exported by the specified bundles.
+ *
+ * @see {@link PackageAdmin#refreshPackages(org.osgi.framework.Bundle[])}
+ *
+ * @param bundles The bundles whose exported packages are to be updated or removed,
+ * or null for all bundles updated or uninstalled since the last call to this method.
+ */
+ void refreshPackages(OSGiBundle[] bundles);
+
+ /**
+ * Resolve the specified bundles.
+ *
+ * @see {@link PackageAdmin#resolveBundles(org.osgi.framework.Bundle[])}
+ *
+ * @param bundles The bundles to resolve or null to resolve all unresolved bundles installed in the Framework.
+ * @return true if all specified bundles are resolved
+ */
+ boolean resolveBundles(OSGiBundle[] bundles);
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing;
+
+import javax.management.MBeanServerConnection;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.osgi.spi.capability.Capability;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
+import org.osgi.jmx.framework.BundleStateMBean;
+import org.osgi.jmx.framework.FrameworkMBean;
+import org.osgi.jmx.framework.PackageStateMBean;
+import org.osgi.jmx.framework.ServiceStateMBean;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An abstraction of an OSGi Runtime.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public interface OSGiRuntime
+{
+ /**
+ * Add a {@link Capability} to the runtime.
+ *
+ * Adding a capability recursively adds the orderded set of dependent capabilities
+ * before it installs and starts the orderded set bundles.
+ */
+ void addCapability(Capability capability) throws BundleException;
+
+ /**
+ * Remove a {@link Capability} from the runtime.
+ *
+ * Removing a capability does the reverse of {@link #addCapability(Capability)}.
+ */
+ void removeCapability(Capability capability);
+
+ /**
+ * Install an {@link OSGiBundle} from the given location.
+ */
+ OSGiBundle installBundle(String location) throws BundleException;
+
+ /**
+ * Get the FrameworkMBean
+ */
+ FrameworkMBean getFrameworkMBean();
+
+ /**
+ * Get the BundleStateMBean
+ */
+ BundleStateMBean getBundleStateMBean();
+
+ /**
+ * Get the PackageStateMBean
+ */
+ PackageStateMBean getPackageStateMBean();
+
+ /**
+ * Get the ServiceStateMBean
+ */
+ ServiceStateMBean getServiceStateMBean();
+
+ /**
+ * Get the array of installed {@link OSGiBundle}s
+ */
+ OSGiBundle[] getBundles();
+
+ /**
+ * Get the {@link OSGiBundle} for a given symbolic name and version
+ *
+ * In case the version is left unspecified, it returns the first bundle that
+ * matches the symbolic name.
+ *
+ * @param version may be null
+ * @return The bundle or null if there is none
+ */
+ OSGiBundle getBundle(String symbolicName, Version version);
+
+ /**
+ * Get the {@link OSGiBundle} for a given bundle id.
+ *
+ * @return The bundle or null if there is none
+ */
+ OSGiBundle getBundle(long bundleId);
+
+ /**
+ * Get an abstraction of the {@link PackageAdmin}.
+ */
+ OSGiPackageAdmin getPackageAdmin();
+
+ /**
+ * Returns a ServiceReference object for a service that implements and was registered
+ * under the specified class.
+ *
+ * @return A ServiceReference object, or null if no services are registered which implement the named class.
+ */
+ OSGiServiceReference getServiceReference(String clazz);
+
+ /**
+ * Returns a ServiceReference object for a service that implements and was registered
+ * under the specified class.
+ *
+ * @param timeout the timeout to wait for the service to become available
+ * @return A ServiceReference object, or null if no services are registered which implement the named class.
+ */
+ OSGiServiceReference getServiceReference(String clazz, long timeout);
+
+ /**
+ * Returns an array of ServiceReference objects.
+ * The returned array of ServiceReference objects contains services that were registered under the specified
+ * class and match the specified filter criteria.
+ */
+ OSGiServiceReference[] getServiceReferences(String clazz, String filter);
+
+ /**
+ * Get the initial naming context for this {@link OSGiRuntime}
+ */
+ InitialContext getInitialContext() throws NamingException;
+
+ /**
+ * Get the MBeanServerConnection for this {@link OSGiRuntime}
+ */
+ MBeanServerConnection getMBeanServer();
+
+ /**
+ * Get the host name that this {@link OSGiRuntime} is running on.
+ *
+ * This is the value of the 'jboss.bind.address' system property.
+ */
+ String getServerHost();
+
+ /**
+ * Return true if this {@link OSGiRuntime} connects to a remote Framework.
+ */
+ boolean isRemoteRuntime();
+
+ /**
+ * Shutdown the {@link OSGiRuntime}.
+ *
+ * This will remove all installed {@link OSGiBundle}s and added {@link Capability}.
+ */
+ void shutdown();
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiServiceReference.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiServiceReference.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiServiceReference.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing;
+
+import org.osgi.framework.ServiceReference;
+
+
+/**
+ * An abstraction of the OSGi {@link ServiceReference}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public interface OSGiServiceReference
+{
+ /**
+ * Returns the property value to which the specified property key is mapped
+ * in the properties Dictionary object of the service referenced by this
+ * ServiceReference object.
+ */
+ Object getProperty(String key);
+
+ /**
+ * Returns an array of the keys in the properties Dictionary
+ * object of the service referenced by this ServiceReference object.
+ */
+ String[] getPropertyKeys();
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiServiceReference.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,224 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.junit.After;
+import org.junit.Before;
+import org.osgi.framework.Bundle;
+
+/**
+ * An abstract OSGi Test.
+ *
+ * {@link OSGiTest} is a convenience wrapper for the functionality provided
+ * by {@link OSGiTestHelper}.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public abstract class OSGiTest
+{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(OSGiTest.class);
+
+ private OSGiTestHelper helper;
+
+ protected OSGiTest()
+ {
+ // Prevent unknown protocol: vfsfile
+ VFS.init();
+ }
+
+ /**
+ * Get the test helper used by this test
+ *
+ * Overwrite if you need to supply another helper
+ * i.e. one that you have statically setup
+ */
+ protected OSGiTestHelper getTestHelper()
+ {
+ if (helper == null)
+ helper = new OSGiTestHelper();
+
+ return helper;
+ }
+
+ /**
+ * Writes a a debug start messge
+ */
+ @Before
+ public void setUp() throws Exception
+ {
+ log.debug("### START " + getLongName());
+ }
+
+ /**
+ * Writes a a debug stop messge
+ */
+ @After
+ public void tearDown() throws Exception
+ {
+ log.debug("### END " + getLongName());
+ }
+
+ /**
+ * Get the last token in the FQN of this test class.
+ */
+ protected String getShortName()
+ {
+ String shortName = getClass().getName();
+ shortName = shortName.substring(shortName.lastIndexOf(".") + 1);
+ return shortName;
+ }
+
+ /**
+ * Get the the FQN of this test class.
+ */
+ protected String getLongName()
+ {
+ return getClass().getName();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getDefaultRuntime()}
+ */
+ protected OSGiRuntime getDefaultRuntime()
+ {
+ return getTestHelper().getDefaultRuntime();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getEmbeddedRuntime()}
+ */
+ protected OSGiRuntime getEmbeddedRuntime()
+ {
+ return getTestHelper().getEmbeddedRuntime();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getRemoteRuntime()}
+ */
+ public OSGiRuntime getRemoteRuntime()
+ {
+ return getTestHelper().getRemoteRuntime();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getResourceURL(String)}
+ */
+ protected URL getResourceURL(String resource)
+ {
+ return getTestHelper().getResourceURL(resource);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getResourceFile(String)}
+ */
+ protected File getResourceFile(String resource)
+ {
+ return getTestHelper().getResourceFile(resource);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTestArchiveURL(String)}
+ */
+ protected URL getTestArchiveURL(String archive)
+ {
+ return getTestHelper().getTestArchiveURL(archive);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTestArchivePath(String)}
+ */
+ protected String getTestArchivePath(String archive)
+ {
+ return getTestHelper().getTestArchivePath(archive);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTestArchiveFile(String)}
+ */
+ protected File getTestArchiveFile(String archive)
+ {
+ return getTestHelper().getTestArchiveFile(archive);
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getInitialContext()}
+ */
+ public InitialContext getInitialContext() throws NamingException
+ {
+ return getTestHelper().getInitialContext();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getServerHost()}
+ */
+ public String getServerHost()
+ {
+ return getTestHelper().getServerHost();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getTargetContainer()}
+ */
+ public String getTargetContainer()
+ {
+ return getTestHelper().getTargetContainer();
+ }
+
+ /**
+ * Delegates to {@link OSGiTestHelper#getFrameworkName()}
+ */
+ public String getFrameworkName()
+ {
+ return getTestHelper().getFrameworkName();
+ }
+
+ public VirtualFile assembleBundle(String name, String resource, Class<?>... packages) throws Exception
+ {
+ return getTestHelper().assembleBundle(name, resource, packages);
+ }
+
+ public VirtualFile assembleBundle(String name, String[] resources, Class<?>... packages) throws Exception
+ {
+ return getTestHelper().assembleBundle(name, resources, packages);
+ }
+
+ public void assertBundleState(int expState, int wasState)
+ {
+ getTestHelper().assertBundleState(expState, wasState);
+ }
+
+ public void assertBundleLoadClass(Bundle bundle, String className, boolean success)
+ {
+ getTestHelper().assertBundleLoadClass(bundle, className, success);
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,288 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Hashtable;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.util.ConstantsHelper;
+import org.jboss.osgi.testing.internal.EmbeddedRuntime;
+import org.jboss.osgi.testing.internal.RemoteRuntime;
+import org.jboss.virtual.AssembledDirectory;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
+
+/**
+ * An OSGi Test Helper
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class OSGiTestHelper
+{
+ private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
+ private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
+
+ // The OSGiBootstrapProvider is a lazy property of the helper
+ private OSGiBootstrapProvider bootProvider;
+ private boolean skipCreateBootstrapProvider;
+
+ private static String testResourcesDir;
+ private static String testArchiveDir;
+
+ public OSGiTestHelper()
+ {
+ testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY, "target/test-classes");
+ testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
+ }
+
+ public OSGiBootstrapProvider getBootstrapProvider()
+ {
+ if (bootProvider == null && skipCreateBootstrapProvider == false)
+ {
+ try
+ {
+ bootProvider = OSGiBootstrap.getBootstrapProvider();
+ }
+ catch (RuntimeException rte)
+ {
+ skipCreateBootstrapProvider = true;
+ throw rte;
+ }
+ }
+ return bootProvider;
+ }
+
+ public void ungetBootstrapProvider()
+ {
+ bootProvider = null;
+ }
+
+ public OSGiRuntime getDefaultRuntime()
+ {
+ OSGiRuntime runtime;
+
+ String target = System.getProperty("target.container");
+ if (target == null)
+ {
+ runtime = getEmbeddedRuntime();
+ }
+ else
+ {
+ runtime = getRemoteRuntime();
+ }
+ return runtime;
+ }
+
+ public OSGiRuntime getEmbeddedRuntime()
+ {
+ return new EmbeddedRuntime(this);
+ }
+
+ public OSGiRuntime getRemoteRuntime()
+ {
+ return new RemoteRuntime(this);
+ }
+
+ /** Try to discover the URL for the test resource */
+ public URL getResourceURL(String resource)
+ {
+ URL resURL = null;
+ try
+ {
+ File resourceFile = getResourceFile(resource);
+ resURL = resourceFile.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ return resURL;
+ }
+
+ /** Try to discover the File for the test resource */
+ public File getResourceFile(String resource)
+ {
+ File file = new File(resource);
+ if (file.exists())
+ return file;
+
+ file = new File(testResourcesDir + "/" + resource);
+ if (file.exists())
+ return file;
+
+ throw new IllegalArgumentException("Cannot obtain '" + testResourcesDir + "/" + resource + "'");
+ }
+
+ /** Try to discover the URL for the deployment archive */
+ public URL getTestArchiveURL(String archive)
+ {
+ try
+ {
+ return getTestArchiveFile(archive).toURI().toURL();
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ /** Try to discover the absolute path for the deployment archive */
+ public String getTestArchivePath(String archive)
+ {
+ return getTestArchiveFile(archive).getAbsolutePath();
+ }
+
+ /** Try to discover the File for the deployment archive */
+ public File getTestArchiveFile(String archive)
+ {
+ File file = new File(archive);
+ if (file.exists())
+ return file;
+
+ file = new File(testArchiveDir + "/" + archive);
+ if (file.exists())
+ return file;
+
+ throw new IllegalArgumentException("Cannot obtain '" + testArchiveDir + "/" + archive + "'.");
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public InitialContext getInitialContext() throws NamingException
+ {
+ String port = System.getProperty("jndi.server.port", "1099");
+ Integer jndiPort = new Integer(port);
+
+ Hashtable env = new Hashtable();
+ env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
+ env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
+ env.put("java.naming.provider.url", "jnp://" + getServerHost() + ":" + jndiPort);
+ return new InitialContext(env);
+ }
+
+ public String getServerHost()
+ {
+ String bindAddress = System.getProperty("jboss.bind.address", "localhost");
+ return bindAddress;
+ }
+
+ public String getTargetContainer()
+ {
+ String targetContainer = System.getProperty("target.container");
+ return targetContainer;
+ }
+
+ public String getFrameworkName()
+ {
+ String framework = System.getProperty("framework");
+ if (framework == null || framework.length() == 0 || framework.equals("${framework}"))
+ framework = "jbossmc";
+
+ return framework;
+ }
+
+ public VirtualFile assembleBundle(String name, String resource, Class<?>... packages) throws Exception
+ {
+ return assembleBundle(name, new String[] { resource }, packages);
+ }
+
+ public VirtualFile assembleBundle(String name, String[] resources, Class<?>... packages) throws Exception
+ {
+ AssembledDirectory assembledDirectory = AssembledDirectory.createAssembledDirectory(name, "");
+ for (String path : resources)
+ addPath(assembledDirectory, path, "");
+ for (Class<?> reference : packages)
+ addPackage(assembledDirectory, reference);
+ return assembledDirectory;
+ }
+
+ public void assertBundleState(int expState, int wasState)
+ {
+ String expstr = ConstantsHelper.bundleState(expState);
+ String wasstr = ConstantsHelper.bundleState(wasState);
+ assertEquals("Bundle " + expstr, expstr, wasstr);
+ }
+
+ public void assertBundleLoadClass(Bundle bundle, String className, boolean success)
+ {
+ String message = bundle.getSymbolicName() + " loads " + className;
+
+ Class<?> clazz;
+ try
+ {
+ clazz = bundle.loadClass(className);
+ if (success)
+ {
+ assertEquals(message, className, clazz.getName());
+ }
+ else
+ {
+ fail("ClassNotFoundException expected for: " + message + "\nLoaded from " + clazz.getClassLoader());
+ }
+ }
+ catch (ClassNotFoundException ex)
+ {
+ if (success)
+ fail("Unexpected ClassNotFoundException for: " + message);
+ }
+ }
+
+ private void addPath(AssembledDirectory dir, String path, String name) throws Exception
+ {
+ URL url = getClass().getResource(path);
+ if (url == null)
+ throw new AssertionFailedError(path + " not found");
+
+ VirtualFile file = VFS.getVirtualFile(url, name);
+ dir.addPath(file);
+ }
+
+ private void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
+ {
+ String packagePath = packageNameToPath(reference.getName());
+ dir.addResources(reference, new String[] { packagePath + "/*.class" }, new String[0]);
+ }
+
+ // Convert a class's package name into a path
+ private String packageNameToPath(final String className)
+ {
+ int end = className.lastIndexOf('.');
+ if (end == -1)
+ return "";
+
+ String packageName = className.substring(0, end);
+ return packageName.replace('.', '/');
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiTestHelper.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Dictionary;
+
+import org.jboss.osgi.spi.util.ExportedPackageHelper;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An OSGi Test Case
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class EmbeddedBundle extends OSGiBundleImpl
+{
+ private Bundle bundle;
+
+ public EmbeddedBundle(OSGiRuntimeImpl runtime, Bundle bundle)
+ {
+ super(runtime);
+ this.bundle = bundle;
+ }
+
+ public Bundle getBundle()
+ {
+ return bundle;
+ }
+
+ @Override
+ public int getState()
+ {
+ return bundle.getState();
+ }
+
+ @Override
+ public String getSymbolicName()
+ {
+ return bundle.getSymbolicName();
+ }
+
+ @Override
+ public Version getVersion()
+ {
+ return bundle.getVersion();
+ }
+
+ @Override
+ public String getLocation()
+ {
+ return bundle.getLocation();
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Dictionary<String, String> getHeaders()
+ {
+ return bundle.getHeaders();
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Dictionary<String, String> getHeaders(String locale)
+ {
+ return bundle.getHeaders(locale);
+ }
+
+ @Override
+ public long getBundleId()
+ {
+ return bundle.getBundleId();
+ }
+
+ @Override
+ public String getProperty(String key)
+ {
+ return bundle.getBundleContext().getProperty(key);
+ }
+
+ @Override
+ public URL getEntry(String path)
+ {
+ return bundle.getEntry(path);
+ }
+
+ @Override
+ public URL getResource(String name)
+ {
+ return bundle.getResource(name);
+ }
+
+ @Override
+ public File getDataFile(String filename)
+ {
+ return bundle.getBundleContext().getDataFile(filename);
+ }
+
+ @Override
+ public OSGiBundle loadClass(String name) throws ClassNotFoundException
+ {
+ Class<?> clazz = bundle.loadClass(name);
+ Bundle providerBundle = getPackageAdmin().getBundle(clazz);
+ if (providerBundle == null)
+ return null;
+
+ return getRuntime().getBundle(providerBundle.getBundleId());
+ }
+
+ @Override
+ public void start() throws BundleException
+ {
+ bundle.start();
+
+ ExportedPackageHelper helper = new ExportedPackageHelper(bundle.getBundleContext());
+ helper.logExportedPackages(bundle);
+ }
+
+ @Override
+ public void stop() throws BundleException
+ {
+ bundle.stop();
+ }
+
+ @Override
+ public void uninstall() throws BundleException
+ {
+ assertNotUninstalled();
+
+ bundle.uninstall();
+
+ OSGiRuntimeImpl runtimeImpl = (OSGiRuntimeImpl)getRuntime();
+ runtimeImpl.unregisterBundle(this);
+ }
+
+ private PackageAdmin getPackageAdmin()
+ {
+ BundleContext context = ((EmbeddedRuntime)getRuntime()).getSystemContext();
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ return (PackageAdmin)context.getService(sref);
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedBundle.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiPackageAdmin;
+import org.osgi.framework.Bundle;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An embedded implementation of the {@link OSGiPackageAdmin}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class EmbeddedPackageAdmin implements OSGiPackageAdmin
+{
+ private PackageAdmin delegate;
+
+ public EmbeddedPackageAdmin(PackageAdmin packAdmin)
+ {
+ this.delegate = packAdmin;
+ }
+
+ public boolean resolveBundles(OSGiBundle[] bundles)
+ {
+ Bundle[] bundleArr = getBundles(bundles);
+ return delegate.resolveBundles(bundleArr);
+ }
+
+ public void refreshPackages(OSGiBundle[] bundles)
+ {
+ Bundle[] bundleArr = getBundles(bundles);
+ delegate.refreshPackages(bundleArr);
+ }
+
+ private Bundle[] getBundles(OSGiBundle[] bundles)
+ {
+ Bundle[] bundleArr = null;
+ if (bundles != null)
+ {
+ bundleArr = new Bundle[bundles.length];
+ for (int i=0; i < bundles.length; i++)
+ {
+ bundleArr[i] = ((EmbeddedBundle)bundles[i]).getBundle();
+ }
+ }
+ return bundleArr;
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,213 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+// $Id$
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.MBeanServerFactory;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiPackageAdmin;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiServiceReference;
+import org.jboss.osgi.testing.OSGiTestHelper;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.launch.Framework;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An embedded implementation of the {@link OSGiRuntime}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class EmbeddedRuntime extends OSGiRuntimeImpl
+{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(EmbeddedRuntime.class);
+
+ public EmbeddedRuntime(OSGiTestHelper helper)
+ {
+ super(helper);
+ }
+
+ public OSGiBundle installBundle(String location) throws BundleException
+ {
+ BundleInfo info = BundleInfo.createBundleInfo(location);
+
+ BundleContext context = getSystemContext();
+ Bundle auxBundle = context.installBundle(info.getLocation());
+ OSGiBundle bundle = new EmbeddedBundle(this, auxBundle);
+
+ return registerBundle(bundle.getLocation(), bundle);
+ }
+
+ public OSGiBundle[] getBundles()
+ {
+ List<OSGiBundle> absBundles = new ArrayList<OSGiBundle>();
+ for (Bundle bundle : getSystemContext().getBundles())
+ {
+ absBundles.add(new EmbeddedBundle(this, bundle));
+ }
+ OSGiBundle[] bundleArr = new OSGiBundle[absBundles.size()];
+ absBundles.toArray(bundleArr);
+ return bundleArr;
+ }
+
+ public OSGiBundle getBundle(long bundleId)
+ {
+ Bundle bundle = getSystemContext().getBundle(bundleId);
+ return bundle != null ? new EmbeddedBundle(this, bundle) : null;
+ }
+
+ public OSGiServiceReference getServiceReference(String clazz)
+ {
+ ServiceReference sref = getSystemContext().getServiceReference(clazz);
+ return (sref != null ? new EmbeddedServiceReference(sref) : null);
+ }
+
+ public OSGiServiceReference[] getServiceReferences(String clazz, String filter)
+ {
+ OSGiServiceReference[] retRefs = null;
+
+ ServiceReference[] srefs;
+ try
+ {
+ srefs = getSystemContext().getServiceReferences(clazz, filter);
+ }
+ catch (InvalidSyntaxException e)
+ {
+ throw new IllegalArgumentException("Invalid filter syntax: " + filter);
+ }
+
+ if (srefs != null)
+ {
+ retRefs = new OSGiServiceReference[srefs.length];
+ for (int i = 0; i < srefs.length; i++)
+ retRefs[i] = new EmbeddedServiceReference(srefs[i]);
+ }
+ return retRefs;
+ }
+
+ @Override
+ public void addCapability(Capability capability) throws BundleException
+ {
+ // Copy the properties to the System props
+ Map<String, String> props = capability.getSystemProperties();
+ for (Entry<String, String> entry : props.entrySet())
+ {
+ String value = System.getProperty(entry.getKey());
+ if (value == null)
+ System.setProperty(entry.getKey(), entry.getValue());
+ }
+
+ super.addCapability(capability);
+ }
+
+ @Override
+ public void shutdown()
+ {
+ OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
+ if (bootProvider != null)
+ {
+ super.shutdown();
+ try
+ {
+ Framework framework = bootProvider.getFramework();
+ log.debug("Framework stop: " + framework);
+ framework.stop();
+ framework.waitForStop(5000);
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot stop the framework", ex);
+ }
+ finally
+ {
+ getTestHelper().ungetBootstrapProvider();
+ }
+ }
+ }
+
+ public MBeanServerConnection getMBeanServer()
+ {
+ ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
+ if (serverArr.size() > 1)
+ throw new IllegalStateException("Multiple MBeanServer instances not supported");
+
+ MBeanServer server = null;
+ if (serverArr.size() == 1)
+ server = serverArr.get(0);
+
+ if (server == null)
+ server = MBeanServerFactory.createMBeanServer();
+
+ return server;
+ }
+
+ public OSGiPackageAdmin getPackageAdmin()
+ {
+ BundleContext context = getSystemContext();
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin packAdmin = (PackageAdmin)context.getService(sref);
+ return new EmbeddedPackageAdmin(packAdmin);
+ }
+
+ public boolean isRemoteRuntime()
+ {
+ return false;
+ }
+
+ BundleContext getSystemContext()
+ {
+ OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
+ Framework framework = bootProvider.getFramework();
+ if (framework.getState() != Bundle.ACTIVE)
+ {
+ try
+ {
+ log.debug("Framework start: " + framework);
+ framework.start();
+ }
+ catch (BundleException ex)
+ {
+ throw new IllegalStateException("Cannot start framework", ex);
+ }
+ }
+ return framework.getBundleContext();
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedServiceReference.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedServiceReference.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedServiceReference.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+// $Id$
+
+import org.jboss.osgi.testing.OSGiServiceReference;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * An embedded implementation of the {@link OSGiServiceReference}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class EmbeddedServiceReference implements OSGiServiceReference
+{
+ private ServiceReference sref;
+
+ public EmbeddedServiceReference(ServiceReference sref)
+ {
+ this.sref = sref;
+ }
+
+ public Object getProperty(String key)
+ {
+ return sref.getProperty(key);
+ }
+
+ public String[] getPropertyKeys()
+ {
+ return sref.getPropertyKeys();
+ }
+
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedServiceReference.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/MainDeployerClient.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/MainDeployerClient.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/MainDeployerClient.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+// $Id$
+
+import java.net.URL;
+
+import javax.management.MBeanException;
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.osgi.framework.BundleException;
+
+/**
+ * An abstract implementation of the {@link OSGiRuntime}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+class MainDeployerClient
+{
+ private final OSGiRuntime runtime;
+
+ MainDeployerClient(OSGiRuntime runtime)
+ {
+ this.runtime = runtime;
+ }
+
+ public void deploy(URL url) throws BundleException
+ {
+ invokeDeployerMBean("deploy", url);
+ }
+
+ public void undeploy(URL url) throws BundleException
+ {
+ invokeDeployerMBean("undeploy", url);
+ }
+
+ private void invokeDeployerMBean(String method, URL url) throws BundleException
+ {
+ try
+ {
+ ObjectName objectName = ObjectNameFactory.create("jboss.system:service=MainDeployer");
+ runtime.getMBeanServer().invoke(objectName, method, new Object[] { url }, new String[] { URL.class.getName() });
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ if (ex instanceof MBeanException)
+ {
+ ex = ((MBeanException)ex).getTargetException();
+ if (ex instanceof BundleException)
+ throw (BundleException)ex;
+ }
+
+ throw new BundleException("Cannot " + method + ": " + url, ex);
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/MainDeployerClient.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+// $Id$
+
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.osgi.framework.Bundle;
+
+/**
+ * An abstract implementation of a {@link OSGiBundle}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public abstract class OSGiBundleImpl extends OSGiBundle
+{
+ private OSGiRuntime runtime;
+
+ OSGiBundleImpl(OSGiRuntime runtime)
+ {
+ this.runtime = runtime;
+ }
+
+ public OSGiRuntime getRuntime()
+ {
+ return runtime;
+ }
+
+ void assertNotUninstalled()
+ {
+ if (getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already uninstalled: " + getLocation());
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiBundleImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,364 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.capability.Capability;
+import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiServiceReference;
+import org.jboss.osgi.testing.OSGiTestHelper;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
+import org.osgi.jmx.framework.BundleStateMBean;
+import org.osgi.jmx.framework.FrameworkMBean;
+import org.osgi.jmx.framework.PackageStateMBean;
+import org.osgi.jmx.framework.ServiceStateMBean;
+
+/**
+ * An abstract implementation of the {@link OSGiRuntime}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public abstract class OSGiRuntimeImpl implements OSGiRuntime
+{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(OSGiRuntimeImpl.class);
+
+ private OSGiTestHelper helper;
+ private Map<String, OSGiBundle> bundles = new LinkedHashMap<String, OSGiBundle>();
+ private List<Capability> capabilities = new ArrayList<Capability>();
+
+ private ServiceStateMBean serviceState;
+ private PackageStateMBean packageState;
+ private BundleStateMBean bundleState;
+ private FrameworkMBean framework;
+
+ public OSGiRuntimeImpl(OSGiTestHelper helper)
+ {
+ this.helper = helper;
+ }
+
+ public OSGiTestHelper getTestHelper()
+ {
+ return helper;
+ }
+
+ public void addCapability(Capability capability) throws BundleException
+ {
+ // Add dependent capabilies
+ for (Capability dependency : capability.getDependencies())
+ addCapability(dependency);
+
+ OSGiServiceReference[] srefs = null;
+
+ // Check if the service provided by the capability exists already
+ String serviceName = capability.getServiceName();
+ if (serviceName != null)
+ srefs = getServiceReferences(serviceName, capability.getFilter());
+
+ if (srefs == null || srefs.length == 0)
+ {
+ log.debug("Add capability: " + capability);
+
+ // Install the capability bundles
+ List<OSGiBundle> installed = new ArrayList<OSGiBundle>();
+ for (BundleInfo info : capability.getBundles())
+ {
+ String location = info.getLocation();
+ String symName = info.getSymbolicName();
+ Version version = info.getVersion();
+ if (bundles.get(location) == null && getBundle(symName, version) == null)
+ {
+ OSGiBundle bundle = installBundle(location);
+ installed.add(bundle);
+ }
+ else
+ {
+ log.debug("Skip bundle: " + location);
+ }
+ }
+
+ // Start the capability bundles
+ for (OSGiBundle bundle : installed)
+ {
+ bundle.start();
+ }
+ capabilities.add(capability);
+ }
+ else
+ {
+ log.debug("Skip capability: " + capability);
+ }
+ }
+
+ public void removeCapability(Capability capability)
+ {
+ if (capabilities.remove(capability))
+ {
+ log.debug("Remove capability : " + capability);
+
+ List<BundleInfo> bundleInfos = new ArrayList<BundleInfo>(capability.getBundles());
+ Collections.reverse(bundleInfos);
+
+ for (BundleInfo info : bundleInfos)
+ failsafeUninstall(bundles.remove(info.getLocation()));
+ }
+
+ List<Capability> dependencies = new ArrayList<Capability>(capability.getDependencies());
+ Collections.reverse(dependencies);
+
+ // Remove dependent capabilities
+ for (Capability dependency : dependencies)
+ removeCapability(dependency);
+ }
+
+ public void shutdown()
+ {
+ log.debug("Start Shutdown");
+
+ // Uninstall the registered bundles
+ ArrayList<String> locations = new ArrayList<String>(bundles.keySet());
+ Collections.reverse(locations);
+
+ while (locations.size() > 0)
+ {
+ String location = locations.remove(0);
+ failsafeUninstall(bundles.remove(location));
+ }
+
+ // Uninstall the capabilities
+ Collections.reverse(capabilities);
+ while (capabilities.size() > 0)
+ {
+ Capability capability = capabilities.get(0);
+ removeCapability(capability);
+ }
+
+ log.debug("End Shutdown");
+ }
+
+ public FrameworkMBean getFrameworkMBean()
+ {
+ if (framework == null)
+ {
+ ObjectName objectName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
+ framework = MBeanProxy.get(getMBeanServer(), objectName, FrameworkMBean.class);
+ }
+ return framework;
+ }
+
+ public BundleStateMBean getBundleStateMBean()
+ {
+ if (bundleState == null)
+ {
+ ObjectName objectName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
+ bundleState = MBeanProxy.get(getMBeanServer(), objectName, BundleStateMBean.class);
+ }
+ return bundleState;
+ }
+
+ public PackageStateMBean getPackageStateMBean()
+ {
+ if (packageState == null)
+ {
+ ObjectName objectName = ObjectNameFactory.create(PackageStateMBean.OBJECTNAME);
+ packageState = MBeanProxy.get(getMBeanServer(), objectName, PackageStateMBean.class);
+ }
+ return packageState;
+ }
+
+ public ServiceStateMBean getServiceStateMBean()
+ {
+ if (serviceState == null)
+ {
+ ObjectName objectName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
+ serviceState = MBeanProxy.get(getMBeanServer(), objectName, ServiceStateMBean.class);
+ }
+ return serviceState;
+ }
+
+ void deploy(URL archiveURL) throws Exception
+ {
+ //DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
+ //deployer.deploy(archiveURL);
+ }
+
+ void undeploy(URL archiveURL) throws Exception
+ {
+ //DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
+ //deployer.undeploy(archiveURL);
+ }
+
+ public InitialContext getInitialContext() throws NamingException
+ {
+ return helper.getInitialContext();
+ }
+
+ public String getServerHost()
+ {
+ return helper.getServerHost();
+ }
+
+ public OSGiBundle getBundle(String symbolicName, Version version)
+ {
+ OSGiBundle bundle = getBundle(symbolicName, version, false);
+ return bundle;
+ }
+
+ public OSGiServiceReference getServiceReference(String clazz, long timeout)
+ {
+ int fraktion = 200;
+ timeout = timeout / fraktion;
+ OSGiServiceReference sref = getServiceReference(clazz);
+ while (sref == null && 0 < timeout--)
+ {
+ try
+ {
+ Thread.sleep(fraktion);
+ }
+ catch (InterruptedException e)
+ {
+ // ignore
+ }
+ sref = getServiceReference(clazz);
+ }
+ return sref;
+ }
+
+ OSGiBundle getBundle(String symbolicName, Version version, boolean mustExist)
+ {
+ OSGiBundle bundle = null;
+ List<OSGiBundle> bundles = Arrays.asList(getBundles());
+ for (OSGiBundle aux : bundles)
+ {
+ if (aux.getSymbolicName().equals(symbolicName))
+ {
+ if (version == null || version.equals(aux.getVersion()))
+ {
+ bundle = aux;
+ break;
+ }
+ }
+ }
+
+ if (bundle == null && mustExist == true)
+ throw new IllegalStateException("Cannot obtain bundle: " + symbolicName + "-" + version + ". We have " + bundles);
+
+ return bundle;
+ }
+
+ String getManifestEntry(String location, String key)
+ {
+ Manifest manifest = getManifest(location);
+ Attributes attribs = manifest.getMainAttributes();
+ String value = attribs.getValue(key);
+ return value;
+ }
+
+ private Manifest getManifest(String location)
+ {
+ Manifest manifest;
+ try
+ {
+ File archiveFile = getTestHelper().getTestArchiveFile(location);
+ JarFile jarFile = new JarFile(archiveFile);
+ manifest = jarFile.getManifest();
+ jarFile.close();
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot get manifest from: " + location);
+
+ }
+ return manifest;
+ }
+
+ OSGiBundle registerBundle(String location, OSGiBundle bundle)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Cannot register null bundle for: " + location);
+
+ bundles.put(location, bundle);
+ return bundle;
+ }
+
+ void unregisterBundle(OSGiBundle bundle)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Cannot unregister null bundle");
+
+ if (bundles.containsValue(bundle))
+ {
+ Set<Entry<String, OSGiBundle>> entrySet = bundles.entrySet();
+ for (Entry<String, OSGiBundle> entry : entrySet)
+ {
+ if (bundle.equals(entry.getValue()))
+ {
+ String key = entry.getKey();
+ bundles.remove(key);
+ break;
+ }
+ }
+ }
+ }
+
+ private void failsafeUninstall(OSGiBundle bundle)
+ {
+ if (bundle != null)
+ {
+ try
+ {
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ bundle.uninstall();
+ }
+ catch (Exception ex)
+ {
+ log.warn("Cannot uninstall bundle: " + bundle, ex);
+ }
+ }
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,291 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+// $Id$
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.util.Dictionary;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.osgi.spi.management.ManagedBundle;
+import org.jboss.osgi.spi.management.ManagedBundleMBean;
+import org.jboss.osgi.spi.util.UnmodifiableDictionary;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
+import org.osgi.jmx.framework.BundleStateMBean;
+
+/**
+ * An implementation of a remote {@link OSGiBundle}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class RemoteBundle extends OSGiBundleImpl
+{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(RemoteBundle.class);
+
+ private long bundleId;
+ private String location;
+ private String symbolicName;
+ private ObjectName objectName;
+ private ManagedBundleMBean bundleMBean;
+ private Dictionary<String, String> defaultHeaders;
+ private Dictionary<String, String> rawHeaders;
+ private Version version;
+ boolean uninstalled;
+
+ public RemoteBundle(OSGiRuntime runtime, long bundleId)
+ {
+ super(runtime);
+ this.bundleId = bundleId;
+
+ BundleStateMBean bundleState = runtime.getBundleStateMBean();
+ try
+ {
+ symbolicName = bundleState.getSymbolicName(bundleId);
+ location = bundleState.getLocation(bundleId);
+
+ String versionStr = bundleState.getVersion(bundleId);
+ version = Version.parseVersion(versionStr);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot initialize remote bundle", ex);
+ }
+
+ objectName = ManagedBundle.getObjectName(bundleId, symbolicName, version);
+ bundleMBean = MBeanProxy.get(runtime.getMBeanServer(), objectName, ManagedBundleMBean.class);
+
+ // The getHeaders methods must continue to provide the manifest header
+ // information after the bundle enters the UNINSTALLED state.
+ defaultHeaders = bundleMBean.getHeaders(null);
+ rawHeaders = bundleMBean.getHeaders("");
+ }
+
+ @Override
+ public int getState()
+ {
+ if (uninstalled == true)
+ return Bundle.UNINSTALLED;
+
+ try
+ {
+ BundleStateMBean bundleState = getRuntime().getBundleStateMBean();
+ String state = bundleState.getState(bundleId);
+ if ("INSTALLED".equals(state))
+ return Bundle.INSTALLED;
+ if ("RESOLVED".equals(state))
+ return Bundle.RESOLVED;
+ if ("STARTING".equals(state))
+ return Bundle.STARTING;
+ if ("ACTIVE".equals(state))
+ return Bundle.ACTIVE;
+ if ("STOPPING".equals(state))
+ return Bundle.STOPPING;
+ if ("UNINSTALLED".equals(state))
+ return Bundle.UNINSTALLED;
+
+ }
+ catch (Exception rte)
+ {
+ Throwable cause = rte.getCause() != null ? rte.getCause() : rte;
+ if (cause instanceof InstanceNotFoundException == false)
+ log.warn("Cannot get state for bundle: " + bundleId, cause);
+ }
+ return Bundle.UNINSTALLED;
+ }
+
+ @Override
+ public long getBundleId()
+ {
+ return bundleId;
+ }
+
+ @Override
+ public String getSymbolicName()
+ {
+ return symbolicName;
+ }
+
+ @Override
+ public Version getVersion()
+ {
+ return version;
+ }
+
+ @Override
+ public String getLocation()
+ {
+ return location;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Dictionary<String, String> getHeaders()
+ {
+ return new UnmodifiableDictionary(defaultHeaders);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Dictionary<String, String> getHeaders(String locale)
+ {
+ if (locale == null)
+ return new UnmodifiableDictionary(defaultHeaders);
+ else if (locale.length() == 0)
+ return new UnmodifiableDictionary(rawHeaders);
+ else
+ return bundleMBean.getHeaders(locale);
+ }
+
+ @Override
+ public String getProperty(String key)
+ {
+ assertNotUninstalled();
+ return bundleMBean.getProperty(key);
+ }
+
+ @Override
+ public URL getEntry(String path)
+ {
+ assertNotUninstalled();
+ return toURL(bundleMBean.getEntry(path), null);
+ }
+
+ @Override
+ public URL getResource(String name)
+ {
+ assertNotUninstalled();
+ return toURL(bundleMBean.getResource(name), null);
+ }
+
+ @Override
+ public File getDataFile(String filename)
+ {
+ assertNotUninstalled();
+ return bundleMBean.getDataFile(filename);
+ }
+
+ @Override
+ public OSGiBundle loadClass(String name) throws ClassNotFoundException
+ {
+ assertNotUninstalled();
+ ObjectName providerBundle = bundleMBean.loadClass(name);
+ if (providerBundle == null)
+ return null;
+
+ String bundleId = providerBundle.getKeyProperty(ManagedBundle.PROPERTY_ID);
+ return getRuntime().getBundle(new Long(bundleId));
+ }
+
+ @Override
+ public void start() throws BundleException
+ {
+ assertNotUninstalled();
+ try
+ {
+ getRuntime().getFrameworkMBean().startBundle(bundleId);
+ }
+ catch (IOException ex)
+ {
+ throw new BundleException("Cannot start bundle: " + objectName, ex);
+ }
+ }
+
+ @Override
+ public void stop() throws BundleException
+ {
+ assertNotUninstalled();
+ try
+ {
+ getRuntime().getFrameworkMBean().stopBundle(bundleId);
+ }
+ catch (IOException ex)
+ {
+ throw new BundleException("Cannot stop bundle: " + objectName, ex);
+ }
+ }
+
+ @Override
+ public void uninstall() throws BundleException
+ {
+ assertNotUninstalled();
+ try
+ {
+ OSGiRuntimeImpl runtimeImpl = (OSGiRuntimeImpl)getRuntime();
+ runtimeImpl.getFrameworkMBean().uninstallBundle(bundleId);
+ runtimeImpl.unregisterBundle(this);
+ uninstalled = true;
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot uninstall: " + getLocation(), ex);
+ }
+ }
+
+ private URL toURL(String urlstr, URLStreamHandler sh)
+ {
+ if (urlstr == null)
+ return null;
+
+ try
+ {
+ return sh == null ? new URL(urlstr) : new URL(null, urlstr, sh);
+ }
+ catch (MalformedURLException ex)
+ {
+ // In case of the 'bundle' and 'bundleentry' protocol, use a dummy URLStreamHandler
+ // Access to remote content via the bundle URL is invalid anyway
+ if (sh == null && urlstr.startsWith("bundle"))
+ {
+ sh = new URLStreamHandler()
+ {
+ @Override
+ protected URLConnection openConnection(URL url) throws IOException
+ {
+ return null;
+ }
+ };
+ return toURL(urlstr, sh);
+ }
+ throw new IllegalArgumentException("Invalid URL: " + urlstr);
+ }
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteFramework.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteFramework.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteFramework.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+//$Id$
+
+import org.jboss.osgi.spi.management.ManagedServiceReference;
+
+/**
+ * The supported functionality of a remote OSGi Framework
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 04-Mar-2009
+ */
+public interface RemoteFramework
+{
+ /**
+ * Returns a ServiceReference object for a service that implements and was registered
+ * under the specified class.
+ */
+ ManagedServiceReference getServiceReference(String clazz);
+
+ /**
+ * Returns an array of ManagedServiceReference objects.
+ * The returned array of ManagedServiceReference objects contains services
+ * that were registered under the specified class, match the specified filter criteria,
+ * and the packages for the class names under which the services were registered.
+ */
+ ManagedServiceReference[] getServiceReferences(String clazz, String filter);
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteFramework.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteFrameworkException.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteFrameworkException.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteFrameworkException.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+// $Id$
+
+/**
+ * A remote OSGi Framework exception that should be thrown on unrecoverable errors.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jan-2009
+ */
+ at SuppressWarnings("serial")
+public class RemoteFrameworkException extends RuntimeException
+{
+ public RemoteFrameworkException(String message)
+ {
+ super(message);
+ }
+
+ public RemoteFrameworkException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public RemoteFrameworkException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteFrameworkException.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+import java.io.IOException;
+
+import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiPackageAdmin;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.osgi.jmx.framework.FrameworkMBean;
+
+/**
+ * A remote implementation of the {@link OSGiPackageAdmin}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class RemotePackageAdmin implements OSGiPackageAdmin
+{
+ private OSGiRuntime runtime;
+
+ public RemotePackageAdmin(OSGiRuntime runtime)
+ {
+ this.runtime = runtime;
+ }
+
+ public boolean resolveBundles(OSGiBundle[] bundles)
+ {
+ // JMX FrameworkMBean does not allow to resolve/refresh all bundles
+ // https://www.osgi.org/members/bugzilla/show_bug.cgi?id=1586
+ if (bundles == null)
+ {
+ ManagedFrameworkMBean mbeanProxy = MBeanProxy.get(runtime.getMBeanServer(), ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK, ManagedFrameworkMBean.class);
+ return mbeanProxy.resolveAllBundles();
+ }
+
+ FrameworkMBean framework = runtime.getFrameworkMBean();
+ try
+ {
+ long[] ids = getBundleIds(bundles);
+ return framework.resolveBundles(ids);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot resolve bundles", ex);
+ }
+ }
+
+ public void refreshPackages(OSGiBundle[] bundles)
+ {
+ // JMX FrameworkMBean does not allow to resolve/refresh all bundles
+ // https://www.osgi.org/members/bugzilla/show_bug.cgi?id=1586
+ if (bundles == null)
+ {
+ ManagedFrameworkMBean mbeanProxy = MBeanProxy.get(runtime.getMBeanServer(), ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK, ManagedFrameworkMBean.class);
+ mbeanProxy.refreshAllPackages();
+ return;
+ }
+
+ FrameworkMBean framework = runtime.getFrameworkMBean();
+ try
+ {
+ long[] ids = getBundleIds(bundles);
+ framework.refreshPackages(ids);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot resolve bundles", ex);
+ }
+ }
+
+ private long[] getBundleIds(OSGiBundle[] bundles)
+ {
+ long[] ids = new long[bundles.length];
+ for (int i = 0; i < bundles.length; i++)
+ ids[i] = bundles[i].getBundleId();
+
+ return ids;
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,206 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+// $Id$
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
+import org.jboss.osgi.spi.management.ManagedServiceReference;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiPackageAdmin;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiServiceReference;
+import org.jboss.osgi.testing.OSGiTestHelper;
+import org.osgi.framework.BundleException;
+import org.osgi.jmx.framework.BundleStateMBean;
+
+/**
+ * A remote implementation of the {@link OSGiRuntime}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class RemoteRuntime extends OSGiRuntimeImpl
+{
+ private MBeanServerConnection mbeanServer;
+
+ public RemoteRuntime(OSGiTestHelper helper)
+ {
+ super(helper);
+ }
+
+ public OSGiBundle installBundle(String location) throws BundleException
+ {
+ try
+ {
+ // Get the bundle info from the location
+ BundleInfo info = BundleInfo.createBundleInfo(location);
+ String rootURL = info.getRootURL().toExternalForm();
+
+ long bundleId = getFrameworkMBean().installBundle(rootURL);
+
+ RemoteBundle bundle = new RemoteBundle(this, bundleId);
+ return registerBundle(bundle.getLocation(), bundle);
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (BundleException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new BundleException("Cannot install: " + location, ex);
+ }
+ }
+
+ public void deploy(String location) throws Exception
+ {
+ URL archiveURL = getTestHelper().getTestArchiveURL(location);
+ MainDeployerClient deployer = new MainDeployerClient(this);
+ deployer.deploy(archiveURL);
+ }
+
+ public void undeploy(String location) throws Exception
+ {
+ URL archiveURL = getTestHelper().getTestArchiveURL(location);
+ MainDeployerClient deployer = new MainDeployerClient(this);
+ deployer.undeploy(archiveURL);
+ }
+
+ public OSGiBundle[] getBundles()
+ {
+ Set<OSGiBundle> bundles = new HashSet<OSGiBundle>();
+ try
+ {
+ TabularData listBundles = getBundleStateMBean().listBundles();
+ Iterator<?> iterator = listBundles.values().iterator();
+ while(iterator.hasNext())
+ {
+ CompositeData next = (CompositeData)iterator.next();
+ Object bundleId = next.get(BundleStateMBean.IDENTIFIER);
+ bundles.add(new RemoteBundle(this, (Long)bundleId));
+ }
+
+ OSGiBundle[] bundleArr = new OSGiBundle[bundles.size()];
+ bundles.toArray(bundleArr);
+ return bundleArr;
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot obtain remote bundles", ex);
+ }
+ }
+
+ public OSGiBundle getBundle(long bundleId)
+ {
+ for (OSGiBundle bundle : getBundles())
+ {
+ if (bundleId == bundle.getBundleId())
+ return bundle;
+ }
+ return null;
+ }
+
+ public OSGiServiceReference getServiceReference(String clazz)
+ {
+ ManagedServiceReference manref = getRemoteFramework().getServiceReference(clazz);
+ return manref != null ? new RemoteServiceReference(manref) : null;
+ }
+
+ public OSGiServiceReference[] getServiceReferences(String clazz, String filter)
+ {
+ OSGiServiceReference[] srefs = null;
+
+ ManagedServiceReference[] manrefs = getRemoteFramework().getServiceReferences(clazz, filter);
+ if (manrefs != null)
+ {
+ srefs = new OSGiServiceReference[manrefs.length];
+ for (int i = 0; i < manrefs.length; i++)
+ srefs[i] = new RemoteServiceReference(manrefs[i]);
+ }
+
+ return srefs;
+ }
+
+ public MBeanServerConnection getMBeanServer()
+ {
+ if (mbeanServer == null)
+ {
+ try
+ {
+ InitialContext iniCtx = getInitialContext();
+ mbeanServer = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
+ }
+ catch (NamingException ex)
+ {
+ throw new IllegalStateException("Cannot obtain MBeanServerConnection", ex);
+ }
+ }
+ return mbeanServer;
+ }
+
+ public OSGiPackageAdmin getPackageAdmin()
+ {
+ return new RemotePackageAdmin(this);
+ }
+
+ private RemoteFramework getRemoteFramework()
+ {
+ ObjectName objectName = ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK;
+ final ManagedFrameworkMBean managedFramework = MBeanProxy.get(getMBeanServer(), objectName, ManagedFrameworkMBean.class);
+
+ return new RemoteFramework()
+ {
+ public ManagedServiceReference getServiceReference(String clazz)
+ {
+ return managedFramework.getServiceReference(clazz);
+ }
+
+ public ManagedServiceReference[] getServiceReferences(String clazz, String filter)
+ {
+ return managedFramework.getServiceReferences(clazz, filter);
+ }
+ };
+ }
+
+ public boolean isRemoteRuntime()
+ {
+ return true;
+ }
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteServiceReference.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteServiceReference.java (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteServiceReference.java 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.testing.internal;
+
+import org.jboss.osgi.spi.management.ManagedServiceReference;
+import org.jboss.osgi.testing.OSGiServiceReference;
+
+/**
+ * A remote implementation of the {@link OSGiServiceReference}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class RemoteServiceReference implements OSGiServiceReference
+{
+ private ManagedServiceReference sref;
+
+ public RemoteServiceReference(ManagedServiceReference sref)
+ {
+ this.sref = sref;
+ }
+
+ public Object getProperty(String key)
+ {
+ return sref.getProperty(key);
+ }
+
+ public String[] getPropertyKeys()
+ {
+ return sref.getPropertyKeys();
+ }
+
+}
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteServiceReference.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/package.html
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/package.html (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/package.html 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,5 @@
+<html>
+<body>
+OSGi test support classes and interfaces.
+</body>
+</html>
Added: projects/jboss-osgi/projects/testing/trunk/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/test/resources/jboss-osgi-framework.properties (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/test/resources/jboss-osgi-framework.properties 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,40 @@
+#
+# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
+#
+# $Id$
+#
+
+# Properties to configure the Framework
+org.osgi.framework.storage=${test.archive.directory}/../osgi-store
+org.osgi.framework.storage.clean=onFirstInit
+
+# Husky socket connector properties
+org.jboss.osgi.husky.runtime.connector.host=localhost
+org.jboss.osgi.husky.runtime.connector.port=5401
+
+# Framework bootdelegation
+# org.osgi.framework.bootdelegation=org.osgi.service.log
+
+# Extra System Packages
+org.osgi.framework.system.packages.extra=\
+ org.apache.log4j;version=1.2, \
+ org.jboss.logging;version=2.1, \
+ org.jboss.osgi.deployment.deployer;version=1.0, \
+ org.jboss.osgi.deployment.interceptor;version=1.0, \
+ org.jboss.osgi.spi;version=1.0, \
+ org.jboss.osgi.spi.capability;version=1.0, \
+ org.jboss.osgi.spi.framework;version=1.0, \
+ org.jboss.osgi.spi.management;version=1.0, \
+ org.jboss.osgi.spi.service;version=1.0, \
+ org.jboss.osgi.spi.util;version=1.0, \
+ org.jboss.virtual;version=2.1, \
+ org.osgi.framework;version=1.5
+
+# Bundles that need to be installed with the Framework automatically
+org.jboss.osgi.spi.framework.autoInstall=\
+ file://${test.archive.directory}/bundles/org.osgi.compendium.jar
+
+# Bundles that need to be started automatically
+org.jboss.osgi.spi.framework.autoStart=\
+ file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
+ file://${test.archive.directory}/bundles/jboss-osgi-common.jar
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/test/resources/jboss-osgi-framework.properties
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/testing/trunk/src/test/resources/log4j.xml
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/test/resources/log4j.xml (rev 0)
+++ projects/jboss-osgi/projects/testing/trunk/src/test/resources/log4j.xml 2010-02-19 10:43:03 UTC (rev 101149)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <appender name="FILE" class="org.apache.log4j.FileAppender">
+ <param name="File" value="${log4j.output.dir}/test.log"/>
+ <param name="Append" value="false"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <param name="Threshold" value="INFO" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{1}] %m%n" />
+ </layout>
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <!-- Show jboss deployer traces
+ <category name="org.jboss.deployers">
+ <priority value="TRACE" />
+ </category>
+ -->
+
+ <!-- Show jboss deployer traces
+ <category name="org.jboss.xb">
+ <priority value="TRACE" />
+ </category>
+ -->
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <!--appender-ref ref="CONSOLE"/-->
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Property changes on: projects/jboss-osgi/projects/testing/trunk/src/test/resources/log4j.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jboss-osgi-commits
mailing list