use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.
the class DefaultResourceDaoTest method testGetResourceForNodeWithNullOnmsNode.
@Test
public void testGetResourceForNodeWithNullOnmsNode() {
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new IllegalArgumentException("node argument must not be null"));
m_easyMockUtils.replayAll();
try {
m_resourceDao.getResourceForNode(null);
} catch (Throwable t) {
ta.throwableReceived(t);
}
m_easyMockUtils.verifyAll();
ta.verifyAnticipated();
}
use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.
the class AuthenticationIT method testAuthenticateBadPassword.
@Test
public void testAuthenticateBadPassword() {
org.springframework.security.core.Authentication authentication = new UsernamePasswordAuthenticationToken("admin", "badPassword");
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new BadCredentialsException("Bad credentials"));
try {
m_provider.authenticate(authentication);
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.
the class AuthenticationIT method testAuthenticateBadUsername.
@Test
public void testAuthenticateBadUsername() {
org.springframework.security.core.Authentication authentication = new UsernamePasswordAuthenticationToken("badUsername", "admin");
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new BadCredentialsException("Bad credentials"));
try {
m_provider.authenticate(authentication);
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.
the class OpenNMSUserDetailsServiceTest method testGetUnknownUser.
public void testGetUnknownUser() {
SpringSecurityUserDao userDao = createMock(SpringSecurityUserDao.class);
OpenNMSUserDetailsService detailsService = new OpenNMSUserDetailsService();
detailsService.setUserDao(userDao);
expect(userDao.getByUsername("test_user")).andReturn(null);
replay(userDao);
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new UsernameNotFoundException("Unable to locate test_user in the userDao"));
try {
detailsService.loadUserByUsername("test_user");
} catch (Throwable t) {
ta.throwableReceived(t);
}
verify(userDao);
ta.verifyAnticipated();
}
use of org.opennms.test.ThrowableAnticipator in project opennms by OpenNMS.
the class TopNAttributeStatisticVisitorTest method testAfterPropertiesSetNoCount.
public void testAfterPropertiesSetNoCount() throws Exception {
BottomNAttributeStatisticVisitor visitor = new TopNAttributeStatisticVisitor();
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new IllegalStateException("property count must be set to a non-null value"));
visitor.setCount(null);
try {
visitor.afterPropertiesSet();
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
Aggregations