• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PostgresConfig类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PostgresConfig类属于ru.yandex.qatools.embed.postgresql.config包,在下文中一共展示了PostgresConfig类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: startPostgres

import ru.yandex.qatools.embed.postgresql.config.PostgresConfig; //导入依赖的package包/类
PostgresProcess startPostgres(int postgresPort, String username, String password) {
  log.debug("startPostgres(postgresPort={0}, username={1}, password [not shown])", postgresPort, username);
  try {
    final PostgresConfig config = new PostgresConfig(
        Version.Main.V9_6,
        new PostgresConfig.Net("localhost", postgresPort),
        new PostgresConfig.Storage("database"),
        new PostgresConfig.Timeout(),
        new PostgresConfig.Credentials(username, password));

    String locale = "en_US.UTF-8";
    if (System.getProperty("os.name").toLowerCase().contains("win")) {
      locale = "american_usa";
    }
    config.getAdditionalInitDbParams().addAll(Arrays.asList(
      "-E", "UTF-8",
      "--locale", locale
    ));

    return startPostgres(config);
  }
  catch (IOException e) {
    throw new IllegalStateException(e);
  }
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:26,代码来源:PostgresRunner.java


示例2: requests

import ru.yandex.qatools.embed.postgresql.config.PostgresConfig; //导入依赖的package包/类
@Test
public void requests(TestContext context) throws IOException {
  PostgresRunner mock = new PostgresRunnerMock() {
    @Override
    PostgresProcess startPostgres(PostgresConfig postgresConfig) throws IOException {
      getRequests.add(null);
      postRequests.add(null);
      return super.startPostgres(postgresConfig);
    }
  };

  Async async = context.async();
  Ports ports = getPorts(context);
  PostgresRunnerMock.main(mock, ports.port1, ports.port2, "u", "p", h -> {
    context.assertTrue(PostgresRunnerMock.getInvoked);
    context.assertTrue(PostgresRunnerMock.postInvoked);
    context.assertEquals("u", PostgresRunnerMock.postgresConfig.credentials().username());
    context.assertEquals("p", PostgresRunnerMock.postgresConfig.credentials().password());
    async.complete();
  });
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:22,代码来源:PostgresRunnerTest.java


示例3: before

import ru.yandex.qatools.embed.postgresql.config.PostgresConfig; //导入依赖的package包/类
@Override
public void before() throws Throwable {
  port = defaultPort;
  if (port  < 0) {
    port = Helper.findRandomOpenPortOnAllLocalInterfaces();
  }

  postgresRuntime = PostgresStarter.getDefaultInstance()
      .prepare(
          new PostgresConfig(
              version,
              new Net("localhost", port),
              new Storage(databaseName),
              new Timeout(30000),
              new Credentials(username, password)))
      .start();
}
 
开发者ID:mlk,项目名称:AssortmentOfJUnitRules,代码行数:18,代码来源:PostgresRule.java


示例4: start

import ru.yandex.qatools.embed.postgresql.config.PostgresConfig; //导入依赖的package包/类
public synchronized void start() throws IOException {
	if (process != null) {
		throw new IllegalStateException();
	}

	Command command = Command.Postgres;

	IDownloadConfig downloadConfig = new PostgresDownloadConfigBuilder()
			.defaultsForCommand(command)
			.artifactStorePath(new FixedPath(artifactStorePath))
			.build();

	ArtifactStoreBuilder artifactStoreBuilder = new PostgresArtifactStoreBuilder()
			.defaults(command)
			.download(downloadConfig);

	LogWatchStreamProcessor logWatch = new LogWatchStreamProcessor("started",
			new HashSet<>(singletonList("failed")),
			new Slf4jStreamProcessor(getLogger("postgres"), Slf4jLevel.TRACE));

	IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
			.defaults(command)
			.processOutput(new ProcessOutput(logWatch, logWatch, logWatch))
			.artifactStore(artifactStoreBuilder)
			.build();

	PostgresStarter<PostgresExecutable, PostgresProcess> starter = new PostgresStarter<>(PostgresExecutable.class, runtimeConfig);

	PostgresConfig config = new PostgresConfig(version,
			new AbstractPostgresConfig.Net(host, port == 0 ? Network.getFreeServerPort() : port),
			new AbstractPostgresConfig.Storage(dbName),
			new AbstractPostgresConfig.Timeout(),
			new AbstractPostgresConfig.Credentials(username, password));
	process = starter.prepare(config).start();
	jdbcUrl = "jdbc:postgresql://" + config.net().host() + ":" + config.net().port() + "/" + config.storage().dbName();
}
 
开发者ID:honourednihilist,项目名称:gradle-postgresql-embedded,代码行数:37,代码来源:EmbeddedPostgres.java


示例5: launchPostgres

import ru.yandex.qatools.embed.postgresql.config.PostgresConfig; //导入依赖的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


示例6: setupPostgres

import ru.yandex.qatools.embed.postgresql.config.PostgresConfig; //导入依赖的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


示例7: startPostgres

import ru.yandex.qatools.embed.postgresql.config.PostgresConfig; //导入依赖的package包/类
@Override
PostgresProcess startPostgres(PostgresConfig postgresConfig) throws IOException {
  log.debug("startPostgres(PostgresConfig)");
  PostgresRunnerMock.postgresConfig = postgresConfig;
  startInvoked = true;
  return null;
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:8,代码来源:PostgresRunnerMock.java


示例8: DatabaseRule

import ru.yandex.qatools.embed.postgresql.config.PostgresConfig; //导入依赖的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


示例9: main

import ru.yandex.qatools.embed.postgresql.config.PostgresConfig; //导入依赖的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


示例10: startEmbeddedPostgres

import ru.yandex.qatools.embed.postgresql.config.PostgresConfig; //导入依赖的package包/类
/**
 * Start an embedded PostgreSQL using the configuration of {@link #getConnectionConfig()}.
 * It also sets embedded mode to true, see {@link #setIsEmbedded(boolean)}, but
 * doesn't change the configuration.
 *
 * @throws IOException  when starting embedded PostgreSQL fails
 */
public void startEmbeddedPostgres() throws IOException {
  // starting Postgres
  embeddedMode = true;
  if (postgresProcess == null || !postgresProcess.isProcessRunning()) {
    // turns off the default functionality of unzipping on every run.
    IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
      .defaults(Command.Postgres)
      .artifactStore(
        new NonCachedPostgresArtifactStoreBuilder().defaults(Command.Postgres).
        download(new PostgresDownloadConfigBuilder().defaultsForCommand(Command.Postgres)
        // .progressListener(new LoggingProgressListener(logger, Level.ALL))
          .build())).build();
    PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getInstance(runtimeConfig);

    int port = postgreSQLClientConfig.getInteger(PORT);
    String username = postgreSQLClientConfig.getString(_USERNAME);
    String password = postgreSQLClientConfig.getString(_PASSWORD);
    String database = postgreSQLClientConfig.getString(DATABASE);

    String locale = "en_US.UTF-8";
    String OS = System.getProperty("os.name").toLowerCase();
    if(OS.indexOf("win") >= 0){
      locale = "american_usa";
    }

    final PostgresConfig config = new PostgresConfig(Version.Main.V9_6,
      new AbstractPostgresConfig.Net(DEFAULT_IP, port),
      new AbstractPostgresConfig.Storage(database),
      new AbstractPostgresConfig.Timeout(20000),
      new AbstractPostgresConfig.Credentials(username, password));

    config.getAdditionalInitDbParams().addAll(Arrays.asList(
      "-E", "UTF-8",
      "--locale", locale
    ));

    postgresProcess = runtime.prepare(config).start();

    log.info("embedded postgress started....");
  } else {
    log.info("embedded postgress is already running...");
  }
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:51,代码来源:PostgresClient.java


示例11: initializePostgresql

import ru.yandex.qatools.embed.postgresql.config.PostgresConfig; //导入依赖的package包/类
String initializePostgresql() throws SQLException, IOException,
                              URISyntaxException {

    String password = System.getProperty(NAVI_PASSWORD, "changeMe"); // TODO no default
    final Command cmd = Command.Postgres;
    // the cached directory should contain pgsql folder
    final FixedPath cachedDir = new FixedPath(UAAS_POSTGRES);
    ArtifactStoreBuilder download = new CachedArtifactStoreBuilder().defaults(cmd)
                                                                    .tempDir(cachedDir)
                                                                    .download(new DownloadConfigBuilder().defaultsForCommand(cmd)
                                                                                                         .packageResolver(new PackagePaths(cmd,
                                                                                                                                           cachedDir))
                                                                                                         .build());
    IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(cmd)
                                                             .artifactStore(download)
                                                             .build();

    PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getInstance(runtimeConfig);

    log.info("Starting Postgres");
    final PostgresConfig config = new PostgresConfig(PRODUCTION,
                                                     new Net("localhost",
                                                             findFreePort()),
                                                     new Storage(NAVI,
                                                                 UAAS_STATE),
                                                     new Timeout(),
                                                     new Credentials(NAVI,
                                                                     password));
    // pass info regarding encoding, locale, collate, ctype, instead of setting global environment settings
    config.getAdditionalInitDbParams()
          .addAll(Arrays.asList("-E", "UTF-8", "--locale=en_US.UTF-8",
                                "--lc-collate=en_US.UTF-8",
                                "--lc-ctype=en_US.UTF-8"));
    PostgresExecutable exec = runtime.prepare(config);
    PostgresProcess process = exec.start();
    Runtime.getRuntime()
           .addShutdownHook(new Thread(() -> process.stop(),
                                       "Local NAVI shutdown"));

    String uri = String.format("jdbc:postgresql://%s:%s/%s?user=%s&password=%s",
                               config.net()
                                     .host(),
                               config.net()
                                     .port(),
                               config.storage()
                                     .dbName(),
                               config.credentials()
                                     .username(),
                               config.credentials()
                                     .password());

    DbaConfiguration dbaConfig = new DbaConfiguration();
    dbaConfig.coreDb = config.storage()
                             .dbName();
    dbaConfig.corePort = config.net()
                               .port();
    dbaConfig.coreServer = config.net()
                                 .host();
    dbaConfig.coreUsername = config.credentials()
                                   .username();
    dbaConfig.corePassword = config.credentials()
                                   .password();
    try {
        new Loader(dbaConfig).bootstrap();
    } catch (Exception e) {
        throw new IllegalStateException("Cannot bootstrap CORE", e);
    }
    return uri;
}
 
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:70,代码来源:EmbeddedConfiguration.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EMGroup类代码示例发布时间:2022-05-23
下一篇:
Java ConstantPoolGen类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap