You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by ms...@apache.org on 2014/09/01 15:29:56 UTC
[48/63] [abbrv] Completed rework of the tests derived from the API
documentation. Implemented some of the test cases:
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2f638d7a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/RenderRequestWrapperChecker.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/RenderRequestWrapperChecker.java b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/RenderRequestWrapperChecker.java
new file mode 100644
index 0000000..759a4f5
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/RenderRequestWrapperChecker.java
@@ -0,0 +1,462 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package javax.portlet.tck.beans;
+
+import java.security.*;
+import java.util.*;
+import java.io.*;
+
+import javax.portlet.RenderRequest;
+import javax.portlet.PortalContext;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.WindowState;
+import javax.servlet.http.Cookie;
+
+/**
+ * This class tests a wrapper class by simulating the class to be wrapped.The test code
+ * verifies that the arguments passed to the wrapping method are correctly passed to
+ * the wrapped class. Simulated return data is passed back to the caller.
+ *
+ * @author nick
+ */
+
+
+public class RenderRequestWrapperChecker extends WrapperChecker implements RenderRequest {
+
+ private PortletRequest req;
+ private PortletSession sess;
+ private PortletPreferences prefs;
+ private PortalContext pcntxt;
+ private Principal ppal;
+
+ public RenderRequestWrapperChecker(PortletRequest portletReq) {
+ req = portletReq;
+ sess = req.getPortletSession();
+ prefs = req.getPreferences();
+ pcntxt = req.getPortalContext();
+ ppal = req.getUserPrincipal();
+ }
+
+ @Override
+ public boolean isWindowStateAllowed(WindowState state) {
+ String meth = "isWindowStateAllowed";
+ Object[] args = {state};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public boolean isPortletModeAllowed(PortletMode mode) {
+ String meth = "isPortletModeAllowed";
+ Object[] args = {mode};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortletMode getPortletMode() {
+ String meth = "getPortletMode";
+ Object[] args = {};
+ PortletMode ret = PortletMode.EDIT;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public WindowState getWindowState() {
+ String meth = "getWindowState";
+ Object[] args = {};
+ WindowState ret = WindowState.NORMAL;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortletPreferences getPreferences() {
+ String meth = "getPreferences";
+ Object[] args = {};
+ PortletPreferences ret = prefs;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortletSession getPortletSession() {
+ String meth = "getPortletSession";
+ Object[] args = {};
+ PortletSession ret = sess;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortletSession getPortletSession(boolean create) {
+ String meth = "getPortletSession";
+ Object[] args = {create};
+ PortletSession ret = sess;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getProperty(String name) {
+ String meth = "getProperty";
+ Object[] args = {name};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<String> getProperties(String name) {
+ String meth = "getProperties";
+ Object[] args = {name};
+ String[] strs = {"val1", "val2"};
+ Enumeration<String> ret = Collections.enumeration(Arrays.asList(strs));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<String> getPropertyNames() {
+ String meth = "getPropertyNames";
+ Object[] args = {};
+ String[] strs = {"val1", "val2"};
+ Enumeration<String> ret = Collections.enumeration(Arrays.asList(strs));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortalContext getPortalContext() {
+ String meth = "getPortalContext";
+ Object[] args = {};
+ PortalContext ret = pcntxt;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getAuthType() {
+ String meth = "getAuthType";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getContextPath() {
+ String meth = "getContextPath";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getRemoteUser() {
+ String meth = "getRemoteUser";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Principal getUserPrincipal() {
+ String meth = "getUserPrincipal";
+ Object[] args = {};
+ Principal ret = ppal;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public boolean isUserInRole(String role) {
+ String meth = "isUserInRole";
+ Object[] args = {role};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Object getAttribute(String name) {
+ String meth = "getAttribute";
+ Object[] args = {name};
+ Object ret = "object";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<String> getAttributeNames() {
+ String meth = "getAttributeNames";
+ Object[] args = {};
+ String[] strs = {"val1", "val2"};
+ Enumeration<String> ret = Collections.enumeration(Arrays.asList(strs));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getParameter(String name) {
+ String meth = "getParameter";
+ Object[] args = {name};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<String> getParameterNames() {
+ String meth = "getParameterNames";
+ Object[] args = {};
+ String[] strs = {"val1", "val2"};
+ Enumeration<String> ret = Collections.enumeration(Arrays.asList(strs));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String[] getParameterValues(String name) {
+ String meth = "getParameterValues";
+ Object[] args = {name};
+ String[] ret = {"val1", "val2"};
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Map<String, String[]> getParameterMap() {
+ String meth = "getParameterMap";
+ Object[] args = {};
+ Map<String, String[]> parms = new HashMap<String, String[]>();
+ parms.put("parm1", new String[] {"val1", "val2"});
+ parms.put("parm2", new String[] {"val1", "val2"});
+ Map<String, String[]> ret = parms;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public boolean isSecure() {
+ String meth = "isSecure";
+ Object[] args = {};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void setAttribute(String name, Object o) {
+ String meth = "setAttribute";
+ Object[] args = {name, o};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void removeAttribute(String name) {
+ String meth = "removeAttribute";
+ Object[] args = {name};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public String getRequestedSessionId() {
+ String meth = "getRequestedSessionId";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdValid() {
+ String meth = "isRequestedSessionIdValid";
+ Object[] args = {};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getResponseContentType() {
+ String meth = "getResponseContentType";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<String> getResponseContentTypes() {
+ String meth = "getResponseContentTypes";
+ Object[] args = {};
+ String[] strs = {"val1", "val2"};
+ Enumeration<String> ret = Collections.enumeration(Arrays.asList(strs));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Locale getLocale() {
+ String meth = "getLocale";
+ Object[] args = {};
+ Locale ret = new Locale("en");
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<Locale> getLocales() {
+ String meth = "getLocales";
+ Object[] args = {};
+ Locale[] la = {new Locale("en"), new Locale("de")};
+ Enumeration<Locale> ret = Collections.enumeration(Arrays.asList(la));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getScheme() {
+ String meth = "getScheme";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getServerName() {
+ String meth = "getServerName";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public int getServerPort() {
+ String meth = "getServerPort";
+ Object[] args = {};
+ int ret = 42;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getWindowID() {
+ String meth = "getWindowID";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Cookie[] getCookies() {
+ String meth = "getCookies";
+ Object[] args = {};
+ Cookie[] ret = {new Cookie("name", "Bob"), new Cookie("name", "Alice")};
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Map<String, String[]> getPrivateParameterMap() {
+ String meth = "getPrivateParameterMap";
+ Object[] args = {};
+ Map<String, String[]> parms = new HashMap<String, String[]>();
+ parms.put("parm1", new String[] {"val1", "val2"});
+ parms.put("parm2", new String[] {"val1", "val2"});
+ Map<String, String[]> ret = parms;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Map<String, String[]> getPublicParameterMap() {
+ String meth = "getPublicParameterMap";
+ Object[] args = {};
+ Map<String, String[]> parms = new HashMap<String, String[]>();
+ parms.put("parm1", new String[] {"val1", "val2"});
+ parms.put("parm2", new String[] {"val1", "val2"});
+ Map<String, String[]> ret = parms;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getETag() {
+ String meth = "getETag";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2f638d7a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/RenderResponseWrapperChecker.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/RenderResponseWrapperChecker.java b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/RenderResponseWrapperChecker.java
new file mode 100644
index 0000000..e3ef213
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/RenderResponseWrapperChecker.java
@@ -0,0 +1,293 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package javax.portlet.tck.beans;
+
+import java.security.*;
+import java.util.*;
+import java.io.*;
+
+import javax.portlet.*;
+import javax.servlet.http.Cookie;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+
+/**
+ * This class tests a wrapper class by simulating the class to be wrapped.The test code
+ * verifies that the arguments passed to the wrapping method are correctly passed to
+ * the wrapped class. Simulated return data is passed back to the caller.
+ *
+ * @author nick
+ */
+
+public class RenderResponseWrapperChecker extends WrapperChecker implements
+ RenderResponse {
+
+ PortletResponse resp;
+ Element element;
+
+ public RenderResponseWrapperChecker(PortletResponse portletResp) {
+ resp = portletResp;
+ element = resp.createElement("p");
+ }
+
+ @Override
+ public void addProperty(String key, String value) {
+ String meth = "addProperty";
+ Object[] args = {key, value};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void setProperty(String key, String value) {
+ String meth = "setProperty";
+ Object[] args = {key, value};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public String encodeURL(String path) {
+ String meth = "encodeURL";
+ Object[] args = {path};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getNamespace() {
+ String meth = "getNamespace";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void addProperty(Cookie cookie) {
+ String meth = "addProperty";
+ Object[] args = {cookie};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void addProperty(String key, Element element) {
+ String meth = "addProperty";
+ Object[] args = {key, element};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public Element createElement(String tagName) throws DOMException {
+ String meth = "createElement";
+ Object[] args = {tagName};
+ Element ret = element;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getContentType() {
+ String meth = "getContentType";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getCharacterEncoding() {
+ String meth = "getCharacterEncoding";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PrintWriter getWriter() throws IOException {
+ String meth = "getWriter";
+ Object[] args = {};
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(baos);
+ PrintWriter ret = pw;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Locale getLocale() {
+ String meth = "getLocale";
+ Object[] args = {};
+ Locale ret = new Locale("en");
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void setBufferSize(int size) {
+ String meth = "setBufferSize";
+ Object[] args = {size};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public int getBufferSize() {
+ String meth = "getBufferSize";
+ Object[] args = {};
+ int ret = 42;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void flushBuffer() throws IOException {
+ String meth = "flushBuffer";
+ Object[] args = {};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void resetBuffer() {
+ String meth = "resetBuffer";
+ Object[] args = {};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public boolean isCommitted() {
+ String meth = "isCommitted";
+ Object[] args = {};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void reset() {
+ String meth = "reset";
+ Object[] args = {};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public OutputStream getPortletOutputStream() throws IOException {
+ String meth = "getPortletOutputStream";
+ Object[] args = {};
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ OutputStream ret = baos;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortletURL createRenderURL() {
+ String meth = "createRenderURL";
+ Object[] args = {};
+ PortletURL ret = ((MimeResponse)resp).createRenderURL();
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortletURL createActionURL() {
+ String meth = "createActionURL";
+ Object[] args = {};
+ PortletURL ret = ((MimeResponse)resp).createRenderURL();
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public ResourceURL createResourceURL() {
+ String meth = "createResourceURL";
+ Object[] args = {};
+ ResourceURL ret = ((MimeResponse)resp).createResourceURL();
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public CacheControl getCacheControl() {
+ String meth = "getCacheControl";
+ Object[] args = {};
+ CacheControl ret = ((MimeResponse)resp).getCacheControl();
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void setTitle(String title) {
+ String meth = "setTitle";
+ Object[] args = {title};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void setNextPossiblePortletModes(Collection<PortletMode> portletModes) {
+ String meth = "setNextPossiblePortletModes";
+ Object[] args = {portletModes};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void setContentType(String type) {
+ String meth = "setContentType";
+ Object[] args = {type};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2f638d7a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/ResourceRequestWrapperChecker.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/ResourceRequestWrapperChecker.java b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/ResourceRequestWrapperChecker.java
new file mode 100644
index 0000000..f8e9670
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/ResourceRequestWrapperChecker.java
@@ -0,0 +1,568 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package javax.portlet.tck.beans;
+
+import java.security.*;
+import java.util.*;
+import java.io.*;
+
+import javax.portlet.ResourceRequest;
+import javax.portlet.PortalContext;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.WindowState;
+import javax.servlet.http.Cookie;
+
+/**
+ * This class tests a wrapper class by simulating the class to be wrapped.The test code
+ * verifies that the arguments passed to the wrapping method are correctly passed to
+ * the wrapped class. Simulated return data is passed back to the caller.
+ *
+ * @author nick
+ */
+
+
+public class ResourceRequestWrapperChecker extends WrapperChecker implements ResourceRequest {
+
+ private PortletRequest req;
+ private PortletSession sess;
+ private PortletPreferences prefs;
+ private PortalContext pcntxt;
+ private Principal ppal;
+
+ public ResourceRequestWrapperChecker(PortletRequest portletReq) {
+ req = portletReq;
+ sess = req.getPortletSession();
+ prefs = req.getPreferences();
+ pcntxt = req.getPortalContext();
+ ppal = req.getUserPrincipal();
+ }
+
+ @Override
+ public InputStream getPortletInputStream() throws IOException {
+ String meth = "getPortletInputStream";
+ Object[] args = {};
+ byte[] bytes = "Hi there!".getBytes();
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ InputStream ret = bais;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void setCharacterEncoding(String enc) throws UnsupportedEncodingException {
+ String meth = "setCharacterEncoding";
+ Object[] args = {enc};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public BufferedReader getReader() throws UnsupportedEncodingException, IOException {
+ String meth = "getReader";
+ Object[] args = {};
+ StringReader rdr = new StringReader("Hi there!");
+ BufferedReader br = new BufferedReader(rdr);
+ BufferedReader ret = br;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getCharacterEncoding() {
+ String meth = "getCharacterEncoding";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getContentType() {
+ String meth = "getContentType";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public int getContentLength() {
+ String meth = "getContentLength";
+ Object[] args = {};
+ int ret = 42;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getMethod() {
+ String meth = "getMethod";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public boolean isWindowStateAllowed(WindowState state) {
+ String meth = "isWindowStateAllowed";
+ Object[] args = {state};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public boolean isPortletModeAllowed(PortletMode mode) {
+ String meth = "isPortletModeAllowed";
+ Object[] args = {mode};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortletMode getPortletMode() {
+ String meth = "getPortletMode";
+ Object[] args = {};
+ PortletMode ret = PortletMode.EDIT;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public WindowState getWindowState() {
+ String meth = "getWindowState";
+ Object[] args = {};
+ WindowState ret = WindowState.NORMAL;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortletPreferences getPreferences() {
+ String meth = "getPreferences";
+ Object[] args = {};
+ PortletPreferences ret = prefs;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortletSession getPortletSession() {
+ String meth = "getPortletSession";
+ Object[] args = {};
+ PortletSession ret = sess;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortletSession getPortletSession(boolean create) {
+ String meth = "getPortletSession";
+ Object[] args = {create};
+ PortletSession ret = sess;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getProperty(String name) {
+ String meth = "getProperty";
+ Object[] args = {name};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<String> getProperties(String name) {
+ String meth = "getProperties";
+ Object[] args = {name};
+ String[] strs = {"val1", "val2"};
+ Enumeration<String> ret = Collections.enumeration(Arrays.asList(strs));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<String> getPropertyNames() {
+ String meth = "getPropertyNames";
+ Object[] args = {};
+ String[] strs = {"val1", "val2"};
+ Enumeration<String> ret = Collections.enumeration(Arrays.asList(strs));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortalContext getPortalContext() {
+ String meth = "getPortalContext";
+ Object[] args = {};
+ PortalContext ret = pcntxt;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getAuthType() {
+ String meth = "getAuthType";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getContextPath() {
+ String meth = "getContextPath";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getRemoteUser() {
+ String meth = "getRemoteUser";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Principal getUserPrincipal() {
+ String meth = "getUserPrincipal";
+ Object[] args = {};
+ Principal ret = ppal;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public boolean isUserInRole(String role) {
+ String meth = "isUserInRole";
+ Object[] args = {role};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Object getAttribute(String name) {
+ String meth = "getAttribute";
+ Object[] args = {name};
+ Object ret = "object";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<String> getAttributeNames() {
+ String meth = "getAttributeNames";
+ Object[] args = {};
+ String[] strs = {"val1", "val2"};
+ Enumeration<String> ret = Collections.enumeration(Arrays.asList(strs));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getParameter(String name) {
+ String meth = "getParameter";
+ Object[] args = {name};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<String> getParameterNames() {
+ String meth = "getParameterNames";
+ Object[] args = {};
+ String[] strs = {"val1", "val2"};
+ Enumeration<String> ret = Collections.enumeration(Arrays.asList(strs));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String[] getParameterValues(String name) {
+ String meth = "getParameterValues";
+ Object[] args = {name};
+ String[] ret = {"val1", "val2"};
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Map<String, String[]> getParameterMap() {
+ String meth = "getParameterMap";
+ Object[] args = {};
+ Map<String, String[]> parms = new HashMap<String, String[]>();
+ parms.put("parm1", new String[] {"val1", "val2"});
+ parms.put("parm2", new String[] {"val1", "val2"});
+ Map<String, String[]> ret = parms;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public boolean isSecure() {
+ String meth = "isSecure";
+ Object[] args = {};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void setAttribute(String name, Object o) {
+ String meth = "setAttribute";
+ Object[] args = {name, o};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void removeAttribute(String name) {
+ String meth = "removeAttribute";
+ Object[] args = {name};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public String getRequestedSessionId() {
+ String meth = "getRequestedSessionId";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public boolean isRequestedSessionIdValid() {
+ String meth = "isRequestedSessionIdValid";
+ Object[] args = {};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getResponseContentType() {
+ String meth = "getResponseContentType";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<String> getResponseContentTypes() {
+ String meth = "getResponseContentTypes";
+ Object[] args = {};
+ String[] strs = {"val1", "val2"};
+ Enumeration<String> ret = Collections.enumeration(Arrays.asList(strs));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Locale getLocale() {
+ String meth = "getLocale";
+ Object[] args = {};
+ Locale ret = new Locale("en");
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Enumeration<Locale> getLocales() {
+ String meth = "getLocales";
+ Object[] args = {};
+ Locale[] la = {new Locale("en"), new Locale("de")};
+ Enumeration<Locale> ret = Collections.enumeration(Arrays.asList(la));
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getScheme() {
+ String meth = "getScheme";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getServerName() {
+ String meth = "getServerName";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public int getServerPort() {
+ String meth = "getServerPort";
+ Object[] args = {};
+ int ret = 42;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getWindowID() {
+ String meth = "getWindowID";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Cookie[] getCookies() {
+ String meth = "getCookies";
+ Object[] args = {};
+ Cookie[] ret = {new Cookie("name", "Bob"), new Cookie("name", "Alice")};
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Map<String, String[]> getPrivateParameterMap() {
+ String meth = "getPrivateParameterMap";
+ Object[] args = {};
+ Map<String, String[]> parms = new HashMap<String, String[]>();
+ parms.put("parm1", new String[] {"val1", "val2"});
+ parms.put("parm2", new String[] {"val1", "val2"});
+ Map<String, String[]> ret = parms;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Map<String, String[]> getPublicParameterMap() {
+ String meth = "getPublicParameterMap";
+ Object[] args = {};
+ Map<String, String[]> parms = new HashMap<String, String[]>();
+ parms.put("parm1", new String[] {"val1", "val2"});
+ parms.put("parm2", new String[] {"val1", "val2"});
+ Map<String, String[]> ret = parms;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getETag() {
+ String meth = "getETag";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getResourceID() {
+ String meth = "getResourceID";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Map<String, String[]> getPrivateRenderParameterMap() {
+ String meth = "getPrivateRenderParameterMap";
+ Object[] args = {};
+ Map<String, String[]> parms = new HashMap<String, String[]>();
+ parms.put("parm1", new String[] {"val1", "val2"});
+ parms.put("parm2", new String[] {"val1", "val2"});
+ Map<String, String[]> ret = parms;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getCacheability() {
+ String meth = "getCacheability";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2f638d7a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/ResourceResponseWrapperChecker.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/ResourceResponseWrapperChecker.java b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/ResourceResponseWrapperChecker.java
new file mode 100644
index 0000000..765f68b
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/ResourceResponseWrapperChecker.java
@@ -0,0 +1,302 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package javax.portlet.tck.beans;
+
+import java.security.*;
+import java.util.*;
+import java.io.*;
+
+import javax.portlet.*;
+import javax.servlet.http.Cookie;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+
+/**
+ * This class tests a wrapper class by simulating the class to be wrapped.The test code
+ * verifies that the arguments passed to the wrapping method are correctly passed to
+ * the wrapped class. Simulated return data is passed back to the caller.
+ *
+ * @author nick
+ */
+
+public class ResourceResponseWrapperChecker extends WrapperChecker implements
+ ResourceResponse {
+
+ PortletResponse resp;
+ Element element;
+
+ public ResourceResponseWrapperChecker(PortletResponse portletResp) {
+ resp = portletResp;
+ element = resp.createElement("p");
+ }
+
+ @Override
+ public void addProperty(String key, String value) {
+ String meth = "addProperty";
+ Object[] args = {key, value};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void setProperty(String key, String value) {
+ String meth = "setProperty";
+ Object[] args = {key, value};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public String encodeURL(String path) {
+ String meth = "encodeURL";
+ Object[] args = {path};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getNamespace() {
+ String meth = "getNamespace";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void addProperty(Cookie cookie) {
+ String meth = "addProperty";
+ Object[] args = {cookie};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void addProperty(String key, Element element) {
+ String meth = "addProperty";
+ Object[] args = {key, element};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public Element createElement(String tagName) throws DOMException {
+ String meth = "createElement";
+ Object[] args = {tagName};
+ Element ret = element;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public String getContentType() {
+ String meth = "getContentType";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void setContentType(String type) {
+ String meth = "setContentType";
+ Object[] args = {type};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public String getCharacterEncoding() {
+ String meth = "getCharacterEncoding";
+ Object[] args = {};
+ String ret = "value";
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PrintWriter getWriter() throws IOException {
+ String meth = "getWriter";
+ Object[] args = {};
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(baos);
+ PrintWriter ret = pw;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public Locale getLocale() {
+ String meth = "getLocale";
+ Object[] args = {};
+ Locale ret = new Locale("en");
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void setBufferSize(int size) {
+ String meth = "setBufferSize";
+ Object[] args = {size};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public int getBufferSize() {
+ String meth = "getBufferSize";
+ Object[] args = {};
+ int ret = 42;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void flushBuffer() throws IOException {
+ String meth = "flushBuffer";
+ Object[] args = {};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void resetBuffer() {
+ String meth = "resetBuffer";
+ Object[] args = {};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public boolean isCommitted() {
+ String meth = "isCommitted";
+ Object[] args = {};
+ boolean ret = true;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void reset() {
+ String meth = "reset";
+ Object[] args = {};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public OutputStream getPortletOutputStream() throws IOException {
+ String meth = "getPortletOutputStream";
+ Object[] args = {};
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ OutputStream ret = baos;
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public CacheControl getCacheControl() {
+ String meth = "getCacheControl";
+ Object[] args = {};
+ CacheControl ret = ((MimeResponse)resp).getCacheControl();
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public void setLocale(Locale loc) {
+ String meth = "setLocale";
+ Object[] args = {loc};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void setCharacterEncoding(String charset) {
+ String meth = "setCharacterEncoding";
+ Object[] args = {charset};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public void setContentLength(int len) {
+ String meth = "setContentLength";
+ Object[] args = {len};
+ checkArgs(meth, args);
+ return;
+
+ }
+
+ @Override
+ public PortletURL createRenderURL() {
+ String meth = "createRenderURL";
+ Object[] args = {};
+ PortletURL ret = ((MimeResponse)resp).createRenderURL();
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public PortletURL createActionURL() {
+ String meth = "createActionURL";
+ Object[] args = {};
+ PortletURL ret = ((MimeResponse)resp).createActionURL();
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+ @Override
+ public ResourceURL createResourceURL() {
+ String meth = "createResourceURL";
+ Object[] args = {};
+ ResourceURL ret = ((MimeResponse)resp).createResourceURL();
+ retVal = ret;
+ checkArgs(meth, args);
+ return ret;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2f638d7a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/WrapperChecker.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/WrapperChecker.java b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/WrapperChecker.java
new file mode 100644
index 0000000..0147085
--- /dev/null
+++ b/portlet-tck_3.0/common/src/main/java/javax/portlet/tck/beans/WrapperChecker.java
@@ -0,0 +1,90 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package javax.portlet.tck.beans;
+
+/**
+ * Abstract base class to be extended by the specific checker classes for the wrappers.
+ * The extending checker class must implement the interface to be tested.
+ *
+ * This class provides the mechanism for verifying that the arguments passed to each
+ * wrapper class method are passed correctly to the wrapped class and to verfiy that
+ * the returned value from the wrapped method is received correctly by the caller.
+ *
+ * @author Scott
+ *
+ */
+public abstract class WrapperChecker {
+
+ // expected values set before method call
+ String name;
+ Object[] args;
+
+ // expected return value from wrapped method
+ Object retVal;
+
+ // Test case handling
+ TestResult tr;
+
+ /**
+ * Prepares the wrapper tester for a specific test case
+ * @param tr test result to be updated as necessary
+ * @param name name of method to be tested
+ * @param args parameter array
+ */
+ public void prepare(TestResult tr, String name, Object... args) {
+ this.tr = tr;
+ this.name = name;
+ this.args = (args==null) ? new Object[] {} : args;
+ this.retVal = null;
+ }
+
+ public void checkRetval(Object retVal) {
+ if (tr.isTcSuccess() == false) return; // parameter check failed
+
+ if (retVal == this.retVal){
+ tr.setTcSuccess(true);
+ } else {
+ tr.setTcSuccess(false);
+ tr.appendTcDetail("return value mismatch. Expected: " + this.retVal +
+ ", Actual: " + retVal);
+ }
+ }
+
+ protected void checkArgs(String name, Object[] args) {
+ tr.setTcSuccess(true);
+ if (!name.equals(this.name)) {
+ tr.setTcSuccess(false);
+ tr.appendTcDetail("Wrong method called. Expected: " + this.name +
+ ", Actual: " + name);
+ } else if (args.length != this.args.length) {
+ tr.setTcSuccess(false);
+ tr.appendTcDetail("Wrong number of arguments. Expected: " + this.args.length +
+ ", Actual: " + args.length);
+ } else {
+ for (int ii=0; ii<args.length; ii++) {
+ if (args[ii] != this.args[ii]) {
+ tr.setTcSuccess(false);
+ tr.appendTcDetail("Argument " + ii + " mismatch: " +
+ "Expected: " + this.args[ii] + ", Actual: " + args[ii]);
+ }
+ }
+ }
+ }
+}