Skip to content

Commit

Permalink
proper setu
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Neubauer committed Apr 30, 2012
1 parent 4ebb8a8 commit dabb108
Showing 1 changed file with 55 additions and 41 deletions.
Expand Up @@ -28,6 +28,9 @@
import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle; import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd; import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;


import java.util.ArrayList;
import java.util.Arrays;

import org.junit.Test; import org.junit.Test;
import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.index.Index; import org.neo4j.graphdb.index.Index;
Expand All @@ -42,67 +45,78 @@
import org.osgi.framework.Bundle; import org.osgi.framework.Bundle;
import org.osgi.framework.Constants; import org.osgi.framework.Constants;


public class OSGiTest { public class OSGiTest
{


public static final String NEO4J_VERSION = "1.8-SNAPSHOT"; public static final String NEO4J_VERSION = "1.8-SNAPSHOT";
public static final String GERONIMO_JTA_VERSION = "1.1.1"; public static final String GERONIMO_JTA_VERSION = "1.1.1";


@Test @Test
public void neo4jStartupTestFelix() public void neo4jStartupTestFelix() throws Exception
throws Exception
{ {


Option[] options = testOptions( ); Option[] options = testOptions();
Player player = new Player().with( Player player = new Player().with( options );
options test( player, 19 );
);
test(player, 19);
} }


public Option[] testOptions( ) public Option[] gogoShellOptions()
{ {
String gogoVersion = "0.8.0"; String gogoVersion = "0.8.0";
return options(
mavenBundle().groupId( "org.ops4j.pax.logging" ).artifactId(
"pax-logging-api" ).version( "1.6.1" ),
mavenBundle().groupId( "org.osgi" ).artifactId(
"org.osgi.compendium" ).version( "4.2.0" ),
mavenBundle().groupId( "org.apache.felix" ).artifactId(
"org.apache.felix.gogo.runtime" ).version( gogoVersion ),
mavenBundle().groupId( "org.apache.felix" ).artifactId(
"org.apache.felix.gogo.shell" ).version( gogoVersion ),
mavenBundle().groupId( "org.apache.felix" ).artifactId(
"org.apache.felix.gogo.command" ).version( gogoVersion ) );
}

public Option[] testOptions()
{
Option[] options = options( Option[] options = options(
repository("https://oss.sonatype.org/content/groups/ops4j/"), repository( "https://oss.sonatype.org/content/groups/ops4j/" ),
cleanCaches(), cleanCaches(),
frameworkStartLevel( 10), frameworkStartLevel( 10 ),
mavenBundle().groupId( "org.apache.geronimo.specs" ).artifactId( "geronimo-jta_1.1_spec" ).version( GERONIMO_JTA_VERSION ), mavenBundle().groupId( "org.apache.geronimo.specs" ).artifactId(
wrappedBundle( mavenBundle().groupId( "org.apache.lucene" ).artifactId( "lucene-core" ).version( "3.5.0" )), "geronimo-jta_1.1_spec" ).version( GERONIMO_JTA_VERSION ),
wrappedBundle( mavenBundle().groupId( "org.neo4j" ).artifactId( "neo4j-kernel" ).version( NEO4J_VERSION )), wrappedBundle( mavenBundle().groupId( "org.apache.lucene" ).artifactId(
wrappedBundle( mavenBundle().groupId( "org.neo4j" ).artifactId( "neo4j-lucene-index" ).version( NEO4J_VERSION )), "lucene-core" ).version( "3.5.0" ) ),
// mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version("1.6.1"), wrappedBundle( mavenBundle().groupId( "org.neo4j" ).artifactId(
// mavenBundle().groupId("org.osgi").artifactId("org.osgi.compendium").version("4.2.0"), "neo4j-kernel" ).version( NEO4J_VERSION ) ),
// wrappedBundle( mavenBundle().groupId( "org.neo4j" ).artifactId(
// mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.gogo.runtime").version(gogoVersion), "neo4j-lucene-index" ).version( NEO4J_VERSION ) ),
// mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.gogo.shell").version(gogoVersion), provision( bundle().add( Neo4jActivator.class ).set(
// mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.gogo.command").version(gogoVersion), Constants.BUNDLE_ACTIVATOR,
// workingDirectory( "target/server" ) Neo4jActivator.class.getName() ).build( withBnd() ) ) );
provision( bundle()
.add (Neo4jActivator.class )
.set( Constants.BUNDLE_ACTIVATOR, Neo4jActivator.class.getName() )
.build( withBnd() ) )
);
return options; return options;
} }


private void test(Player player, int expectedBundles) throws Exception private void test( Player player, int expectedBundles ) throws Exception
{ {
player player.test( WaitForService.class,
.test( WaitForService.class, GraphDatabaseService.class.getName(), 10000 ) GraphDatabaseService.class.getName(), 10000 ).test(
.test( WaitForService.class, Index.class.getName(), 15000 ) WaitForService.class, Index.class.getName(), 15000 ).test(
.test( CountBundles.class, expectedBundles) CountBundles.class, expectedBundles ).test(
.test( BundlesInState.class, Bundle.ACTIVE, Bundle.ACTIVE ) BundlesInState.class, Bundle.ACTIVE, Bundle.ACTIVE ).play();
.play();
} }


public static void main( String[] args ) public static void main( String[] args ) throws Exception
throws Exception
{ {
// create a proper ExamSystem with your options. Focus on "createServerSystem" // create a proper ExamSystem with your options. Focus on
ExamSystem system = PaxExamRuntime.createServerSystem( new OSGiTest().testOptions() ); // "createServerSystem"
OSGiTest instance = new OSGiTest();
ArrayList<Option> ops = new ArrayList<Option>();
ops.addAll( Arrays.asList( instance.testOptions() ) );
ops.addAll( Arrays.asList( instance.gogoShellOptions() ) );
ExamSystem system = PaxExamRuntime.createServerSystem( (Option[]) ops.toArray( new Option[] {} ) );
// create Container (you should have exactly one configured!) and start. // create Container (you should have exactly one configured!) and start.
TestContainer container = PaxExamRuntime.createContainer( system ); TestContainer container = PaxExamRuntime.createContainer( system );
container.start(); container.start();

} }
} }

0 comments on commit dabb108

Please sign in to comment.