org.springframework.boot.test.util.TestPropertyValues#of ( )源码实例Demo

下面列出了org.springframework.boot.test.util.TestPropertyValues#of ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void initialize(@NotNull ConfigurableApplicationContext configurableApplicationContext) {
	String jdbcUrl = String.format("jdbc:postgresql://%s:%d/%s", postgres.getContainerIpAddress(),
			postgres.getMappedPort(5432), "postgres");

	TestPropertyValues values = TestPropertyValues.of(
			"postgres.host=" + postgres.getContainerIpAddress(),
			"postgres.port=" + postgres.getMappedPort(5432),
			"postgres.url=" + jdbcUrl,
			"postgres.database-name=postgres",
			"spring.application.name=friend-service",
			"spring.datasource.data-username=postgres",
			"spring.datasource.data-password=password",
			"spring.datasource.url=" + jdbcUrl,
			"eureka.client.enabled=false");

	values.applyTo(configurableApplicationContext);
}
 
@Override
public void initialize(@NotNull ConfigurableApplicationContext configurableApplicationContext) {
	String jdbcUrl = String.format("jdbc:postgresql://%s:%d/%s", postgres.getContainerIpAddress(),
			postgres.getMappedPort(5432), "postgres");

	TestPropertyValues values = TestPropertyValues.of(
			"postgres.host=" + postgres.getContainerIpAddress(),
			"postgres.port=" + postgres.getMappedPort(5432),
			"postgres.url=" + jdbcUrl,
			"postgres.database-name=postgres",
			"spring.application.name=user-service",
			"spring.datasource.data-username=postgres",
			"spring.datasource.data-password=password",
			"spring.datasource.url=" + jdbcUrl,
			"eureka.client.enabled=false");

	values.applyTo(configurableApplicationContext);
}
 
源代码3 项目: blog-tutorials   文件: GetPersonByIdIT.java
@Override
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
  TestPropertyValues values = TestPropertyValues.of(
    "spring.datasource.url=" + postgreSQLContainer.getJdbcUrl(),
    "spring.datasource.password=" + postgreSQLContainer.getPassword(),
    "spring.datasource.username=" + postgreSQLContainer.getUsername()
  );
  values.applyTo(configurableApplicationContext);
}
 
源代码4 项目: blog-tutorials   文件: GetAllPersonsIT.java
@Override
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
  TestPropertyValues values = TestPropertyValues.of(
    "spring.datasource.url=" + postgreSQLContainer.getJdbcUrl(),
    "spring.datasource.password=" + postgreSQLContainer.getPassword(),
    "spring.datasource.username=" + postgreSQLContainer.getUsername()
  );
  values.applyTo(configurableApplicationContext);
}
 
源代码5 项目: blog-tutorials   文件: DeletePersonIT.java
@Override
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
  TestPropertyValues values = TestPropertyValues.of(
    "spring.datasource.url=" + postgreSQLContainer.getJdbcUrl(),
    "spring.datasource.password=" + postgreSQLContainer.getPassword(),
    "spring.datasource.username=" + postgreSQLContainer.getUsername()
  );
  values.applyTo(configurableApplicationContext);
}
 
源代码6 项目: pitchfork   文件: ZipkinForwarderTest.java
public void initialize(ConfigurableApplicationContext context) {
    var values = TestPropertyValues.of(
            "pitchfork.forwarders.zipkin.http.enabled=true",
            "pitchfork.forwarders.zipkin.http.endpoint=http://" + zipkinContainer.getContainerIpAddress() + ":" + zipkinContainer
                    .getFirstMappedPort() + "/api/v2/spans"
    );
    values.applyTo(context);
}
 
源代码7 项目: pitchfork   文件: RabbitMqIngressTest.java
public void initialize(ConfigurableApplicationContext context) {
    var values = TestPropertyValues.of(
            "pitchfork.ingress.rabbitmq.enabled=true",
            "pitchfork.ingress.rabbitmq.host=" + rabbitMqContainer.getContainerIpAddress(),
            "pitchfork.ingress.rabbitmq.port=" + rabbitMqContainer.getFirstMappedPort(),
            "pitchfork.ingress.rabbitmq.queue-name=zipkin",
            "pitchfork.ingress.rabbitmq.source-format=PROTO3",
            "pitchfork.forwarders.haystack.kafka.enabled=true",
            "pitchfork.forwarders.haystack.kafka.bootstrap-servers=" + kafkaContainer.getBootstrapServers()
    );
    values.applyTo(context);
}
 
