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.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import static org.ops4j.pax.tinybundles.core.TinyBundles.bundle;
import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;

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

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

public class OSGiTest {
public class OSGiTest
{

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

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

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

public Option[] testOptions( )
public Option[] gogoShellOptions()
{
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(
repository("https://oss.sonatype.org/content/groups/ops4j/"),
cleanCaches(),
frameworkStartLevel( 10),
mavenBundle().groupId( "org.apache.geronimo.specs" ).artifactId( "geronimo-jta_1.1_spec" ).version( GERONIMO_JTA_VERSION ),
wrappedBundle( mavenBundle().groupId( "org.apache.lucene" ).artifactId( "lucene-core" ).version( "3.5.0" )),
wrappedBundle( mavenBundle().groupId( "org.neo4j" ).artifactId( "neo4j-kernel" ).version( NEO4J_VERSION )),
wrappedBundle( mavenBundle().groupId( "org.neo4j" ).artifactId( "neo4j-lucene-index" ).version( NEO4J_VERSION )),
// 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),
// workingDirectory( "target/server" )
provision( bundle()
.add (Neo4jActivator.class )
.set( Constants.BUNDLE_ACTIVATOR, Neo4jActivator.class.getName() )
.build( withBnd() ) )
);
repository( "https://oss.sonatype.org/content/groups/ops4j/" ),
cleanCaches(),
frameworkStartLevel( 10 ),
mavenBundle().groupId( "org.apache.geronimo.specs" ).artifactId(
"geronimo-jta_1.1_spec" ).version( GERONIMO_JTA_VERSION ),
wrappedBundle( mavenBundle().groupId( "org.apache.lucene" ).artifactId(
"lucene-core" ).version( "3.5.0" ) ),
wrappedBundle( mavenBundle().groupId( "org.neo4j" ).artifactId(
"neo4j-kernel" ).version( NEO4J_VERSION ) ),
wrappedBundle( mavenBundle().groupId( "org.neo4j" ).artifactId(
"neo4j-lucene-index" ).version( NEO4J_VERSION ) ),
provision( bundle().add( Neo4jActivator.class ).set(
Constants.BUNDLE_ACTIVATOR,
Neo4jActivator.class.getName() ).build( withBnd() ) ) );
return options;
}

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

public static void main( String[] args )
throws Exception

public static void main( String[] args ) throws Exception
{
// create a proper ExamSystem with your options. Focus on "createServerSystem"
ExamSystem system = PaxExamRuntime.createServerSystem( new OSGiTest().testOptions() );
// create a proper ExamSystem with your options. Focus on
// "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.
TestContainer container = PaxExamRuntime.createContainer( system );
container.start();

}
}

0 comments on commit dabb108

Please sign in to comment.