org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RepositoryTransactionManagerConfigurationTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void testZeroCustomTransactionManagerConfiguration() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withConfiguration(
					AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
							SimpleTaskAutoConfiguration.class,
							ZeroTransactionManagerConfiguration.class))
			.withPropertyValues("application.name=transactionManagerTask");

	applicationContextRunner.run((context) -> {
		DataSource dataSource = context.getBean("dataSource", DataSource.class);

		int taskExecutionCount = JdbcTestUtils
				.countRowsInTable(new JdbcTemplate(dataSource), "TASK_EXECUTION");

		assertThat(taskExecutionCount).isEqualTo(1);
	});
}
 
Example #2
Source File: ZipkinKinesisCollectorModuleTest.java    From zipkin-aws with Apache License 2.0 6 votes vote down vote up
@Test
public void kinesisCollectorConfiguredWithCorrectRegion() {
  TestPropertyValues.of(
      "zipkin.collector.kinesis.stream-name: zipkin-test",
      "zipkin.collector.kinesis.app-name: zipkin",
      "zipkin.collector.kinesis.aws-sts-region: us-east-1",
      "zipkin.collector.kinesis.aws-kinesis-region: us-east-1",
      "zipkin.collector.kinesis.aws-access-key-id: x",
      "zipkin.collector.kinesis.aws-secret-access-key: x",
      "zipkin.collector.kinesis.aws-sts-role-arn: test")
      .applyTo(context);

  context.register(
      PropertyPlaceholderAutoConfiguration.class,
      ZipkinKinesisCollectorModule.class,
      ZipkinKinesisCredentialsConfiguration.class,
      InMemoryConfiguration.class);
  context.refresh();

  KinesisCollector collector = context.getBean(KinesisCollector.class);

  assertThat(collector)
      .extracting("regionName")
      .as("Kinesis region is set from zipkin.collector.kinesis.aws-kinesis-region")
      .isEqualTo("us-east-1");
}
 
