struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cnenn...@apache.org
Subject [1/3] struts git commit: Revert "Cleaned up project to be buildable with jdk8. Moved StrutsPortletTestCase to src/test where it belongs! Declared dependencies -junit-plugin and junit as scope test, as it should be."
Date Tue, 13 Oct 2015 11:28:23 GMT
Repository: struts
Updated Branches:
  refs/heads/master 4bff5a874 -> ed1b8cc7b


Revert "Cleaned up project to be buildable with jdk8. Moved StrutsPortletTestCase to src/test
where it belongs! Declared dependencies -junit-plugin and junit as scope test, as it should
be."

This reverts commit 4bff5a87486b67a6da0f7703af574f2eff65e036.


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9d5b9481
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9d5b9481
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9d5b9481

Branch: refs/heads/master
Commit: 9d5b948190480aa6916acf639f84529f534b7041
Parents: 4bff5a8
Author: cnenning <cnenning@apache.org>
Authored: Tue Oct 13 12:52:54 2015 +0200
Committer: cnenning <cnenning@apache.org>
Committed: Tue Oct 13 12:52:54 2015 +0200

----------------------------------------------------------------------
 plugins/portlet/pom.xml                         | 27 +++---
 .../apache/struts2/StrutsPortletTestCase.java   | 90 +++++++++++++++++++
 .../struts2/portlet/StrutsPortletTestCase.java  | 94 --------------------
 3 files changed, 102 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/9d5b9481/plugins/portlet/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/portlet/pom.xml b/plugins/portlet/pom.xml
index f3f71a2..da5a8ca 100644
--- a/plugins/portlet/pom.xml
+++ b/plugins/portlet/pom.xml
@@ -12,6 +12,18 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.struts</groupId>
+            <artifactId>struts2-junit-plugin</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>jsp-api</artifactId>
             <scope>provided</scope>
@@ -42,21 +54,6 @@
             <scope>provided</scope>
         </dependency>
 
-        <!-- tests -->
-        <dependency>
-            <groupId>org.apache.struts</groupId>
-            <artifactId>struts2-junit-plugin</artifactId>
-            <optional>true</optional>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <optional>true</optional>
-            <scope>test</scope>
-        </dependency>
-
         <dependency>
             <groupId>mockobjects</groupId>
             <artifactId>mockobjects-jdk1.3-j2ee1.3</artifactId>

