Search in sources :

Example 81 with ThrowableAnticipator

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();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Test(org.junit.Test)

Example 82 with ThrowableAnticipator

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();
}
Also used : UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) BadCredentialsException(org.springframework.security.authentication.BadCredentialsException) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Test(org.junit.Test)

Example 83 with ThrowableAnticipator

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();
}
Also used : UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) BadCredentialsException(org.springframework.security.authentication.BadCredentialsException) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator) Test(org.junit.Test)

Example 84 with ThrowableAnticipator

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();
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 85 with ThrowableAnticipator

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();
}
Also used : ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Aggregations

ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)105 Test (org.junit.Test)44 Ignore (org.junit.Ignore)12 ThresholdEvaluatorStateHighLow (org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow)9 Threshold (org.opennms.netmgt.config.threshd.Threshold)8 BindException (org.springframework.validation.BindException)8 Date (java.util.Date)6 LocationMonitorIdCommand (org.opennms.web.svclayer.model.LocationMonitorIdCommand)6 MarshallingResourceFailureException (org.opennms.core.xml.MarshallingResourceFailureException)4 DistributedStatusDetailsCommand (org.opennms.web.svclayer.model.DistributedStatusDetailsCommand)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 InputStreamResource (org.springframework.core.io.InputStreamResource)4 Resource (org.springframework.core.io.Resource)4 Errors (org.springframework.validation.Errors)4 File (java.io.File)3 IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 JdbcFilterDao (org.opennms.netmgt.filter.JdbcFilterDao)2 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)2 RrdException (org.opennms.netmgt.rrd.RrdException)2