use of org.springframework.test.annotation.DirtiesContext in project camel by apache.
the class JmsConsumerShutdownTest method testJmsConsumerShutdownWithMessageInFlight.
@Test
@DirtiesContext
public void testJmsConsumerShutdownWithMessageInFlight() throws InterruptedException {
end.expectedMessageCount(0);
end.setResultWaitTime(2000);
// direct:dir route always fails
exception.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
throw new Exception("Kaboom!");
}
});
activemq.sendBody("activemq:start", "Hello");
end.assertIsSatisfied();
}
use of org.springframework.test.annotation.DirtiesContext in project spring-framework by spring-projects.
the class AbstractDirtiesContextTestExecutionListener method beforeOrAfterTestClass.
/**
* Perform the actual work for {@link #beforeTestClass} and {@link #afterTestClass}
* by dirtying the context if appropriate (i.e., according to the required mode).
* @param testContext the test context whose application context should
* potentially be marked as dirty; never {@code null}
* @param requiredClassMode the class mode required for a context to
* be marked dirty in the current phase; never {@code null}
* @throws Exception allows any exception to propagate
* @since 4.2
* @see #dirtyContext
*/
protected void beforeOrAfterTestClass(TestContext testContext, ClassMode requiredClassMode) throws Exception {
Assert.notNull(testContext, "TestContext must not be null");
Assert.notNull(requiredClassMode, "requiredClassMode must not be null");
Class<?> testClass = testContext.getTestClass();
Assert.notNull(testClass, "The test class of the supplied TestContext must not be null");
DirtiesContext dirtiesContext = AnnotatedElementUtils.findMergedAnnotation(testClass, DirtiesContext.class);
boolean classAnnotated = (dirtiesContext != null);
ClassMode classMode = (classAnnotated ? dirtiesContext.classMode() : null);
if (logger.isDebugEnabled()) {
String phase = (requiredClassMode.name().startsWith("BEFORE") ? "Before" : "After");
logger.debug(String.format("%s test class: context %s, class annotated with @DirtiesContext [%s] with mode [%s].", phase, testContext, classAnnotated, classMode));
}
if (classMode == requiredClassMode) {
dirtyContext(testContext, dirtiesContext.hierarchyMode());
}
}
use of org.springframework.test.annotation.DirtiesContext in project spring-security by spring-projects.
the class DelegatingAuthenticationEntryPointContextTests method testFirstAEP.
@Test
@DirtiesContext
public void testFirstAEP() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setRemoteAddr("192.168.1.10");
request.addHeader("User-Agent", "Mozilla/5.0");
daep.commence(request, null, null);
verify(firstAEP).commence(request, null, null);
verify(defaultAEP, never()).commence(any(HttpServletRequest.class), any(HttpServletResponse.class), any(AuthenticationException.class));
}
use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.
the class TrapHandlerITCase method testV1EnterpriseIdAndGenericAndSpecificAndMatchWithVarbindsAndTC.
// These exist to provide testing for the new Textual Convention feature
// See EventConfDataTest for the other part of this testing
@Test
@DirtiesContext
public void testV1EnterpriseIdAndGenericAndSpecificAndMatchWithVarbindsAndTC() throws Exception {
SnmpValueFactory valueFactory = SnmpUtils.getValueFactory();
LinkedHashMap<String, SnmpValue> varbinds = new LinkedHashMap<String, SnmpValue>();
varbinds.put(".1.3.6.1.4.1.14179.2.6.2.20.0", valueFactory.getOctetString(new byte[] { (byte) 0x00, (byte) 0x14, (byte) 0xf1, (byte) 0xad, (byte) 0xa7, (byte) 0x50 }));
Collection<Event> events = anticipateAndSend(false, true, "uei.opennms.org/vendor/cisco/bsnAPNoiseProfileUpdatedToPass", "v1", ".1.3.6.1.4.1.14179.2.6.3", 6, 38, varbinds);
boolean foundMacAddress = false;
// Assert that the MAC address varbind has been formatted into a colon-separated octet string
for (Event event : events) {
for (Parm parm : event.getParmCollection()) {
if (".1.3.6.1.4.1.14179.2.6.2.20.0".equals(parm.getParmName())) {
assertEquals("MAC address does not match", "00:14:F1:AD:A7:50", parm.getValue().getContent());
foundMacAddress = true;
}
}
}
assertTrue("Did not find expected MAC address parm", foundMacAddress);
}
use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.
the class EventMappingRulesIT method testMapIfUp.
@Test
@DirtiesContext
public void testMapIfUp() throws Exception {
Event event = createVpnIfUpEvent(17, m_pe1NodeId, "10.1.1.1", "5", "ge-1/0/2.50");
testEventMapping(event, ComponentUpEvent.class, "ServiceElementComponent", "NA-SvcElemComp", "8765,jnxVpnIf");
}
Aggregations