Author: chris.laprun(a)jboss.com
Date: 2009-11-18 13:35:56 -0500 (Wed, 18 Nov 2009)
New Revision: 652
Added:
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpSession.java
Removed:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpSession.java
Modified:
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.java
components/wsrp/trunk/pom.xml
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
Log:
- Upgraded to using common 2.0.0-CR1-SNAPSHOT for now until a new version is released.
- Made WSRPProducerImpl.getInstance return WSRPProducerImpl and added access to
"WS" interfaces for tests.
- Replaced WSRPUtils.existsAndIsNotEmpty methods by ParameterValidation versions.
- Moved MockHttp* classes to test framework so that they can be used by producer tests.
- Updated ConsumerBean so that it compiles with the removal of individual endpoint URLs,
though logic
and facelets files haven't been updated.
Modified:
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java
===================================================================
---
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java 2009-11-18
17:34:29 UTC (rev 651)
+++
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java 2009-11-18
18:35:56 UTC (rev 652)
@@ -52,10 +52,6 @@
private boolean modified;
private boolean registrationLocallyModified;
- private String serviceDescription;
- private String markup;
- private String portletManagement;
- private String registration;
private String wsdl;
private transient RegistrationInfo expectedRegistrationInfo;
@@ -92,12 +88,7 @@
public boolean isUseWSDL()
{
- if (useWSDL != null)
- {
- return useWSDL.booleanValue();
- }
-
- return getProducerInfo().getEndpointConfigurationInfo().usesWSDL();
+ return true;
}
public void setUseWSDL(boolean useWSDL)
@@ -146,12 +137,7 @@
if (consumer != null)
{
EndpointConfigurationInfo endpoint =
getProducerInfo().getEndpointConfigurationInfo();
- serviceDescription = endpoint.getServiceDescriptionURL();
- markup = endpoint.getMarkupURL();
- portletManagement = endpoint.getPortletManagementURL();
- registration = endpoint.getRegistrationURL();
wsdl = endpoint.getWsdlDefinitionURL();
- useWSDL = endpoint.usesWSDL();
}
else
{
@@ -170,46 +156,6 @@
getProducerInfo().setExpirationCacheSeconds((Integer)modifyIfNeeded(getCache(),
cache, "cache", false));
}
- public String getServiceDescription()
- {
- return serviceDescription;
- }
-
- public void setServiceDescription(String sdURL)
- {
- serviceDescription = (String)modifyIfNeeded(serviceDescription, sdURL,
"sd", true);
- }
-
- public String getMarkup()
- {
- return markup;
- }
-
- public void setMarkup(String markupURL)
- {
- markup = (String)modifyIfNeeded(markup, markupURL, "m", true);
- }
-
- public String getPortletManagement()
- {
- return portletManagement;
- }
-
- public void setPortletManagement(String pmURL)
- {
- portletManagement = (String)modifyIfNeeded(portletManagement, pmURL,
"pm", true);
- }
-
- public String getRegistration()
- {
- return registration;
- }
-
- public void setRegistration(String rURL)
- {
- registration = (String)modifyIfNeeded(registration, rURL, "r", true);
- }
-
public String getWsdl()
{
return wsdl;
@@ -375,14 +321,7 @@
// update values
ProducerInfo prodInfo = getProducerInfo();
EndpointConfigurationInfo endpointInfo =
prodInfo.getEndpointConfigurationInfo();
- endpointInfo.setMarkupURL(markup);
- endpointInfo.setServiceDescriptionURL(serviceDescription);
- endpointInfo.setPortletManagementURL(portletManagement);
- endpointInfo.setRegistrationURL(registration);
- if (isUseWSDL())
- {
- internalSetWsdl(wsdl);
- }
+ internalSetWsdl(wsdl);
saveToRegistry(prodInfo);
}
@@ -554,6 +493,7 @@
}
// todo: valueChangeListener not needed anymore when events on RegistrationProperties
work
+
public void regPropListener(ValueChangeEvent event)
{
if (!registrationLocallyModified)
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java 2009-11-18
17:34:29 UTC (rev 651)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/UserContextConverter.java 2009-11-18
18:35:56 UTC (rev 652)
@@ -24,7 +24,7 @@
package org.gatein.wsrp;
import org.gatein.common.NotYetImplemented;
-import static org.gatein.common.p3p.P3PConstants.*;
+import org.gatein.common.util.ParameterValidation;
import org.gatein.pc.api.spi.UserContext;
import org.oasis.wsrp.v1.Contact;
import org.oasis.wsrp.v1.EmployerInfo;
@@ -45,6 +45,8 @@
import java.util.Locale;
import java.util.Map;
+import static org.gatein.common.p3p.P3PConstants.*;
+
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision: 11352 $
@@ -68,7 +70,7 @@
{
org.oasis.wsrp.v1.UserContext wsrpUserContext =
WSRPTypeFactory.createUserContext(userContextKey);
wsrpUserContext.setProfile(createUserProfileFrom(userContext));
- if (WSRPUtils.existsAndIsNotEmpty(userCategories))
+ if (ParameterValidation.existsAndIsNotEmpty(userCategories))
{
wsrpUserContext.getUserCategories().addAll(userCategories);
}
@@ -79,7 +81,7 @@
{
Map<String, String> userInfos = userContext.getInformations();
- if (!WSRPUtils.existsAndIsNotEmpty(userInfos))
+ if (!ParameterValidation.existsAndIsNotEmpty(userInfos))
{
return null;
}
@@ -304,7 +306,7 @@
{
List<Locale> locales = Collections.emptyList();
- if (WSRPUtils.existsAndIsNotEmpty(desiredLocales))
+ if (ParameterValidation.existsAndIsNotEmpty(desiredLocales))
{
locales = new ArrayList<Locale>(desiredLocales.size());
for (String desiredLocale : desiredLocales)
Modified: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java 2009-11-18
17:34:29 UTC (rev 651)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPTypeFactory.java 2009-11-18
18:35:56 UTC (rev 652)
@@ -365,11 +365,11 @@
markupParams.setSecureClientCommunication(secureClientCommunication);
markupParams.setMode(mode);
markupParams.setWindowState(windowState);
- if (WSRPUtils.existsAndIsNotEmpty(locales))
+ if (ParameterValidation.existsAndIsNotEmpty(locales))
{
markupParams.getLocales().addAll(locales);
}
- if (WSRPUtils.existsAndIsNotEmpty(mimeTypes))
+ if (ParameterValidation.existsAndIsNotEmpty(mimeTypes))
{
markupParams.getMimeTypes().addAll(mimeTypes);
}
@@ -782,7 +782,7 @@
public static ModelDescription createModelDescription(List<PropertyDescription>
propertyDescriptions)
{
ModelDescription description = new ModelDescription();
- if (WSRPUtils.existsAndIsNotEmpty(propertyDescriptions))
+ if (ParameterValidation.existsAndIsNotEmpty(propertyDescriptions))
{
description.getPropertyDescriptions().addAll(propertyDescriptions);
}
@@ -880,7 +880,7 @@
description.setRegistrationContext(registrationContext);
description.setPortletContext(portletContext);
description.setUserContext(userContext);
- if (WSRPUtils.existsAndIsNotEmpty(desiredLocales))
+ if (ParameterValidation.existsAndIsNotEmpty(desiredLocales))
{
description.getDesiredLocales().addAll(desiredLocales);
}
@@ -929,7 +929,7 @@
public static DestroyPortletsResponse
createDestroyPortletsResponse(List<DestroyFailed> destroyFailed)
{
DestroyPortletsResponse destroyPortletsResponse = new DestroyPortletsResponse();
- if (WSRPUtils.existsAndIsNotEmpty(destroyFailed))
+ if (ParameterValidation.existsAndIsNotEmpty(destroyFailed))
{
destroyPortletsResponse.getDestroyFailed().addAll(destroyFailed);
}
@@ -1004,7 +1004,7 @@
DestroyPortlets destroyPortlets = new DestroyPortlets();
destroyPortlets.setRegistrationContext(registrationContext);
- if (WSRPUtils.existsAndIsNotEmpty(portletHandles))
+ if (ParameterValidation.existsAndIsNotEmpty(portletHandles))
{
destroyPortlets.getPortletHandles().addAll(portletHandles);
}
@@ -1054,7 +1054,7 @@
ReleaseSessions sessions = new ReleaseSessions();
sessions.setRegistrationContext(registrationContext);
- if (WSRPUtils.existsAndIsNotEmpty(sessionIDs))
+ if (ParameterValidation.existsAndIsNotEmpty(sessionIDs))
{
sessions.getSessionIDs().addAll(sessionIDs);
}
@@ -1105,15 +1105,15 @@
MarkupType markupType = new MarkupType();
markupType.setMimeType(mimeType);
- if (WSRPUtils.existsAndIsNotEmpty(modeNames))
+ if (ParameterValidation.existsAndIsNotEmpty(modeNames))
{
markupType.getModes().addAll(modeNames);
}
- if (WSRPUtils.existsAndIsNotEmpty(windowStateNames))
+ if (ParameterValidation.existsAndIsNotEmpty(windowStateNames))
{
markupType.getWindowStates().addAll(windowStateNames);
}
- if (WSRPUtils.existsAndIsNotEmpty(localeNames))
+ if (ParameterValidation.existsAndIsNotEmpty(localeNames))
{
markupType.getLocales().addAll(localeNames);
}
Modified: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.java
===================================================================
--- components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.java 2009-11-18
17:34:29 UTC (rev 651)
+++ components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPUtils.java 2009-11-18
18:35:56 UTC (rev 652)
@@ -47,7 +47,6 @@
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -453,24 +452,4 @@
localizedString.setResourceName(wsrpLocalizedString.getResourceName());
return localizedString;
}
-
- /**
- * @param collection
- * @return
- * @deprecated use ParameterValidation.existsAndIsNotEmpty instead
- */
- public static boolean existsAndIsNotEmpty(Collection collection)
- {
- return collection != null && !collection.isEmpty();
- }
-
- /**
- * @param map
- * @return
- * @deprecated use ParameterValidation.existsAndIsNotEmpty instead
- */
- public static boolean existsAndIsNotEmpty(Map map)
- {
- return map != null && !map.isEmpty();
- }
}
Deleted:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java 2009-11-18
17:34:29 UTC (rev 651)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java 2009-11-18
18:35:56 UTC (rev 652)
@@ -1,130 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.gatein.wsrp.test.support;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.test.support.MockHttpServletRequest">Chris
- * Laprun</a>
- * @version $Revision: 11416 $
- * @since 2.4
- */
-public class MockHttpServletRequest implements InvocationHandler, Serializable
-{
- private HttpSession session;
-
- private Map attrs;
- public static String scheme = "http";
- public static String serverName = "test";
- public static Integer serverPort = 1234;
-
- private MockHttpServletRequest(HttpSession session)
- {
- this.session = session;
- this.attrs = new HashMap();
- }
-
- /**
- * @param session if <code>null</code>, a new MockHttpSession will be
created and used instead
- * @return
- */
- public static HttpServletRequest createMockRequest(HttpSession session)
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- if (session == null)
- {
- session = MockHttpSession.createMockSession();
- }
-
- return (HttpServletRequest)Proxy.newProxyInstance(loader, new
Class[]{HttpServletRequest.class},
- new MockHttpServletRequest(session));
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- {
- String methodName = method.getName();
- if ("getSession".equals(methodName))
- {
- return session;
- }
- if ("getHeader".equals(methodName))
- {
- if ("User-Agent".equals(args[0]))
- {
- return "Mock Client User Agent";
- }
- return null;
- }
- if ("toString".equals(methodName))
- {
- return "MockHttpServletResponse";
- }
- if ("getAttribute".equals(methodName))
- {
- return attrs.get(args[0]);
- }
- if ("setAttribute".equals(methodName))
- {
- String name = (String)args[0];
- Object value = args[1];
- if (value != null)
- {
- attrs.put(name, value);
- }
- else
- {
- attrs.remove(value);
- }
- return null;
- }
- if ("removeAttribute".equals(methodName))
- {
- String name = (String)args[0];
- attrs.remove(name);
- return null;
- }
- if ("getScheme".equals(methodName))
- {
- return scheme;
- }
- if ("getServerName".equals(methodName))
- {
- return serverName;
- }
- if ("getServerPort".equals(methodName))
- {
- return serverPort;
- }
- throw new UnsupportedOperationException("MockHttpServletRequest does not
support: " + method);
- }
-}
Deleted:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java 2009-11-18
17:34:29 UTC (rev 651)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java 2009-11-18
18:35:56 UTC (rev 652)
@@ -1,71 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.gatein.wsrp.test.support;
-
-import javax.servlet.http.HttpServletResponse;
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-/**
- * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.test.support.MockHttpServletResponse">Chris
- * Laprun</a>
- * @version $Revision: 8784 $
- * @since 2.4
- */
-public class MockHttpServletResponse implements InvocationHandler, Serializable
-{
- Object cookie;
-
- private MockHttpServletResponse()
- {
- }
-
- public static HttpServletResponse createMockResponse()
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- return (HttpServletResponse)Proxy.newProxyInstance(loader, new
Class[]{HttpServletResponse.class}, new MockHttpServletResponse());
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- {
- String methodName = method.getName();
- if ("addCookie".equals(methodName))
- {
- cookie = args[0];
- return null;
- }
- else if ("reset".equals(methodName))
- {
- cookie = null;
- return null;
- }
- else if ("toString".equals(methodName))
- {
- return "MockHttpServletResponse";
- }
- throw new UnsupportedOperationException("MockHttpServletResponse does not
support: " + method);
- }
-}
Deleted:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpSession.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpSession.java 2009-11-18
17:34:29 UTC (rev 651)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpSession.java 2009-11-18
18:35:56 UTC (rev 652)
@@ -1,90 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.gatein.wsrp.test.support;
-
-import org.gatein.common.util.Tools;
-
-import javax.servlet.http.HttpSession;
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.test.support.MockHttpSession">Chris
- * Laprun</a>
- * @version $Revision: 8784 $
- * @since 2.4
- */
-public class MockHttpSession implements InvocationHandler, Serializable
-{
- private final Map map = new HashMap();
-
- private MockHttpSession()
- {
- }
-
- public static HttpSession createMockSession()
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- return (HttpSession)Proxy.newProxyInstance(loader, new Class[]{HttpSession.class},
new MockHttpSession());
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- {
- String methodName = method.getName();
- if ("setAttribute".equals(methodName))
- {
- map.put(args[0], args[1]);
- return null;
- }
- else if ("removeAttribute".equals(methodName))
- {
- map.remove(args[0]);
- return null;
- }
- else if ("getAttribute".equals(methodName))
- {
- return map.get(args[0]);
- }
- else if ("getAttributeNames".equals(methodName))
- {
- return Tools.toEnumeration(map.keySet().iterator());
- }
- else if ("toString".equals(methodName))
- {
- return "MockHttpSession";
- }
- else if ("getId".equals(methodName))
- {
- return "SESSION_ID";
- }
- else
- {
- throw new UnsupportedOperationException("MockHttpSession does not support:
" + method);
- }
- }
-}
Modified: components/wsrp/trunk/pom.xml
===================================================================
--- components/wsrp/trunk/pom.xml 2009-11-18 17:34:29 UTC (rev 651)
+++ components/wsrp/trunk/pom.xml 2009-11-18 18:35:56 UTC (rev 652)
@@ -49,7 +49,7 @@
<properties>
<version.gatein.pc>2.1.0-Beta02</version.gatein.pc>
- <version.gatein.common>2.0.0-Beta03</version.gatein.common>
+ <version.gatein.common>2.0.0-CR1-SNAPSHOT</version.gatein.common>
<version.gatein.wci>2.0.0-Beta02</version.gatein.wci>
<version.jsf>1.2_12</version.jsf>
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java 2009-11-18
17:34:29 UTC (rev 651)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/WSRPProducerImpl.java 2009-11-18
18:35:56 UTC (rev 652)
@@ -120,12 +120,13 @@
private boolean started = false;
// On-demand class holder Singleton pattern (multi-thread safe)
+
private static final class InstanceHolder
{
public static final WSRPProducerImpl producer = new WSRPProducerImpl();
}
- static WSRPProducer getInstance()
+ static WSRPProducerImpl getInstance()
{
return InstanceHolder.producer;
}
@@ -473,4 +474,26 @@
{
WSRPValidator.setStrict(strictMode);
}
+
+ // access to handlers for tests
+
+ MarkupInterface getMarkupInterface()
+ {
+ return markupHandler;
+ }
+
+ ServiceDescriptionInterface getServiceDescriptionInterface()
+ {
+ return serviceDescriptionHandler;
+ }
+
+ RegistrationInterface getRegistrationInterface()
+ {
+ return registrationHandler;
+ }
+
+ PortletManagementInterface getPortletManagementInterface()
+ {
+ return portletManagementHandler;
+ }
}
Copied:
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java
(from rev 642,
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java)
===================================================================
---
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java
(rev 0)
+++
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java 2009-11-18
18:35:56 UTC (rev 652)
@@ -0,0 +1,130 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.gatein.wsrp.test.support;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.test.support.MockHttpServletRequest">Chris
+ * Laprun</a>
+ * @version $Revision: 11416 $
+ * @since 2.4
+ */
+public class MockHttpServletRequest implements InvocationHandler, Serializable
+{
+ private HttpSession session;
+
+ private Map attrs;
+ public static String scheme = "http";
+ public static String serverName = "test";
+ public static Integer serverPort = 1234;
+
+ private MockHttpServletRequest(HttpSession session)
+ {
+ this.session = session;
+ this.attrs = new HashMap();
+ }
+
+ /**
+ * @param session if <code>null</code>, a new MockHttpSession will be
created and used instead
+ * @return
+ */
+ public static HttpServletRequest createMockRequest(HttpSession session)
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+ if (session == null)
+ {
+ session = MockHttpSession.createMockSession();
+ }
+
+ return (HttpServletRequest)Proxy.newProxyInstance(loader, new
Class[]{HttpServletRequest.class},
+ new MockHttpServletRequest(session));
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ String methodName = method.getName();
+ if ("getSession".equals(methodName))
+ {
+ return session;
+ }
+ if ("getHeader".equals(methodName))
+ {
+ if ("User-Agent".equals(args[0]))
+ {
+ return "Mock Client User Agent";
+ }
+ return null;
+ }
+ if ("toString".equals(methodName))
+ {
+ return "MockHttpServletResponse";
+ }
+ if ("getAttribute".equals(methodName))
+ {
+ return attrs.get(args[0]);
+ }
+ if ("setAttribute".equals(methodName))
+ {
+ String name = (String)args[0];
+ Object value = args[1];
+ if (value != null)
+ {
+ attrs.put(name, value);
+ }
+ else
+ {
+ attrs.remove(value);
+ }
+ return null;
+ }
+ if ("removeAttribute".equals(methodName))
+ {
+ String name = (String)args[0];
+ attrs.remove(name);
+ return null;
+ }
+ if ("getScheme".equals(methodName))
+ {
+ return scheme;
+ }
+ if ("getServerName".equals(methodName))
+ {
+ return serverName;
+ }
+ if ("getServerPort".equals(methodName))
+ {
+ return serverPort;
+ }
+ throw new UnsupportedOperationException("MockHttpServletRequest does not
support: " + method);
+ }
+}
Property changes on:
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java
___________________________________________________________________
Name: svn:executable
+ *
Copied:
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java
(from rev 642,
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java)
===================================================================
---
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java
(rev 0)
+++
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java 2009-11-18
18:35:56 UTC (rev 652)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.gatein.wsrp.test.support;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.test.support.MockHttpServletResponse">Chris
+ * Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.4
+ */
+public class MockHttpServletResponse implements InvocationHandler, Serializable
+{
+ Object cookie;
+
+ private MockHttpServletResponse()
+ {
+ }
+
+ public static HttpServletResponse createMockResponse()
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return (HttpServletResponse)Proxy.newProxyInstance(loader, new
Class[]{HttpServletResponse.class}, new MockHttpServletResponse());
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ String methodName = method.getName();
+ if ("addCookie".equals(methodName))
+ {
+ cookie = args[0];
+ return null;
+ }
+ else if ("reset".equals(methodName))
+ {
+ cookie = null;
+ return null;
+ }
+ else if ("toString".equals(methodName))
+ {
+ return "MockHttpServletResponse";
+ }
+ throw new UnsupportedOperationException("MockHttpServletResponse does not
support: " + method);
+ }
+}
Property changes on:
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java
___________________________________________________________________
Name: svn:executable
+ *
Copied:
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpSession.java
(from rev 642,
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpSession.java)
===================================================================
---
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpSession.java
(rev 0)
+++
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpSession.java 2009-11-18
18:35:56 UTC (rev 652)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.gatein.wsrp.test.support;
+
+import org.gatein.common.util.Tools;
+
+import javax.servlet.http.HttpSession;
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.test.support.MockHttpSession">Chris
+ * Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.4
+ */
+public class MockHttpSession implements InvocationHandler, Serializable
+{
+ private final Map map = new HashMap();
+
+ private MockHttpSession()
+ {
+ }
+
+ public static HttpSession createMockSession()
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return (HttpSession)Proxy.newProxyInstance(loader, new Class[]{HttpSession.class},
new MockHttpSession());
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ String methodName = method.getName();
+ if ("setAttribute".equals(methodName))
+ {
+ map.put(args[0], args[1]);
+ return null;
+ }
+ else if ("removeAttribute".equals(methodName))
+ {
+ map.remove(args[0]);
+ return null;
+ }
+ else if ("getAttribute".equals(methodName))
+ {
+ return map.get(args[0]);
+ }
+ else if ("getAttributeNames".equals(methodName))
+ {
+ return Tools.toEnumeration(map.keySet().iterator());
+ }
+ else if ("toString".equals(methodName))
+ {
+ return "MockHttpSession";
+ }
+ else if ("getId".equals(methodName))
+ {
+ return "SESSION_ID";
+ }
+ else
+ {
+ throw new UnsupportedOperationException("MockHttpSession does not support:
" + method);
+ }
+ }
+}
Property changes on:
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/support/MockHttpSession.java
___________________________________________________________________
Name: svn:executable
+ *