本文整理汇总了Java中io.bootique.BQRuntime.run方法的典型用法代码示例。如果您正苦于以下问题:Java BQRuntime.run方法的具体用法?Java BQRuntime.run怎么用?Java BQRuntime.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.bootique.BQRuntime
的用法示例。
在下文中一共展示了BQRuntime.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRun_Debug
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testRun_Debug() throws IOException {
File logFile = prepareLogFile("target/logback/testRun_Debug.log");
BQRuntime runtime = app
.app("--config=src/test/resources/io/bootique/bom/logback/test-debug.yml").createRuntime();
CommandOutcome outcome = runtime.run();
// stopping runtime to ensure the logs are flushed before we start making assertions...
runtime.shutdown();
assertEquals(0, outcome.getExitCode());
assertTrue(logFile.isFile());
String logfileContents = Files.lines(logFile.toPath()).collect(joining("\n"));
assertTrue(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-debug"));
assertTrue(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-info"));
assertTrue(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-warn"));
assertTrue(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-error"));
}
示例2: testRun_Warn
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testRun_Warn() throws IOException {
File logFile = prepareLogFile("target/logback/testRun_Warn.log");
BQRuntime runtime = app.app("--config=src/test/resources/io/bootique/bom/logback/test-warn.yml")
.createRuntime();
CommandOutcome outcome = runtime.run();
// stopping runtime to ensure the logs are flushed before we start making assertions...
runtime.shutdown();
assertEquals(0, outcome.getExitCode());
assertTrue(logFile.isFile());
String logfileContents = Files.lines(logFile.toPath()).collect(joining("\n"));
assertFalse(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-debug"));
assertFalse(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-info"));
assertTrue("Logfile contents: " + logfileContents,
logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-warn"));
assertTrue(logfileContents.contains("i.b.b.l.LogbackTestCommand: logback-test-error"));
}
示例3: testMultipleConnectors
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testMultipleConnectors() {
BQRuntime runtime = testFactory.app("-s", "-c", "classpath:io/bootique/jetty/server/connectors.yml")
.module(new UnitModule())
.createRuntime();
runtime.run();
// deprecated default connector must NOT be started
Connector[] connectors = runtime.getInstance(Server.class).getConnectors();
assertEquals(2, connectors.length);
Response r1NormalConnector = client.target("http://localhost:14001/").request().get();
assertEquals(Response.Status.OK.getStatusCode(), r1NormalConnector.getStatus());
assertEquals(OUT_CONTENT, r1NormalConnector.readEntity(String.class));
Response r2NormalConnector = client.target("http://localhost:14002/").request().get();
assertEquals(Response.Status.OK.getStatusCode(), r2NormalConnector.getStatus());
assertEquals(OUT_CONTENT, r2NormalConnector.readEntity(String.class));
}
示例4: testAcceptorSelectorThreads
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testAcceptorSelectorThreads() {
BQRuntime runtime = testFactory.app("-s", "-c", "classpath:io/bootique/jetty/server/threads.yml")
.autoLoadModules()
.createRuntime();
runtime.run();
Connector[] connectors = runtime.getInstance(Server.class).getConnectors();
ServerConnector c1 = (ServerConnector) connectors[0];
assertEquals(3, c1.getAcceptors());
assertEquals(4, c1.getSelectorManager().getSelectorCount());
ServerConnector c2 = (ServerConnector) connectors[1];
// default counts are CPU count-sensitive, so do a sanity check instead of an exact match
assertTrue(c2.getAcceptors() > 0);
assertTrue(c2.getSelectorManager().getSelectorCount() > 0);
}
示例5: testScheduleCommand_AllJobs
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testScheduleCommand_AllJobs() {
BQRuntime runtime = testFactory.app()
.args("--schedule", "-c", "classpath:io/bootique/job/fixture/scheduler_test_command.yml")
.module(JobModule.class)
.module(b -> JobModule.extend(b).addJob(ScheduledJob1.class).addJob(ScheduledJob2.class))
.createRuntime();
Scheduler scheduler = runtime.getInstance(Scheduler.class);
assertFalse(scheduler.isStarted());
runtime.run();
assertTrue(scheduler.isStarted());
assertEquals(2, scheduler.getScheduledJobs().size());
}
示例6: testScheduleCommand_SelectedJobs
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testScheduleCommand_SelectedJobs() {
BQRuntime runtime = testFactory.app()
.args("--schedule", "--job=scheduledjob1", "-c", "classpath:io/bootique/job/fixture/scheduler_test_triggers.yml")
.module(JobModule.class)
.module(b -> JobModule.extend(b).addJob(ScheduledJob1.class).addJob(ScheduledJob2.class))
.createRuntime();
Scheduler scheduler = runtime.getInstance(Scheduler.class);
runtime.run();
assertTrue(scheduler.isStarted());
assertEquals(1, scheduler.getScheduledJobs().size());
assertEquals("scheduledjob1", scheduler.getScheduledJobs().iterator().next().getJobName());
}
示例7: testAlsoRun_DecorateWithPrivate
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testAlsoRun_DecorateWithPrivate() {
// use private "-s" command in decorator
BQModuleProvider commandsOverride = Commands.builder().add(MainCommand.class).noModuleCommands().build();
CommandDecorator decorator = CommandDecorator.alsoRun("s");
BQRuntime runtime = createRuntime(commandsOverride, decorator);
CommandOutcome outcome = runtime.run();
waitForAllToFinish();
assertTrue(outcome.isSuccess());
assertTrue(getCommand(runtime, MainCommand.class).isExecuted());
assertTrue(getCommand(runtime, SuccessfulCommand.class).isExecuted());
}
示例8: testDefaultDataSource
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testDefaultDataSource() throws SQLException {
BQRuntime runtime = testFactory
.app("-c", "classpath:io/bootique/liquibase/noconfig.yml", "-u")
.autoLoadModules()
.createRuntime();
CommandOutcome result = runtime.run();
assertTrue(result.isSuccess());
try (Connection c = DatabaseChannel.get(runtime).getConnection();) {
DatabaseMetaData md = c.getMetaData();
assertEquals("jdbc:derby:target/derby/bqjdbc_noconfig", md.getURL());
}
}
示例9: testMigration_NoContext
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testMigration_NoContext() throws SQLException {
//not specify a context when you run the migrator, ALL contexts will be run
BQRuntime runtime = testFactory
.app("-c", "classpath:io/bootique/liquibase/migration_context.yml", "-u")
.autoLoadModules()
.createRuntime();
CommandOutcome result = runtime.run();
assertTrue(result.isSuccess());
Table a = DatabaseChannel.get(runtime).newTable("A").columnNames("ID", "CONTEXT").build();
assertEquals(7, a.getRowCount());
// rerun....
runtime = testFactory
.app("-c", "classpath:io/bootique/liquibase/migration_context.yml", "-u")
.autoLoadModules()
.createRuntime();
result = runtime.run();
assertTrue(result.isSuccess());
assertEquals(7, a.getRowCount());
}
示例10: testMigrateCommand
import io.bootique.BQRuntime; //导入方法依赖的package包/类
private void testMigrateCommand(BQRuntime runtime) {
CommandOutcome result = runtime.run();
assertTrue(result.isSuccess());
Table a = DatabaseChannel.get(runtime).newTable("TEST").columnNames("ID", "NAME").build();
List<Object[]> row = a.select();
assertEquals(1, row.get(0)[0]);
assertEquals("Test", row.get(0)[1]);
assertEquals(2, row.get(1)[0]);
assertEquals("Test 2", row.get(1)[1]);
assertEquals(2, a.getRowCount());
}
示例11: testChecksLoaded
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testChecksLoaded() {
BQRuntime runtime = testFactory.app("-s").createRuntime();
runtime.run();
HealthCheckRegistry registry = runtime.getInstance(HealthCheckRegistry.class);
Map<String, HealthCheckOutcome> results = registry.runHealthChecks();
assertTrue(results.containsKey(JettyHealthCheckGroupFactory.THREAD_POOL_UTILIZATION_CHECK));
assertTrue(results.containsKey(JettyHealthCheckGroupFactory.QUEUED_REQUESTS_CHECK));
}
示例12: startRuntime
import io.bootique.BQRuntime; //导入方法依赖的package包/类
private BQRuntime startRuntime(String config, Servlet servlet) {
BQRuntime runtime = app.app("-s", "-c", config)
.module(
b -> JettyModule.extend(b).addServlet(servlet, "s1", "/*"))
.createRuntime();
runtime.run();
return runtime;
}
示例13: startApp
import io.bootique.BQRuntime; //导入方法依赖的package包/类
private BQRuntime startApp(Module module) {
BQRuntime runtime = testFactory.app("-s")
.module(module)
.createRuntime();
runtime.run();
return runtime;
}
示例14: testBeforeRun_DecorateWithPrivate
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testBeforeRun_DecorateWithPrivate() {
// use private "-s" command in decorator
BQModuleProvider commandsOverride = Commands.builder().add(MainCommand.class).noModuleCommands().build();
CommandDecorator decorator = CommandDecorator.beforeRun("s");
BQRuntime runtime = createRuntime(commandsOverride, decorator);
CommandOutcome outcome = runtime.run();
assertTrue(outcome.isSuccess());
assertTrue(getCommand(runtime, MainCommand.class).isExecuted());
assertTrue(getCommand(runtime, SuccessfulCommand.class).isExecuted());
}
示例15: testMigration_Schema
import io.bootique.BQRuntime; //导入方法依赖的package包/类
@Test
public void testMigration_Schema() {
BQRuntime runtime = testFactory
.app("-c", "classpath:io/bootique/liquibase/migration_schema.yml", "-u")
.autoLoadModules()
.createRuntime();
CommandOutcome result = runtime.run();
assertTrue(result.isSuccess());
Table y = DatabaseChannel.get(runtime).newTable("Y").columnNames("ID", "SCHEMA").build();
Object[] row = y.selectOne();
assertEquals("1", row[0]);
assertEquals("APP", row[1]);
assertEquals(1, y.getRowCount());
Table x = DatabaseChannel.get(runtime).newTable("X").columnNames("ID", "SCHEMA").build();
try {
x.selectOne();
fail("Exception expected");
} catch (Exception e) {
assertTrue(e.getCause() instanceof SQLSyntaxErrorException);
}
// rerun....
runtime = testFactory
.app("-c", "classpath:io/bootique/liquibase/migration_schema.yml", "-u")
.autoLoadModules()
.createRuntime();
result = runtime.run();
assertTrue(result.isSuccess());
assertEquals(1, y.getRowCount());
}