本文整理汇总了Java中org.springframework.test.annotation.DirtiesContext类的典型用法代码示例。如果您正苦于以下问题:Java DirtiesContext类的具体用法?Java DirtiesContext怎么用?Java DirtiesContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DirtiesContext类属于org.springframework.test.annotation包,在下文中一共展示了DirtiesContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNoDataFlowServer
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test
@DirtiesContext
public void testNoDataFlowServer() throws Exception{
String exceptionMessage = null;
final String ERROR_MESSAGE =
"I/O error on GET request for \"http://localhost:9393\": Connection refused; nested exception is java.net.ConnectException: Connection refused";
Mockito.doThrow(new ResourceAccessException(ERROR_MESSAGE))
.when(this.taskOperations).launch(Matchers.anyString(),
(Map<String,String>) Matchers.any(),
(List<String>) Matchers.any());
TaskLauncherTasklet taskLauncherTasklet = getTaskExecutionTasklet();
ChunkContext chunkContext = chunkContext();
try {
taskLauncherTasklet.execute(null, chunkContext);
}
catch (ResourceAccessException rae) {
exceptionMessage = rae.getMessage();
}
assertEquals(ERROR_MESSAGE, exceptionMessage);
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:21,代码来源:TaskLauncherTaskletTests.java
示例2: testComposedConfiguration
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test
@DirtiesContext
public void testComposedConfiguration() throws Exception {
JobExecution jobExecution = this.jobRepository.createJobExecution(
"ComposedTest", new JobParameters());
job.execute(jobExecution);
Map<String, String> props = new HashMap<>(1);
props.put("format", "yyyy");
assertEquals(1010, composedTaskProperties.getMaxWaitTime());
assertEquals(1100, composedTaskProperties.getIntervalTimeBetweenChecks());
assertEquals("http://bar", composedTaskProperties.getDataflowServerUri().toASCIIString());
List<String> args = new ArrayList<>(1);
args.add("--baz=boo");
Assert.isNull(job.getJobParametersIncrementer(), "JobParametersIncrementer must be null.");
verify(this.taskOperations).launch("AAA", props, args);
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:19,代码来源:ComposedTaskRunnerConfigurationWithPropertiesTests.java
示例3: testMocksAreValid
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test
@DirtiesContext
public void testMocksAreValid() throws Exception {
result.setExpectedCount(1);
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
producerTemplate.sendBody("direct:start", Util.generateMockTwitterStatus());
MockEndpoint.assertIsSatisfied(camelContext);
Object body = result.getExchanges().get(0).getIn().getBody();
assertEquals(String.class, body.getClass());
ObjectMapper mapper = new ObjectMapper();
JsonNode outJson = mapper.readTree((String)body);
assertEquals("Bob", outJson.get("FirstName").asText());
assertEquals("Vila", outJson.get("LastName").asText());
assertEquals("bobvila1982", outJson.get("Title").asText());
assertEquals("Let's build a house!", outJson.get("Description").asText());
}
示例4: testTaskLauncherTasklet
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test
@DirtiesContext
public void testTaskLauncherTasklet() throws Exception{
getCompleteTaskExecution(0);
TaskLauncherTasklet taskLauncherTasklet =
getTaskExecutionTasklet();
ChunkContext chunkContext = chunkContext();
mockReturnValForTaskExecution(1L);
taskLauncherTasklet.execute(null, chunkContext);
assertEquals(1L, chunkContext.getStepContext()
.getStepExecution().getExecutionContext()
.get("task-execution-id"));
mockReturnValForTaskExecution(2L);
chunkContext = chunkContext();
getCompleteTaskExecution(0);
taskLauncherTasklet = getTaskExecutionTasklet();
taskLauncherTasklet.execute(null, chunkContext);
assertEquals(2L, chunkContext.getStepContext()
.getStepExecution().getExecutionContext()
.get("task-execution-id"));
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:23,代码来源:TaskLauncherTaskletTests.java
示例5: testTaskLauncherTaskletTimeout
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test
@DirtiesContext
public void testTaskLauncherTaskletTimeout() throws Exception {
boolean isException = false;
mockReturnValForTaskExecution(1L);
this.composedTaskProperties.setMaxWaitTime(1000);
TaskLauncherTasklet taskLauncherTasklet = getTaskExecutionTasklet();
ChunkContext chunkContext = chunkContext();
try {
taskLauncherTasklet.execute(null, chunkContext);
}
catch (TaskExecutionTimeoutException te) {
isException = true;
assertThat(te.getMessage(),is(equalTo("Timeout occurred while " +
"processing task with Execution Id 1")));
}
assertThat(isException,is(true));
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:19,代码来源:TaskLauncherTaskletTests.java
示例6: testInvalidTaskName
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test
@DirtiesContext
public void testInvalidTaskName() throws Exception {
String exceptionMessage = null;
final String ERROR_MESSAGE =
"Could not find task definition named " + TASK_NAME;
VndErrors errors = new VndErrors("message", ERROR_MESSAGE, new Link("ref"));
Mockito.doThrow(new DataFlowClientException(errors))
.when(this.taskOperations)
.launch(Matchers.anyString(),
(Map<String, String>) Matchers.any(),
(List<String>) Matchers.any());
TaskLauncherTasklet taskLauncherTasklet = getTaskExecutionTasklet();
ChunkContext chunkContext = chunkContext();
try {
taskLauncherTasklet.execute(null, chunkContext);
}
catch (DataFlowClientException dfce) {
exceptionMessage = dfce.getMessage();
}
assertEquals(ERROR_MESSAGE+"\n", exceptionMessage);
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:23,代码来源:TaskLauncherTaskletTests.java
示例7: testTaskLauncherTaskletFailure
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test
@DirtiesContext
public void testTaskLauncherTaskletFailure() throws Exception {
boolean isException = false;
mockReturnValForTaskExecution(1L);
TaskLauncherTasklet taskLauncherTasklet = getTaskExecutionTasklet();
ChunkContext chunkContext = chunkContext();
getCompleteTaskExecution(1);
try {
taskLauncherTasklet.execute(null, chunkContext);
}
catch (UnexpectedJobExecutionException jobExecutionException) {
isException = true;
assertThat(jobExecutionException.getMessage(),is(equalTo("Task returned a non zero exit code.")));
}
assertThat(isException,is(true));
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:18,代码来源:TaskLauncherTaskletTests.java
示例8: testComposedConfiguration
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test
@DirtiesContext
public void testComposedConfiguration() throws Exception {
JobExecution jobExecution = this.jobRepository.createJobExecution(
"ComposedTest", new JobParameters());
job.execute(jobExecution);
Assert.isNull(job.getJobParametersIncrementer(), "JobParametersIncrementer must be null.");
verify(this.taskOperations).launch("AAA", new HashMap<String, String>(0), new ArrayList<String>(0));
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:11,代码来源:ComposedTaskRunnerConfigurationNoPropertiesTests.java
示例9: testMocksAreValid
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test
@DirtiesContext
public void testMocksAreValid() throws Exception {
result.setExpectedCount(1);
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
producerTemplate.sendBody("direct:start", Util.generateMockTwitterStatus());
MockEndpoint.assertIsSatisfied(camelContext);
Object body = result.getExchanges().get(0).getIn().getBody();
assertEquals(String.class, body.getClass());
ObjectMapper mapper = new ObjectMapper();
JsonNode sfJson = mapper.readTree((String)body);
assertNotNull(sfJson.get("TwitterScreenName__c"));
assertEquals("bobvila1982", sfJson.get("TwitterScreenName__c").asText());
}
示例10: testSeparateNotSucceed
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test
@DirtiesContext
public void testSeparateNotSucceed() throws Exception {
result.setExpectedCount(1);
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
Status s = Util.generateMockTwitterStatus();
when(s.getUser().getName()).thenReturn("BobVila");
producerTemplate.sendBody("direct:start", s);
MockEndpoint.assertIsSatisfied(camelContext);
Object body = result.getExchanges().get(0).getIn().getBody();
assertEquals(String.class, body.getClass());
ObjectMapper mapper = new ObjectMapper();
JsonNode outJson = mapper.readTree((String)body);
assertEquals("BobVila", outJson.get("FirstName").asText());
assertNull(outJson.get("LastName"));
assertEquals("bobvila1982", outJson.get("Title").asText());
assertEquals("Let's build a house!", outJson.get("Description").asText());
}
示例11: testEmptyStoreFollowNonMatching
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test(timeout = 10000)
@DirtiesContext
public void testEmptyStoreFollowNonMatching() throws Exception {
TestFactObserver observer = testObserver();
uut.subscribeToFacts(SubscriptionRequest.follow(ANY).fromScratch(), observer)
.awaitCatchup();
verify(observer).onCatchup();
verify(observer, never()).onComplete();
verify(observer, never()).onError(any());
verify(observer, never()).onNext(any());
uut.publishWithMark(Fact.of("{\"id\":\"" + UUID.randomUUID()
+ "\",\"type\":\"someType\",\"ns\":\"other\"}", "{}"));
uut.publishWithMark(Fact.of("{\"id\":\"" + UUID.randomUUID()
+ "\",\"type\":\"someType\",\"ns\":\"other\"}", "{}"));
observer.await(2);
// the mark facts only
verify(observer, times(2)).onNext(any());
assertEquals(MarkFact.MARK_TYPE, observer.values.get(0).type());
assertEquals(MarkFact.MARK_TYPE, observer.values.get(1).type());
}
示例12: testEmptyStoreFollowMatching
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test(timeout = 10000)
@DirtiesContext
public void testEmptyStoreFollowMatching() throws Exception {
TestFactObserver observer = testObserver();
uut.subscribeToFacts(SubscriptionRequest.follow(ANY).fromScratch(), observer)
.awaitCatchup();
verify(observer).onCatchup();
verify(observer, never()).onComplete();
verify(observer, never()).onError(any());
verify(observer, never()).onNext(any());
uut.publish(Fact.of("{\"id\":\"" + UUID.randomUUID()
+ "\",\"type\":\"someType\",\"ns\":\"default\"}", "{}"));
observer.await(1);
}
示例13: testEmptyStoreEphemeral
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test(timeout = 10000)
@DirtiesContext
public void testEmptyStoreEphemeral() throws Exception {
uut.publish(Fact.of("{\"id\":\"" + UUID.randomUUID()
+ "\",\"type\":\"someType\",\"ns\":\"default\"}", "{}"));
uut.publish(Fact.of("{\"id\":\"" + UUID.randomUUID()
+ "\",\"type\":\"someType\",\"ns\":\"default\"}", "{}"));
uut.publish(Fact.of("{\"id\":\"" + UUID.randomUUID()
+ "\",\"type\":\"someType\",\"ns\":\"default\"}", "{}"));
TestFactObserver observer = testObserver();
uut.subscribeToFacts(SubscriptionRequest.follow(ANY).fromNowOn(), observer).awaitCatchup();
// nothing recieved
verify(observer).onCatchup();
verify(observer, never()).onComplete();
verify(observer, never()).onError(any());
verify(observer, never()).onNext(any());
uut.publish(Fact.of("{\"id\":\"" + UUID.randomUUID()
+ "\",\"type\":\"someType\",\"ns\":\"default\"}", "{}"));
observer.await(1);
verify(observer, times(1)).onNext(any());
}
示例14: testEmptyStoreFollowMatchingDelayed
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test(timeout = 10000)
@DirtiesContext
public void testEmptyStoreFollowMatchingDelayed() throws Exception {
TestFactObserver observer = testObserver();
uut.publish(Fact.of("{\"id\":\"" + UUID.randomUUID()
+ "\",\"type\":\"someType\",\"ns\":\"default\"}", "{}"));
uut.subscribeToFacts(SubscriptionRequest.follow(ANY).fromScratch(), observer)
.awaitCatchup();
verify(observer).onCatchup();
verify(observer, never()).onComplete();
verify(observer, never()).onError(any());
verify(observer).onNext(any());
uut.publish(Fact.of("{\"id\":\"" + UUID.randomUUID()
+ "\",\"type\":\"someType\",\"ns\":\"default\"}", "{}"));
observer.await(2);
}
示例15: testEmptyStoreFollowNonMatchingDelayed
import org.springframework.test.annotation.DirtiesContext; //导入依赖的package包/类
@Test(timeout = 10000)
@DirtiesContext
public void testEmptyStoreFollowNonMatchingDelayed() throws Exception {
TestFactObserver observer = testObserver();
uut.publish(Fact.of("{\"id\":\"" + UUID.randomUUID()
+ "\",\"ns\":\"default\",\"type\":\"t1\"}", "{}"));
uut.subscribeToFacts(SubscriptionRequest.follow(ANY).fromScratch(), observer)
.awaitCatchup();
verify(observer).onCatchup();
verify(observer, never()).onComplete();
verify(observer, never()).onError(any());
verify(observer).onNext(any());
uut.publish(Fact.of("{\"id\":\"" + UUID.randomUUID()
+ "\",\"ns\":\"other\",\"type\":\"t1\"}", "{}"));
observer.await(1);
}