源代码8 项目: pitchfork   文件: KafkaIngressTest.java
public void initialize(ConfigurableApplicationContext context) {
    var values = TestPropertyValues.of(
            "pitchfork.ingress.kafka.enabled=true",
            "pitchfork.ingress.kafka.bootstrap-servers=" + kafkaContainer.getBootstrapServers(),
            "pitchfork.ingress.kafka.source-format=PROTO3",
            "pitchfork.forwarders.haystack.kafka.enabled=true",
            "pitchfork.forwarders.haystack.kafka.bootstrap-servers=" + kafkaContainer.getBootstrapServers()
    );
    values.applyTo(context);
}
 
源代码9 项目: pitchfork   文件: HaystackKinesisForwarderTest.java
public void initialize(ConfigurableApplicationContext context) {
    var values = TestPropertyValues.of(
            "pitchfork.forwarders.haystack.kinesis.enabled=true",
            "pitchfork.forwarders.haystack.kinesis.auth.config-type=BASIC",
            "pitchfork.forwarders.haystack.kinesis.client.config-type=ENDPOINT",
            "pitchfork.forwarders.haystack.kinesis.client.endpoint.service-endpoint=" + KINESIS_SERVICE_ENDPOINT
    );

    values.applyTo(context);
}
 
源代码10 项目: pitchfork   文件: HaystackKafkaForwarderTest.java
public void initialize(ConfigurableApplicationContext context) {
    var values = TestPropertyValues.of(
            "pitchfork.forwarders.haystack.kafka.enabled=true",
            "pitchfork.forwarders.haystack.kafka.bootstrap-servers=" + kafkaContainer.getBootstrapServers()
    );
    values.applyTo(context);
}
 
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
    INSTANCE.start();
    String url = applicationContext.getEnvironment()
                                   .getProperty("spring.datasource.url")
                                   .replace("<port>", INSTANCE.getMappedPort(MS_SQL_SERVER_PORT).toString());
    TestPropertyValues values = TestPropertyValues.of(
            "spring.datasource.url=" + url);
    values.applyTo(applicationContext);
    DatabaseCreator creator = new DatabaseCreator(url, INSTANCE.getUsername(), INSTANCE.getPassword());
    creator.createDatabaseIfItDoesntExist();
}
 
@Override
public void initialize(@NotNull ConfigurableApplicationContext configurableApplicationContext) {
    String jdbcUrl = String.format("jdbc:postgresql://%s:%d/%s", postgres.getContainerIpAddress(),
            postgres.getMappedPort(5432), "postgres");
    TestPropertyValues values = TestPropertyValues.of(
            "postgres.host=" + postgres.getContainerIpAddress(),
            "postgres.port=" + postgres.getMappedPort(5432),
            "postgres.url=" + jdbcUrl,
            "spring.datasource.url=" + jdbcUrl,
            "spring.cloud.stream.kafka.binder.brokers=" + kafka.getBootstrapServers(),
            "eureka.client.enabled=false");
    values.applyTo(configurableApplicationContext);
}
 
@Override
public void initialize(@NotNull ConfigurableApplicationContext configurableApplicationContext) {
    String jdbcUrl = String.format("jdbc:postgresql://%s:%d/%s", postgres.getContainerIpAddress(),
            postgres.getMappedPort(5432), "postgres");
    TestPropertyValues values = TestPropertyValues.of(
            "postgres.host=" + postgres.getContainerIpAddress(),
            "postgres.port=" + postgres.getMappedPort(5432),
            "postgres.url=" + jdbcUrl,
            "spring.datasource.url=" + jdbcUrl,
            "spring.cloud.stream.kafka.binder.brokers=" + kafka.getBootstrapServers(),
            "eureka.client.enabled=false");
    values.applyTo(configurableApplicationContext);
}
 
@Test(expected = IllegalArgumentException.class)
public void testEmptyFormat() {
	AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
	TestPropertyValues testPropertyValues = TestPropertyValues.of("format:");
	testPropertyValues.applyTo(context);
	context.register(Conf.class);
	context.refresh();
	TimestampTaskProperties properties = context
		.getBean(TimestampTaskProperties.class);
	properties.getFormat();
}