本文整理匯總了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);
}