Example #3
Source File: SimpleTaskAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void testAutoConfigurationDisabled() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withConfiguration(AutoConfigurations.of(
					PropertyPlaceholderAutoConfiguration.class,
					SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
			.withPropertyValues("spring.cloud.task.autoconfiguration.enabled=false");
	Executable executable = () -> {
		applicationContextRunner.run((context) -> {
			context.getBean(TaskRepository.class);
		});
	};
	verifyExceptionThrown(NoSuchBeanDefinitionException.class, "No qualifying "
			+ "bean of type 'org.springframework.cloud.task.repository.TaskRepository' "
			+ "available", executable);
}
 
Example #4
Source File: DiscoveryClientConfigServiceAutoConfigurationTests.java    From spring-cloud-zookeeper with Apache License 2.0 6 votes vote down vote up
private void setup(String... env) {
	AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
	TestPropertyValues.of(env).applyTo(parent);
	parent.register(UtilAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class, EnvironmentKnobbler.class,
			ZookeeperDiscoveryClientConfigServiceBootstrapConfiguration.class,
			DiscoveryClientConfigServiceBootstrapConfiguration.class,
			ConfigClientProperties.class);
	parent.refresh();
	this.context = new AnnotationConfigApplicationContext();
	this.context.setParent(parent);
	this.context.register(PropertyPlaceholderAutoConfiguration.class,
			ZookeeperConfigServerAutoConfiguration.class,
			ZookeeperAutoConfiguration.class,
			ZookeeperDiscoveryClientConfiguration.class);
	this.context.refresh();
}
 
Example #5
Source File: SimpleSingleTaskAutoConfigurationWithDataSourceTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void testConfiguration() {

	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withConfiguration(AutoConfigurations.of(
					PropertyPlaceholderAutoConfiguration.class,
					SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class,
					EmbeddedDataSourceConfiguration.class))
			.withPropertyValues("spring.cloud.task.singleInstanceEnabled=true");
	applicationContextRunner.run((context) -> {
		SingleInstanceTaskListener singleInstanceTaskListener = context
				.getBean(SingleInstanceTaskListener.class);

		assertThat(singleInstanceTaskListener)
				.as("singleInstanceTaskListener should not be null").isNotNull();

		assertThat(SingleInstanceTaskListener.class)
				.isEqualTo(singleInstanceTaskListener.getClass());
	});
}
 
Example #6
Source File: TaskEventTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskEventListener() throws Exception {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withConfiguration(AutoConfigurations.of(TaskEventAutoConfiguration.class,
					PropertyPlaceholderAutoConfiguration.class,
					RabbitServiceAutoConfiguration.class,
					SimpleTaskAutoConfiguration.class,
					BindingServiceConfiguration.class))
			.withUserConfiguration(TaskEventsConfiguration.class)
			.withPropertyValues("--spring.cloud.task.closecontext_enabled=false",
					"--spring.cloud.task.name=" + TASK_NAME,
					"--spring.main.web-environment=false",
					"--spring.cloud.stream.defaultBinder=rabbit",
					"--spring.cloud.stream.bindings.task-events.destination=test");
	applicationContextRunner.run((context) -> {
		assertThat(context.getBean("taskEventListener")).isNotNull();
		assertThat(
				context.getBean(TaskEventAutoConfiguration.TaskEventChannels.class))
						.isNotNull();
	});
	assertThat(latch.await(1, TimeUnit.SECONDS)).isTrue();
}
 
Example #7
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 6 votes vote down vote up
@Test
public void encoderDirectsEndpoint() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	environment().setProperty("spring.zipkin.base-url",
			this.server.url("/").toString());
	environment().setProperty("spring.zipkin.encoder", "JSON_V1");
	this.context.register(ZipkinAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class, TraceAutoConfiguration.class,
			Config.class);
	this.context.refresh();
	Span span = this.context.getBean(Tracing.class).tracer().nextSpan().name("foo")
			.tag("foo", "bar").start();

	span.finish();

	Awaitility.await().untilAsserted(
			() -> then(this.server.getRequestCount()).isGreaterThan(0));
	// first request is for health check
	this.server.takeRequest();
	// second request is the span one
	RecordedRequest request = this.server.takeRequest();
	then(request.getPath()).isEqualTo("/api/v1/spans");
	then(request.getBody().readUtf8()).contains("binaryAnnotations");
}
 
Example #8
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 6 votes vote down vote up
@Test
public void overrideActiveMqQueue() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	environment().setProperty("spring.jms.cache.enabled", "false");
	environment().setProperty("spring.zipkin.activemq.queue", "zipkin2");
	environment().setProperty("spring.zipkin.activemq.message-max-bytes", "50");
	environment().setProperty("spring.zipkin.sender.type", "activemq");
	this.context.register(PropertyPlaceholderAutoConfiguration.class,
			ActiveMQAutoConfiguration.class, ZipkinAutoConfiguration.class,
			TraceAutoConfiguration.class);
	this.context.refresh();

	then(this.context.getBean(Sender.class)).isInstanceOf(ActiveMQSender.class);

	this.context.close();
}
 
Example #9
Source File: ZipkinServerConfigurationTest.java    From pivotal-bank-demo with Apache License 2.0 6 votes vote down vote up
@Test public void query_canDisable() {
  addEnvironment(context, "zipkin.query.enabled:false");
  context.register(
    PropertyPlaceholderAutoConfiguration.class,
    ZipkinServerConfigurationTest.Config.class,
    ZipkinServerConfiguration.class,
    ZipkinQueryApiV2.class
  );
  context.refresh();

  try {
    context.getBean(ZipkinQueryApiV2.class);
    failBecauseExceptionWasNotThrown(NoSuchBeanDefinitionException.class);
  } catch (NoSuchBeanDefinitionException e) {
  }
}
 
