INT-1389 removed all dependencies on StringMessage from unit tests in spring-integration-security

This commit is contained in:
Mark Fisher
2010-08-30 18:59:49 +00:00
parent 1d2bfd0c63
commit 9ca348da6c
2 changed files with 16 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +20,11 @@ import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.security.SecurityTestUtils;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.core.AuthenticationException;
@@ -62,14 +63,14 @@ public class ChannelAdapterSecurityIntegrationTests extends AbstractJUnit4Spring
@DirtiesContext
public void testSecuredWithNotEnoughPermission() {
login("bob", "bobspassword", "ROLE_ADMIN");
securedChannelAdapter.send(new StringMessage("test"));
securedChannelAdapter.send(new GenericMessage<String>("test"));
}
@Test
@DirtiesContext
public void testSecuredWithPermission() {
login("bob", "bobspassword", "ROLE_ADMIN, ROLE_PRESIDENT");
securedChannelAdapter.send(new StringMessage("test"));
securedChannelAdapter.send(new GenericMessage<String>("test"));
assertEquals("Wrong size of message list in target", 1, testConsumer.sentMessages.size());
}
@@ -77,20 +78,20 @@ public class ChannelAdapterSecurityIntegrationTests extends AbstractJUnit4Spring
@DirtiesContext
public void testSecuredWithoutPermision() {
login("bob", "bobspassword", "ROLE_USER");
securedChannelAdapter.send(new StringMessage("test"));
securedChannelAdapter.send(new GenericMessage<String>("test"));
}
@Test(expected = AuthenticationException.class)
@DirtiesContext
public void testSecuredWithoutAuthenticating() {
securedChannelAdapter.send(new StringMessage("test"));
securedChannelAdapter.send(new GenericMessage<String>("test"));
}
@Test
@DirtiesContext
public void testUnsecuredAsAdmin() {
login("bob", "bobspassword", "ROLE_ADMIN");
unsecuredChannelAdapter.send(new StringMessage("test"));
unsecuredChannelAdapter.send(new GenericMessage<String>("test"));
assertEquals("Wrong size of message list in target", 1, testConsumer.sentMessages.size());
}
@@ -98,14 +99,14 @@ public class ChannelAdapterSecurityIntegrationTests extends AbstractJUnit4Spring
@DirtiesContext
public void testUnsecuredAsUser() {
login("bob", "bobspassword", "ROLE_USER");
unsecuredChannelAdapter.send(new StringMessage("test"));
unsecuredChannelAdapter.send(new GenericMessage<String>("test"));
assertEquals("Wrong size of message list in target", 1, testConsumer.sentMessages.size());
}
@Test
@DirtiesContext
public void testUnsecuredWithoutAuthenticating() {
unsecuredChannelAdapter.send(new StringMessage("test"));
unsecuredChannelAdapter.send(new GenericMessage<String>("test"));
assertEquals("Wrong size of message list in target", 1, testConsumer.sentMessages.size());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,10 +21,11 @@ import java.util.regex.Pattern;
import org.junit.After;
import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.security.MockAuthenticationManager;
import org.springframework.integration.security.SecurityTestUtils;
import org.springframework.security.access.AccessDecisionVoter;
@@ -49,7 +50,7 @@ public class ChannelSecurityInterceptorTests {
@Test(expected = AuthenticationException.class)
public void securedSendWithoutAuthentication() throws Exception {
MessageChannel channel = getSecuredChannel("ROLE_ADMIN");
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
}
@Test(expected = AccessDeniedException.class)
@@ -57,7 +58,7 @@ public class ChannelSecurityInterceptorTests {
MessageChannel channel = getSecuredChannel("ROLE_ADMIN");
SecurityContext context = SecurityTestUtils.createContext("test", "pwd", "ROLE_USER");
SecurityContextHolder.setContext(context);
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
}
@Test
@@ -65,7 +66,7 @@ public class ChannelSecurityInterceptorTests {
MessageChannel channel = getSecuredChannel("ROLE_ADMIN");
SecurityContext context = SecurityTestUtils.createContext("test", "pwd", "ROLE_ADMIN");
SecurityContextHolder.setContext(context);
channel.send(new StringMessage("test"));
channel.send(new GenericMessage<String>("test"));
}