[java-idp-testbed COMMIT] in /trunk/src/test/java/idp: AbstractFlowTest.java saml1/SAML1UnsolicitedFlowTest.java saml...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Jan 22 21:27:02 EST 2014
Author: tzeller
Date: Wed Jan 22 21:27:02 2014
New Revision: 125
URL: http://svn.shibboleth.net/view/java-idp-testbed?rev=125&view=rev
Log:
Move common flow test setup to abstract superclass.
Modified:
trunk/src/test/java/idp/AbstractFlowTest.java
trunk/src/test/java/idp/saml1/SAML1UnsolicitedFlowTest.java
trunk/src/test/java/idp/saml2/SAML2UnsolicitedFlowTest.java
Modified: trunk/src/test/java/idp/AbstractFlowTest.java
URL: http://svn.shibboleth.net/view/java-idp-testbed/trunk/src/test/java/idp/AbstractFlowTest.java?rev=125&r1=124&r2=125&view=diff
==============================================================================
--- trunk/src/test/java/idp/AbstractFlowTest.java (original)
+++ trunk/src/test/java/idp/AbstractFlowTest.java Wed Jan 22 21:27:02 2014
@@ -18,12 +18,25 @@
package idp;
import javax.annotation.Nonnull;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import net.shibboleth.utilities.java.support.net.HttpServletRequestResponseContext;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.webflow.executor.FlowExecutor;
+import org.springframework.webflow.test.MockExternalContext;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import com.unboundid.ldap.sdk.LDAPException;
@@ -33,16 +46,64 @@
* Abstract flow test.
*/
@ActiveProfiles("dev")
- at WebAppConfiguration
@ContextConfiguration({"/system/conf/global-system.xml", "/conf/global-user.xml", "/system/conf/mvc-beans.xml",
"/conf/webflow-config.xml"})
+ at WebAppConfiguration
public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests {
+
+ /** Class logger. */
+ @Nonnull private final Logger log = LoggerFactory.getLogger(AbstractFlowTest.class);
/** Path to LDIF file to be imported into directory server. */
@Nonnull public final static String LDIF_FILE = "src/main/resources/test/ldap.ldif";
/** In-memory directory server. */
@Nonnull protected InMemoryDirectory directoryServer;
+
+ /** Mock external context. */
+ @Nonnull protected MockExternalContext externalContext;
+
+ /** The web flow executor. */
+ @Nonnull protected FlowExecutor flowExecutor;
+
+ /** Mock request. */
+ @Nonnull protected MockHttpServletRequest request;
+
+ /** Mock response. */
+ @Nonnull protected MockHttpServletResponse response;
+
+ /**
+ * {@link HttpServletRequestResponseContext#clearCurrent()}
+ */
+ @AfterMethod public void clearThreadLocals() {
+ HttpServletRequestResponseContext.clearCurrent();
+ }
+
+ /**
+ * Initialize the web flow executor.
+ */
+ @BeforeMethod public void initializeFlowExecutor() {
+ flowExecutor = applicationContext.getBean("flowExecutor", FlowExecutor.class);
+ Assert.assertNotNull(flowExecutor);
+ }
+
+ /**
+ * Initialize mock request, response, and external context.
+ */
+ @BeforeMethod public void initializeMocks() {
+ request = new MockHttpServletRequest();
+ response = new MockHttpServletResponse();
+ externalContext = new MockExternalContext();
+ externalContext.setNativeRequest(request);
+ externalContext.setNativeResponse(response);
+ }
+
+ /**
+ * {@link HttpServletRequestResponseContext#loadCurrent(HttpServletRequest, HttpServletResponse)}
+ */
+ @BeforeMethod public void initializeThreadLocals() {
+ HttpServletRequestResponseContext.loadCurrent((HttpServletRequest) request, (HttpServletResponse) response);
+ }
/**
* Creates an UnboundID in-memory directory server. Leverages LDIF found at {@value #LDIF_FILE}.
Modified: trunk/src/test/java/idp/saml1/SAML1UnsolicitedFlowTest.java
URL: http://svn.shibboleth.net/view/java-idp-testbed/trunk/src/test/java/idp/saml1/SAML1UnsolicitedFlowTest.java?rev=125&r1=124&r2=125&view=diff
==============================================================================
--- trunk/src/test/java/idp/saml1/SAML1UnsolicitedFlowTest.java (original)
+++ trunk/src/test/java/idp/saml1/SAML1UnsolicitedFlowTest.java Wed Jan 22 21:27:02 2014
@@ -20,19 +20,11 @@
import idp.AbstractFlowTest;
import javax.annotation.Nonnull;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import net.shibboleth.utilities.java.support.net.HttpServletRequestResponseContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.mock.web.MockHttpServletRequest;
[... 124 lines stripped ...]
More information about the commits
mailing list