Example #10
Source File: SimpleTaskAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
/**
 * Verify that the verifyEnvironment method skips DataSource Proxy Beans when
 * determining the number of available dataSources.
 */
@Test
public void testWithDataSourceProxy() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withConfiguration(AutoConfigurations.of(
					EmbeddedDataSourceConfiguration.class,
					PropertyPlaceholderAutoConfiguration.class,
					SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
			.withUserConfiguration(DataSourceProxyConfiguration.class);
	applicationContextRunner.run((context) -> {
		assertThat(context.getBeanNamesForType(DataSource.class).length).isEqualTo(2);
		SimpleTaskAutoConfiguration taskConfiguration = context
				.getBean(SimpleTaskAutoConfiguration.class);
		assertThat(taskConfiguration).isNotNull();
		assertThat(taskConfiguration.taskExplorer()).isNotNull();
	});
}
 
Example #11
Source File: ZipkinKafkaStreamFactoryAutoConfigurationTest.java    From zipkin-sparkstreaming with Apache License 2.0 6 votes vote down vote up
@Test
public void providesCollectorComponent_whenKafkaZookeeperSet() {
  addEnvironment(context,
      "zipkin.sparkstreaming.stream.kafka.zookeeper.connect:" + KAFKA_ZOOKEEPER
  );
  context.register(
      PropertyPlaceholderAutoConfiguration.class,
      ZipkinKafkaStreamFactoryAutoConfiguration.class
  );
  context.refresh();

  ZipkinKafkaStreamFactoryProperties props =
      context.getBean(ZipkinKafkaStreamFactoryProperties.class);
  assertThat(props.getZookeeper().getConnect())
      .isEqualTo(KAFKA_ZOOKEEPER);
}
 
Example #12
Source File: SimpleTaskAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultipleDataSources() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withConfiguration(AutoConfigurations.of(
					PropertyPlaceholderAutoConfiguration.class,
					SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class))
			.withUserConfiguration(MultipleDataSources.class);

	verifyExceptionThrownDefaultExecutable(BeanCreationException.class,
			"Error creating bean "
					+ "with name 'simpleTaskAutoConfiguration': Invocation of init method "
					+ "failed; nested exception is java.lang.IllegalStateException: To use "
					+ "the default TaskConfigurer the context must contain no more than "
					+ "one DataSource, found 2",
			applicationContextRunner);

}
 
Example #13
Source File: ZipkinSQSCollectorModuleTest.java    From zipkin-aws with Apache License 2.0 6 votes vote down vote up
@Test
public void provideCollectorComponent_setsZipkinSqsCollectorProperties() {
  context = new AnnotationConfigApplicationContext();
  TestPropertyValues.of(
      "zipkin.collector.sqs.queue-url:" + sqsRule.queueUrl(),
      "zipkin.collector.sqs.wait-time-seconds:1",
      "zipkin.collector.sqs.parallelism:3",
      "zipkin.collector.sqs.aws-access-key-id: x",
      "zipkin.collector.sqs.aws-secret-access-key: x")
      .applyTo(context);
  context.register(
      PropertyPlaceholderAutoConfiguration.class,
      Region.class,
      ZipkinSQSCollectorModule.class,
      ZipkinSQSCredentialsConfiguration.class,
      InMemoryConfiguration.class);
  context.refresh();

  ZipkinSQSCollectorProperties properties = context.getBean(ZipkinSQSCollectorProperties.class);

  assertThat(properties.getQueueUrl()).isEqualTo(sqsRule.queueUrl());
  assertThat(properties.getWaitTimeSeconds()).isEqualTo(1);
  assertThat(properties.getParallelism()).isEqualTo(3);
}
 
