当前位置: 首页>>代码示例>>Java>>正文


Java BQRuntime.run方法代码示例

本文整理汇总了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"));
}
 
开发者ID:bootique,项目名称:bootique-bom,代码行数:22,代码来源:LogbackAppIT.java

示例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"));
}
 
开发者ID:bootique,项目名称:bootique-bom,代码行数:23,代码来源:LogbackAppIT.java

示例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));
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:22,代码来源:ServerFactoryConnectorsIT.java

示例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);
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:21,代码来源:ThreadsIT.java

示例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());
}
 
开发者ID:bootique,项目名称:bootique-job,代码行数:17,代码来源:ScheduleCommandIT.java

示例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());
}
 
开发者ID:bootique,项目名称:bootique-job,代码行数:17,代码来源:ScheduleCommandIT.java

示例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());
}
 
开发者ID:bootique,项目名称:bootique,代码行数:17,代码来源:CommandDecorator_CommandsIT.java

示例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());
    }
}
 
开发者ID:bootique,项目名称:bootique-liquibase,代码行数:17,代码来源:LiquibaseModuleIT.java

示例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());
}
 
开发者ID:bootique,项目名称:bootique-liquibase,代码行数:26,代码来源:LiquibaseModuleIT.java

示例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());
}
 
开发者ID:bootique,项目名称:bootique-flyway,代码行数:13,代码来源:MigrateTest.java

示例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));
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:12,代码来源:JettyHealthCheckGroupIT.java

示例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;
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:10,代码来源:ThreadPoolTester.java

示例13: startApp

import io.bootique.BQRuntime; //导入方法依赖的package包/类
private BQRuntime startApp(Module module) {
    BQRuntime runtime = testFactory.app("-s")
            .module(module)
            .createRuntime();
    runtime.run();
    return runtime;
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:8,代码来源:JettyModuleIT.java

示例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());
}
 
开发者ID:bootique,项目名称:bootique,代码行数:15,代码来源:CommandDecorator_CommandsIT.java

示例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());
}
 
开发者ID:bootique,项目名称:bootique-liquibase,代码行数:36,代码来源:LiquibaseModuleIT.java


注:本文中的io.bootique.BQRuntime.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。