http://git-wip-us.apache.org/repos/asf/struts/blob/9d5b9481/plugins/portlet/src/main/java/org/apache/struts2/StrutsPortletTestCase.java
----------------------------------------------------------------------
diff --git a/plugins/portlet/src/main/java/org/apache/struts2/StrutsPortletTestCase.java b/plugins/portlet/src/main/java/org/apache/struts2/StrutsPortletTestCase.java
new file mode 100644
index 0000000..ad89df1
--- /dev/null
+++ b/plugins/portlet/src/main/java/org/apache/struts2/StrutsPortletTestCase.java
@@ -0,0 +1,90 @@
+package org.apache.struts2;
+
+import com.opensymphony.xwork2.ActionContext;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.struts2.portlet.PortletConstants;
+import org.apache.struts2.portlet.PortletPhase;
+import org.springframework.mock.web.portlet.MockPortletContext;
+import org.springframework.mock.web.portlet.MockPortletRequest;
+import org.springframework.mock.web.portlet.MockPortletResponse;
+import org.springframework.mock.web.portlet.MockPortletSession;
+import org.springframework.mock.web.portlet.MockStateAwareResponse;
+
+import javax.portlet.PortletMode;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Base class used to test action in portlet environment
+ */
+public abstract class StrutsPortletTestCase extends StrutsTestCase {
+
+    private static final Logger LOG = LogManager.getLogger(StrutsPortletTestCase.class);
+
+    protected MockPortletSession portletSession;
+    protected MockPortletRequest portletRequest;
+    protected MockPortletResponse portletResponse;
+    protected MockContext portletContext;
+
+    @Override
+    protected void initActionContext(ActionContext actionContext) {
+        super.initActionContext(actionContext);
+        initPortletContext(actionContext);
+    }
+
+    protected void initPortletContext(ActionContext actionContext) {
+        LOG.debug("Initializing mock portlet environment");
+        portletContext = new MockContext();
+        portletContext.setMajorVersion(getMajorVersion());
+        actionContext.put(StrutsStatics.STRUTS_PORTLET_CONTEXT, portletContext);
+
+        portletRequest = new MockPortletRequest(portletContext);
+        portletResponse = new MockStateAwareResponse();
+        portletSession = new MockPortletSession();
+        portletRequest.setSession(portletSession);
+        actionContext.setSession(createSession());
+        actionContext.put(PortletConstants.REQUEST, portletRequest);
+        actionContext.put(PortletConstants.RESPONSE, portletResponse);
+        actionContext.put(PortletConstants.MODE_NAMESPACE_MAP, new HashMap<PortletMode,
String>());
+        actionContext.put(PortletConstants.PHASE, PortletPhase.EVENT_PHASE);
+    }
+
+    /**
+     * Override to define version of your portlet environment
+     *
+     * @return portlet version
+     */
+    protected int getMajorVersion() {
+        return 2;
+    }
+
+    /**
+     * Override to create your own session
+     *
+     * @return Map with session parameters
+     */
+    private Map<String, Object> createSession() {
+        return new HashMap<String, Object>(portletRequest.getPortletSession().getAttributeMap());
+    }
+
+}
+
+/**
+ * Simple workaround to define Portlet version
+ */
+class MockContext extends MockPortletContext {
+
+    private int majorVersion;
+
+    @Override
+    public int getMajorVersion() {
+        return majorVersion;
+    }
+
+    public void setMajorVersion(int majorVersion) {
+        this.majorVersion = majorVersion;
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/struts/blob/9d5b9481/plugins/portlet/src/test/java/org/apache/struts2/portlet/StrutsPortletTestCase.java
----------------------------------------------------------------------
diff --git a/plugins/portlet/src/test/java/org/apache/struts2/portlet/StrutsPortletTestCase.java
b/plugins/portlet/src/test/java/org/apache/struts2/portlet/StrutsPortletTestCase.java
deleted file mode 100644
index a4bb71c..0000000
--- a/plugins/portlet/src/test/java/org/apache/struts2/portlet/StrutsPortletTestCase.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package org.apache.struts2.portlet;
-
-import com.opensymphony.xwork2.ActionContext;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
-import org.apache.struts2.StrutsStatics;
-import org.apache.struts2.StrutsTestCase;
-import org.apache.struts2.portlet.PortletConstants;
-import org.apache.struts2.portlet.PortletPhase;
-import org.springframework.mock.web.portlet.MockPortletContext;
-import org.springframework.mock.web.portlet.MockPortletRequest;
-import org.springframework.mock.web.portlet.MockPortletResponse;
-import org.springframework.mock.web.portlet.MockPortletSession;
-import org.springframework.mock.web.portlet.MockStateAwareResponse;
-
-import javax.portlet.PortletMode;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Base class used to test action in portlet environment
- */
-public abstract class StrutsPortletTestCase extends StrutsTestCase {
-
-    private static final Logger LOG = LogManager.getLogger(StrutsPortletTestCase.class);
-
-    protected MockPortletSession portletSession;
-    protected MockPortletRequest portletRequest;
-    protected MockPortletResponse portletResponse;
-    protected MockContext portletContext;
-
-    @Override
-    protected void initActionContext(ActionContext actionContext) {
-        super.initActionContext(actionContext);
-        initPortletContext(actionContext);
-    }
-
-    protected void initPortletContext(ActionContext actionContext) {
-        LOG.debug("Initializing mock portlet environment");
-        portletContext = new MockContext();
-        portletContext.setMajorVersion(getMajorVersion());
-        actionContext.put(StrutsStatics.STRUTS_PORTLET_CONTEXT, portletContext);
-
-        portletRequest = new MockPortletRequest(portletContext);
-        portletResponse = new MockStateAwareResponse();
-        portletSession = new MockPortletSession();
-        portletRequest.setSession(portletSession);
-        actionContext.setSession(createSession());
-        actionContext.put(PortletConstants.REQUEST, portletRequest);
-        actionContext.put(PortletConstants.RESPONSE, portletResponse);
-        actionContext.put(PortletConstants.MODE_NAMESPACE_MAP, new HashMap<PortletMode,
String>());
-        actionContext.put(PortletConstants.PHASE, PortletPhase.EVENT_PHASE);
-    }
-
-    /**
-     * Override to define version of your portlet environment
-     *
-     * @return portlet version
-     */
-    protected int getMajorVersion() {
-        return 2;
-    }
-
-    /**
-     * Override to create your own session
-     *
-     * @return Map with session parameters
-     */
-    private Map<String, Object> createSession() {
-        return new HashMap<String, Object>(portletRequest.getPortletSession().getAttributeMap());
-    }
-
-}
-
-/**
- * Simple workaround to define Portlet version
- */
-class MockContext extends MockPortletContext {
-
-    private int majorVersion;
-
-    @Override
-    public int getMajorVersion() {
-        return majorVersion;
-    }
-
-    public void setMajorVersion(int majorVersion) {
-        this.majorVersion = majorVersion;
-    }
-
-}
-


Mime
View raw message