Example #14
Source File: FlatFileItemWriterAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomLineAggregatorFileGeneration() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withUserConfiguration(LineAggregatorConfiguration.class)
			.withConfiguration(
					AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
							BatchAutoConfiguration.class,
							SingleStepJobAutoConfiguration.class,
							FlatFileItemWriterAutoConfiguration.class))
			.withPropertyValues("spring.batch.job.jobName=job",
					"spring.batch.job.stepName=step1", "spring.batch.job.chunkSize=5",
					"spring.batch.job.flatfilewriter.name=fooWriter",
					String.format(
							"spring.batch.job.flatfilewriter.resource=file://%s",
							this.outputFile.getAbsolutePath()),
					"spring.batch.job.flatfilewriter.encoding=UTF-8");

	applicationContextRunner.run((context) -> {
		JobLauncher jobLauncher = context.getBean(JobLauncher.class);

		Job job = context.getBean(Job.class);

		JobExecution jobExecution = jobLauncher.run(job, new JobParameters());

		JobExplorer jobExplorer = context.getBean(JobExplorer.class);

		while (jobExplorer.getJobExecution(jobExecution.getJobId()).isRunning()) {
			Thread.sleep(1000);
		}

		AssertFile.assertLineCount(3, this.outputFile);

		String results = FileCopyUtils.copyToString(new InputStreamReader(
				new FileSystemResource(this.outputFile).getInputStream()));
		assertThat(results).isEqualTo("{item=foo}\n{item=bar}\n{item=baz}\n");
	});
}
 
Example #15
Source File: FlatFileItemWriterAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testFormattedFieldExtractorFileGeneration() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withUserConfiguration(FormattedFieldExtractorJobConfiguration.class)
			.withConfiguration(
					AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
							BatchAutoConfiguration.class,
							SingleStepJobAutoConfiguration.class,
							FlatFileItemWriterAutoConfiguration.class))
			.withPropertyValues("spring.batch.job.jobName=job",
					"spring.batch.job.stepName=step1", "spring.batch.job.chunkSize=5",
					"spring.batch.job.flatfilewriter.name=fooWriter",
					String.format(
							"spring.batch.job.flatfilewriter.resource=file://%s",
							this.outputFile.getAbsolutePath()),
					"spring.batch.job.flatfilewriter.encoding=UTF-8",
					"spring.batch.job.flatfilewriter.formatted=true",
					"spring.batch.job.flatfilewriter.names=item",
					"spring.batch.job.flatfilewriter.format=item = %s");

	applicationContextRunner.run((context) -> {
		JobLauncher jobLauncher = context.getBean(JobLauncher.class);

		Job job = context.getBean(Job.class);

		JobExecution jobExecution = jobLauncher.run(job, new JobParameters());

		JobExplorer jobExplorer = context.getBean(JobExplorer.class);

		while (jobExplorer.getJobExecution(jobExecution.getJobId()).isRunning()) {
			Thread.sleep(1000);
		}

		AssertFile.assertLineCount(3, this.outputFile);

		String results = FileCopyUtils.copyToString(new InputStreamReader(
				new FileSystemResource(this.outputFile).getInputStream()));
		assertThat(results).isEqualTo("item = f\nitem = b\nitem = b\n");
	});
}
 
Example #16
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Test
public void canOverrideBySenderAndIsCaseInsensitive() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	environment().setProperty("spring.zipkin.sender.type", "WEB");
	this.context.register(PropertyPlaceholderAutoConfiguration.class,
			RabbitAutoConfiguration.class, KafkaAutoConfiguration.class,
			ZipkinAutoConfiguration.class, TraceAutoConfiguration.class);
	this.context.refresh();

	then(this.context.getBean(Sender.class).getClass().getName())
			.contains("RestTemplateSender");

	this.context.close();
}
 
