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


Java PostgresStarter.getDefaultInstance方法代码示例

本文整理汇总了Java中ru.yandex.qatools.embed.postgresql.PostgresStarter.getDefaultInstance方法的典型用法代码示例。如果您正苦于以下问题:Java PostgresStarter.getDefaultInstance方法的具体用法?Java PostgresStarter.getDefaultInstance怎么用?Java PostgresStarter.getDefaultInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ru.yandex.qatools.embed.postgresql.PostgresStarter的用法示例。


在下文中一共展示了PostgresStarter.getDefaultInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: launchPostgres

import ru.yandex.qatools.embed.postgresql.PostgresStarter; //导入方法依赖的package包/类
protected static PostgresConfig launchPostgres() throws IOException {
    PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getDefaultInstance();
    final PostgresConfig pgConfig = PostgresConfig.defaultWithDbName("eventsourcing",
                                                                     "eventsourcing", "eventsourcing");
    PostgresExecutable exec = runtime.prepare(pgConfig);
    PostgresProcess process = exec.start();

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override public void run() {
            process.stop();
        }
    });

    return pgConfig;
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:16,代码来源:PostgreSQLTest.java

示例2: setupPostgres

import ru.yandex.qatools.embed.postgresql.PostgresStarter; //导入方法依赖的package包/类
@BeforeClass
public static void setupPostgres() {
    try {
        PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getDefaultInstance();
        final PostgresConfig config = PostgresConfig.defaultWithDbName("test","testuser","testpw");
        PostgresExecutable exec = runtime.prepare(config);
        postgresProcess = exec.start();
        Jdbc3SimpleDataSource _postgresDatasource = new Jdbc3SimpleDataSource();
        _postgresDatasource.setServerName(config.net().host());
        _postgresDatasource.setPortNumber(config.net().port());
        _postgresDatasource.setDatabaseName(config.storage().dbName());
        _postgresDatasource.setUser(config.credentials().username());
        _postgresDatasource.setPassword(config.credentials().password());
        _postgresDatasource.setAutosave(AutoSave.NEVER);
        postgresDatasource = Mockito.spy(_postgresDatasource);
        Mockito.when(postgresDatasource.getConnection()).thenAnswer(new Answer<Connection>() {
            @Override
            public Connection answer(InvocationOnMock invocation) throws Throwable {
                Connection connection = _postgresDatasource.getConnection();
                connection.setAutoCommit(false);
                return connection;
            }
        });
    } catch (IOException | SQLException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:28,代码来源:PostgresDataStorageTest.java

示例3: DatabaseRule

import ru.yandex.qatools.embed.postgresql.PostgresStarter; //导入方法依赖的package包/类
DatabaseRule(ConnectionPoolBuilder builder) {
    this.builder = builder;
    if (builder instanceof EmbeddedConnectionPoolBuilder)
    {
        if (process == null)
        {
            try
            {
                PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getDefaultInstance();
                PostgresConfig config = new PostgresConfig(V9_6_2, new AbstractPostgresConfig.Net(),
                    new AbstractPostgresConfig.Storage("async-pg"), new AbstractPostgresConfig.Timeout(),
                    new AbstractPostgresConfig.Credentials("async-pg", "async-pg"));
                PostgresExecutable exec = runtime.prepare(config);
                process = exec.start();

                out.printf("Started postgres to %s:%d%n", process.getConfig().net().host(), process.getConfig().net().port());
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
        }

        builder.hostname(process.getConfig().net().host());
        builder.port(process.getConfig().net().port());
    }
}
 
开发者ID:alaisi,项目名称:postgres-async-driver,代码行数:28,代码来源:DatabaseRule.java

示例4: main

import ru.yandex.qatools.embed.postgresql.PostgresStarter; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    //embedded postgres db
    PostgresProcess postgresProcess;
    PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getDefaultInstance();
    final PostgresConfig config = PostgresConfig.defaultWithDbName("test","testuser","testpw");
    PostgresExecutable exec = runtime.prepare(config);
    postgresProcess = exec.start();
    Jdbc3SimpleDataSource postgresDatasource = new Jdbc3SimpleDataSource();
    postgresDatasource.setServerName(config.net().host());
    postgresDatasource.setPortNumber(config.net().port());
    postgresDatasource.setDatabaseName(config.storage().dbName());
    postgresDatasource.setUser(config.credentials().username());
    postgresDatasource.setPassword(config.credentials().password());
    postgresDatasource.setAutosave(AutoSave.NEVER);
    DisableAutocommitDatasource datasource = new DisableAutocommitDatasource(postgresDatasource);

    System.out.println("\n\n\n\n\n\n\n\n");

    RootFactory root = new RootFactory();
    root.stringAttribute.set("1");
    DataSerialisationManager<RootFactory,Void> serialisationManager = new DataSerialisationManager<>(new JacksonSerialisation<>(1),new JacksonDeSerialisation<>(RootFactory.class,1),new ArrayList<>(),1);
    PostgresDataStorage<RootFactory,Void> postgresFactoryStorage = new PostgresDataStorage<>(datasource, root, serialisationManager);


    ApplicationServer<Void,Root, RootFactory,Void> applicationServer = new ApplicationServer<>(new FactoryManager<>(new RethrowingFactoryExceptionHandler<>()),postgresFactoryStorage);
    applicationServer.start();
    //output is 1 from initial factory

    DataAndNewMetadata<RootFactory> update = applicationServer.prepareNewFactory();
    update.root.stringAttribute.set("2");
    applicationServer.updateCurrentFactory(update, "", "", s -> true);
    //output is 2 from initial factory

    applicationServer.stop();
    ApplicationServer<Void,Root, RootFactory,Void> newApplicationServer = new ApplicationServer<>(new FactoryManager<>(new RethrowingFactoryExceptionHandler<>()),postgresFactoryStorage);
    newApplicationServer.start();
    //output is 2 again from the saved update



    System.out.println("\n\n\n\n\n\n\n\n");
    postgresProcess.stop();


}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:46,代码来源:Main.java


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