本文整理汇总了Java中org.ops4j.pax.exam.ExamSystem类的典型用法代码示例。如果您正苦于以下问题:Java ExamSystem类的具体用法?Java ExamSystem怎么用?Java ExamSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExamSystem类属于org.ops4j.pax.exam包,在下文中一共展示了ExamSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: basicOSGiConnectionAcquireTest
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Test
@DisplayName( "test deployment on OSGi container" )
public void basicOSGiConnectionAcquireTest() throws Exception {
ExamSystem examSystem = PaxExamRuntime.createTestSystem(
CoreOptions.systemProperty( "org.ops4j.pax.logging.DefaultServiceLog.level" ).value( "WARN" ),
CoreOptions.mavenBundle().groupId( "io.agroal" ).artifactId( "agroal-api" ).versionAsInProject(),
CoreOptions.mavenBundle().groupId( "io.agroal" ).artifactId( "agroal-pool" ).versionAsInProject()
);
ExamReactor examReactor = new DefaultExamReactor( examSystem, PaxExamRuntime.getTestContainerFactory() );
examReactor.addProbe( AgroalProbe.getTestProbeBuilder( examSystem ) );
logger.info( "Starting OSGi container ..." );
StagedExamReactor stagedReactor = examReactor.stage( new PerClass() );
stagedReactor.beforeClass();
try {
for ( TestAddress call : stagedReactor.getTargets() ) {
stagedReactor.invoke( call );
}
logger.info( "Stopping OSGi container after successful invocation" );
} finally {
stagedReactor.afterClass();
}
}
示例2: create
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Override
public TestContainer[] create(ExamSystem system) {
// we use ServiceLoader to load the OSGi Framework Factory
List<TestContainer> containers = new ArrayList<>();
Iterator<FrameworkFactory> factories = ServiceLoader.load(FrameworkFactory.class)
.iterator();
boolean factoryFound = false;
while (factories.hasNext()) {
try {
containers.add(new MotechNativeTestContainer(system, factories.next()));
factoryFound = true;
} catch (IOException e) {
throw new TestContainerException("Problem initializing container.", e);
}
}
if (!factoryFound) {
throw new TestContainerException(
"No service org.osgi.framework.launch.FrameworkFactory found in META-INF/services on classpath");
}
return containers.toArray(new TestContainer[containers.size()]);
}
示例3: create
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Override
public TestContainer[] create(ExamSystem system) {
if (system.getOptions(CarbonDistributionBaseOption.class).length > 1) {
logger.warn("Multiple distribution options are specified in the configuration!!!");
}
List<TestContainer> containers = Arrays.stream(system.getOptions(CarbonDistributionBaseOption.class))
.map(option -> new CarbonTestContainer(system, option))
.collect(Collectors.toList());
if (containers.isEmpty()) {
containers.add(new CarbonTestContainer(system, getDefaultConfiguration()));
}
return containers.toArray(new TestContainer[containers.size()]);
}
示例4: run
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Test
public void run() throws Exception {
Assume.assumeTrue( RabbitMqTestUtils.checkRabbitMqIsRunning());
File appDirectory = TestUtils.findApplicationDirectory( "lamp" );
// Prepare to run an agent distribution
ExamSystem system = PaxExamRuntime.createServerSystem( config());
TestContainer container = PaxExamRuntime.createContainer( system );
Assert.assertEquals( KarafTestContainer.class, container.getClass());
WsClient client = null;
try {
// Start the DM's distribution... and wait... :(
container.start();
ItUtils.waitForDmRestServices( getCurrentPort());
// Find the Karaf directory
this.karafDirectory = TestUtils.getInternalField( container, "targetFolder", File.class );
Assert.assertNotNull( this.karafDirectory );
// Build a REST client
String rootUrl = "http://localhost:" + getCurrentPort() + "/roboconf-dm";
client = new WsClient( rootUrl );
// Perform the checks
testRestInteractions( appDirectory.getAbsolutePath(), rootUrl, client );
} finally {
container.stop();
if( client != null )
client.destroy();
}
}
示例5: setupSystemProperties
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
/**
* Setup system properties.
*
* @param options options
* @throws IOException
*/
private void setupSystemProperties(List<String> options, ExamSystem examSystem) throws IOException {
Arrays.asList(examSystem.getOptions(SystemPropertyOption.class)).forEach(systemPropertyOption -> {
String property = String.format("-D%s=%s", systemPropertyOption.getKey(), systemPropertyOption.getValue());
options.add(property);
});
}
示例6: getTestProbeBuilder
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
private static TestProbeBuilder getTestProbeBuilder(ExamSystem examSystem) throws IOException {
TestProbeBuilder testProbeBuilder = examSystem.createProbe();
testProbeBuilder.addTest( AgroalProbe.class );
return testProbeBuilder;
}
示例7: MotechNativeTestContainer
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
public MotechNativeTestContainer(ExamSystem system, FrameworkFactory frameworkFactory) throws IOException {
super(system, frameworkFactory);
examSystem = system;
}
示例8: run
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Test
public void run() throws Exception {
Assume.assumeTrue( RabbitMqTestUtils.checkRabbitMqIsRunning());
// Prepare to run an agent distribution
Option[] options = super.config();
ExamSystem system = PaxExamRuntime.createServerSystem( options );
TestContainer container = PaxExamRuntime.createContainer( system );
Assert.assertEquals( KarafTestContainer.class, container.getClass());
try {
// Start the DM's distribution... and wait... :(
container.start();
ItUtils.waitForDmRestServices( getCurrentPort());
// The console may take time to be ready
Thread.sleep( 4000 );
// Since this test runs outside Karaf, we cannot rely on System.getProperty( "karaf.base" );
// So, we need to extract the Karaf directory by Java reflection.
File karafDirectory = TestUtils.getInternalField( container, "targetFolder", File.class );
Assert.assertNotNull( karafDirectory );
File binDirectory = new File( karafDirectory, "bin" );
Assert.assertTrue( binDirectory.exists());
Logger logger = Logger.getLogger( getClass().getName());
LogManager.getLogManager().addLogger( logger );
logger.setLevel( Level.ALL );
final StringHandler logHandler = new StringHandler();
logger.addHandler( logHandler );
List<String> command = new ArrayList<> ();
command.add( "/bin/sh" );
command.add( "client" );
command.add( "feature:list" );
int code = ProgramUtils.executeCommand( logger, command, binDirectory, null, null, null);
Assert.assertEquals( 0, code );
Assert.assertTrue( logHandler.getLogs().contains( "ipojo-all" ));
} finally {
container.stop();
}
}
示例9: run
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Test
public void run() throws Exception {
Assume.assumeTrue( RabbitMqTestUtils.checkRabbitMqIsRunning());
// Prepare to run a DM distribution
Option[] options = super.config();
ExamSystem system = PaxExamRuntime.createServerSystem( options );
TestContainer container = PaxExamRuntime.createContainer( system );
Assert.assertEquals( KarafTestContainer.class, container.getClass());
try {
// Start the DM's distribution... and wait... :(
container.start();
ItUtils.waitForDmRestServices( getCurrentPort());
// Verify we get the default CSS, which is quite big
Logger logger = Logger.getLogger( getClass().getName());
String cssUrl = "http://localhost:" + getCurrentPort() + "/roboconf-web-administration/roboconf.min.css";
String cssContent = Utils.readUrlContentQuietly( cssUrl, logger );
Assert.assertTrue( cssContent.length() > 100 );
// Now, override it with our custom one and verify it is returned by our servlet
//
// Since this test runs outside Karaf, we cannot rely on System.getProperty( "karaf.base" );
// So, we need to extract the Karaf directory by Java reflection.
File karafDirectory = TestUtils.getInternalField( container, "targetFolder", File.class );
Assert.assertNotNull( karafDirectory );
File etcDirectory = new File( karafDirectory, "etc" );
Utils.writeStringInto( "hi!", new File( etcDirectory, "roboconf.custom.css" ));
// Now, verify what we get
cssUrl = "http://localhost:" + getCurrentPort() + "/roboconf-web-administration/roboconf.min.css";
cssContent = Utils.readUrlContentQuietly( cssUrl, logger );
Assert.assertEquals( "hi!", cssContent );
// Verify that by default, there is no web extension
String url = "http://localhost:" + getCurrentPort() + "/roboconf-dm/preferences";
String received = Utils.readUrlContentQuietly( url, logger );
String expected = "{\"name\":\"" + IPreferencesMngr.WEB_EXTENSIONS + "\",\"value\":\"\",";
Assert.assertTrue( received.contains( expected ));
} finally {
container.stop();
}
}
示例10: run
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Test
public void run() throws Exception {
Assume.assumeTrue( RabbitMqTestUtils.checkRabbitMqIsRunning());
// Prepare to run an agent distribution
Option[] options = super.config();
ExamSystem system = PaxExamRuntime.createServerSystem( options );
TestContainer container = PaxExamRuntime.createContainer( system );
Assert.assertEquals( KarafTestContainer.class, container.getClass());
try {
// Start the agent's distribution... and wait... :(
container.start();
ItUtils.waitForDmRestServices( getCurrentPort());
// Try to connect to our web socket.
WebSocketClient client = new WebSocketClient();
TestWebsocket socket = new TestWebsocket();
try {
client.start();
URI echoUri = new URI( "ws://localhost:" + getCurrentPort() + "/roboconf-dm-websocket" );
ClientUpgradeRequest request = new ClientUpgradeRequest();
client.connect( socket, echoUri, request );
// Wait more or less (Travis builds with Java 8 may need it).
for( int i=0; i<10; i++ ) {
Thread.sleep( 2000 );
if( socket.wasConnected )
break;
}
} finally {
client.stop();
}
// Did the connection work?
Assert.assertTrue( socket.wasConnected );
} finally {
container.stop();
}
}
示例11: run
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Test
public void run() throws Exception {
Assume.assumeTrue( RabbitMqTestUtils.checkRabbitMqIsRunning());
// Prepare to run a DM distribution
String roboconfVersion = ItUtils.findRoboconfVersion();
List<Option> options = new ArrayList<>( Arrays.asList( super.config()));
options.add( mavenBundle()
.groupId( "net.roboconf" )
.artifactId( "roboconf-web-extension-for-kibana" )
.version( roboconfVersion )
.start());
ExamSystem system = PaxExamRuntime.createServerSystem( ItUtils.asArray( options ));
TestContainer container = PaxExamRuntime.createContainer( system );
Assert.assertEquals( KarafTestContainer.class, container.getClass());
try {
// Start the DM's distribution... and wait... :(
container.start();
ItUtils.waitForDmRestServices( getCurrentPort());
// It may not work at the first time, since the extension needs to be loaded.
// Verify that by default, there is a web extension
boolean found = false;
URL url = new URL( "http://localhost:" + getCurrentPort() + "/roboconf-dm/preferences" );
for( int i=0; i<10; i++ ) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
InputStream in = url.openStream();
try {
Utils.copyStreamUnsafelyUseWithCaution( in, os );
} finally {
Utils.closeQuietly( in );
}
String received = os.toString( "UTF-8" );
String expected = "{\"name\":\"" + IPreferencesMngr.WEB_EXTENSIONS + "\",\"value\":\"" + KibanaExtensionConstants.CONTEXT + "\",";
found = received.contains( expected );
if( found )
break;
}
Assert.assertTrue( found );
} finally {
container.stop();
}
}
示例12: run
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Test
public void run() throws Exception {
Assume.assumeTrue( RabbitMqTestUtils.checkRabbitMqIsRunning());
// Prepare karaf container
Option[] options = super.config();
ExamSystem system = PaxExamRuntime.createServerSystem( options );
TestContainer container = PaxExamRuntime.createContainer( system );
Assert.assertEquals( KarafTestContainer.class, container.getClass());
try {
// Start the DM's distribution... and wait... :(
container.start();
ItUtils.waitForDmRestServices( getCurrentPort());
// The console may take time to be ready
Thread.sleep( 4000 );
// Get Karaf directory by Java reflection.
File karafDirectory = TestUtils.getInternalField( container, "targetFolder", File.class );
Assert.assertNotNull( karafDirectory );
File binDirectory = new File( karafDirectory, "bin" );
Assert.assertTrue( binDirectory.exists());
Logger execLogger = Logger.getLogger( getClass().getName());
LogManager.getLogManager().addLogger( execLogger );
execLogger.setLevel( Level.ALL );
final StringHandler logHandler = new StringHandler();
execLogger.addHandler( logHandler );
// Targets list
Map<String,String> targets = new HashMap<> ();
targets.put( "roboconf:target in-memory", "Roboconf :: Target :: In-Memory" );
targets.put( "roboconf:target openstack", "Roboconf :: Target :: Openstack IaaS" );
targets.put( "roboconf:target aws", "Roboconf :: Target :: EC2 IaaS" );
targets.put( "roboconf:target docker", "Roboconf :: Target :: Docker" );
targets.put( "roboconf:target embedded", "Roboconf :: Target :: Embedded" );
targets.put( "roboconf:target azure", "Roboconf :: Target :: Azure IaaS" );
targets.put( "roboconf:target occi", "Roboconf :: Target :: OCCI" );
// Verify if all targets are deployed
for( String target : targets.keySet() ) {
this.logger.info( "Installing " + target + "..." );
List<String> command = new ArrayList<> ();
command.add( "/bin/sh" );
command.add( "client" );
command.add( target );
int code = ProgramUtils.executeCommand( execLogger, command, binDirectory, null, null, null );
if( code != 0 ) {
System.out.println( "\n\n\n" + logHandler.getLogs() + "\n\n\n" );
}
Assert.assertEquals( "Handler for " + target + " failed to be deployed.", 0, code );
Assert.assertFalse(
"Handler for " + target + " failed to be deployed (exec).",
logHandler.getLogs().contains( "Error" ));
}
// Verify if all targets are in bundle list
List<String> cmd = new ArrayList<> ();
cmd.add( "/bin/sh" );
cmd.add( "client" );
cmd.add( "bundle:list" );
int c = ProgramUtils.executeCommand( execLogger, cmd, binDirectory, null, null, null );
Assert.assertEquals( 0, c );
for( String value : targets.values() ) {
Assert.assertTrue( logHandler.getLogs().contains( value ) );
}
} finally {
container.stop();
}
}
示例13: run
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Test
public void run() throws Exception {
Assume.assumeTrue( RabbitMqTestUtils.checkRabbitMqIsRunning());
// Prepare to run an agent distribution
Option[] options = super.config();
ExamSystem system = PaxExamRuntime.createServerSystem( options );
TestContainer container = PaxExamRuntime.createContainer( system );
Assert.assertEquals( KarafTestContainer.class, container.getClass());
try {
// Start the agent's distribution... and wait... :(
container.start();
Thread.sleep( ItUtils.getTimeout() / 3 );
// Since this test runs outside Karaf, we cannot rely on System.getProperty( "karaf.base" );
// So, we need to extract the Karaf directory by Java reflection.
File karafDirectory = TestUtils.getInternalField( container, "targetFolder", File.class );
Assert.assertNotNull( karafDirectory );
File binDirectory = new File( karafDirectory, "bin" );
Assert.assertTrue( binDirectory.exists());
Logger logger = Logger.getLogger( getClass().getName());
LogManager.getLogManager().addLogger( logger );
logger.setLevel( Level.ALL );
final StringHandler logHandler = new StringHandler();
logger.addHandler( logHandler );
List<String> command = new ArrayList<> ();
command.add( "/bin/sh" );
command.add( "client" );
command.add( "feature:list" );
int code = ProgramUtils.executeCommand( logger, command, binDirectory, null, null, null);
Assert.assertEquals( 0, code );
Assert.assertTrue( logHandler.getLogs().contains( "ipojo-all" ));
} finally {
container.stop();
}
}
示例14: run
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Test
public void run() throws Exception {
Assume.assumeTrue( RabbitMqTestUtils.checkRabbitMqIsRunning());
// Prepare karaf container
Option[] options = super.config();
ExamSystem system = PaxExamRuntime.createServerSystem( options );
TestContainer container = PaxExamRuntime.createContainer( system );
Assert.assertEquals( KarafTestContainer.class, container.getClass());
try {
// Start the DM's distribution... and wait... :(
container.start();
Thread.sleep( ItUtils.getTimeout() / 3 );
// The console may take time to be ready
Thread.sleep( 4000 );
// Get Karaf directory by Java reflection.
File karafDirectory = TestUtils.getInternalField( container, "targetFolder", File.class );
Assert.assertNotNull( karafDirectory );
File binDirectory = new File( karafDirectory, "bin" );
Assert.assertTrue( binDirectory.exists());
Logger execLogger = Logger.getLogger( getClass().getName());
LogManager.getLogManager().addLogger( execLogger );
execLogger.setLevel( Level.ALL );
final StringHandler logHandler = new StringHandler();
execLogger.addHandler( logHandler );
// Targets list
Map<String,String> plugins = new HashMap<> ();
plugins.put( "roboconf:plugin file", "Roboconf :: Plugin :: File" );
plugins.put( "roboconf:plugin logger", "Roboconf :: Plugin :: Logger" );
plugins.put( "roboconf:plugin script", "Roboconf :: Plugin :: Script" );
plugins.put( "roboconf:plugin puppet", "Roboconf :: Plugin :: Puppet" );
// Verify if all targets are deployed
for( String plugin : plugins.keySet() ) {
this.logger.info( "Installing " + plugin + "..." );
List<String> command = new ArrayList<> ();
command.add( "/bin/sh" );
command.add( "client" );
command.add( plugin );
int code = ProgramUtils.executeCommand( execLogger, command, binDirectory, null, null, null );
if( code != 0 ) {
System.out.println( "\n\n\n" + logHandler.getLogs() + "\n\n\n" );
}
Assert.assertEquals( "Agent extension for " + plugin + " failed to be deployed.", 0, code );
Assert.assertFalse(
"Agent extension for " + plugin + " failed to be deployed (exec).",
logHandler.getLogs().contains( "Error" ));
}
// Verify if all targets are in bundle list
List<String> cmd = new ArrayList<> ();
cmd.add( "/bin/sh" );
cmd.add( "client" );
cmd.add( "bundle:list" );
int c = ProgramUtils.executeCommand( execLogger, cmd, binDirectory, null, null, null );
Assert.assertEquals( 0, c );
for( String value : plugins.values() ) {
Assert.assertTrue( logHandler.getLogs().contains( value ) );
}
} finally {
container.stop();
}
}
示例15: run
import org.ops4j.pax.exam.ExamSystem; //导入依赖的package包/类
@Test
public void run() throws Exception {
// We copy an application template and we add it a command
Assume.assumeTrue( RabbitMqTestUtils.checkRabbitMqIsRunning());
File sourceAppDirectory = TestUtils.findApplicationDirectory( "lamp" );
File appDirectory = this.folder.newFolder();
Utils.copyDirectory( sourceAppDirectory, appDirectory );
// Create a command that writes into a file
this.tmpFile = File.createTempFile( "roboconf-it-", "scheduler" );
Utils.deleteFilesRecursively( this.tmpFile );
Assert.assertFalse( this.tmpFile.exists());
File cmdFile = new File( appDirectory, Constants.PROJECT_DIR_COMMANDS + "/append something" + Constants.FILE_EXT_COMMANDS );
Utils.deleteFilesRecursively( cmdFile.getParentFile());
Utils.deleteFilesRecursively( new File( appDirectory, Constants.PROJECT_DIR_RULES_AUTONOMIC ));
Assert.assertTrue( cmdFile.getParentFile().mkdirs());
Utils.writeStringInto( "append this into " + this.tmpFile.getAbsolutePath(), cmdFile );
// Prepare to run an agent distribution
Option[] options = config();
ExamSystem system = PaxExamRuntime.createServerSystem( options );
TestContainer container = PaxExamRuntime.createContainer( system );
Assert.assertEquals( KarafTestContainer.class, container.getClass());
WsClient client = null;
try {
// Start the DM's distribution... and wait... :(
container.start();
ItUtils.waitForDmRestServices( getCurrentPort());
// Find the Karaf directory
this.karafDirectory = TestUtils.getInternalField( container, "targetFolder", File.class );
Assert.assertNotNull( this.karafDirectory );
// Build a REST client
String rootUrl = "http://localhost:" + getCurrentPort() + "/roboconf-dm";
client = new WsClient( rootUrl );
// Perform the checks
testScheduler( appDirectory.getAbsolutePath(), client );
} finally {
container.stop();
if( client != null )
client.destroy();
}
}