Example #17
Source File: SingleStepJobAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleConfiguration() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withUserConfiguration(SimpleConfiguration.class)
			.withConfiguration(
					AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
							BatchAutoConfiguration.class,
							SingleStepJobAutoConfiguration.class))
			.withPropertyValues("spring.batch.job.jobName=job",
					"spring.batch.job.stepName=step1",
					"spring.batch.job.chunkSize=5");

	applicationContextRunner.run((context) -> {
		JobLauncher jobLauncher = context.getBean(JobLauncher.class);

		Job job = context.getBean(Job.class);

		ListItemWriter itemWriter = context.getBean(ListItemWriter.class);

		JobExecution jobExecution = jobLauncher.run(job, new JobParameters());

		JobExplorer jobExplorer = context.getBean(JobExplorer.class);

		while (jobExplorer.getJobExecution(jobExecution.getJobId()).isRunning()) {
			Thread.sleep(1000);
		}

		List<Map<Object, Object>> writtenItems = itemWriter.getWrittenItems();

		assertThat(writtenItems.size()).isEqualTo(3);

		assertThat(writtenItems.get(0).get("item")).isEqualTo("foo");
		assertThat(writtenItems.get(1).get("item")).isEqualTo("bar");
		assertThat(writtenItems.get(2).get("item")).isEqualTo("baz");
	});
}
 
Example #18
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Test
public void supportsMultipleReporters() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	environment().setProperty("spring.zipkin.base-url",
			this.server.url("/").toString());
	this.context.register(ZipkinAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class, TraceAutoConfiguration.class,
			Config.class, MultipleReportersConfig.class);
	this.context.refresh();

	then(this.context.getBeansOfType(Sender.class)).hasSize(2);
	then(this.context.getBeansOfType(Sender.class))
			.containsKeys(ZipkinAutoConfiguration.SENDER_BEAN_NAME, "otherSender");

	then(this.context.getBeansOfType(Reporter.class)).hasSize(2);
	then(this.context.getBeansOfType(Reporter.class)).containsKeys(
			ZipkinAutoConfiguration.REPORTER_BEAN_NAME, "otherReporter");

	Span span = this.context.getBean(Tracing.class).tracer().nextSpan().name("foo")
			.tag("foo", "bar").start();

	span.finish();

	Awaitility.await().untilAsserted(
			() -> then(this.server.getRequestCount()).isGreaterThan(1));
	// first request is for health check
	this.server.takeRequest();
	// second request is the span one
	RecordedRequest request = this.server.takeRequest();
	then(request.getPath()).isEqualTo("/api/v2/spans");
	then(request.getBody().readUtf8()).contains("localEndpoint");

	MultipleReportersConfig.OtherSender sender = this.context
			.getBean(MultipleReportersConfig.OtherSender.class);
	Awaitility.await().untilAsserted(() -> then(sender.isSpanSent()).isTrue());
}
 
Example #19
Source File: ZipkinElasticsearchAwsStorageModuleTest.java    From zipkin-aws with Apache License 2.0 5 votes vote down vote up
void refreshContextWithProperties(String... pairs) {
  TestPropertyValues.of(pairs).applyTo(context);
  context.register(
      PropertyPlaceholderAutoConfiguration.class,
      DefaultHostsConfiguration.class,
      ZipkinElasticsearchAwsStorageModule.class,
      TestGraph.class);
  context.refresh();
}
 
Example #20
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldOverrideDefaultBeans() {
	this.context = new AnnotationConfigApplicationContext();
	this.context.register(ZipkinAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class, TraceAutoConfiguration.class,
			Config.class, MyConfig.class);
	this.context.refresh();

	then(this.context.getBeansOfType(Sender.class)).hasSize(1);
	then(this.context.getBeansOfType(Sender.class))
			.containsKeys(ZipkinAutoConfiguration.SENDER_BEAN_NAME);

	then(this.context.getBeansOfType(Reporter.class)).hasSize(1);
	then(this.context.getBeansOfType(Reporter.class))
			.containsKeys(ZipkinAutoConfiguration.REPORTER_BEAN_NAME);

	Span span = this.context.getBean(Tracing.class).tracer().nextSpan().name("foo")
			.tag("foo", "bar").start();

	span.finish();

	Awaitility.await()
			.untilAsserted(() -> then(this.server.getRequestCount()).isEqualTo(0));

	MyConfig.MySender sender = this.context.getBean(MyConfig.MySender.class);
	Awaitility.await().untilAsserted(() -> then(sender.isSpanSent()).isTrue());
}
 
Example #21
Source File: FlatFileItemReaderAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomMapping() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withUserConfiguration(CustomMappingConfiguration.class)
			.withConfiguration(AutoConfigurations.of(
					PropertyPlaceholderAutoConfiguration.class,
					BatchAutoConfiguration.class,
					SingleStepJobAutoConfiguration.class,
					FlatFileItemReaderAutoConfiguration.class, RangeConverter.class))
			.withPropertyValues("spring.batch.job.jobName=job",
					"spring.batch.job.stepName=step1", "spring.batch.job.chunkSize=5",
					"spring.batch.job.flatfilereader.name=fixedWidthConfiguration",
					"spring.batch.job.flatfilereader.resource=/test.txt",
					"spring.batch.job.flatfilereader.maxItemCount=1",
					"spring.batch.job.flatfilereader.strict=true");

	applicationContextRunner.run((context) -> {
		JobLauncher jobLauncher = context.getBean(JobLauncher.class);

		Job job = context.getBean(Job.class);

		ListItemWriter itemWriter = context.getBean(ListItemWriter.class);

		JobExecution jobExecution = jobLauncher.run(job, new JobParameters());

		JobExplorer jobExplorer = context.getBean(JobExplorer.class);

		while (jobExplorer.getJobExecution(jobExecution.getJobId()).isRunning()) {
			Thread.sleep(1000);
		}

		List<Map<Object, Object>> writtenItems = itemWriter.getWrittenItems();

		assertThat(writtenItems.size()).isEqualTo(1);
		assertThat(writtenItems.get(0).get("one")).isEqualTo("1 2 3");
		assertThat(writtenItems.get(0).get("two")).isEqualTo("4 5 six");
	});
}
 
Example #22
Source File: ZipkinStackdriverStorageModuleTest.java    From zipkin-gcp with Apache License 2.0 5 votes vote down vote up
@Test
public void providesStorageComponent_whenStorageTypeStackdriverAndProjectIdSet() {
  TestPropertyValues.of(
      "zipkin.storage.type:stackdriver",
      "zipkin.storage.stackdriver.project-id:zipkin",
      "zipkin.storage.type:stackdriver").applyTo(context);
  context.register(
      PropertyPlaceholderAutoConfiguration.class,
      ZipkinStackdriverStorageModule.class,
      TestConfiguration.class);
  context.refresh();

  assertThat(context.getBean(StackdriverStorage.class)).isNotNull();
}
 
Example #23
Source File: ZipkinKinesisCollectorModuleTest.java    From zipkin-aws with Apache License 2.0 5 votes vote down vote up
@Test
public void kinesisCollectorNotCreatedWhenMissingRequiredConfigValue() {
  context.register(
      PropertyPlaceholderAutoConfiguration.class, ZipkinKinesisCollectorModule.class);
  context.refresh();

  assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
      .isThrownBy(() -> context.getBean(KinesisCollector.class));
}
 
Example #24
Source File: ZipkinXRayStorageModuleTest.java    From zipkin-aws with Apache License 2.0 5 votes vote down vote up
@Test
public void canOverrideProperty_daemonAddress() {
  context = new AnnotationConfigApplicationContext();
  TestPropertyValues.of(
      "zipkin.storage.type:xray", "zipkin.storage.xray.daemon-address:localhost:3000"
  ).applyTo(context);
  context.register(
      PropertyPlaceholderAutoConfiguration.class, ZipkinXRayStorageModule.class);
  context.refresh();

  assertThat(context.getBean(ZipkinXRayStorageProperties.class).getDaemonAddress())
      .isEqualTo("localhost:3000");
}
 
Example #25
Source File: TaskDatabaseInitializerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoTaskConfiguration() {
	this.context = new AnnotationConfigApplicationContext();
	this.context.register(EmptyConfiguration.class,
			EmbeddedDataSourceConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	assertThat(this.context.getBeanNamesForType(SimpleTaskRepository.class).length)
			.isEqualTo(0);
}
 
Example #26
Source File: ZipkinXRayStorageModuleTest.java    From zipkin-aws with Apache License 2.0 5 votes vote down vote up
@Test(expected = NoSuchBeanDefinitionException.class)
public void doesntProvideStorageComponent_whenStorageTypeNotXRay() {
  context = new AnnotationConfigApplicationContext();
  TestPropertyValues.of("zipkin.storage.type:elasticsearch").applyTo(context);
  context.register(
      PropertyPlaceholderAutoConfiguration.class, ZipkinXRayStorageModule.class);
  context.refresh();

  context.getBean(XRayUDPStorage.class);
}
 
Example #27
Source File: ZipkinSQSCollectorModuleTest.java    From zipkin-aws with Apache License 2.0 5 votes vote down vote up
@Test
public void provideSecurityTokenService_whenAwsStsRoleArnIsSet() {
  context = new AnnotationConfigApplicationContext();
  TestPropertyValues.of(
      "zipkin.collector.sqs.queue-url:" + sqsRule.queueUrl(),
      "zipkin.collector.sqs.wait-time-seconds:1",
      "zipkin.collector.sqs.aws-access-key-id: x",
      "zipkin.collector.sqs.aws-secret-access-key: x",
      "zipkin.collector.sqs.aws-sts-role-arn: test",
      "zipkin.collector.sqs.aws-sts-region: ap-southeast-1")
      .applyTo(context);
  context.register(
      PropertyPlaceholderAutoConfiguration.class,
      Region.class,
      ZipkinSQSCollectorModule.class,
      ZipkinSQSCredentialsConfiguration.class,
      InMemoryConfiguration.class);
  context.refresh();

  assertThat(context.getBean(SQSCollector.class)).isNotNull();
  assertThat(context.getBean(ZipkinSQSCollectorProperties.class).getAwsStsRegion())
      .isEqualTo("ap-southeast-1");
  assertThat(context.getBean(AWSSecurityTokenService.class)).isNotNull();

  assertThat(context.getBean(AWSCredentialsProvider.class))
      .isInstanceOf(STSAssumeRoleSessionCredentialsProvider.class);
}
 
Example #28
Source File: TaskExecutionListenerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private void setupContextForFailedTaskErrorAnnotatedListener() {
	this.context = new AnnotationConfigApplicationContext(
			TestDefaultConfiguration.class,
			FailedTaskErrorAnnotationConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.setId("failedTaskAnnotatedTask");
}
 
Example #29
Source File: ZipkinSQSCollectorModuleTest.java    From zipkin-aws with Apache License 2.0 5 votes vote down vote up
@Test(expected = NoSuchBeanDefinitionException.class)
public void doesntProvideCollectorComponent_whenSqsQueueUrlUnset() {
  context = new AnnotationConfigApplicationContext();
  context.register(
      PropertyPlaceholderAutoConfiguration.class,
      Region.class,
      ZipkinSQSCollectorModule.class,
      ZipkinSQSCredentialsConfiguration.class,
      InMemoryConfiguration.class);
  context.refresh();

  context.getBean(SQSCollector.class);
}
 
Example #30
Source File: KubernetesConfigConfigurationTest.java    From spring-cloud-kubernetes with Apache License 2.0 5 votes vote down vote up
private void setup(String... env) {
	this.context = new SpringApplicationBuilder(
			PropertyPlaceholderAutoConfiguration.class,
			KubernetesClientTestConfiguration.class, BootstrapConfiguration.class)
					.web(org.springframework.boot.WebApplicationType.NONE)
					.properties(env).run();
}