Author: chris.laprun(a)jboss.com
Date: 2009-11-12 07:42:15 -0500 (Thu, 12 Nov 2009)
New Revision: 579
Added:
components/wsrp/trunk/consumer/src/test/
components/wsrp/trunk/consumer/src/test/java/
components/wsrp/trunk/consumer/src/test/java/org/
components/wsrp/trunk/consumer/src/test/java/org/gatein/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ConsumerRegistryTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/EndpointConfigurationInfoTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerSessionInformationTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RegistrationInfoTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RegistrationPropertyTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RenderHandlerTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/WSRPConsumerBaseTest.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/handler/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/handler/RequestHeaderClientHandlerTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/InteropServiceDescriptionTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/PortletManagementTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/ServiceDescriptionTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/V1ConsumerBaseTest.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/BehaviorRegistry.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/TestWSRPProducer.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/TestWSRPProducerImpl.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/MarkupBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/PortletManagementBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/RegistrationBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/ServiceDescriptionBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/TestProducerBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicMarkupBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicPortletManagementBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicServiceDescriptionBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/DestroyClonesPortletManagementBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/EmptyMarkupBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/GroupedPortletsServiceDescriptionBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/InitCookieMarkupBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/InitCookieNotRequiredMarkupBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/NullMarkupBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/PerGroupInitCookieMarkupBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/PerUserInitCookieMarkupBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/ResourceMarkupBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/SessionMarkupBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/interop/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/interop/LiferayServiceDescriptionBehavior.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/BehaviorBackedServiceFactory.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockConsumerRegistry.java
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
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/TestPortletInvocationContext.java
Modified:
components/wsrp/trunk/consumer/pom.xml
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/handler/MockSOAPMessageContext.java
Log:
- Added tests though some are currently not activated until they can be fully migrated to
the new architecture.
- Make EndpointConfigurationInfo use ServiceFactory instead of specific implementation.
- Added WSDL-related methods on ServiceFactory. Should probably remove individual endpoint
methods at some point.
- Fixed MockSOAPMessageContext.invoke as getProperty is now get in JAX-WS and added
argument checking for added test security.
Modified: components/wsrp/trunk/consumer/pom.xml
===================================================================
--- components/wsrp/trunk/consumer/pom.xml 2009-11-12 12:04:05 UTC (rev 578)
+++ components/wsrp/trunk/consumer/pom.xml 2009-11-12 12:42:15 UTC (rev 579)
@@ -21,7 +21,8 @@
~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-->
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.gatein.wsrp</groupId>
<artifactId>wsrp-parent</artifactId>
@@ -45,7 +46,7 @@
<groupId>org.gatein.wsrp</groupId>
<artifactId>wsrp-wsrp1-ws</artifactId>
</dependency>
-
+
<dependency>
<groupId>org.gatein.common</groupId>
<artifactId>common-common</artifactId>
@@ -86,6 +87,34 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>jboss-unit-remote</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.wsrp</groupId>
+ <artifactId>test-framework</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
+ <!-- Disable some tests for now until we can find some time to work on migrating
them -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>org/gatein/wsrp/protocol/v1/*</exclude>
+
<exclude>org/gatein/wsrp/consumer/ConsumerRegistryTestCase*</exclude>
+
<exclude>org/gatein/wsrp/consumer/EndpointConfigurationInfoTestCase*</exclude>
+
<exclude>org/gatein/wsrp/consumer/ProducerInfoTestCase*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java 2009-11-12
12:04:05 UTC (rev 578)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/EndpointConfigurationInfo.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -56,7 +56,7 @@
// transient variables
/** Access to the WS */
- private transient SOAPServiceFactory serviceFactory;
+ private transient ServiceFactory serviceFactory;
private transient String remoteHostAddress;
// Used to ensure that even invalid values can be persisted to DB so that it can be
accessed from the GUI
@@ -80,6 +80,13 @@
serviceFactory = new SOAPServiceFactory();
}
+ EndpointConfigurationInfo(ProducerInfo producerInfo, ServiceFactory serviceFactory)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(producerInfo,
"ProducerInfo");
+ producerInfo.setEndpointConfigurationInfo(this);
+ this.serviceFactory = serviceFactory;
+ }
+
public Long getKey()
{
return key;
@@ -313,7 +320,7 @@
}
}
- private ServiceFactory getServiceFactory()
+ ServiceFactory getServiceFactory()
{
initServiceFactoryIfNeeded();
startServiceFactoryIfNeeded();
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java 2009-11-12
12:04:05 UTC (rev 578)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/ServiceFactory.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -69,4 +69,8 @@
void start() throws Exception;
void stop();
+
+ void setWsdlDefinitionURL(String wsdlDefinitionURL) throws Exception;
+
+ String getWsdlDefinitionURL();
}
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ConsumerRegistryTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ConsumerRegistryTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ConsumerRegistryTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,123 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, 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.consumer;
+
+import junit.framework.TestCase;
+import org.gatein.wsrp.WSRPConsumer;
+import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
+import org.gatein.wsrp.consumer.registry.xml.XMLConsumerRegistry;
+import org.jboss.unit.api.pojo.annotations.Test;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 12686 $
+ * @since 2.6
+ */
+@Test
+public class ConsumerRegistryTestCase extends TestCase
+{
+ private ConsumerRegistry registry = new XMLConsumerRegistry();
+
+ public ConsumerRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry(ConsumerRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public void testCRUD()
+ {
+// TransactionAssert.beginTransaction();
+ String id = "test";
+ WSRPConsumer consumer = registry.createConsumer(id, null);
+ assertNotNull(consumer);
+ assertEquals(id, consumer.getProducerId());
+ ProducerInfo info = consumer.getProducerInfo();
+ assertNotNull(info);
+ assertEquals(consumer.getProducerId(), info.getId());
+ EndpointConfigurationInfo endpoint = info.getEndpointConfigurationInfo();
+ assertNotNull(endpoint);
+ assertEquals(EndpointConfigurationInfo.UNSET,
endpoint.getServiceDescriptionURL());
+ assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getMarkupURL());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
+// TransactionAssert.commitTransaction();
+
+// TransactionAssert.beginTransaction();
+ try
+ {
+ registry.createConsumer(id, null);
+ fail("Shouldn't be possible to create a consumer with an existing
id");
+ }
+ catch (ConsumerException expected)
+ {
+ // transaction should have been rolled back
+// TransactionAssert.rollbackTransaction();
+ }
+
+// TransactionAssert.beginTransaction();
+ consumer = registry.getConsumer(id);
+ assertNotNull(consumer);
+ assertEquals(id, consumer.getProducerId());
+ info = consumer.getProducerInfo();
+ assertNotNull(info);
+ assertEquals(consumer.getProducerId(), info.getId());
+ endpoint = info.getEndpointConfigurationInfo();
+ assertNotNull(endpoint);
+ assertEquals(EndpointConfigurationInfo.UNSET,
endpoint.getServiceDescriptionURL());
+ assertEquals(EndpointConfigurationInfo.UNSET, endpoint.getMarkupURL());
+ assertTrue(info.getRegistrationInfo().isUndetermined());
+
+ assertNull(registry.getConsumer("inexistent"));
+ Collection consumers = registry.getConfiguredConsumers();
+ assertNotNull(consumers);
+ assertEquals(1, consumers.size());
+ assertTrue(consumers.contains(consumer));
+// TransactionAssert.commitTransaction();
+ }
+
+ public void testUpdateProducerInfo()
+ {
+ // create a foo consumer
+// TransactionAssert.beginTransaction();
+ String id = "foo";
+ WSRPConsumer consumer = registry.createConsumer(id, null);
+ ProducerInfo info = consumer.getProducerInfo();
+// TransactionAssert.commitTransaction();
+
+// TransactionAssert.beginTransaction();
+ // change the id on the consumer's producer info and save it
+ info.setId("bar");
+ registry.updateProducerInfo(info);
+
+ assertNull(registry.getConsumer(id));
+ assertEquals(consumer, registry.getConsumer("bar"));
+// TransactionAssert.commitTransaction();
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ConsumerRegistryTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/EndpointConfigurationInfoTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/EndpointConfigurationInfoTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/EndpointConfigurationInfoTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,160 @@
+/*
+* 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.consumer;
+
+import junit.framework.TestCase;
+import org.gatein.pc.api.InvokerUnavailableException;
+import org.gatein.wsrp.services.ServiceFactory;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8893 $
+ * @since 2.6
+ */
+public class EndpointConfigurationInfoTestCase extends TestCase
+{
+ private EndpointConfigurationInfo info;
+ private String url = "http://www.example.com/";
+
+ protected void setUp() throws Exception
+ {
+// info = new EndpointConfigurationInfo(); // todo fix me
+ }
+
+ public void testSetURLs() throws InvokerUnavailableException
+ {
+ // default state is to use WSDL
+ assertTrue(info.usesWSDL());
+
+
+ info.setServiceDescriptionURL(url);
+ assertEquals(url, info.getServiceDescriptionURL());
+
+ // changing the URLs should switch to not using WSDL anymore...
+ assertFalse(info.usesWSDL());
+ try
+ {
+ info.getServiceFactory();
+ fail("Missing markup URL: service factory should not be
initialized");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+
+ info.setMarkupURL(url);
+ assertFalse(info.usesWSDL());
+ assertNotNull(info.getServiceFactory());
+ assertEquals(url, info.getServiceFactory().getServiceDescriptionURL());
+ assertEquals(url, info.getServiceFactory().getMarkupURL());
+ assertTrue(info.getServiceFactory().isAvailable());
+ }
+
+ public void testSetWSDLURL() throws InvokerUnavailableException
+ {
+ assertTrue(info.usesWSDL());
+
+ // todo fix me
+
+ /*info.setServiceDescriptionURL(url);
+ info.setMarkupURL(url);
+ assertTrue(info.getServiceFactory() instanceof
PerEndpointSOAPInvokerServiceFactory);
+ assertFalse(info.usesWSDL());
+
+ String bea = "http://wsrp.bea.com:7001/producer/producer?WSDL";
+ info.setWsdlDefinitionURL(bea);
+ assertEquals(bea, info.getWsdlDefinitionURL());
+ assertTrue(info.getServiceFactory() instanceof RemoteSOAPInvokerServiceFactory);
+ assertEquals(bea,
((RemoteSOAPInvokerServiceFactory)info.getServiceFactory()).getWsdlDefinitionURL());
+ assertTrue(info.usesWSDL());
+
+ info.setMarkupURL(url);
+ assertEquals(url, info.getMarkupURL());
+ assertEquals(url, info.getServiceFactory().getMarkupURL());
+ assertFalse(info.usesWSDL());*/
+ }
+
+ public void testSetInvalidWSDLURL()
+ {
+ info.setWsdlDefinitionURL(url);
+ assertTrue(info.usesWSDL());
+ assertEquals(url, info.getWsdlDefinitionURL());
+ }
+
+ public void testSetNullWSDLURL()
+ {
+ info.setServiceDescriptionURL(url);
+ info.setMarkupURL(url);
+
+ // it should be possible to set the WSDL to null for Hibernate
+ info.setWsdlDefinitionURL(null);
+
+ assertFalse(info.usesWSDL());
+ }
+
+ public void testRefreshWSDL() throws Exception
+ {
+ assertTrue(info.isRefreshNeeded());
+ assertFalse(info.isAvailable());
+
+ String bea = "http://wsrp.bea.com:7001/producer/producer?WSDL";
+ info.setWsdlDefinitionURL(bea);
+ info.refresh();
+ assertFalse(info.isRefreshNeeded());
+ assertTrue(info.isAvailable());
+ }
+
+ public void testRefresh() throws Exception
+ {
+ assertTrue(info.isRefreshNeeded());
+ assertFalse(info.isAvailable());
+
+ // change the service factory to a fake one to be able to simulate access to
endpoint
+// info.setServiceFactory(new BehaviorBackedServiceFactory()); //todo
+ info.refresh();
+ assertFalse(info.isRefreshNeeded());
+ assertTrue(info.isAvailable());
+
+ info.setServiceDescriptionURL(url);
+ assertTrue(info.isRefreshNeeded());
+
+ info.getRegistrationService();
+ assertTrue(info.isRefreshNeeded());
+
+ info.getServiceDescriptionService();
+ assertFalse(info.isRefreshNeeded());
+ }
+
+ public void testGetServiceFactory() throws Exception
+ {
+ assertTrue(info.isRefreshNeeded());
+ assertFalse(info.isAvailable());
+
+ // change the service factory to a fake one to be able to simulate access to
endpoint
+// info.setServiceFactory(new BehaviorBackedServiceFactory()); // todo
+ ServiceFactory factory = info.getServiceFactory();
+ assertNotNull(factory);
+ assertFalse(info.isRefreshNeeded());
+ assertTrue(info.isAvailable());
+ assertTrue(factory.isAvailable());
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/EndpointConfigurationInfoTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,373 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, 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.consumer;
+
+import junit.framework.TestCase;
+import org.gatein.pc.api.Portlet;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.wsrp.WSRPExceptionFactory;
+import org.gatein.wsrp.test.protocol.v1.PortletManagementBehavior;
+import org.gatein.wsrp.test.protocol.v1.RegistrationBehavior;
+import org.gatein.wsrp.test.protocol.v1.ServiceDescriptionBehavior;
+import org.gatein.wsrp.test.support.BehaviorBackedServiceFactory;
+import org.gatein.wsrp.test.support.MockConsumerRegistry;
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.InconsistentParameters;
+import org.oasis.wsrp.v1.InvalidHandle;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.InvalidRegistrationFault;
+import org.oasis.wsrp.v1.InvalidUserCategory;
+import org.oasis.wsrp.v1.MissingParameters;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.OperationFailedFault;
+import org.oasis.wsrp.v1.PortletDescription;
+import org.oasis.wsrp.v1.Property;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.RegistrationData;
+import org.oasis.wsrp.v1.ResourceList;
+import org.oasis.wsrp.v1.UserContext;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 12686 $
+ * @since 2.6
+ */
+public class ProducerInfoTestCase extends TestCase
+{
+ private ProducerInfo info;
+ private BehaviorBackedServiceFactory serviceFactory;
+
+ protected void setUp() throws Exception
+ {
+ info = new ProducerInfo();
+ info.setId("test");
+ serviceFactory = new BehaviorBackedServiceFactory();
+
+ EndpointConfigurationInfo eci = new EndpointConfigurationInfo(info,
serviceFactory);
+
+ info.setRegistry(new MockConsumerRegistry());
+ }
+
+ public void testRefreshAndCache() throws Exception
+ {
+ ServiceDescriptionBehavior behavior = new ServiceDescriptionBehavior();
+ serviceFactory.getRegistry().setServiceDescriptionBehavior(behavior);
+
+ assertNull(info.getExpirationCacheSeconds());
+
+ assertTrue(info.isRefreshNeeded(false));
+ assertFalse(info.isRegistrationChecked());
+ assertTrue(info.refresh(false));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
+ assertTrue(info.refresh(false));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
+ assertEquals(2, behavior.getCallCount());
+
+ info.setExpirationCacheSeconds(1);
+ assertEquals(new Integer(1), info.getExpirationCacheSeconds());
+ assertTrue(info.refresh(false));
+ assertFalse(info.refresh(false));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
+ assertEquals(3, behavior.getCallCount());
+
+ // wait for cache expiration
+ Thread.sleep(1500);
+ assertFalse("refresh is not needed if cache is not considered",
info.isRefreshNeeded(false));
+ assertTrue("refresh is needed if cache is considered since it has
expired", info.isRefreshNeeded(true));
+ assertTrue(info.refresh(false));
+ assertFalse("Was just refreshed so refresh is not needed even considering
cache", info.isRefreshNeeded(true));
+ assertTrue(info.isRegistrationChecked());
+ assertFalse(info.refresh(false));
+ assertTrue(info.refresh(true));
+ assertFalse(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistrationChecked());
+ assertEquals(5, behavior.getCallCount());
+ }
+
+ public void testGetPortlet() throws Exception
+ {
+ ServiceDescriptionBehavior behavior = new ServiceDescriptionBehavior();
+ behavior.addPortletDescription(behavior.createPortletDescription("test",
null));
+ serviceFactory.getRegistry().setServiceDescriptionBehavior(behavior);
+
+ // activate caching for this test so that we can simulate portlet deployment on the
producer with a cached SD
+ info.setExpirationCacheSeconds(1000);
+
+ PortletContext portletContext =
PortletContext.createPortletContext("test");
+ Portlet portlet = info.getPortlet(portletContext);
+ assertNotNull(portlet);
+ assertEquals(portletContext, portlet.getContext());
+ assertEquals(1, behavior.getCallCount());
+
+ // test2 is not in the service description, so it should be looked up via Portlet
Management...
+ portletContext = PortletContext.createPortletContext("test2");
+ // add portlet management behavior
+ TestPortletManagementBehavior pmBehavior = new TestPortletManagementBehavior();
+ serviceFactory.getRegistry().setPortletManagementBehavior(pmBehavior);
+ portlet = info.getPortlet(portletContext);
+ assertEquals(1, pmBehavior.getCallCount());
+ assertNotNull(portlet);
+ assertEquals(portletContext, portlet.getContext());
+
+ // try again, this time without a portlet management interface, the service
description should be refreshed
+ serviceFactory.getRegistry().setPortletManagementBehavior(null);
+ // simulate a new portlet deployment since last time the SD was refreshed
+ behavior.addPortletDescription(behavior.createPortletDescription("test3",
null));
+ portletContext = PortletContext.createPortletContext("test3");
+ portlet = info.getPortlet(portletContext);
+ assertEquals(2, behavior.getCallCount());
+ assertNotNull(portlet);
+ assertEquals(portletContext, portlet.getContext());
+ }
+
+ public void testRefreshAndRegistration() throws Exception
+ {
+ assertFalse(info.isRegistered());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
+
+ ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
+ sd.setRequiresRegistration(true);
+ serviceFactory.getRegistry().setServiceDescriptionBehavior(sd);
+ RegistrationBehavior regBehavior = new RegistrationBehavior();
+ serviceFactory.getRegistry().setRegistrationBehavior(regBehavior);
+
+ assertTrue(info.refresh(false));
+ assertEquals(1, regBehavior.getCallCount());
+ assertTrue(info.isRegistered());
+ assertNotNull(info.getRegistrationInfo());
+ assertEquals(RegistrationBehavior.REGISTRATION_HANDLE,
info.getRegistrationContext().getRegistrationHandle());
+
+ assertTrue(info.refresh(true));
+ assertEquals(1, regBehavior.getCallCount());
+ }
+
+ public void testGetRegistrationContext() throws Exception
+ {
+ assertFalse(info.isRegistered());
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ assertTrue(regInfo.isUndetermined());
+
+ ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
+ sd.setRequiresRegistration(true);
+ serviceFactory.getRegistry().setServiceDescriptionBehavior(sd);
+ RegistrationBehavior regBehavior = new RegistrationBehavior();
+ serviceFactory.getRegistry().setRegistrationBehavior(regBehavior);
+
+ RegistrationContext registrationContext = info.getRegistrationContext();
+ assertNotNull(registrationContext);
+ assertEquals(RegistrationBehavior.REGISTRATION_HANDLE,
registrationContext.getRegistrationHandle());
+ assertEquals("Registration should have occured", 1,
regBehavior.getCallCount());
+ assertEquals("Service description should have been called once unregistered
and once registered", 2, sd.getCallCount());
+ }
+
+ public void testRegister() throws Exception
+ {
+ ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
+ sd.setServiceDescription(true, 1);
+
+ serviceFactory.getRegistry().setServiceDescriptionBehavior(sd);
+ RegistrationBehavior regBehavior = new TestRegistrationBehavior();
+ serviceFactory.getRegistry().setRegistrationBehavior(regBehavior);
+
+ try
+ {
+ info.register();
+ fail("Shouldn't register with invalid information");
+ }
+ catch (PortletInvokerException expected)
+ {
+ }
+
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ regInfo.setRegistrationPropertyValue(TestRegistrationBehavior.PROP_NAME,
TestRegistrationBehavior.ORIGINAL_VALUE);
+
+ info.register();
+ RegistrationContext registrationContext = info.getRegistrationContext();
+ assertNotNull(registrationContext);
+ assertEquals(RegistrationBehavior.REGISTRATION_HANDLE,
registrationContext.getRegistrationHandle());
+ assertTrue(info.isRegistered());
+ assertTrue(info.isRegistrationChecked());
+ assertTrue(info.isRegistrationRequired());
+ }
+
+ public void testDeregister() throws Exception
+ {
+ try
+ {
+ info.deregister();
+ fail("Shouldn't be able to deregister without being registered");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+
+ // setup registration
+ register();
+
+ info.deregister();
+ assertNull(info.getRegistrationContext());
+ assertFalse(info.isRegistered());
+ assertTrue(info.isRegistrationRequired());
+ assertTrue(info.isRegistrationChecked());
+ }
+
+ private void register() throws PortletInvokerException
+ {
+ ServiceDescriptionBehavior sd = new ServiceDescriptionBehavior();
+ sd.setServiceDescription(true, 1);
+ serviceFactory.getRegistry().setServiceDescriptionBehavior(sd);
+ RegistrationBehavior regBehavior = new TestRegistrationBehavior();
+ serviceFactory.getRegistry().setRegistrationBehavior(regBehavior);
+ info.refresh(false);
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ regInfo.setRegistrationPropertyValue(TestRegistrationBehavior.PROP_NAME,
TestRegistrationBehavior.ORIGINAL_VALUE);
+
+ info.register();
+ }
+
+ public void testModifyRegistration() throws Exception
+ {
+ try
+ {
+ info.modifyRegistration();
+ fail("Shouldn't be able to modify registration without being
registered");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+
+ register();
+
+ RegistrationInfo regInfo = info.getRegistrationInfo();
+ regInfo.setRegistrationPropertyValue(TestRegistrationBehavior.PROP_NAME,
"invalid");
+ assertTrue(info.isRefreshNeeded(false));
+ assertTrue(info.isRegistered());
+ assertTrue(info.isModifyRegistrationRequired());
+ RegistrationProperty prop =
regInfo.getRegistrationProperty(TestRegistrationBehavior.PROP_NAME);
+ assertNull(prop.isInvalid());
+
+ try
+ {
+ info.modifyRegistration();
+ fail("invalid value for property should fail to modify
registration");
+ }
+ catch (PortletInvokerException expected)
+ {
+ }
+
+ regInfo.setRegistrationPropertyValue(TestRegistrationBehavior.PROP_NAME,
TestRegistrationBehavior.MODIFIED_VALUE);
+ assertTrue(info.isRefreshNeeded(false));
+ assertNull(prop.isInvalid());
+ assertTrue(info.isModifyRegistrationRequired());
+
+ info.modifyRegistration();
+
+ assertTrue(info.isRefreshNeeded(true)); // cache should have been invalidated
+ assertFalse(info.isRefreshNeeded(false)); // but the rest of the information is
valid so no refresh needed there
+ assertTrue(info.refresh(false)); // however, if we refresh the producer info, it
should have refreshed
+ assertFalse(info.isModifyRegistrationRequired());
+
+ Boolean invalid = prop.isInvalid();
+ assertNotNull(invalid);
+ assertFalse(invalid);
+ }
+
+ private static class TestPortletManagementBehavior extends PortletManagementBehavior
+ {
+ @Override
+ public void getPortletDescription(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") org.oasis.wsrp.v1.PortletContext
portletContext, @WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"desiredLocales", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> desiredLocales,
@WebParam(mode = WebParam.Mode.OUT, name = "portletDescription", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<PortletDescription>
portletDescription, @WebParam(mode = WebParam.Mode.OUT, name = "resourceList",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<ResourceList>
resourceList, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension!
> extensions) throws MissingParameters, InconsistentParameters,
InvalidHandle, InvalidRegistration, InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ super.getPortletDescription(registrationContext, portletContext, userContext,
desiredLocales, portletDescription, resourceList, extensions);
+ portletDescription.value = createPortletDescription("test2", null);
+ }
+ }
+
+ private static class TestRegistrationBehavior extends RegistrationBehavior
+ {
+ private static final String PROP_NAME = "prop0";
+ private static final String MODIFIED_VALUE = "value2";
+ private static final String ORIGINAL_VALUE = "value";
+
+ @Override
+ public void register(@WebParam(name = "consumerName", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") String consumerName, @WebParam(name =
"consumerAgent", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
String consumerAgent, @WebParam(name = "methodGetSupported", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") boolean methodGetSupported, @WebParam(name =
"consumerModes", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
List<String> consumerModes, @WebParam(name = "consumerWindowStates",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") List<String>
consumerWindowStates, @WebParam(name = "consumerUserScopes", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> consumerUserScopes,
@WebParam(name = "customUserProfileData", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> customUserProfileData,
@WebParam(name = "registrationProperties", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<Property> regist!
rationProperties, @WebParam(mode = WebParam.Mode.INOUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions, @WebParam(mode = WebParam.Mode.OUT, name =
"registrationHandle", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<String> registrationHandle,
@WebParam(mode = WebParam.Mode.OUT, name = "registrationState", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<byte[]> registrationState)
throws MissingParameters, OperationFailed
+ {
+ Property prop = checkRegistrationData(registrationProperties);
+
+ String value = prop.getStringValue();
+ if (ORIGINAL_VALUE.equals(value) && PROP_NAME.equals(prop.getName()))
+ {
+ super.register(consumerName, consumerAgent, methodGetSupported,
consumerModes, consumerWindowStates, consumerUserScopes, customUserProfileData,
registrationProperties, extensions, registrationHandle, registrationState);
+ return;
+ }
+
+ throw WSRPExceptionFactory.<OperationFailed,
OperationFailedFault>throwWSException(WSRPExceptionFactory.OPERATION_FAILED,
+ value + " is not a valid value for " + PROP_NAME, null);
+ }
+
+ @Override
+ public void modifyRegistration(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "registrationData", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationData registrationData,
@WebParam(mode = WebParam.Mode.OUT, name = "registrationState", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<byte[]> registrationState,
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<Extension>>
extensions) throws MissingParameters, InvalidRegistration, OperationFailed
+ {
+ incrementCallCount();
+
+ WSRPExceptionFactory.throwMissingParametersIfValueIsMissing(registrationContext,
"RegistrationContext", null);
+
+ if
(!RegistrationBehavior.REGISTRATION_HANDLE.equals(registrationContext.getRegistrationHandle()))
+ {
+ WSRPExceptionFactory.<InvalidRegistration,
InvalidRegistrationFault>throwWSException(WSRPExceptionFactory.INVALID_REGISTRATION,
"Invalid registration", null);
+ }
+
+ WSRPExceptionFactory.throwMissingParametersIfValueIsMissing(registrationData,
"RegistrationData", null);
+
+ Property prop =
checkRegistrationData(registrationData.getRegistrationProperties());
+
+ String value = prop.getStringValue();
+ if (MODIFIED_VALUE.equals(value) && PROP_NAME.equals(prop.getName()))
+ {
+ return;
+ }
+
+ throw WSRPExceptionFactory.<OperationFailed,
OperationFailedFault>throwWSException(WSRPExceptionFactory.OPERATION_FAILED, value
+ + " is not a valid value for " + PROP_NAME, null);
+ }
+
+ private Property checkRegistrationData(List<Property> registrationProperties)
throws OperationFailed
+ {
+
WSRPExceptionFactory.throwOperationFailedIfValueIsMissing(registrationProperties,
"RegistrationData");
+
+ Property prop = registrationProperties.get(0);
+ WSRPExceptionFactory.throwOperationFailedIfValueIsMissing(prop,
"Registration property");
+ return prop;
+ }
+ }
+}
\ No newline at end of file
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerSessionInformationTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerSessionInformationTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerSessionInformationTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,220 @@
+/******************************************************************************
+ * 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.consumer;
+
+import junit.framework.TestCase;
+import org.apache.commons.httpclient.Cookie;
+import org.gatein.wsrp.WSRPConstants;
+import org.gatein.wsrp.WSRPTypeFactory;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.consumer.ProducerSessionInformationTestCase">Chris
+ * Laprun</a>
+ * @version $Revision: 10388 $
+ * @since 2.4
+ */
+public class ProducerSessionInformationTestCase extends TestCase
+{
+ ProducerSessionInformation info;
+
+ protected void setUp() throws Exception
+ {
+ info = new ProducerSessionInformation();
+ }
+
+ public void testUserCookie() throws Exception
+ {
+ assertNull(info.getUserCookie());
+
+ Cookie[] cookies = new Cookie[]{createCookie("name", "value",
1)};
+ info.setUserCookie(cookies);
+
+ assertEquals("name=value", info.getUserCookie());
+
+ // wait for cookie expiration
+ Thread.sleep(1000);
+ assertNull(info.getUserCookie()); // we shouldn't have a cookie now
+
+ cookies = new Cookie[]{createCookie("name1", "value1", 1),
createCookie("name2", "value2", 3)};
+ info.setUserCookie(cookies);
+ assertEquals("name1=value1,name2=value2", info.getUserCookie());
+
+ Thread.sleep(1000);
+ assertEquals("name2=value2", info.getUserCookie());
+
+ try
+ {
+ info.setUserCookie(null);
+ fail("Should have thrown an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException e)
+ {
+ //expected
+ }
+ }
+
+ public void testGroupCookies() throws Exception
+ {
+ String groupId = "groupId";
+
+ try
+ {
+ info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name1",
"value1", 1), createCookie("name2", "value2", -1)});
+ fail("Cannot add group cookie if not perGroup");
+ }
+ catch (IllegalStateException e)
+ {
+ //expected
+ }
+
+ info.setPerGroupCookies(true);
+ info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name1",
"value1", 1),
+ createCookie("name2", "value2",
WSRPConstants.SESSION_NEVER_EXPIRES)});
+
+ assertEquals("name1=value1,name2=value2",
info.getGroupCookieFor(groupId));
+
+ Thread.sleep(1000);
+ assertEquals("name2=value2", info.getGroupCookieFor(groupId));
+
+ info.clearGroupCookies();
+ assertNull(info.getGroupCookieFor(groupId));
+ }
+
+ public void testSessionForPortlet() throws Exception
+ {
+ String handle = "handle";
+ String handle2 = "handle2";
+ String sid = "id";
+ String sid2 = "id2";
+
+ assertNull(info.getSessionIdForPortlet(handle));
+ assertEquals(0, info.getNumberOfSessions());
+
+ addSession(handle, sid, 1);
+ addSession(handle2, sid2, 3);
+
+ assertNull(info.getSessionIdForPortlet("unknown"));
+
+ assertEquals(sid, info.getSessionIdForPortlet(handle));
+ assertEquals(2, info.getNumberOfSessions());
+
+ Thread.sleep(1000);
+ assertNull(info.getSessionIdForPortlet(handle));
+ assertEquals(sid2, info.getSessionIdForPortlet(handle2));
+ assertEquals(1, info.getNumberOfSessions());
+
+ info.removeSessionForPortlet(handle2);
+ assertEquals(0, info.getNumberOfSessions());
+ }
+
+ public void testReplaceUserCookies() throws Exception
+ {
+ info.setUserCookie(new Cookie[]{createCookie("name", "value",
1)});
+
+ info.replaceUserCookiesWith(null);
+ assertEquals("name=value", info.getUserCookie());
+
+ ProducerSessionInformation other = new ProducerSessionInformation();
+
+ info.replaceUserCookiesWith(other);
+ assertEquals("name=value", info.getUserCookie());
+
+ other.setUserCookie(new Cookie[]{createCookie("name2",
"value2", 1)});
+ info.replaceUserCookiesWith(other);
+ assertEquals("name2=value2", info.getUserCookie());
+
+ Thread.sleep(1000);
+ info.replaceUserCookiesWith(other);
+ assertNull(info.getUserCookie());
+ }
+
+ public void testReleaseSessions()
+ {
+ addSession("handle", "id", 1);
+ addSession("handle2", "id2", 1);
+ addSession("handle3", "id3", 1);
+
+ assertEquals(3, info.getNumberOfSessions());
+
+ info.removeSessions();
+
+ assertEquals(0, info.getNumberOfSessions());
+
+ addSession("handle", "id", 1);
+ addSession("handle2", "id2", 2);
+
+ info.removeSession("id2");
+
+ assertEquals(1, info.getNumberOfSessions());
+ assertNull(info.getSessionIdForPortlet("handle2"));
+ assertEquals("id", info.getSessionIdForPortlet("handle"));
+
+ info.removeSessionForPortlet("handle");
+
+ assertEquals(0, info.getNumberOfSessions());
+ assertNull(info.getSessionIdForPortlet("handle"));
+
+ try
+ {
+ info.removeSessionForPortlet("handle");
+ fail("Session for portlet 'handle' should have already been
released!");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
+ }
+
+ public void testSetParentSessionId()
+ {
+ assertNull(info.getParentSessionId());
+
+ String id = "session";
+ info.setParentSessionId(id);
+ assertEquals(id, info.getParentSessionId());
+
+ // trying to set the same id should work
+ info.setParentSessionId(id);
+
+ try
+ {
+ info.setParentSessionId("other");
+ fail("Cannot modify session id once it has been set");
+ }
+ catch (IllegalStateException expected)
+ {
+ // expected
+ }
+ }
+
+ private Cookie createCookie(String name, String value, int secondsBeforeExpiration)
+ {
+ return new Cookie("domain", name, value, "path",
secondsBeforeExpiration, false);
+ }
+
+ private void addSession(String handle, String sid, int expires)
+ {
+ info.addSessionForPortlet(handle, WSRPTypeFactory.createSessionContext(sid,
expires));
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerSessionInformationTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RegistrationInfoTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RegistrationInfoTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RegistrationInfoTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,453 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.consumer;
+
+import junit.framework.TestCase;
+import org.gatein.wsrp.WSRPTypeFactory;
+import org.gatein.wsrp.test.protocol.v1.ServiceDescriptionBehavior;
+import org.oasis.wsrp.v1.Property;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.RegistrationData;
+import org.oasis.wsrp.v1.ServiceDescription;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 11967 $
+ * @since 2.6
+ */
+public class RegistrationInfoTestCase extends TestCase
+{
+ private RegistrationInfo info;
+ private static final String producerId = "test";
+
+ protected void setUp() throws Exception
+ {
+ info = new RegistrationInfo();
+ }
+
+ public void testInitialState()
+ {
+ assertTrue(info.getRegistrationProperties().isEmpty());
+ assertTrue(info.getRegistrationPropertyNames().isEmpty());
+ assertNull(info.getRegistrationContext());
+ assertNotNull(info.getRegistrationData());
+ assertNull(info.getRegistrationHandle());
+ assertNull(info.getRegistrationState());
+
+ // before refresh, refresh is needed...
+ assertTrue(info.isRefreshNeeded());
+ // we don't know if the the local info is consistent with the producer
expectations...
+ assertNull(info.isConsistentWithProducerExpectations());
+ // we don't know if the registration is required...
+ assertNull(info.isRegistrationRequired());
+ // and we don't know if the registration is valid
+ assertNull(info.isRegistrationValid());
+
+ assertFalse(info.isModifiedSinceLastRefresh());
+ assertFalse(info.isModifyRegistrationNeeded());
+
+ try
+ {
+ info.isRegistrationDeterminedNotRequired();
+ fail("refresh hasn't been called, isRegistrationDeterminedNotRequired
should fail");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+
+ try
+ {
+ info.isRegistrationDeterminedRequired();
+ fail("refresh hasn't been called, isRegistrationDeterminedRequired
should fail");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ }
+
+ public void testSimpleSetGetRegistrationProperty()
+ {
+ String key = "foo";
+ info.setRegistrationPropertyValue(key, "bar");
+
+ // check status
+ assertNull(info.isConsistentWithProducerExpectations());
+ assertTrue(info.isModifiedSinceLastRefresh());
+ assertTrue(info.isModifyRegistrationNeeded());
+
+ Map properties = info.getRegistrationProperties();
+ assertFalse(properties.isEmpty());
+ Set names = info.getRegistrationPropertyNames();
+ assertFalse(names.isEmpty());
+ assertTrue(properties.containsKey(key));
+ assertTrue(names.contains(key));
+ Object prop = properties.get(key);
+ assertNotNull(prop);
+ RegistrationProperty registrationProperty = info.getRegistrationProperty(key);
+ assertEquals(prop, registrationProperty);
+ assertEquals("bar", registrationProperty.getValue());
+ }
+
+ public void testRegistrationPropertiesAndRefresh()
+ {
+ info.setRegistrationPropertyValue("prop0", "value0");
+ RefreshResult result = info.refresh(createServiceDescription(true, 1), producerId,
true, false, false);
+ RegistrationProperty prop = info.getRegistrationProperty("prop0");
+ assertNull(prop.isInvalid());
+ assertFalse(result.hasIssues());
+ assertFalse(info.isModifiedSinceLastRefresh());
+ assertFalse(info.isModifyRegistrationNeeded());
+ assertTrue(info.isConsistentWithProducerExpectations());
+
+ // specifiy that the prop is valid to simulate a successful registration
(integration test, should have something
+ // testing that in ProducerInfoTestCase)
+ prop.setInvalid(Boolean.FALSE, RegistrationProperty.Status.VALID);
+
+ info.setRegistrationPropertyValue("prop0", "value1");
+ assertTrue(info.isRefreshNeeded());
+ assertNull("Property value has changed since last refresh, status should be
unknown", prop.isInvalid());
+ assertEquals("Property value has changed since last refresh, status should be
unknown",
+ RegistrationProperty.Status.UNCHECKED_VALUE, prop.getStatus());
+ }
+
+ public void testRefreshNoRegistration()
+ {
+ // no registration expected
+ ServiceDescription sd = createServiceDescription(false, 0);
+ RefreshResult result = info.refresh(sd, producerId, true, false, false);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isConsistentWithProducerExpectations());
+ assertFalse(info.isRegistrationRequired());
+ assertTrue(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isRegistrationDeterminedRequired());
+ assertTrue(info.isRegistrationValid());
+ assertFalse(info.isModifyRegistrationNeeded());
+
+ result = info.refresh(sd, producerId, false, false, false);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isConsistentWithProducerExpectations());
+ assertFalse(info.isRegistrationRequired());
+ assertTrue(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isRegistrationDeterminedRequired());
+ assertTrue(info.isRegistrationValid());
+ assertFalse(info.isModifyRegistrationNeeded());
+ }
+
+ public void testRefreshRegistrationDefaultRegistrationNoLocalInfo()
+ {
+ // before refresh registration status is undetermined
+ assertNull(info.isRegistrationRequired());
+ assertNull(info.isRegistrationValid());
+
+ RegistrationInfo.RegistrationRefreshResult result = info.refresh(
+ createServiceDescription(true, 0), producerId, true, false, false);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isRegistrationRequired());
+ assertTrue(info.isRegistrationDeterminedRequired());
+ assertFalse(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isRegistrationValid());
+ }
+
+ public void testRefreshRegistrationDefaultRegistrationExtraLocalInfo()
+ {
+ // set a registration property
+ info.setRegistrationPropertyValue("foo", "bar");
+
+ // we were not registered so this is a failure and not a need to call
modifyRegistration
+ RegistrationInfo.RegistrationRefreshResult result = info.refresh(
+ createServiceDescription(true, 0), producerId, false, false, true);
+ assertNotNull(result);
+ assertTrue(result.hasIssues());
+ assertEquals(RefreshResult.Status.FAILURE, result.getStatus());
+ assertEquals(1, info.getRegistrationProperties().size());
+ assertEquals(1, result.getRegistrationProperties().size());
+ assertFalse(info.isModifyRegistrationNeeded());
+
+ Map regProps = result.getRegistrationProperties();
+ assertNotNull(regProps);
+
+ RegistrationProperty prop = (RegistrationProperty)regProps.get("foo");
+ assertNotNull(prop);
+ assertEquals("bar", prop.getValue());
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.INEXISTENT, prop.getStatus());
+ }
+
+ public void testRefreshRegistrationDefaultRegistrationExtraLocalInfoWhileRegistered()
+ {
+ // set a registration property
+ info.setRegistrationPropertyValue("foo", "bar");
+
+ // simulate being registered
+ info.setRegistrationHandle("blah");
+
+ // we were registered so we need to call modifyRegistration, force check of extra
props
+ RegistrationInfo.RegistrationRefreshResult result = info.refresh(
+ createServiceDescription(true, 0), producerId, false, false, true);
+ assertNotNull(result);
+ assertEquals(RefreshResult.Status.MODIFY_REGISTRATION_REQUIRED,
result.getStatus());
+ assertTrue(result.hasIssues());
+ assertEquals(1, info.getRegistrationProperties().size());
+ assertEquals(1, result.getRegistrationProperties().size());
+ assertTrue(info.isModifyRegistrationNeeded());
+
+ Map regProps = result.getRegistrationProperties();
+ assertNotNull(regProps);
+
+ RegistrationProperty prop = (RegistrationProperty)regProps.get("foo");
+ assertNotNull(prop);
+ assertEquals("bar", prop.getValue());
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.INEXISTENT, prop.getStatus());
+ }
+
+ public void testRefreshRegistrationRegistrationNoLocalInfo()
+ {
+ // producer requests 2 registration properties
+ ServiceDescription sd = createServiceDescription(true, 2);
+
+ RegistrationInfo.RegistrationRefreshResult result = info.refresh(sd, producerId,
false, false, false);
+ assertNotNull(result);
+ assertTrue(result.hasIssues());
+ assertEquals(RefreshResult.Status.FAILURE, result.getStatus());
+ assertEquals(0, info.getRegistrationProperties().size());
+ assertEquals(2, result.getRegistrationProperties().size());
+ assertFalse(info.isModifyRegistrationNeeded()); // we weren't registered
+
+ Map regProps = result.getRegistrationProperties();
+ assertNotNull(regProps);
+
+ RegistrationProperty prop = (RegistrationProperty)regProps.get("prop0");
+ assertNotNull(prop);
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.MISSING, prop.getStatus());
+ prop = (RegistrationProperty)regProps.get("prop1");
+ assertNotNull(prop);
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.MISSING, prop.getStatus());
+ }
+
+ public void testRefreshRegistrationRegistrationNoLocalInfoWhileRegistered()
+ {
+ // producer requests 2 registration properties
+ ServiceDescription sd = createServiceDescription(true, 2);
+
+ // simulate registration
+ info.setRegistrationHandle("blah");
+
+ RegistrationInfo.RegistrationRefreshResult result = info.refresh(sd, producerId,
false, false, false);
+ assertNotNull(result);
+ assertTrue(result.hasIssues());
+ assertEquals(RefreshResult.Status.MODIFY_REGISTRATION_REQUIRED,
result.getStatus());
+ assertEquals(0, info.getRegistrationProperties().size());
+ assertEquals(2, result.getRegistrationProperties().size());
+ assertTrue(info.isModifyRegistrationNeeded());
+
+ Map regProps = result.getRegistrationProperties();
+ assertNotNull(regProps);
+
+ RegistrationProperty prop = (RegistrationProperty)regProps.get("prop0");
+ assertNotNull(prop);
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.MISSING, prop.getStatus());
+ prop = (RegistrationProperty)regProps.get("prop1");
+ assertNotNull(prop);
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.MISSING, prop.getStatus());
+ }
+
+ public void testRefreshRegistrationRegistrationMergeWithLocalInfo()
+ {
+ info.setRegistrationPropertyValue("foo", "bar");
+
+ RegistrationInfo.RegistrationRefreshResult result =
info.refresh(createServiceDescription(true, 2),
+ producerId, true, false, false);
+ assertNotNull(result);
+ assertTrue(result.hasIssues());
+
+ RegistrationProperty prop = info.getRegistrationProperty("prop0");
+ assertNotNull(prop);
+ assertNull(prop.getValue());
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.MISSING_VALUE, prop.getStatus());
+
+ prop = info.getRegistrationProperty("prop1");
+ assertNotNull(prop);
+ assertNull(prop.getValue());
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.MISSING_VALUE, prop.getStatus());
+ assertEquals(2, info.getRegistrationProperties().size());
+ assertEquals(2, result.getRegistrationProperties().size());
+
+ assertNull(info.getRegistrationProperty("foo"));
+ }
+
+ public void testForceRefreshRegistration()
+ {
+ //
+ RefreshResult result = info.refresh(createServiceDescription(true, 0), producerId,
false, false, false);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertFalse(info.isRegistrationValid());
+
+ // Modifying a property renders the info dirty and hence should be refreshed
+ info.setRegistrationPropertyValue("foo", "bar");
+ result = info.refresh(createServiceDescription(true, 0), producerId, false, false,
false);
+ assertTrue(result.hasIssues());
+ assertFalse(info.isRegistrationValid());
+
+ info.removeRegistrationProperty("foo");
+ result = info.refresh(createServiceDescription(true, 0), producerId, false, false,
false);
+ assertFalse(result.hasIssues());
+ assertFalse(info.isRegistrationValid());
+
+ // producer has changed but we're not forcing refresh so registration should
still be invalid
+ result = info.refresh(createServiceDescription(false, 0), producerId, false, false,
false);
+ assertFalse(result.hasIssues());
+ assertFalse(info.isRegistrationValid());
+
+ // force refresh, registration should now be valid
+ result = info.refresh(createServiceDescription(false, 0), producerId, false, true,
false);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isRegistrationValid());
+ }
+
+ public void testSetRegistrationContext()
+ {
+ assertNull(info.isConsistentWithProducerExpectations());
+ assertNull(info.getRegistrationHandle());
+
+ String registrationHandle = "registrationHandle";
+
info.setRegistrationContext(WSRPTypeFactory.createRegistrationContext(registrationHandle));
+ RegistrationContext registrationContext = info.getRegistrationContext();
+ assertNotNull(registrationContext);
+ assertEquals(registrationHandle, registrationContext.getRegistrationHandle());
+ assertNull(registrationContext.getRegistrationState());
+ assertTrue(info.isConsistentWithProducerExpectations());
+ assertTrue(info.isRegistrationValid());
+ assertFalse(info.isRefreshNeeded());
+ assertTrue(info.isRegistrationRequired());
+ assertTrue(info.isRegistrationDeterminedRequired());
+ assertFalse(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isModifyRegistrationNeeded());
+ }
+
+ public void testGetRegistrationData()
+ {
+ assertNotNull(info.getRegistrationData());
+ assertFalse(info.isModifiedSinceLastRefresh());
+ assertFalse(info.isModifyRegistrationNeeded());
+
+ info.setRegistrationPropertyValue("prop0", "value0");
+ assertTrue(info.isModifiedSinceLastRefresh());
+ assertTrue(info.isModifyRegistrationNeeded());
+ RegistrationData registrationData = info.getRegistrationData();
+ checkRegistrationData(registrationData, "value0");
+
+ // check that setRegistrationValidInternalState properly updates RegistrationData
if required
+ info.setRegistrationPropertyValue("prop0", "value1");
+ assertTrue(info.isModifiedSinceLastRefresh());
+ assertTrue(info.isModifyRegistrationNeeded());
+ info.setRegistrationValidInternalState();
+ assertFalse(info.isModifiedSinceLastRefresh());
+ assertFalse(info.isModifyRegistrationNeeded());
+ List<Property> properties =
info.getRegistrationData().getRegistrationProperties();
+ assertEquals("value1", properties.get(0).getStringValue());
+ }
+
+ public void testGetRegistrationDataWithInitialWrongValue()
+ {
+ info.setRegistrationPropertyValue("prop0", "incorrect");
+ info.refresh(createServiceDescription(true, 1), producerId, true, true, false);
+ checkRegistrationData(info.getRegistrationData(), "incorrect");
+
+ info.setRegistrationPropertyValue("prop0", "value0");
+ RefreshResult res = info.refresh(createServiceDescription(true, 1), producerId,
true, true, false);
+ assertFalse(res.hasIssues());
+ checkRegistrationData(info.getRegistrationData(), "value0");
+ }
+
+ public void testRefreshWhileRegisteredAndProducerNotSendingPropertyDescriptions()
+ {
+ info.setRegistrationPropertyValue("prop0", "value0");
+ info.refresh(createServiceDescription(true, 1), producerId, true, true, false);
+
+ // simulate successful registration
+
info.setRegistrationContext(WSRPTypeFactory.createRegistrationContext("handle"));
+
+ assertTrue(info.isRegistrationRequired());
+ assertTrue(info.isRegistrationValid());
+
+ ServiceDescription description = createServiceDescription(true, 0);
+ info.refresh(description, producerId, true, true, false);
+ assertTrue(info.isRegistrationValid());
+ RegistrationProperty prop = info.getRegistrationProperty("prop0");
+ assertNotNull(prop);
+ assertFalse(prop.isInvalid());
+
+ // check that forcing check of extra properties work
+ info.refresh(description, producerId, true, true, true);
+ assertFalse(info.isRegistrationValid());
+ assertNull(info.getRegistrationProperty("prop0"));
+ }
+
+ public void testRefreshRegisteredWithoutPropsAndProducerNowSendsProps()
+ {
+ // simulate successful registration
+
info.setRegistrationContext(WSRPTypeFactory.createRegistrationContext("handle"));
+ assertTrue(info.isRegistrationRequired());
+ assertTrue(info.isRegistrationValid());
+
+ // producer now requires a registration property
+ info.refresh(createServiceDescription(true, 1), producerId, true, true, true);
+ assertTrue(info.isRegistrationRequired());
+ assertTrue(info.isRegistrationDeterminedRequired());
+ assertFalse(info.isRegistrationValid());
+ assertFalse(info.isConsistentWithProducerExpectations());
+ assertFalse(info.isModifiedSinceLastRefresh());
+ }
+
+ private void checkRegistrationData(RegistrationData registrationData, String
prop0Value)
+ {
+ assertNotNull(registrationData);
+ List<Property> properties = registrationData.getRegistrationProperties();
+ assertNotNull(properties);
+ assertEquals(1, properties.size());
+ Property property = properties.get(0);
+ assertEquals("prop0", property.getName());
+ assertEquals(prop0Value, property.getStringValue());
+ }
+
+ private ServiceDescription createServiceDescription(boolean requiresRegistration, int
numberOfProperties)
+ {
+ return ServiceDescriptionBehavior.createServiceDescription(requiresRegistration,
numberOfProperties);
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RegistrationInfoTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RegistrationPropertyTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RegistrationPropertyTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RegistrationPropertyTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,128 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.consumer;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 11941 $
+ * @since 2.6
+ */
+public class RegistrationPropertyTestCase extends TestCase
+{
+ private RegistrationProperty prop;
+
+ private Listener listener = new Listener();
+
+ private static final String VALUE = "value";
+ private static final String NEW_VALUE = "newValue";
+
+ private class Listener implements RegistrationProperty.PropertyChangeListener
+ {
+ boolean called;
+
+ public void propertyValueChanged(RegistrationProperty property, Object oldValue,
Object newValue)
+ {
+ called = (prop == property) && VALUE.equals(oldValue) &&
NEW_VALUE.equals(newValue);
+ }
+ }
+
+ protected void setUp() throws Exception
+ {
+ prop = new RegistrationProperty("name", VALUE, "en",
listener);
+ }
+
+ public void testGetters()
+ {
+ assertEquals("name", prop.getName());
+ assertEquals("value", prop.getValue());
+ assertEquals("en", prop.getLang());
+ assertNull(prop.isInvalid());
+ assertFalse(prop.isDeterminedInvalid());
+ assertNull(prop.getDescription());
+ assertEquals(RegistrationProperty.Status.UNCHECKED_VALUE, prop.getStatus());
+ }
+
+ public void testSetValue()
+ {
+ prop.setInvalid(Boolean.FALSE, RegistrationProperty.Status.VALID);
+
+ // we haven't changed the value, so the status shouldn't have changed
+ prop.setValue(VALUE);
+ assertEquals(Boolean.FALSE, prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.VALID, prop.getStatus());
+
+ // we changed the value, status is now unknown
+ prop.setValue(NEW_VALUE);
+ assertEquals(NEW_VALUE, prop.getValue());
+ assertNull(prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.UNCHECKED_VALUE, prop.getStatus());
+ }
+
+ public void testSetInvalid()
+ {
+ prop.setInvalid(Boolean.FALSE, RegistrationProperty.Status.VALID);
+ assertEquals(Boolean.FALSE, prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.VALID, prop.getStatus());
+
+ // whatever the status, if we specifiy that the property is valid, its status
should be VALID
+ prop.setInvalid(Boolean.FALSE, RegistrationProperty.Status.INEXISTENT);
+ assertEquals(Boolean.FALSE, prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.VALID, prop.getStatus());
+
+ prop.setInvalid(Boolean.FALSE, null);
+ assertEquals(Boolean.FALSE, prop.isInvalid());
+ assertEquals(RegistrationProperty.Status.VALID, prop.getStatus());
+
+ try
+ {
+ prop.setInvalid(true, null);
+ fail("setInvalid should not accept a prop to be set invalid without a
proper status");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+
+ try
+ {
+ prop.setInvalid(true, RegistrationProperty.Status.VALID);
+ fail("setInvalid should not accept a prop to be set invalid with a VALID
status");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+ }
+
+ public void testPropertyChangedEvent()
+ {
+ prop.setValue(VALUE);
+ assertFalse(listener.called);
+
+ prop.setValue(NEW_VALUE);
+ assertTrue(listener.called);
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RegistrationPropertyTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RenderHandlerTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RenderHandlerTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RenderHandlerTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.consumer;
+
+import junit.framework.TestCase;
+import org.gatein.common.net.URLTools;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 10507 $
+ * @since 2.6
+ */
+public class RenderHandlerTestCase extends TestCase
+{
+ public void testResourceURLRewriterProcessNonResource()
+ {
+ String markup = "<a
href=\"/portal/portal/default/Test/EXAMPLE/EXAMPLE?action=1d&windowstate=&mode="
+
+
"&ns=_next%3D%2Fdk%2Fskat%2Fportal%2Ffront%2Fportlets%2Fexample%2Findex.jsp"
+
+
"&is=_action%3D%252Fdk%252Fskat%252Fportal%252Ffront%252Fportlets%252Fexample%252FprocessLink"
+
+
"%26jbpns_2fdefault_2fTest_2fEXAMPLE_2fEXAMPLEsnpbjname%3DChris\">Press to
use default name.</a>";
+ String result = URLTools.replaceURLsBy(markup, new
RenderHandler.ResourceURLRewriter());
+ assertEquals(markup, result);
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/RenderHandlerTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/WSRPConsumerBaseTest.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/WSRPConsumerBaseTest.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/WSRPConsumerBaseTest.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,249 @@
+/******************************************************************************
+ * 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.consumer;
+
+import junit.framework.TestCase;
+import org.gatein.wsrp.WSRPConsumer;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.ExtendedAssert;
+import org.gatein.wsrp.test.TestWSRPProducer;
+import org.gatein.wsrp.test.TestWSRPProducerImpl;
+import org.gatein.wsrp.test.protocol.v1.MarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.PortletManagementBehavior;
+import org.gatein.wsrp.test.protocol.v1.RegistrationBehavior;
+import org.gatein.wsrp.test.protocol.v1.ServiceDescriptionBehavior;
+import org.gatein.wsrp.test.protocol.v1.TestProducerBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.BasicMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.BasicPortletManagementBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.BasicServiceDescriptionBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.EmptyMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.InitCookieNotRequiredMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.NullMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.PerGroupInitCookieMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.PerUserInitCookieMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.ResourceMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.SessionMarkupBehavior;
+import org.gatein.wsrp.test.support.MockConsumerRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
+ * @version $Revision: 11344 $
+ */
+public abstract class WSRPConsumerBaseTest extends TestCase
+{
+ private static Logger log = LoggerFactory.getLogger(WSRPConsumerBaseTest.class);
+
+ /** . */
+ private static final String TEST_PRODUCER_ID = "test_producer";
+
+ /** . */
+ protected TestWSRPProducer producer = new TestWSRPProducerImpl();
+
+ /** . */
+ protected WSRPConsumer consumer = new WSRPConsumerImpl();
+
+ private boolean strict = true;
+ private String sdClassName;
+ private String mClassName;
+ private String pmClassName;
+ private String rClassName;
+
+
+ public void setUp() throws Exception
+ {
+ // reset producer state
+ producer.reset();
+
+ // set the test producer identifier
+ consumer.getProducerInfo().setId(TEST_PRODUCER_ID);
+
+ // reset the behaviors
+ BehaviorRegistry registry = producer.getBehaviorRegistry();
+ setSDClassName(sdClassName);
+ setMClassName(mClassName);
+ setPMClassName(pmClassName);
+ setRClassName(rClassName);
+ registerAdditionalMarkupBehaviors(registry);
+
+ // use a fresh ConsumerRegistry
+ consumer.getProducerInfo().setRegistry(new MockConsumerRegistry());
+
+ // make sure we use clean producer info for each test
+ consumer.refreshProducerInfo();
+
+ // use cache to avoid un-necessary calls
+ consumer.getProducerInfo().setExpirationCacheSeconds(120);
+ }
+
+ protected void setRegistrationBehavior(RegistrationBehavior behavior)
+ {
+ producer.getBehaviorRegistry().setRegistrationBehavior(behavior);
+ }
+
+ protected void setServiceDescriptionBehavior(ServiceDescriptionBehavior behavior)
+ {
+ if (behavior == null)
+ {
+ log.info("Given service description behavior was null, using the default
one instead!");
+ behavior = new BasicServiceDescriptionBehavior();
+ }
+
+ producer.getBehaviorRegistry().setServiceDescriptionBehavior(behavior);
+ }
+
+ protected void setPortletManagementBehavior(PortletManagementBehavior behavior)
+ {
+ BehaviorRegistry registry = producer.getBehaviorRegistry();
+
+ if (behavior == null)
+ {
+ log.info("Given portlet management behavior was null, using the default one
instead!");
+ behavior = new BasicPortletManagementBehavior(registry);
+ }
+
+ registry.setPortletManagementBehavior(behavior);
+ }
+
+ public TestWSRPProducer getProducer()
+ {
+ return producer;
+ }
+
+ public void setProducer(TestWSRPProducer producer)
+ {
+ this.producer = producer;
+ }
+
+ public WSRPConsumer getConsumer()
+ {
+ return consumer;
+ }
+
+ public void setConsumer(WSRPConsumer consumer)
+ {
+ this.consumer = consumer;
+ }
+
+ public void testProducerId()
+ {
+ ExtendedAssert.assertEquals(TEST_PRODUCER_ID, consumer.getProducerId());
+ }
+
+ public void setSDClassName(String behaviorClassName)
+ {
+ sdClassName = behaviorClassName;
+ setServiceDescriptionBehavior(createBehavior(behaviorClassName,
ServiceDescriptionBehavior.class));
+ }
+
+ public void setMClassName(String behaviorClassName)
+ {
+ mClassName = behaviorClassName;
+ if (behaviorClassName != null)
+ {
+
producer.getBehaviorRegistry().registerMarkupBehavior(createBehavior(behaviorClassName,
MarkupBehavior.class));
+ }
+ }
+
+ public void setPMClassName(String behaviorClassName)
+ {
+ pmClassName = behaviorClassName;
+ setPortletManagementBehavior(createBehavior(behaviorClassName,
PortletManagementBehavior.class));
+ }
+
+ public void setRClassName(String behaviorClassName)
+ {
+ rClassName = behaviorClassName;
+ setRegistrationBehavior(createBehavior(behaviorClassName,
RegistrationBehavior.class));
+ }
+
+ public void setStrict(boolean strict)
+ {
+ this.strict = strict;
+ producer.usingStrictModeChangedTo(strict);
+ }
+
+ public boolean isStrict()
+ {
+ return strict;
+ }
+
+ private <T extends TestProducerBehavior> T createBehavior(String
behaviorClassName, Class<T> expectedBehaviorClass)
+ {
+ if (behaviorClassName != null)
+ {
+ try
+ {
+ Class behaviorClass =
getClass().getClassLoader().loadClass(behaviorClassName);
+ if (expectedBehaviorClass.isAssignableFrom(behaviorClass))
+ {
+ return expectedBehaviorClass.cast(behaviorClass.newInstance());
+ }
+ else
+ {
+ throw new IllegalArgumentException(behaviorClassName + " is not a
" + expectedBehaviorClass.getSimpleName());
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IllegalArgumentException("Could not find behavior: " +
behaviorClassName, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new IllegalArgumentException("Could not access behavior: " +
behaviorClassName, e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new IllegalArgumentException("Could not instantiate behavior:
" + behaviorClassName, e);
+ }
+ }
+
+ return null;
+ }
+
+ protected void registerAdditionalMarkupBehaviors(BehaviorRegistry registry)
+ {
+ registry.registerMarkupBehavior(new BasicMarkupBehavior(registry));
+ registry.registerMarkupBehavior(new EmptyMarkupBehavior(registry));
+ registry.registerMarkupBehavior(new
InitCookieNotRequiredMarkupBehavior(registry));
+ registry.registerMarkupBehavior(new PerGroupInitCookieMarkupBehavior(registry));
+ registry.registerMarkupBehavior(new PerUserInitCookieMarkupBehavior(registry));
+ registry.registerMarkupBehavior(new NullMarkupBehavior(registry));
+ registry.registerMarkupBehavior(new SessionMarkupBehavior(registry));
+ registry.registerMarkupBehavior(new ResourceMarkupBehavior(registry));
+ }
+
+ protected Set<String> getPortletHandles()
+ {
+ return
producer.getBehaviorRegistry().getServiceDescriptionBehavior().getPortletHandles();
+ }
+
+ protected int getPortletNumber()
+ {
+ return
producer.getBehaviorRegistry().getServiceDescriptionBehavior().getPortletNumber();
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/WSRPConsumerBaseTest.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/handler/RequestHeaderClientHandlerTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/handler/RequestHeaderClientHandlerTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/handler/RequestHeaderClientHandlerTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,180 @@
+/******************************************************************************
+ * 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.handler;
+
+import junit.framework.TestCase;
+import org.apache.commons.httpclient.Cookie;
+import org.gatein.wsrp.consumer.ProducerSessionInformation;
+import org.gatein.wsrp.test.handler.MockSOAPMessage;
+import org.gatein.wsrp.test.handler.MockSOAPMessageContext;
+
+import javax.xml.soap.MimeHeaders;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.handler.RequestHeaderClientHandlerTestCase">Chris
+ * Laprun</a>
+ * @version $Revision: 10388 $
+ * @since 2.4
+ */
+public class RequestHeaderClientHandlerTestCase extends TestCase
+{
+ RequestHeaderClientHandler handler;
+
+
+ protected void setUp() throws Exception
+ {
+ handler = new RequestHeaderClientHandler();
+ RequestHeaderClientHandler.resetCurrentInfo();
+ }
+
+ public void testSimpleCookieHandleRequest()
+ {
+ MockSOAPMessage message = new MockSOAPMessage();
+ SOAPMessageContext msgContext =
MockSOAPMessageContext.createMessageContext(message, getClass().getClassLoader());
+
+ handler.handleRequest(msgContext);
+ MimeHeaders headers = message.getMimeHeaders();
+ assertNull(headers.getHeader("Cookie"));
+
+ ProducerSessionInformation sessionInformation = new ProducerSessionInformation();
+ sessionInformation.setUserCookie(new Cookie[]{createCookie("name",
"value", 1)});
+ RequestHeaderClientHandler.setCurrentInfo(null, sessionInformation);
+ handler.handleRequest(msgContext);
+
+ headers = message.getMimeHeaders();
+ String[] cookie = headers.getHeader("Cookie");
+ assertEquals(1, cookie.length);
+ assertEquals("name=value", cookie[0]);
+ }
+
+ public void testGroupCookieHandleRequest()
+ {
+ MockSOAPMessage message = new MockSOAPMessage();
+ SOAPMessageContext msgContext =
MockSOAPMessageContext.createMessageContext(message, getClass().getClassLoader());
+
+ ProducerSessionInformation info = new ProducerSessionInformation();
+ info.setPerGroupCookies(true);
+ String groupId = "group";
+ info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name",
"value", 1)});
+ RequestHeaderClientHandler.setCurrentInfo(null, info);
+
+ try
+ {
+ handler.handleRequest(msgContext);
+ fail("group id hasn't been set so shouldn't be able to complete
request");
+ }
+ catch (IllegalStateException e)
+ {
+ // expected
+ }
+
+ RequestHeaderClientHandler.setCurrentGroupId(groupId);
+
+ handler.handleRequest(msgContext);
+
+ MimeHeaders headers = message.getMimeHeaders();
+ String[] cookie = headers.getHeader("Cookie");
+ assertEquals(1, cookie.length);
+ assertEquals("name=value", cookie[0]);
+ }
+
+ public void testBothCookiesHandleRequest()
+ {
+ MockSOAPMessage message = new MockSOAPMessage();
+ SOAPMessageContext msgContext =
MockSOAPMessageContext.createMessageContext(message, getClass().getClassLoader());
+
+ ProducerSessionInformation info = new ProducerSessionInformation();
+ info.setPerGroupCookies(true);
+ String groupId = "group";
+ info.setGroupCookieFor(groupId, new Cookie[]{createCookie("name",
"value", 1)});
+ info.setUserCookie(new Cookie[]{createCookie("usercookie",
"uservalue", 1)});
+ RequestHeaderClientHandler.setCurrentInfo(groupId, info);
+
+
+ handler.handleRequest(msgContext);
+ MimeHeaders headers = message.getMimeHeaders();
+ String[] cookie = headers.getHeader("Cookie");
+ assertEquals(1, cookie.length);
+ assertEquals("name=value,usercookie=uservalue", cookie[0]);
+ }
+
+ public void testCookieWithoutInitHandleResponse()
+ {
+ MockSOAPMessage message = new MockSOAPMessage();
+ SOAPMessageContext msgContext =
MockSOAPMessageContext.createMessageContext(message, getClass().getClassLoader());
+ MimeHeaders headers = new MimeHeaders();
+ headers.setHeader("Set-Cookie", "name=value");
+ message.setMimeHeaders(headers);
+
+ handler.handleResponse(msgContext);
+ ProducerSessionInformation info =
RequestHeaderClientHandler.getCurrentProducerSessionInformation();
+ assertEquals("name=value", info.getUserCookie());
+ assertFalse(info.isInitCookieDone());
+ assertFalse(info.isPerGroupCookies());
+ }
+
+ public void testMultipleCookiesInResponse()
+ {
+ MockSOAPMessage message = new MockSOAPMessage();
+ SOAPMessageContext msgContext =
MockSOAPMessageContext.createMessageContext(message, getClass().getClassLoader());
+ MimeHeaders headers = new MimeHeaders();
+ headers.addHeader("Set-Cookie", "name1=value1");
+ headers.addHeader("Set-Cookie", "name2=value2");
+ headers.addHeader("Set-Cookie", "name3=value3");
+ message.setMimeHeaders(headers);
+
+ handler.handleResponse(msgContext);
+ ProducerSessionInformation info =
RequestHeaderClientHandler.getCurrentProducerSessionInformation();
+ assertEquals("name1=value1,name2=value2,name3=value3",
info.getUserCookie());
+ }
+
+ public void testCurrentInfo()
+ {
+ assertNull(RequestHeaderClientHandler.getCurrentProducerSessionInformation());
+ assertNull(RequestHeaderClientHandler.getCurrentGroupId());
+
+ try
+ {
+ RequestHeaderClientHandler.setCurrentGroupId("foo");
+ fail("Current info was not set, shouldn't have thrown an
IllegalStateException");
+ }
+ catch (IllegalStateException e)
+ {
+ // expected
+ }
+
+ ProducerSessionInformation info = new ProducerSessionInformation();
+ String groupId = "group";
+ RequestHeaderClientHandler.setCurrentInfo(groupId, info);
+
+ assertSame(info,
RequestHeaderClientHandler.getCurrentProducerSessionInformation());
+ assertEquals(groupId, RequestHeaderClientHandler.getCurrentGroupId());
+ }
+
+ private Cookie createCookie(String name, String value, int secondsBeforeExpiration)
+ {
+ return new Cookie("domain", name, value, "path",
secondsBeforeExpiration, false);
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/handler/RequestHeaderClientHandlerTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/InteropServiceDescriptionTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/InteropServiceDescriptionTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/InteropServiceDescriptionTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,79 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.protocol.v1;
+
+import org.gatein.pc.api.Portlet;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.ExtendedAssert;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class InteropServiceDescriptionTestCase extends V1ConsumerBaseTest
+{
+ public InteropServiceDescriptionTestCase() throws Exception
+ {
+ super();
+ }
+
+ @Override
+ public void setUp() throws Exception
+ {
+ setStrict(false);
+ super.setUp();
+ }
+
+ public void testUsesRelaxedMode()
+ {
+ ExtendedAssert.assertFalse(isStrict());
+ }
+
+ public void testGetPortlets() throws PortletInvokerException
+ {
+ //invoke consumer
+ Set returnedPortlets = consumer.getPortlets();
+
+ int portletNumber = returnedPortlets.size();
+ ExtendedAssert.assertEquals(getPortletNumber(), portletNumber);
+ Set<String> handles = getPortletHandles();
+ Set<String> consumerHandles = new HashSet<String>(portletNumber);
+ for (Object o : returnedPortlets)
+ {
+ Portlet portlet = (Portlet)o;
+ consumerHandles.add(portlet.getContext().getId());
+ }
+
+ ExtendedAssert.assertTrue(handles.containsAll(consumerHandles));
+ }
+
+ @Override
+ protected void registerAdditionalMarkupBehaviors(BehaviorRegistry registry)
+ {
+ // do nothing so that we don't pollute the service description with markup
behaviors
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/InteropServiceDescriptionTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,301 @@
+/******************************************************************************
+ * 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.protocol.v1;
+
+import org.gatein.pc.api.Mode;
+import org.gatein.pc.api.OpaqueStateString;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.api.WindowState;
+import org.gatein.pc.api.invocation.ActionInvocation;
+import org.gatein.pc.api.invocation.RenderInvocation;
+import org.gatein.pc.api.invocation.response.ErrorResponse;
+import org.gatein.pc.api.invocation.response.FragmentResponse;
+import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
+import org.gatein.pc.api.invocation.response.UpdateNavigationalStateResponse;
+import org.gatein.pc.portlet.impl.spi.AbstractInstanceContext;
+import org.gatein.pc.portlet.impl.spi.AbstractPortalContext;
+import org.gatein.pc.portlet.impl.spi.AbstractSecurityContext;
+import org.gatein.pc.portlet.impl.spi.AbstractUserContext;
+import org.gatein.pc.portlet.impl.spi.AbstractWindowContext;
+import org.gatein.wsrp.consumer.ProducerSessionInformation;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.ExtendedAssert;
+import org.gatein.wsrp.test.protocol.v1.behaviors.BasicMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.EmptyMarkupBehavior;
+import
org.gatein.wsrp.test.protocol.v1.behaviors.GroupedPortletsServiceDescriptionBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.InitCookieMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.InitCookieNotRequiredMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.NullMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.PerGroupInitCookieMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.PerUserInitCookieMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.ResourceMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.SessionMarkupBehavior;
+import org.gatein.wsrp.test.support.MockHttpServletRequest;
+import org.gatein.wsrp.test.support.TestPortletInvocationContext;
+import org.oasis.wsrp.v1.CookieProtocol;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.InvalidHandle;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.ItemDescription;
+import org.oasis.wsrp.v1.ModelDescription;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.PortletDescription;
+import org.oasis.wsrp.v1.ResourceList;
+
+import javax.servlet.http.HttpSession;
+import javax.xml.ws.Holder;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 11320 $
+ * @since 2.4 (May 4, 2006)
+ */
+public class MarkupTestCase extends V1ConsumerBaseTest
+{
+ public MarkupTestCase() throws Exception
+ {
+ super();
+ }
+
+ public void testInvalidHandle()
+ {
+ try
+ {
+ consumer.invoke(createRenderInvocation("Invalid portlet handle"));
+ ExtendedAssert.fail("Should have failed on invalid portlet handle");
+ }
+ catch (PortletInvokerException expected)
+ {
+ // expected
+ }
+ }
+
+ public void testEmptyRender() throws Exception
+ {
+
checkRenderResult(consumer.invoke(createRenderInvocation(EmptyMarkupBehavior.PORTLET_HANDLE)),
"");
+ }
+
+ public void testNullAction() throws Exception
+ {
+
ExtendedAssert.assertTrue(consumer.invoke(createActionInvocation(NullMarkupBehavior.PORTLET_HANDLE))
instanceof ErrorResponse);
+ }
+
+ public void testNullRender() throws Exception
+ {
+
ExtendedAssert.assertTrue(consumer.invoke(createRenderInvocation(NullMarkupBehavior.PORTLET_HANDLE))
instanceof ErrorResponse);
+ }
+
+ public void testRender() throws Exception
+ {
+ RenderInvocation render =
createRenderInvocation(BasicMarkupBehavior.PORTLET_HANDLE, Mode.EDIT,
+ WindowState.NORMAL, "someNS");
+ FragmentResponse result = checkRenderResult(consumer.invoke(render),
"portlet1:edit:normal:someNS");
+ ExtendedAssert.assertEquals(15, result.getCacheControl().getExpirationSecs());
+
+ render = createRenderInvocation(SessionMarkupBehavior.PORTLET_HANDLE);
+ result = checkRenderResult(consumer.invoke(render),
"portlet2:0:view:maximized");
+ ExtendedAssert.assertEquals(0, result.getCacheControl().getExpirationSecs());
+ }
+
+ public void testAction() throws Exception
+ {
+ ActionInvocation action =
createActionInvocation(BasicMarkupBehavior.PORTLET_HANDLE);
+
+ PortletInvocationResponse response = consumer.invoke(action);
+ ExtendedAssert.assertNotNull(response);
+ ExtendedAssert.assertTrue("Was expecting a RenderResponse. Got: " +
response, response instanceof UpdateNavigationalStateResponse);
+ UpdateNavigationalStateResponse render =
(UpdateNavigationalStateResponse)response;
+ ExtendedAssert.assertEquals(BasicMarkupBehavior.NS,
render.getNavigationalState().getStringValue());
+ }
+
+ public void testSessionHandling() throws Exception
+ {
+ RenderInvocation render =
createRenderInvocation(SessionMarkupBehavior.PORTLET_HANDLE);
+
+ PortletInvocationResponse response = consumer.invoke(render);
+
+ checkRenderResult(response, "portlet2:0:view:maximized");
+
+ // checking session information
+ ProducerSessionInformation sessionInfo =
consumer.getProducerSessionInformationFrom(render);
+ String sessionId =
sessionInfo.getSessionIdForPortlet(SessionMarkupBehavior.PORTLET_HANDLE);
+ ExtendedAssert.assertNotNull(sessionId);
+ ExtendedAssert.assertEquals(SessionMarkupBehavior.SESSION_ID, sessionId);
+ ExtendedAssert.assertFalse(sessionInfo.isPerGroupCookies());
+ ExtendedAssert.assertFalse(sessionInfo.isInitCookieDone());
+
+ response = consumer.invoke(render);
+ checkRenderResult(response, "portlet2:1:view:maximized");
+ }
+
+ public void testInitCookieNotCalledWhenNotNeeded() throws Exception
+ {
+ String handle =
InitCookieNotRequiredMarkupBehavior.INIT_COOKIE_NOT_REQUIRED_HANDLE;
+ InitCookieMarkupBehavior behavior =
(InitCookieMarkupBehavior)producer.getBehaviorRegistry().getMarkupBehaviorFor(handle);
+
+ ProducerSessionInformation sessionInfo = commonInitCookieTest(handle, behavior,
null);
+
+ ExtendedAssert.assertNotNull(sessionInfo);
+ ExtendedAssert.assertFalse(sessionInfo.isPerGroupCookies());
+ ExtendedAssert.assertFalse(sessionInfo.isInitCookieDone());
+
+ ExtendedAssert.assertEquals(0, behavior.getInitCookieCallCount());
+ }
+
+ public void testInitCookiePerUser() throws PortletInvokerException, InvalidHandle
+ {
+ String handle = PerUserInitCookieMarkupBehavior.PER_USER_INIT_COOKIE_HANDLE;
+ InitCookieMarkupBehavior behavior =
(InitCookieMarkupBehavior)producer.getBehaviorRegistry().getMarkupBehaviorFor(handle);
+
+ ProducerSessionInformation sessionInfo = commonInitCookieTest(handle, behavior,
CookieProtocol.PER_USER);
+
+ ExtendedAssert.assertFalse(sessionInfo.isPerGroupCookies());
+ ExtendedAssert.assertTrue(sessionInfo.isInitCookieDone());
+ ExtendedAssert.assertNotNull(sessionInfo.getUserCookie());
+
+ ExtendedAssert.assertEquals(1, behavior.getInitCookieCallCount());
+ }
+
+ public void testInitCookiePerGroup() throws PortletInvokerException, InvalidHandle,
OperationFailed, InvalidRegistration
+ {
+ BehaviorRegistry registry = producer.getBehaviorRegistry();
+
+ // need to setup with a specific service description behavior: we wrap the current
service description
+ Holder<List<PortletDescription>> offeredPortlets = new
Holder<List<PortletDescription>>();
+ registry.getServiceDescriptionBehavior().getServiceDescription(null, null, new
Holder<Boolean>(),
+ offeredPortlets, new Holder<List<ItemDescription>>(),
+ new Holder<List<ItemDescription>>(), new
Holder<List<ItemDescription>>(), new
Holder<List<ItemDescription>>(),
+ new Holder<CookieProtocol>(), new Holder<ModelDescription>(), new
Holder<List<String>>(),
+ new Holder<ResourceList>(), new Holder<List<Extension>>());
+ setServiceDescriptionBehavior(new
GroupedPortletsServiceDescriptionBehavior(offeredPortlets.value));
+
+ String handle = PerGroupInitCookieMarkupBehavior.PER_GROUP_INIT_COOKIE_HANDLE;
+ InitCookieMarkupBehavior behavior =
(InitCookieMarkupBehavior)registry.getMarkupBehaviorFor(handle);
+
+ ProducerSessionInformation sessionInfo = commonInitCookieTest(handle, behavior,
CookieProtocol.PER_GROUP);
+ ExtendedAssert.assertTrue(sessionInfo.isPerGroupCookies());
+ ExtendedAssert.assertTrue(sessionInfo.isInitCookieDone());
+ ExtendedAssert.assertNull(sessionInfo.getUserCookie());
+
+ ExtendedAssert.assertEquals(3, behavior.getInitCookieCallCount());
+ }
+
+ public void testResource() throws PortletInvokerException
+ {
+ RenderInvocation render =
createRenderInvocation(ResourceMarkupBehavior.PORTLET_HANDLE);
+ PortletInvocationResponse response = consumer.invoke(render);
+
+ checkRenderResult(response, "<img
src='http://localhost:8080/test-resource-portlet/gif/logo.gif'/>");
+ }
+
+ private ProducerSessionInformation commonInitCookieTest(String handle,
InitCookieMarkupBehavior behavior, CookieProtocol cookieProtocol)
+ throws PortletInvokerException
+ {
+ RenderInvocation render = createRenderInvocation(handle);
+ TestPortletInvocationContext invocationContext =
(TestPortletInvocationContext)render.getContext();
+ HttpSession session = invocationContext.getClientRequest().getSession();
+
+ // set init cookie requirement
+ producer.setRequiresInitCookie(cookieProtocol);
+
+ // tell the producer which markup behavior we want to use
+ producer.setCurrentMarkupBehaviorHandle(handle);
+
+ render = createRenderInvocation(handle, invocationContext);
+
+ ExtendedAssert.assertEquals(0, behavior.getInitCookieCallCount());
+
+ consumer.invoke(render);
+
+ ExtendedAssert.assertEquals(cookieProtocol,
consumer.getProducerInfo().getRequiresInitCookie());
+
+ return consumer.getProducerSessionInformationFrom(session);
+ }
+
+ private FragmentResponse checkRenderResult(PortletInvocationResponse response, String
markup)
+ {
+ ExtendedAssert.assertNotNull(response);
+ if (response instanceof ErrorResponse)
+ {
+ ErrorResponse errorResponse = (ErrorResponse)response;
+ ExtendedAssert.fail("Got an ErrorResponse instead of a FragmentResponse.
Message: " + errorResponse.getMessage());
+ }
+ ExtendedAssert.assertTrue("Was expecting a FragmentResponse. Got: " +
response, response instanceof FragmentResponse);
+ FragmentResponse fragment = (FragmentResponse)response;
+ ExtendedAssert.assertEquals(markup, fragment.getChars().toString());
+ return fragment;
+ }
+
+ private RenderInvocation createRenderInvocation(String portletHandle)
+ {
+ return createRenderInvocation(portletHandle, null);
+ }
+
+ private RenderInvocation createRenderInvocation(String portletHandle,
TestPortletInvocationContext invocationContext)
+ {
+ return createRenderInvocation(portletHandle, Mode.VIEW, WindowState.MAXIMIZED,
null, invocationContext);
+ }
+
+ private RenderInvocation createRenderInvocation(String portletHandle, Mode mode,
WindowState state, String navigationalState)
+ {
+ return createRenderInvocation(portletHandle, mode, state, navigationalState,
null);
+ }
+
+ private RenderInvocation createRenderInvocation(String portletHandle, Mode mode,
WindowState state, String navigationalState, TestPortletInvocationContext
invocationContext)
+ {
+ if (invocationContext == null)
+ {
+ invocationContext = new TestPortletInvocationContext();
+ }
+
+ RenderInvocation render = new RenderInvocation(invocationContext);
+ render.setTarget(PortletContext.createPortletContext(portletHandle));
+ render.setMode(mode);
+ render.setWindowState(state);
+ if (navigationalState != null)
+ {
+ render.setNavigationalState(new OpaqueStateString(navigationalState));
+ }
+
+ render.setInstanceContext(new AbstractInstanceContext(portletHandle));
+ render.setSecurityContext(new
AbstractSecurityContext(MockHttpServletRequest.createMockRequest(null)));
+ render.setUserContext(new AbstractUserContext());
+ render.setWindowContext(new AbstractWindowContext("windowcontext"));
+ render.setPortalContext(new AbstractPortalContext());
+ return render;
+ }
+
+ private ActionInvocation createActionInvocation(String portletHandle)
+ {
+ TestPortletInvocationContext ac = new TestPortletInvocationContext();
+ ActionInvocation action = new ActionInvocation(ac);
+ action.setInstanceContext(new AbstractInstanceContext(portletHandle));
+ action.setSecurityContext(new
AbstractSecurityContext(MockHttpServletRequest.createMockRequest(null)));
+ action.setUserContext(new AbstractUserContext());
+ action.setTarget(PortletContext.createPortletContext(portletHandle));
+ return action;
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/PortletManagementTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/PortletManagementTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/PortletManagementTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,160 @@
+/******************************************************************************
+ * 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.protocol.v1;
+
+import org.gatein.pc.api.Portlet;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.api.PortletStateType;
+import org.gatein.pc.api.state.DestroyCloneFailure;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.ExtendedAssert;
+import org.gatein.wsrp.test.protocol.v1.behaviors.BasicMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.BasicPortletManagementBehavior;
+import
org.gatein.wsrp.test.protocol.v1.behaviors.DestroyClonesPortletManagementBehavior;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class PortletManagementTestCase extends V1ConsumerBaseTest
+{
+ public PortletManagementTestCase() throws Exception
+ {
+ }
+
+ /*public void testClone() throws Exception
+ {
+ PortletContext original =
PortletContext.createPortletContext(BasicMarkupBehavior.PORTLET_HANDLE);
+ PortletContext clone = consumer.createClone(original);
+ ExtendedAssert.assertNotNull(clone);
+ ExtendedAssert.assertFalse(original.equals(clone));
+ ExtendedAssert.assertEquals(BasicPortletManagementBehavior.CLONED_HANDLE,
clone.getId());
+
+ Portlet originalPortlet = consumer.getPortlet(original);
+ Portlet clonePortlet = consumer.getPortlet(clone);
+ ExtendedAssert.assertNotNull(clonePortlet);
+
ExtendedAssert.assertFalse(originalPortlet.getContext().equals(clonePortlet.getContext()));
+
+ // information about the portlet should be the same
+ MetaInfo originalInfo = originalPortlet.getInfo().getMeta();
+ MetaInfo cloneInfo = clonePortlet.getInfo().getMeta();
+ ExtendedAssert.assertEquals(originalInfo.getMetaValue(MetaInfo.TITLE),
cloneInfo.getMetaValue(MetaInfo.TITLE));
+ ExtendedAssert.assertEquals(originalInfo.getMetaValue(MetaInfo.DESCRIPTION),
cloneInfo.getMetaValue(MetaInfo.DESCRIPTION));
+ }
+
+ public void testGetSetProperties() throws Exception
+ {
+ PortletContext original =
PortletContext.createPortletContext(BasicMarkupBehavior.PORTLET_HANDLE);
+ PropertyMap props = consumer.getProperties(original);
+ checkProperties(props, BasicPortletManagementBehavior.PROPERTY_VALUE);
+
+ PortletContext clone = consumer.createClone(original);
+ props = consumer.getProperties(clone);
+ checkProperties(props, BasicPortletManagementBehavior.PROPERTY_VALUE);
+
+ consumer.setProperties(clone, new PropertyChange[]
+ {
+ PropertyChange.newUpdate(BasicPortletManagementBehavior.PROPERTY_NAME,
+ new StringValue(BasicPortletManagementBehavior.PROPERTY_NEW_VALUE))
+ });
+ checkProperties(consumer.getProperties(clone),
BasicPortletManagementBehavior.PROPERTY_NEW_VALUE);
+
+ consumer.setProperties(clone, new PropertyChange[]
+ {
+ PropertyChange.newReset(BasicPortletManagementBehavior.PROPERTY_NAME)
+ });
+ checkProperties(consumer.getProperties(clone),
BasicPortletManagementBehavior.PROPERTY_VALUE);
+ }
+
+ private void checkProperties(PropertyMap props, String expectedValue)
+ {
+ ExtendedAssert.assertNotNull(props);
+ ExtendedAssert.assertEquals(1, props.size());
+ ExtendedAssert.assertEquals(expectedValue,
+ props.getProperty(BasicPortletManagementBehavior.PROPERTY_NAME).asString());
+ }*/
+
+ public void testDestroyClones() throws Exception
+ {
+ // switch the behavior for portlet management
+ BehaviorRegistry behaviorRegistry = producer.getBehaviorRegistry();
+ behaviorRegistry.setPortletManagementBehavior(new
DestroyClonesPortletManagementBehavior(behaviorRegistry));
+
+ PortletContext original =
PortletContext.createPortletContext(BasicMarkupBehavior.PORTLET_HANDLE);
+ PortletContext clone = consumer.createClone(PortletStateType.OPAQUE, original);
+ ExtendedAssert.assertNotNull(clone);
+ Portlet portlet = consumer.getPortlet(clone);
+ ExtendedAssert.assertNotNull(portlet);
+ ExtendedAssert.assertEquals(BasicPortletManagementBehavior.CLONED_HANDLE,
portlet.getContext().getId());
+
+ List clones = new ArrayList(1);
+ clones.add(clone);
+ List result = consumer.destroyClones(clones);
+ ExtendedAssert.assertTrue(result.isEmpty());
+ try
+ {
+ consumer.getPortlet(clone);
+ ExtendedAssert.fail("Should have failed: clone should not exist
anymore!");
+ }
+ catch (PortletInvokerException expected)
+ {
+ }
+
+ // re-create clone and try again with an added invalid portlet context
+ clone = consumer.createClone(PortletStateType.OPAQUE, original);
+ PortletContext invalidContext =
PortletContext.createPortletContext("invalid");
+ clones.add(invalidContext);
+ result = consumer.destroyClones(clones);
+ ExtendedAssert.assertEquals(1, result.size());
+ DestroyCloneFailure failure = (DestroyCloneFailure)result.get(0);
+ ExtendedAssert.assertEquals("invalid", failure.getPortletId());
+ try
+ {
+ consumer.getPortlet(clone);
+ ExtendedAssert.fail("Should have failed: clone should not exist
anymore!");
+ }
+ catch (PortletInvokerException expected)
+ {
+ }
+ }
+
+ /*public void testInvalidSetProperties() throws Exception
+ {
+ PortletContext original =
PortletContext.createPortletContext(BasicMarkupBehavior.PORTLET_HANDLE);
+ try
+ {
+ consumer.setProperties(original, null);
+ ExtendedAssert.fail("Shouldn't be possible to set properties with null
changes");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ //expected
+ }
+ }*/
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/PortletManagementTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/ServiceDescriptionTestCase.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/ServiceDescriptionTestCase.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/ServiceDescriptionTestCase.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * 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.protocol.v1;
+
+import org.gatein.pc.api.Portlet;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.wsrp.test.ExtendedAssert;
+import org.gatein.wsrp.test.protocol.v1.behaviors.BasicMarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.behaviors.SessionMarkupBehavior;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 11320 $
+ * @since 2.4
+ */
+public class ServiceDescriptionTestCase extends InteropServiceDescriptionTestCase
+{
+
+ public ServiceDescriptionTestCase() throws Exception
+ {
+ super();
+ }
+
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ // use strict mode
+ setStrict(true);
+ }
+
+ public void testUsesRelaxedMode()
+ {
+ ExtendedAssert.assertTrue(isStrict());
+ }
+
+ public void testGetPortlet() throws Exception
+ {
+ //obtain one portlet
+ Portlet portlet =
consumer.getPortlet(PortletContext.createPortletContext(BasicMarkupBehavior.PORTLET_HANDLE));
+ checkPortlet(portlet, "", BasicMarkupBehavior.PORTLET_HANDLE);
+
+ portlet =
consumer.getPortlet(PortletContext.createPortletContext(SessionMarkupBehavior.PORTLET_HANDLE));
+ checkPortlet(portlet, "2", SessionMarkupBehavior.PORTLET_HANDLE);
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/ServiceDescriptionTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/V1ConsumerBaseTest.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/V1ConsumerBaseTest.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/V1ConsumerBaseTest.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * 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.protocol.v1;
+
+import org.gatein.pc.api.Portlet;
+import org.gatein.pc.api.info.MetaInfo;
+import org.gatein.wsrp.consumer.WSRPConsumerBaseTest;
+import org.gatein.wsrp.test.ExtendedAssert;
+import org.gatein.wsrp.test.protocol.v1.TestProducerBehavior;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
+ * @version $Revision: 11320 $
+ */
+public class V1ConsumerBaseTest extends WSRPConsumerBaseTest
+{
+ public V1ConsumerBaseTest() throws Exception
+ {
+ }
+
+ protected void checkPortlet(Portlet portlet, String suffix, String handle)
+ {
+ MetaInfo meta = portlet.getInfo().getMeta();
+ ExtendedAssert.assertEquals(handle, portlet.getContext().getId());
+ ExtendedAssert.assertEquals(TestProducerBehavior.SAMPLE_DESCRIPTION + suffix,
TestProducerBehavior.extractString(meta.getMetaValue(MetaInfo.DESCRIPTION)));
+ ExtendedAssert.assertEquals(TestProducerBehavior.SAMPLE_TITLE + suffix,
TestProducerBehavior.extractString(meta.getMetaValue(MetaInfo.TITLE)));
+ ExtendedAssert.assertEquals(TestProducerBehavior.SAMPLE_SHORTTITLE + suffix,
TestProducerBehavior.extractString(meta.getMetaValue(MetaInfo.SHORT_TITLE)));
+ ExtendedAssert.assertEquals(TestProducerBehavior.SAMPLE_DISPLAYNAME + suffix,
TestProducerBehavior.extractString(meta.getMetaValue(MetaInfo.DISPLAY_NAME)));
+ ExtendedAssert.assertEquals(TestProducerBehavior.SAMPLE_KEYWORD + suffix,
TestProducerBehavior.extractString(meta.getMetaValue(MetaInfo.KEYWORDS)));
+ }
+
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/V1ConsumerBaseTest.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/BehaviorRegistry.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/BehaviorRegistry.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/BehaviorRegistry.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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;
+
+import org.gatein.wsrp.WSRPExceptionFactory;
+import org.gatein.wsrp.test.protocol.v1.MarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.PortletManagementBehavior;
+import org.gatein.wsrp.test.protocol.v1.RegistrationBehavior;
+import org.gatein.wsrp.test.protocol.v1.ServiceDescriptionBehavior;
+import org.oasis.wsrp.v1.InvalidHandle;
+import org.oasis.wsrp.v1.InvalidHandleFault;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 9360 $
+ * @since 2.6
+ */
+public class BehaviorRegistry
+{
+ private final Map<String, MarkupBehavior> behaviors = new HashMap<String,
MarkupBehavior>();
+ private PortletManagementBehavior portletManagementBehavior;
+ private ServiceDescriptionBehavior serviceDescriptionBehavior;
+ private RegistrationBehavior registrationBehavior;
+
+ public ServiceDescriptionBehavior getServiceDescriptionBehavior()
+ {
+ // this is required since the consumer will try to access the producer as soon as
it's started and the test
+ // producer will not be properly setup at that time since it's set up in the
test's setUp method...
+ if (serviceDescriptionBehavior == null)
+ {
+ return ServiceDescriptionBehavior.DEFAULT;
+ }
+
+ return serviceDescriptionBehavior;
+ }
+
+ public void clear()
+ {
+ behaviors.clear();
+ }
+
+ public MarkupBehavior getMarkupBehaviorFor(String handle) throws InvalidHandle
+ {
+ if (behaviors.containsKey(handle))
+ {
+ return behaviors.get(handle);
+ }
+ throw WSRPExceptionFactory.<InvalidHandle,
InvalidHandleFault>throwWSException(WSRPExceptionFactory.INVALID_HANDLE,
+ "There is no registered MarkupBehavior for handle '" + handle +
"'", null);
+ }
+
+ public void registerMarkupBehavior(MarkupBehavior behavior)
+ {
+ for (String handle : behavior.getSupportedHandles())
+ {
+ MarkupBehavior existing = behaviors.get(handle);
+ if (existing != null)
+ {
+ throw new IllegalArgumentException("Cannot register behavior " +
behavior.getClass().getName()
+ + " because it uses a handle '" + handle + "'
that's already associated with behavior "
+ + existing.getClass().getName());
+ }
+ behaviors.put(handle, behavior);
+ }
+ }
+
+ public PortletManagementBehavior getPortletManagementBehavior()
+ {
+ return portletManagementBehavior;
+ }
+
+ public void setPortletManagementBehavior(PortletManagementBehavior
portletManagementBehavior)
+ {
+ this.portletManagementBehavior = portletManagementBehavior;
+ }
+
+ public void setServiceDescriptionBehavior(ServiceDescriptionBehavior
serviceDescriptionBehavior)
+ {
+ this.serviceDescriptionBehavior = serviceDescriptionBehavior;
+ }
+
+ public RegistrationBehavior getRegistrationBehavior()
+ {
+ return registrationBehavior;
+ }
+
+ public void setRegistrationBehavior(RegistrationBehavior registrationBehavior)
+ {
+ this.registrationBehavior = registrationBehavior;
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/BehaviorRegistry.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/TestWSRPProducer.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/TestWSRPProducer.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/TestWSRPProducer.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * 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;
+
+import org.oasis.wsrp.v1.CookieProtocol;
+
+/**
+ * Exposes WSPRProducer test implementation methods - we inject what it returns
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
+ * @version $Revision: 10610 $
+ */
+public interface TestWSRPProducer
+{
+ /** Resets any currently held state. */
+ void reset();
+
+ BehaviorRegistry getBehaviorRegistry();
+
+ /**
+ * Sets the currently used portlet handle identifying the MarkupBehavior we're
using. This is needed to be able to
+ * dispatch calls to initCookie to the proper behavior.
+ *
+ * @param handle
+ */
+ void setCurrentMarkupBehaviorHandle(String handle);
+
+ void setRequiresInitCookie(CookieProtocol requiresInitCookie);
+
+ void usingStrictModeChangedTo(boolean strictMode);
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/TestWSRPProducer.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/TestWSRPProducerImpl.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/TestWSRPProducerImpl.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/TestWSRPProducerImpl.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,256 @@
+/******************************************************************************
+ * 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;
+
+import org.gatein.wsrp.test.protocol.v1.MarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.PortletManagementBehavior;
+import org.gatein.wsrp.test.protocol.v1.ServiceDescriptionBehavior;
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.CookieProtocol;
+import org.oasis.wsrp.v1.DestroyFailed;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.InconsistentParameters;
+import org.oasis.wsrp.v1.InteractionParams;
+import org.oasis.wsrp.v1.InvalidCookie;
+import org.oasis.wsrp.v1.InvalidHandle;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.InvalidSession;
+import org.oasis.wsrp.v1.InvalidUserCategory;
+import org.oasis.wsrp.v1.ItemDescription;
+import org.oasis.wsrp.v1.MarkupContext;
+import org.oasis.wsrp.v1.MarkupParams;
+import org.oasis.wsrp.v1.MissingParameters;
+import org.oasis.wsrp.v1.ModelDescription;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.PortletContext;
+import org.oasis.wsrp.v1.PortletDescription;
+import org.oasis.wsrp.v1.PortletStateChangeRequired;
+import org.oasis.wsrp.v1.Property;
+import org.oasis.wsrp.v1.PropertyList;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.RegistrationData;
+import org.oasis.wsrp.v1.ResetProperty;
+import org.oasis.wsrp.v1.ResourceList;
+import org.oasis.wsrp.v1.RuntimeContext;
+import org.oasis.wsrp.v1.SessionContext;
+import org.oasis.wsrp.v1.UnsupportedLocale;
+import org.oasis.wsrp.v1.UnsupportedMimeType;
+import org.oasis.wsrp.v1.UnsupportedMode;
+import org.oasis.wsrp.v1.UnsupportedWindowState;
+import org.oasis.wsrp.v1.UpdateResponse;
+import org.oasis.wsrp.v1.UserContext;
+import org.oasis.wsrp.v1.WSRPV1MarkupPortType;
+import org.oasis.wsrp.v1.WSRPV1PortletManagementPortType;
+import org.oasis.wsrp.v1.WSRPV1RegistrationPortType;
+import org.oasis.wsrp.v1.WSRPV1ServiceDescriptionPortType;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.List;
+
+/**
+ * This is dummy clone of org.jboss.portal.wsrp.producer.WSRPProducerImpl customizable
from client side. Just for
+ * consumer implementation testing purposes.
+ *
+ * @author <a href="mailto:Boleslaw.Dawidowicz@jboss.com">Boleslaw
Dawidowicz</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 12020 $
+ * @since 2.4
+ */
+public class TestWSRPProducerImpl implements TestWSRPProducer, WSRPV1MarkupPortType,
WSRPV1PortletManagementPortType, WSRPV1RegistrationPortType,
WSRPV1ServiceDescriptionPortType
+{
+ private int sessionExpirationTime = 600;
+
+ private CookieProtocol requiresInitCookie = CookieProtocol.NONE;
+
+ private BehaviorRegistry behaviorRegistry = new BehaviorRegistry();
+
+ public static final String USER_COOKIE = "cookie";
+
+ private String currentMarkupBehaviorHandle;
+
+ private boolean strict = true;
+
+ public TestWSRPProducerImpl()
+ {
+ reset();
+ }
+
+ public BehaviorRegistry getBehaviorRegistry()
+ {
+ return behaviorRegistry;
+ }
+
+ public void setCurrentMarkupBehaviorHandle(String handle)
+ {
+ currentMarkupBehaviorHandle = handle;
+ }
+
+ public void reset()
+ {
+ requiresInitCookie = null;
+ currentMarkupBehaviorHandle = null;
+ behaviorRegistry.clear();
+ }
+
+ private MarkupBehavior getMarkupBehaviorFor(String portletHandle) throws
InvalidHandle
+ {
+ return behaviorRegistry.getMarkupBehaviorFor(portletHandle);
+ }
+
+ private ServiceDescriptionBehavior getServiceDescriptionBehavior()
+ {
+ return behaviorRegistry.getServiceDescriptionBehavior();
+ }
+
+ public PortletManagementBehavior getPortletManagementBehavior()
+ {
+ return behaviorRegistry.getPortletManagementBehavior();
+ }
+
+ // ServiceDescription implementation
********************************************************************************
+
+
+ public void getServiceDescription(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "desiredLocales", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> desiredLocales,
@WebParam(mode = WebParam.Mode.OUT, name = "requiresRegistration",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<Boolean>
requiresRegistration, @WebParam(mode = WebParam.Mode.OUT, name =
"offeredPortlets", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<PortletDescription>>
offeredPortlets, @WebParam(mode = WebParam.Mode.OUT, name =
"userCategoryDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
userCategoryDescriptions, @WebParam(mode = WebParam.Mode.OUT, name =
"customUserProfileItemDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
customUserProfileItemDescrip!
tions, @WebParam(mode = WebParam.Mode.OUT, name =
"customWindowStateDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
customWindowStateDescriptions, @WebParam(mode = WebParam.Mode.OUT, name =
"customModeDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
customModeDescriptions, @WebParam(mode = WebParam.Mode.OUT, name =
"requiresInitCookie", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<CookieProtocol>
requiresInitCookie, @WebParam(mode = WebParam.Mode.OUT, name =
"registrationPropertyDescription", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<ModelDescription>
registrationPropertyDescription, @WebParam(mode = WebParam.Mode.OUT, name =
"locales", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<String>> locales, @WebParam(mode = WebParam.Mode.OUT, name =
"resourceList", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<Res!
ourceList> resourceList, @WebParam(mode = WebParam.Mode.OUT, n!
ame = "e
xtensions", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws InvalidRegistration,
OperationFailed
+ {
+ getServiceDescriptionBehavior().getServiceDescription(registrationContext,
desiredLocales, requiresRegistration,
+ offeredPortlets, userCategoryDescriptions, customUserProfileItemDescriptions,
customWindowStateDescriptions,
+ customModeDescriptions, requiresInitCookie, registrationPropertyDescription,
locales, resourceList, extensions);
+ }
+
+ // MarkupService implementation
*************************************************************************************
+
+
+ public void performBlockingInteraction(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext,
@WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "runtimeContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RuntimeContext runtimeContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"markupParams", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
MarkupParams markupParams, @WebParam(name = "interactionParams", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") InteractionParams interactionParams,
@WebParam(mode = WebParam.Mode.OUT, name = "updateResponse", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<UpdateResponse> updateResponse,
@WebParam(mode = WebParam.Mode.OUT, name = "redirectURL", targe!
tNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<String>
redirectURL, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws UnsupportedMimeType,
UnsupportedMode, UnsupportedWindowState, InvalidCookie, InvalidSession, MissingParameters,
UnsupportedLocale, InconsistentParameters, PortletStateChangeRequired, InvalidHandle,
InvalidRegistration, InvalidUserCategory, AccessDenied, OperationFailed
+ {
+
getMarkupBehaviorFor(portletContext.getPortletHandle()).performBlockingInteraction(registrationContext,
portletContext, runtimeContext, userContext, markupParams, interactionParams,
updateResponse, redirectURL, extensions);
+ }
+
+ public List<Extension> releaseSessions(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext,
@WebParam(name = "sessionIDs", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> sessionIDs) throws
MissingParameters, InvalidRegistration, AccessDenied, OperationFailed
+ {
+ return null;
+ }
+
+ public void getMarkup(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "runtimeContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RuntimeContext runtimeContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"markupParams", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
MarkupParams markupParams, @WebParam(mode = WebParam.Mode.OUT, name =
"markupContext", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<MarkupContext> markupContext, @WebParam(mode = WebParam.Mode.OUT, name =
"sessionContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<SessionContext> sessionContext,
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", t!
argetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws UnsupportedMimeType,
UnsupportedMode, UnsupportedWindowState, InvalidCookie, InvalidSession, MissingParameters,
UnsupportedLocale, InconsistentParameters, InvalidHandle, InvalidRegistration,
InvalidUserCategory, AccessDenied, OperationFailed
+ {
+
getMarkupBehaviorFor(portletContext.getPortletHandle()).getMarkup(registrationContext,
portletContext, runtimeContext, userContext, markupParams, markupContext, sessionContext,
extensions);
+ }
+
+ public List<Extension> initCookie(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext)
throws InvalidRegistration, AccessDenied, OperationFailed
+ {
+ // should only be called if we required cookies to be initialized
+ if (requiresInitCookie == null || CookieProtocol.NONE.equals(requiresInitCookie))
+ {
+ throw new OperationFailed();
+ }
+
+ try
+ {
+ return
getMarkupBehaviorFor(currentMarkupBehaviorHandle).initCookie(registrationContext);
+ }
+ catch (InvalidHandle invalidHandle)
+ {
+ throw new OperationFailed("Invalid handle", invalidHandle);
+ }
+ }
+
+ // Registration implementation
**************************************************************************************
+
+
+ public void register(@WebParam(name = "consumerName", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") String consumerName, @WebParam(name =
"consumerAgent", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
String consumerAgent, @WebParam(name = "methodGetSupported", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") boolean methodGetSupported, @WebParam(name =
"consumerModes", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
List<String> consumerModes, @WebParam(name = "consumerWindowStates",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") List<String>
consumerWindowStates, @WebParam(name = "consumerUserScopes", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> consumerUserScopes,
@WebParam(name = "customUserProfileData", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> customUserProfileData,
@WebParam(name = "registrationProperties", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<Property> registrat!
ionProperties, @WebParam(mode = WebParam.Mode.INOUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions, @WebParam(mode = WebParam.Mode.OUT, name =
"registrationHandle", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<String> registrationHandle,
@WebParam(mode = WebParam.Mode.OUT, name = "registrationState", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<byte[]> registrationState)
throws MissingParameters, OperationFailed
+ {
+ registrationHandle.value = "registration";
+ }
+
+ public void modifyRegistration(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "registrationData", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationData registrationData,
@WebParam(mode = WebParam.Mode.OUT, name = "registrationState", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<byte[]> registrationState,
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<Extension>>
extensions) throws MissingParameters, InvalidRegistration, OperationFailed
+ {
+ // do nothing
+ }
+
+ public List<Extension> deregister(@WebParam(name =
"registrationHandle", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") String registrationHandle, @WebParam(name =
"registrationState", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") byte[] registrationState, @WebParam(name =
"extensions", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
List<Extension> extensions) throws InvalidRegistration, OperationFailed
+ {
+ return null; // do nothing
+ }
+
+ // PortletManagement implementation
*********************************************************************************
+
+ public void getPortletPropertyDescription(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext,
@WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"desiredLocales", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> desiredLocales,
@WebParam(mode = WebParam.Mode.OUT, name = "modelDescription", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<ModelDescription>
modelDescription, @WebParam(mode = WebParam.Mode.OUT, name = "resourceList",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<ResourceList>
resourceList, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) thro!
ws MissingParameters, InconsistentParameters, InvalidHandle, InvalidRegistration,
InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ getPortletManagementBehavior().getPortletPropertyDescription(registrationContext,
portletContext, userContext, desiredLocales, modelDescription, resourceList, extensions);
+ }
+
+ public void setPortletProperties(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"propertyList", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
PropertyList propertyList, @WebParam(mode = WebParam.Mode.OUT, name =
"portletHandle", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<String> portletHandle, @WebParam(mode = WebParam.Mode.OUT, name =
"portletState", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<byte[]> portletState, @WebParam(mode = WebParam.Mode.OUT, name =
"extensions", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws MissingParameters, InconsistentP!
arameters, InvalidHandle, InvalidRegistration, InvalidUserCategory, AccessDenied,
OperationFailed
+ {
+ getPortletManagementBehavior().setPortletProperties(registrationContext,
portletContext, userContext, propertyList, portletHandle, portletState, extensions);
+ }
+
+ public void clonePortlet(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(mode =
WebParam.Mode.OUT, name = "portletHandle", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<String> portletHandle,
@WebParam(mode = WebParam.Mode.OUT, name = "portletState", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<byte[]> portletState,
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<Extension>>
extensions) throws MissingParameters, InconsistentParameters, InvalidHandle,
InvalidRegistration, InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ getPortletManagementBehavior().clonePortlet(registrationContext, portletContext,
userContext, portletHandle, portletState, extensions);
+ }
+
+ public void getPortletDescription(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"desiredLocales", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> desiredLocales,
@WebParam(mode = WebParam.Mode.OUT, name = "portletDescription", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<PortletDescription>
portletDescription, @WebParam(mode = WebParam.Mode.OUT, name = "resourceList",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<ResourceList>
resourceList, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws!
MissingParameters, InconsistentParameters, InvalidHandle, InvalidRegistration,
InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ getPortletManagementBehavior().getPortletDescription(registrationContext,
portletContext, userContext, desiredLocales, portletDescription, resourceList,
extensions);
+ }
+
+ public void getPortletProperties(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"names", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
List<String> names, @WebParam(mode = WebParam.Mode.OUT, name =
"properties", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Property>> properties, @WebParam(mode = WebParam.Mode.OUT, name =
"resetProperties", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ResetProperty>>
resetProperties, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws MissingParameters, Incons!
istentParameters, InvalidHandle, InvalidRegistration, InvalidUserCategory, AccessDenied,
OperationFailed
+ {
+ getPortletManagementBehavior().getPortletProperties(registrationContext,
portletContext, userContext, names, properties, resetProperties, extensions);
+ }
+
+ public void destroyPortlets(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletHandles", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> portletHandles,
@WebParam(mode = WebParam.Mode.OUT, name = "destroyFailed", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<DestroyFailed>>
destroyFailed, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws MissingParameters,
InconsistentParameters, InvalidRegistration, OperationFailed
+ {
+ getPortletManagementBehavior().destroyPortlets(registrationContext, portletHandles,
destroyFailed, extensions);
+ }
+
+ // Producer implementation
******************************************************************************************
+
+ public CookieProtocol getRequiresInitCookie()
+ {
+ return requiresInitCookie;
+ }
+
+ public void setRequiresInitCookie(CookieProtocol requiresInitCookie)
+ {
+ this.requiresInitCookie = requiresInitCookie;
+ getServiceDescriptionBehavior().setRequiresInitCookie(requiresInitCookie);
+ }
+
+ public int getSessionExpirationTime()
+ {
+ return sessionExpirationTime;
+ }
+
+ public void setSessionExpirationTime(int sessionExpirationTime)
+ {
+ this.sessionExpirationTime = sessionExpirationTime;
+ }
+
+ public void usingStrictModeChangedTo(boolean strictMode)
+ {
+// WSRPValidator.setStrict(strictMode);
+ strict = strictMode;
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/TestWSRPProducerImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/MarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/MarkupBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/MarkupBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,205 @@
+/******************************************************************************
+ * 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.protocol.v1;
+
+import org.gatein.common.net.media.MediaType;
+import org.gatein.pc.api.Mode;
+import org.gatein.pc.api.WindowState;
+import org.gatein.wsrp.WSRPTypeFactory;
+import org.gatein.wsrp.WSRPUtils;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.GetMarkup;
+import org.oasis.wsrp.v1.InconsistentParameters;
+import org.oasis.wsrp.v1.InteractionParams;
+import org.oasis.wsrp.v1.InvalidCookie;
+import org.oasis.wsrp.v1.InvalidHandle;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.InvalidSession;
+import org.oasis.wsrp.v1.InvalidUserCategory;
+import org.oasis.wsrp.v1.MarkupContext;
+import org.oasis.wsrp.v1.MarkupParams;
+import org.oasis.wsrp.v1.MarkupResponse;
+import org.oasis.wsrp.v1.MissingParameters;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.PortletContext;
+import org.oasis.wsrp.v1.PortletDescription;
+import org.oasis.wsrp.v1.PortletStateChangeRequired;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.RuntimeContext;
+import org.oasis.wsrp.v1.SessionContext;
+import org.oasis.wsrp.v1.UnsupportedLocale;
+import org.oasis.wsrp.v1.UnsupportedMimeType;
+import org.oasis.wsrp.v1.UnsupportedMode;
+import org.oasis.wsrp.v1.UnsupportedWindowState;
+import org.oasis.wsrp.v1.UpdateResponse;
+import org.oasis.wsrp.v1.UserContext;
+import org.oasis.wsrp.v1.WSRPV1MarkupPortType;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Behavior delivering Markup services.
+ *
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.test.AbstractMarkupBehavior">Chris
Laprun</a>
+ * @version $Revision: 10337 $
+ * @since 2.6
+ */
+public abstract class MarkupBehavior extends TestProducerBehavior implements
WSRPV1MarkupPortType
+{
+ private List<String> handles = new ArrayList<String>(3);
+ private BehaviorRegistry registry;
+
+
+ protected MarkupBehavior(BehaviorRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ /**
+ * Returns a markup String based on the passed information.
+ *
+ * @param mode the requested mode
+ * @param windowState the requested window state
+ * @param navigationalState the current navigational state
+ * @param getMarkup the original GetMarkup request (in case more information
is required by this behavior)
+ * @return a possibly <code>null</code> markup String
+ */
+ protected abstract String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
+ throws UnsupportedWindowState, InvalidCookie, InvalidSession, AccessDenied,
InconsistentParameters, InvalidHandle,
+ UnsupportedLocale, UnsupportedMode, OperationFailed, MissingParameters,
InvalidUserCategory, InvalidRegistration,
+ UnsupportedMimeType;
+
+ /**
+ * Allows this behavior to modify the response after the markup has been generated.
The default implementation does
+ * nothing.
+ *
+ * @param markupResponse the response that will be passed on to the consumer
+ */
+ public void modifyResponseIfNeeded(MarkupResponse markupResponse)
+ {
+ // default implementation does not nothing
+ }
+
+ public List<String> getSupportedHandles()
+ {
+ return handles;
+ }
+
+ public PortletDescription getPortletDescriptionFor(String handle)
+ {
+ if (handles.contains(handle))
+ {
+ return createPortletDescription(handle, getSuffixFor(handle));
+ }
+ throw new IllegalArgumentException("MarkupBehavior " +
getClass().getName() + " is not associated with handle '"
+ + handle + "'");
+ }
+
+ protected String getSuffixFor(String handle)
+ {
+ return "";
+ }
+
+ protected void registerHandle(String handle)
+ {
+ handles.add(handle);
+
registry.getServiceDescriptionBehavior().addPortletDescription(createPortletDescription(handle,
getSuffixFor(handle)));
+ }
+
+ /**
+ * Default implementation doesn't do anything.
+ *
+ * @param registrationContext
+ * @param portletContext
+ * @param runtimeContext
+ * @param userContext
+ * @param markupParams
+ * @param interactionParams
+ * @param updateResponse
+ * @param redirectURL
+ * @param extensions
+ * @throws UnsupportedMimeType
+ * @throws UnsupportedMode
+ * @throws UnsupportedWindowState
+ * @throws InvalidCookie
+ * @throws InvalidSession
+ * @throws MissingParameters
+ * @throws UnsupportedLocale
+ * @throws InconsistentParameters
+ * @throws PortletStateChangeRequired
+ * @throws InvalidHandle
+ * @throws InvalidRegistration
+ * @throws InvalidUserCategory
+ * @throws AccessDenied
+ * @throws OperationFailed
+ */
+ public void performBlockingInteraction(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext,
@WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "runtimeContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RuntimeContext runtimeContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"markupParams", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
MarkupParams markupParams, @WebParam(name = "interactionParams", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") InteractionParams interactionParams,
@WebParam(mode = WebParam.Mode.OUT, name = "updateResponse", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<UpdateResponse> updateResponse,
@WebParam(mode = WebParam.Mode.OUT, name = "redirectURL", targe!
tNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<String>
redirectURL, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws UnsupportedMimeType,
UnsupportedMode, UnsupportedWindowState, InvalidCookie, InvalidSession, MissingParameters,
UnsupportedLocale, InconsistentParameters, PortletStateChangeRequired, InvalidHandle,
InvalidRegistration, InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ // do nothing
+ }
+
+ public List<Extension> releaseSessions(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext,
@WebParam(name = "sessionIDs", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> sessionIDs) throws
MissingParameters, InvalidRegistration, AccessDenied, OperationFailed
+ {
+ return null;
+ }
+
+ public void getMarkup(
+ @WebParam(name = "registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext,
+ @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
+ @WebParam(name = "runtimeContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RuntimeContext runtimeContext,
+ @WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext,
+ @WebParam(name = "markupParams", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") MarkupParams markupParams,
+ @WebParam(mode = WebParam.Mode.OUT, name = "markupContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<MarkupContext> markupContext,
+ @WebParam(mode = WebParam.Mode.OUT, name = "sessionContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<SessionContext> sessionContext,
+ @WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<List<Extension>>
extensions)
+ throws UnsupportedMimeType, UnsupportedMode, UnsupportedWindowState, InvalidCookie,
InvalidSession, MissingParameters, UnsupportedLocale, InconsistentParameters,
InvalidHandle, InvalidRegistration, InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ GetMarkup gm = new GetMarkup();
+ gm.setMarkupParams(markupParams);
+ gm.setPortletContext(portletContext);
+ gm.setRegistrationContext(registrationContext);
+ gm.setRuntimeContext(runtimeContext);
+ gm.setUserContext(userContext);
+
+ String markupString =
getMarkupString(WSRPUtils.getJSR168PortletModeFromWSRPName(markupParams.getMode()),
+ WSRPUtils.getJSR168WindowStateFromWSRPName(markupParams.getWindowState()),
markupParams.getNavigationalState(), gm);
+
+ markupContext.value =
WSRPTypeFactory.createMarkupContext(MediaType.TEXT_HTML.getValue(), markupString);
+ markupContext.value.setRequiresUrlRewriting(Boolean.TRUE);
+
+ MarkupResponse markupResponse =
WSRPTypeFactory.createMarkupResponse(markupContext.value);
+
+ modifyResponseIfNeeded(markupResponse);
+ }
+
+ public List<Extension> initCookie(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext)
throws InvalidRegistration, AccessDenied, OperationFailed
+ {
+ return null;
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/MarkupBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/PortletManagementBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/PortletManagementBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/PortletManagementBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * 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.protocol.v1;
+
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.DestroyFailed;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.InconsistentParameters;
+import org.oasis.wsrp.v1.InvalidHandle;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.InvalidUserCategory;
+import org.oasis.wsrp.v1.MissingParameters;
+import org.oasis.wsrp.v1.ModelDescription;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.PortletContext;
+import org.oasis.wsrp.v1.PortletDescription;
+import org.oasis.wsrp.v1.Property;
+import org.oasis.wsrp.v1.PropertyList;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.ResetProperty;
+import org.oasis.wsrp.v1.ResourceList;
+import org.oasis.wsrp.v1.UserContext;
+import org.oasis.wsrp.v1.WSRPV1PortletManagementPortType;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.List;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.test.PortletManagementBehavior">Chris
+ * Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class PortletManagementBehavior extends TestProducerBehavior implements
WSRPV1PortletManagementPortType
+{
+ public void getPortletPropertyDescription(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext,
@WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"desiredLocales", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> desiredLocales,
@WebParam(mode = WebParam.Mode.OUT, name = "modelDescription", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<ModelDescription>
modelDescription, @WebParam(mode = WebParam.Mode.OUT, name = "resourceList",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<ResourceList>
resourceList, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) thro!
ws MissingParameters, InconsistentParameters, InvalidHandle, InvalidRegistration,
InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ incrementCallCount();
+ }
+
+ public void setPortletProperties(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"propertyList", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
PropertyList propertyList, @WebParam(mode = WebParam.Mode.OUT, name =
"portletHandle", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<String> portletHandle, @WebParam(mode = WebParam.Mode.OUT, name =
"portletState", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<byte[]> portletState, @WebParam(mode = WebParam.Mode.OUT, name =
"extensions", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws MissingParameters, InconsistentP!
arameters, InvalidHandle, InvalidRegistration, InvalidUserCategory, AccessDenied,
OperationFailed
+ {
+ incrementCallCount();
+ }
+
+ public void clonePortlet(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(mode =
WebParam.Mode.OUT, name = "portletHandle", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<String> portletHandle,
@WebParam(mode = WebParam.Mode.OUT, name = "portletState", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<byte[]> portletState,
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<Extension>>
extensions) throws MissingParameters, InconsistentParameters, InvalidHandle,
InvalidRegistration, InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ incrementCallCount();
+ }
+
+ public void getPortletDescription(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"desiredLocales", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> desiredLocales,
@WebParam(mode = WebParam.Mode.OUT, name = "portletDescription", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<PortletDescription>
portletDescription, @WebParam(mode = WebParam.Mode.OUT, name = "resourceList",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<ResourceList>
resourceList, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws!
MissingParameters, InconsistentParameters, InvalidHandle, InvalidRegistration,
InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ incrementCallCount();
+ }
+
+ public void getPortletProperties(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"names", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
List<String> names, @WebParam(mode = WebParam.Mode.OUT, name =
"properties", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Property>> properties, @WebParam(mode = WebParam.Mode.OUT, name =
"resetProperties", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ResetProperty>>
resetProperties, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws MissingParameters, Incons!
istentParameters, InvalidHandle, InvalidRegistration, InvalidUserCategory, AccessDenied,
OperationFailed
+ {
+ incrementCallCount();
+ }
+
+ public void destroyPortlets(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletHandles", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> portletHandles,
@WebParam(mode = WebParam.Mode.OUT, name = "destroyFailed", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<DestroyFailed>>
destroyFailed, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws MissingParameters,
InconsistentParameters, InvalidRegistration, OperationFailed
+ {
+ incrementCallCount();
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/PortletManagementBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/RegistrationBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/RegistrationBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/RegistrationBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * 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.protocol.v1;
+
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.MissingParameters;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.Property;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.RegistrationData;
+import org.oasis.wsrp.v1.WSRPV1RegistrationPortType;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.List;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.test.RegistrationBehavior">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class RegistrationBehavior extends TestProducerBehavior implements
WSRPV1RegistrationPortType
+{
+ public static final String REGISTRATION_HANDLE = "registration";
+
+ public void register(@WebParam(name = "consumerName", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") String consumerName, @WebParam(name =
"consumerAgent", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
String consumerAgent, @WebParam(name = "methodGetSupported", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") boolean methodGetSupported, @WebParam(name =
"consumerModes", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
List<String> consumerModes, @WebParam(name = "consumerWindowStates",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") List<String>
consumerWindowStates, @WebParam(name = "consumerUserScopes", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> consumerUserScopes,
@WebParam(name = "customUserProfileData", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> customUserProfileData,
@WebParam(name = "registrationProperties", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<Property> registrat!
ionProperties, @WebParam(mode = WebParam.Mode.INOUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions, @WebParam(mode = WebParam.Mode.OUT, name =
"registrationHandle", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<String> registrationHandle,
@WebParam(mode = WebParam.Mode.OUT, name = "registrationState", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<byte[]> registrationState)
throws MissingParameters, OperationFailed
+ {
+ incrementCallCount();
+ registrationHandle.value = REGISTRATION_HANDLE;
+ }
+
+ public void modifyRegistration(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "registrationData", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationData registrationData,
@WebParam(mode = WebParam.Mode.OUT, name = "registrationState", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<byte[]> registrationState,
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<Extension>>
extensions) throws MissingParameters, InvalidRegistration, OperationFailed
+ {
+ incrementCallCount();
+ }
+
+ public List<Extension> deregister(@WebParam(name =
"registrationHandle", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") String registrationHandle, @WebParam(name =
"registrationState", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") byte[] registrationState, @WebParam(name =
"extensions", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
List<Extension> extensions) throws InvalidRegistration, OperationFailed
+ {
+ incrementCallCount();
+ return null;
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/RegistrationBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/ServiceDescriptionBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/ServiceDescriptionBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/ServiceDescriptionBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,149 @@
+/******************************************************************************
+ * 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.protocol.v1;
+
+import org.gatein.wsrp.WSRPConstants;
+import org.gatein.wsrp.WSRPTypeFactory;
+import org.oasis.wsrp.v1.CookieProtocol;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.ItemDescription;
+import org.oasis.wsrp.v1.ModelDescription;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.PortletDescription;
+import org.oasis.wsrp.v1.PropertyDescription;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.ResourceList;
+import org.oasis.wsrp.v1.ServiceDescription;
+import org.oasis.wsrp.v1.WSRPV1ServiceDescriptionPortType;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.test.ServiceDescriptionBehavior">Chris
+ * Laprun</a>
+ * @version $Revision: 11320 $
+ * @since 2.6
+ */
+public class ServiceDescriptionBehavior extends TestProducerBehavior implements
WSRPV1ServiceDescriptionPortType
+{
+ protected ServiceDescription serviceDescription;
+ private static final ServiceDescription DEFAULT_SERVICE_DESCRIPTION =
WSRPTypeFactory.createServiceDescription(false);
+ public static final ServiceDescriptionBehavior DEFAULT = new
ServiceDescriptionBehavior();
+
+ protected List<PortletDescription> offeredPortlets;
+ private boolean requiresRegistration;
+ private CookieProtocol cookieProtocol;
+
+ public ServiceDescriptionBehavior()
+ {
+ offeredPortlets = new LinkedList<PortletDescription>();
+ }
+
+ public void setRequiresRegistration(boolean requiresRegistration)
+ {
+ this.requiresRegistration = requiresRegistration;
+ }
+
+ public void setRequiresInitCookie(CookieProtocol requiresInitCookie)
+ {
+ this.cookieProtocol = requiresInitCookie;
+ }
+
+ public void setServiceDescription(boolean requiresRegistration, int numberOfProps)
+ {
+ serviceDescription = createServiceDescription(requiresRegistration,
numberOfProps);
+ }
+
+ public static ServiceDescription getDefaultServiceDescription()
+ {
+ return DEFAULT_SERVICE_DESCRIPTION;
+ }
+
+ public void addPortletDescription(PortletDescription portletDescription)
+ {
+ offeredPortlets.add(portletDescription);
+ }
+
+ public Set<String> getPortletHandles()
+ {
+ Set<String> handles = new HashSet<String>(offeredPortlets.size());
+
+ for (PortletDescription description : offeredPortlets)
+ {
+ handles.add(description.getPortletHandle());
+ }
+
+ return handles;
+ }
+
+ public int getPortletNumber()
+ {
+ return offeredPortlets.size();
+ }
+
+ public static ServiceDescription createServiceDescription(boolean
requiresRegistration, int numberOfProperties)
+ {
+ ServiceDescription sd =
WSRPTypeFactory.createServiceDescription(requiresRegistration);
+
+ if (requiresRegistration)
+ {
+ List<PropertyDescription> descriptions = new
ArrayList<PropertyDescription>(numberOfProperties);
+ for (int i = 0; i < numberOfProperties; i++)
+ {
+ descriptions.add(WSRPTypeFactory.createPropertyDescription("prop" +
i, WSRPConstants.XSD_STRING));
+ }
+
sd.setRegistrationPropertyDescription(WSRPTypeFactory.createModelDescription(descriptions));
+ }
+
+ return sd;
+ }
+
+ public void getServiceDescription(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext,
+ @WebParam(name = "desiredLocales",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") List<String>
desiredLocales,
+ @WebParam(mode = WebParam.Mode.OUT, name =
"requiresRegistration", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<Boolean> requiresRegistration,
+ @WebParam(mode = WebParam.Mode.OUT, name =
"offeredPortlets", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<PortletDescription>>
offeredPortlets,
+ @WebParam(mode = WebParam.Mode.OUT, name =
"userCategoryDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
userCategoryDescriptions,
+ @WebParam(mode = WebParam.Mode.OUT, name =
"customUserProfileItemDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
customUserProfileItemDescriptions,
+ @WebParam(mode = WebParam.Mode.OUT, name =
"customWindowStateDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
customWindowStateDescriptions,
+ @WebParam(mode = WebParam.Mode.OUT, name =
"customModeDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
customModeDescriptions,
+ @WebParam(mode = WebParam.Mode.OUT, name =
"requiresInitCookie", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<CookieProtocol>
requiresInitCookie,
+ @WebParam(mode = WebParam.Mode.OUT, name =
"registrationPropertyDescription", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<ModelDescription>
registrationPropertyDescription,
+ @WebParam(mode = WebParam.Mode.OUT, name =
"locales", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<String>> locales,
+ @WebParam(mode = WebParam.Mode.OUT, name =
"resourceList", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<ResourceList> resourceList,
+ @WebParam(mode = WebParam.Mode.OUT, name =
"extensions", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions)
+ throws InvalidRegistration, OperationFailed
+ {
+ incrementCallCount();
+ offeredPortlets.value = this.offeredPortlets;
+ requiresRegistration.value = this.requiresRegistration;
+ requiresInitCookie.value = this.cookieProtocol;
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/ServiceDescriptionBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/TestProducerBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/TestProducerBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/TestProducerBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * 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.protocol.v1;
+
+import org.gatein.common.net.media.MediaType;
+import org.gatein.wsrp.WSRPConstants;
+import org.gatein.wsrp.WSRPTypeFactory;
+import org.oasis.wsrp.v1.LocalizedString;
+import org.oasis.wsrp.v1.MarkupType;
+import org.oasis.wsrp.v1.PortletDescription;
+
+/**
+ * Provides a base class for Producer behavior used in Consumer testing.
+ *
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.test.TestProducerBehavior">Chris
Laprun</a>
+ * @version $Revision: 11317 $
+ * @since 2.6
+ */
+public abstract class TestProducerBehavior
+{
+ protected int callCount;
+ public static final String SAMPLE_DESCRIPTION = "SampleDescription";
+ public static final String SAMPLE_SHORTTITLE = "SampleShortTitle";
+ public static final String SAMPLE_TITLE = "SampleTitle";
+ public static final String SAMPLE_DISPLAYNAME = "SampleDisplayName";
+ public static final String SAMPLE_KEYWORD = "keyword";
+
+ /**
+ * Increment the number of times methods of this behavior have been called. Used when
the behavior changes depending
+ * on how many times methods have been called.
+ */
+ public void incrementCallCount()
+ {
+ callCount++;
+ }
+
+ public int getCallCount()
+ {
+ return callCount;
+ }
+
+ public PortletDescription createPortletDescription(String portletHandle, String
suffix)
+ {
+ PortletDescription portletDesc = new PortletDescription();
+ portletDesc.setPortletHandle(portletHandle);
+ MarkupType markupType = new MarkupType();
+ markupType.setMimeType(MediaType.TEXT_HTML.getValue());
+ markupType.getModes().add(WSRPConstants.VIEW_MODE);
+ markupType.getWindowStates().add(WSRPConstants.NORMAL_WINDOW_STATE);
+ markupType.getLocales().addAll(WSRPConstants.getDefaultLocales());
+ portletDesc.getMarkupTypes().add(markupType);
+
+ String suffixString = suffix == null ? "" : suffix;
+ portletDesc.setDescription(createLocalizedString(SAMPLE_DESCRIPTION +
suffixString));
+ portletDesc.setTitle(createLocalizedString(SAMPLE_TITLE + suffixString));
+ portletDesc.setShortTitle(createLocalizedString(SAMPLE_SHORTTITLE +
suffixString));
+ portletDesc.setDisplayName(createLocalizedString(SAMPLE_DISPLAYNAME +
suffixString));
+ portletDesc.getKeywords().add(createLocalizedString(SAMPLE_KEYWORD +
suffixString));
+ return portletDesc;
+ }
+
+ /**
+ * Create the dummiest form of LocalizedString
+ *
+ * @param value
+ * @return
+ */
+ public static LocalizedString createLocalizedString(String value)
+ {
+ return WSRPTypeFactory.createLocalizedString(value);
+ }
+
+ /** Produces String from LocalizedString */
+ public static String extractString(org.gatein.common.i18n.LocalizedString ls)
+ {
+ return ls.getPreferredOrBestLocalizedMappingFor(new
String[]{"en"}).getString();
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/TestProducerBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicMarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicMarkupBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicMarkupBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,109 @@
+/******************************************************************************
+ * 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.protocol.v1.behaviors;
+
+import org.gatein.pc.api.Mode;
+import org.gatein.pc.api.WindowState;
+import org.gatein.wsrp.WSRPConstants;
+import org.gatein.wsrp.WSRPTypeFactory;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.protocol.v1.MarkupBehavior;
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.GetMarkup;
+import org.oasis.wsrp.v1.InconsistentParameters;
+import org.oasis.wsrp.v1.InteractionParams;
+import org.oasis.wsrp.v1.InvalidCookie;
+import org.oasis.wsrp.v1.InvalidHandle;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.InvalidSession;
+import org.oasis.wsrp.v1.InvalidUserCategory;
+import org.oasis.wsrp.v1.MarkupParams;
+import org.oasis.wsrp.v1.MarkupResponse;
+import org.oasis.wsrp.v1.MissingParameters;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.PortletContext;
+import org.oasis.wsrp.v1.PortletStateChangeRequired;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.RuntimeContext;
+import org.oasis.wsrp.v1.UnsupportedLocale;
+import org.oasis.wsrp.v1.UnsupportedMimeType;
+import org.oasis.wsrp.v1.UnsupportedMode;
+import org.oasis.wsrp.v1.UnsupportedWindowState;
+import org.oasis.wsrp.v1.UpdateResponse;
+import org.oasis.wsrp.v1.UserContext;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.List;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.v1.consumer.producer.BasicProducer">Chris
+ * Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class BasicMarkupBehavior extends MarkupBehavior
+{
+ public static final String PORTLET_HANDLE = "SamplePortletHandle";
+ public static final String NS = "ns1";
+
+
+ public BasicMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ registerHandle(PORTLET_HANDLE);
+ }
+
+ public String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
+ {
+ StringBuffer markupString = new StringBuffer("portlet1:");
+
+ markupString.append(mode).append(":").append(windowState);
+ if (navigationalState != null)
+ {
+ markupString.append(":").append(navigationalState);
+ }
+
+ return markupString.toString();
+ }
+
+
+ @Override
+ public void performBlockingInteraction(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext,
@WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "runtimeContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RuntimeContext runtimeContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"markupParams", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
MarkupParams markupParams, @WebParam(name = "interactionParams", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") InteractionParams interactionParams,
@WebParam(mode = WebParam.Mode.OUT, name = "updateResponse", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<UpdateResponse> updateResponse,
@WebParam(mode = WebParam.Mode.OUT, name = "redirectURL", targe!
tNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<String>
redirectURL, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions)
+ throws UnsupportedMimeType, UnsupportedMode, UnsupportedWindowState, InvalidCookie,
InvalidSession,
+ MissingParameters, UnsupportedLocale, InconsistentParameters,
PortletStateChangeRequired, InvalidHandle,
+ InvalidRegistration, InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ UpdateResponse ur = WSRPTypeFactory.createUpdateResponse();
+ ur.setNavigationalState(NS);
+ updateResponse.value = ur;
+ }
+
+ public void modifyResponseIfNeeded(MarkupResponse markupResponse)
+ {
+ // fake markup caching
+
markupResponse.getMarkupContext().setCacheControl(WSRPTypeFactory.createCacheControl(15,
WSRPConstants.CACHE_PER_USER));
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicMarkupBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicPortletManagementBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicPortletManagementBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicPortletManagementBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,195 @@
+/******************************************************************************
+ * 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.protocol.v1.behaviors;
+
+import org.gatein.wsrp.WSRPExceptionFactory;
+import org.gatein.wsrp.WSRPTypeFactory;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.protocol.v1.MarkupBehavior;
+import org.gatein.wsrp.test.protocol.v1.PortletManagementBehavior;
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.DestroyFailed;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.InconsistentParameters;
+import org.oasis.wsrp.v1.InvalidHandle;
+import org.oasis.wsrp.v1.InvalidHandleFault;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.InvalidUserCategory;
+import org.oasis.wsrp.v1.MissingParameters;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.OperationFailedFault;
+import org.oasis.wsrp.v1.PortletContext;
+import org.oasis.wsrp.v1.PortletDescription;
+import org.oasis.wsrp.v1.Property;
+import org.oasis.wsrp.v1.PropertyList;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.ResetProperty;
+import org.oasis.wsrp.v1.ResourceList;
+import org.oasis.wsrp.v1.UserContext;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class BasicPortletManagementBehavior extends PortletManagementBehavior
+{
+ private static final String CLONE_SUFFIX = "_clone";
+ public static final String PROPERTY_NAME = "prop1";
+ public static final String PROPERTY_VALUE = "value1";
+ public static final String PROPERTY_NEW_VALUE = "value2";
+ public static final String CLONED_HANDLE = BasicMarkupBehavior.PORTLET_HANDLE +
CLONE_SUFFIX;
+ private BehaviorRegistry registry;
+
+ public BasicPortletManagementBehavior(BehaviorRegistry registry)
+ {
+ super();
+ this.registry = registry;
+ }
+
+ @Override
+ public void clonePortlet(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(mode =
WebParam.Mode.OUT, name = "portletHandle", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<String> portletHandle,
@WebParam(mode = WebParam.Mode.OUT, name = "portletState", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<byte[]> portletState,
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<Extension>>
extensions) throws MissingParameters, InconsistentParameters, InvalidHandle,
InvalidRegistration, InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ String handle = getHandleFrom(portletContext, "portlet context");
+
+ if (!BasicMarkupBehavior.PORTLET_HANDLE.equals(handle))
+ {
+ throw WSRPExceptionFactory.<InvalidHandle,
InvalidHandleFault>throwWSException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Can only clone portlet with handle '" +
BasicMarkupBehavior.PORTLET_HANDLE + "'", null);
+ }
+
+ portletHandle.value = CLONED_HANDLE;
+ }
+
+ @Override
+ public void getPortletDescription(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"desiredLocales", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> desiredLocales,
@WebParam(mode = WebParam.Mode.OUT, name = "portletDescription", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<PortletDescription>
portletDescription, @WebParam(mode = WebParam.Mode.OUT, name = "resourceList",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<ResourceList>
resourceList, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws!
MissingParameters, InconsistentParameters, InvalidHandle, InvalidRegistration,
InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ super.getPortletDescription(registrationContext, portletContext, userContext,
desiredLocales, portletDescription, resourceList, extensions);
+
+ String handle = getHandleFrom(portletContext, "portlet context");
+
+ // need to fake that the clone exists... so remove suffix to get the description of
the POP
+ int index = handle.indexOf(CLONE_SUFFIX);
+ if (index != -1)
+ {
+ handle = handle.substring(0, index);
+ }
+
+ // get the POP description...
+ MarkupBehavior markupBehaviorFor = registry.getMarkupBehaviorFor(handle);
+ PortletDescription description =
markupBehaviorFor.getPortletDescriptionFor(handle);
+
+ // if it was a clone, add the suffix back to the handle.
+ if (index != -1)
+ {
+ description.setPortletHandle(handle + CLONE_SUFFIX);
+ }
+
+ portletDescription.value = description;
+ }
+
+ @Override
+ public void getPortletProperties(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"names", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
List<String> names, @WebParam(mode = WebParam.Mode.OUT, name =
"properties", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Property>> properties, @WebParam(mode = WebParam.Mode.OUT, name =
"resetProperties", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ResetProperty>>
resetProperties, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws MissingParameters, Incons!
istentParameters, InvalidHandle, InvalidRegistration, InvalidUserCategory, AccessDenied,
OperationFailed
+ {
+ String handle = getHandleFrom(portletContext, "portlet context");
+
+ List<Property> propertyList = new ArrayList<Property>(1);
+
+ if (BasicMarkupBehavior.PORTLET_HANDLE.equals(handle))
+ {
+ propertyList.add(WSRPTypeFactory.createProperty(PROPERTY_NAME, "en",
PROPERTY_VALUE));
+ }
+ else if (CLONED_HANDLE.equals(handle))
+ {
+ if (callCount != 2)
+ {
+ propertyList.add(WSRPTypeFactory.createProperty(PROPERTY_NAME,
"en", PROPERTY_VALUE));
+ }
+ else
+ {
+ propertyList.add(WSRPTypeFactory.createProperty(PROPERTY_NAME,
"en", PROPERTY_NEW_VALUE));
+ }
+ }
+ else
+ {
+ WSRPExceptionFactory.<InvalidHandle,
InvalidHandleFault>throwWSException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Unknown handle '" + handle + "'", null);
+ }
+
+ incrementCallCount();
+ properties.value = propertyList;
+ }
+
+ @Override
+ public void setPortletProperties(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"propertyList", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
PropertyList propertyList, @WebParam(mode = WebParam.Mode.OUT, name =
"portletHandle", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<String> portletHandle, @WebParam(mode = WebParam.Mode.OUT, name =
"portletState", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<byte[]> portletState, @WebParam(mode = WebParam.Mode.OUT, name =
"extensions", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws MissingParameters, InconsistentP!
arameters, InvalidHandle, InvalidRegistration, InvalidUserCategory, AccessDenied,
OperationFailed
+ {
+ String handle = getHandleFrom(portletContext, "portlet context");
+
+ if (!(CLONED_HANDLE).equals(handle))
+ {
+ throw WSRPExceptionFactory.<OperationFailed,
OperationFailedFault>throwWSException(WSRPExceptionFactory.OPERATION_FAILED,
+ "Cannot modify portlet '" + handle + "'", null);
+ }
+
+ portletHandle.value = handle;
+ }
+
+ private String getHandleFrom(PortletContext portletContext, String context) throws
MissingParameters, InvalidHandle
+ {
+ WSRPExceptionFactory.throwMissingParametersIfValueIsMissing(portletContext,
"portlet context", context);
+ String handle = portletContext.getPortletHandle();
+ WSRPExceptionFactory.throwMissingParametersIfValueIsMissing(handle, "portlet
handle", "PortletContext");
+ if (handle.length() == 0)
+ {
+ throw WSRPExceptionFactory.<InvalidHandle,
InvalidHandleFault>throwWSException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Portlet handle is empty", null);
+ }
+
+ return handle;
+ }
+
+ @Override
+ public void destroyPortlets(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletHandles", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> portletHandles,
@WebParam(mode = WebParam.Mode.OUT, name = "destroyFailed", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<DestroyFailed>>
destroyFailed, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws MissingParameters,
InconsistentParameters, InvalidRegistration, OperationFailed
+ {
+ super.destroyPortlets(registrationContext, portletHandles, destroyFailed,
extensions);
+ WSRPExceptionFactory.throwMissingParametersIfValueIsMissing(portletHandles,
"portlet handles", "destroyPortlets");
+ if (portletHandles.isEmpty())
+ {
+ WSRPExceptionFactory.throwMissingParametersIfValueIsMissing(portletHandles,
"portlet handles", "DestroyPortlets");
+ }
+
+ for (String handle : portletHandles)
+ {
+ if (!CLONED_HANDLE.equals(handle))
+ {
+ destroyFailed.value.add(WSRPTypeFactory.createDestroyFailed(handle,
"Handle '" + handle + "' doesn't exist"));
+ }
+ }
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicPortletManagementBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicServiceDescriptionBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicServiceDescriptionBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicServiceDescriptionBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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.protocol.v1.behaviors;
+
+import org.gatein.wsrp.test.protocol.v1.ServiceDescriptionBehavior;
+import org.oasis.wsrp.v1.PortletDescription;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.protocol.v1.behaviors.BasicServiceDescriptionBehavior">Chris
+ * Laprun</a>
+ * @version $Revision: 10610 $
+ * @since 2.6
+ */
+public class BasicServiceDescriptionBehavior extends ServiceDescriptionBehavior
+{
+
+ public BasicServiceDescriptionBehavior()
+ {
+ //Prepare description of two portlets
+ PortletDescription pd1 =
createPortletDescription(BasicMarkupBehavior.PORTLET_HANDLE, "");
+ PortletDescription pd2 =
createPortletDescription(SessionMarkupBehavior.PORTLET_HANDLE, "2");
+ offeredPortlets.add(pd1);
+ offeredPortlets.add(pd2);
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/BasicServiceDescriptionBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/DestroyClonesPortletManagementBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/DestroyClonesPortletManagementBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/DestroyClonesPortletManagementBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.protocol.v1.behaviors;
+
+import org.gatein.wsrp.WSRPExceptionFactory;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.InconsistentParameters;
+import org.oasis.wsrp.v1.InvalidHandle;
+import org.oasis.wsrp.v1.InvalidHandleFault;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.InvalidUserCategory;
+import org.oasis.wsrp.v1.MissingParameters;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.PortletContext;
+import org.oasis.wsrp.v1.PortletDescription;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.ResourceList;
+import org.oasis.wsrp.v1.UserContext;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.List;
+
+/**
+ * Specific behavior used in PortletManagementCase.testDestroyClones.
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class DestroyClonesPortletManagementBehavior extends
BasicPortletManagementBehavior
+{
+ public DestroyClonesPortletManagementBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ }
+
+ @Override
+ public void getPortletDescription(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"desiredLocales", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> desiredLocales,
@WebParam(mode = WebParam.Mode.OUT, name = "portletDescription", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<PortletDescription>
portletDescription, @WebParam(mode = WebParam.Mode.OUT, name = "resourceList",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<ResourceList>
resourceList, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws!
MissingParameters, InconsistentParameters, InvalidHandle, InvalidRegistration,
InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ // only return the portlet description the first time the method is called since
all other calls happen after
+ // the clone has been destroyed...
+ if (getCallCount() == 0)
+ {
+ incrementCallCount();
+ super.getPortletDescription(registrationContext, portletContext, userContext,
desiredLocales, portletDescription, resourceList, extensions);
+ }
+ else
+ {
+ throw WSRPExceptionFactory.<InvalidHandle,
InvalidHandleFault>throwWSException(WSRPExceptionFactory.INVALID_HANDLE,
+ "Invalid portlet handle: " + portletContext.getPortletHandle(),
null);
+ }
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/DestroyClonesPortletManagementBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/EmptyMarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/EmptyMarkupBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/EmptyMarkupBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * 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.protocol.v1.behaviors;
+
+import org.gatein.pc.api.Mode;
+import org.gatein.pc.api.WindowState;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.protocol.v1.MarkupBehavior;
+import org.oasis.wsrp.v1.GetMarkup;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.v1.consumer.producer.EmptyMarkupBehavior">Chris
+ * Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class EmptyMarkupBehavior extends MarkupBehavior
+{
+ public static final String PORTLET_HANDLE = "EmptyMarkup";
+
+
+ public EmptyMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ registerHandle(PORTLET_HANDLE);
+ }
+
+ public String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
+ {
+ return "";
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/EmptyMarkupBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/GroupedPortletsServiceDescriptionBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/GroupedPortletsServiceDescriptionBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/GroupedPortletsServiceDescriptionBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,63 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.protocol.v1.behaviors;
+
+import org.gatein.wsrp.test.protocol.v1.ServiceDescriptionBehavior;
+import org.oasis.wsrp.v1.CookieProtocol;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.ItemDescription;
+import org.oasis.wsrp.v1.ModelDescription;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.PortletDescription;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.ResourceList;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.List;
+
+/**
+ * Wraps a service description to add group information on portlet descriptions...
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class GroupedPortletsServiceDescriptionBehavior extends
ServiceDescriptionBehavior
+{
+ public GroupedPortletsServiceDescriptionBehavior(List<PortletDescription>
offeredPortlets)
+ {
+ this.offeredPortlets = offeredPortlets;
+ }
+
+ @Override
+ public void getServiceDescription(@WebParam(name = "registrationContext",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") RegistrationContext
registrationContext, @WebParam(name = "desiredLocales", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") List<String> desiredLocales,
@WebParam(mode = WebParam.Mode.OUT, name = "requiresRegistration",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<Boolean>
requiresRegistration, @WebParam(mode = WebParam.Mode.OUT, name =
"offeredPortlets", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<PortletDescription>>
offeredPortlets, @WebParam(mode = WebParam.Mode.OUT, name =
"userCategoryDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
userCategoryDescriptions, @WebParam(mode = WebParam.Mode.OUT, name =
"customUserProfileItemDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
customUserProfileItemDescrip!
tions, @WebParam(mode = WebParam.Mode.OUT, name =
"customWindowStateDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
customWindowStateDescriptions, @WebParam(mode = WebParam.Mode.OUT, name =
"customModeDescriptions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<List<ItemDescription>>
customModeDescriptions, @WebParam(mode = WebParam.Mode.OUT, name =
"requiresInitCookie", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<CookieProtocol>
requiresInitCookie, @WebParam(mode = WebParam.Mode.OUT, name =
"registrationPropertyDescription", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<ModelDescription>
registrationPropertyDescription, @WebParam(mode = WebParam.Mode.OUT, name =
"locales", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<String>> locales, @WebParam(mode = WebParam.Mode.OUT, name =
"resourceList", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<Res!
ourceList> resourceList, @WebParam(mode = WebParam.Mode.OUT, n!
ame = "e
xtensions", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws InvalidRegistration,
OperationFailed
+ {
+ super.getServiceDescription(registrationContext, desiredLocales,
requiresRegistration, offeredPortlets, userCategoryDescriptions,
customUserProfileItemDescriptions, customWindowStateDescriptions, customModeDescriptions,
requiresInitCookie, registrationPropertyDescription, locales, resourceList, extensions);
+ List<PortletDescription> portletDescriptions = offeredPortlets.value;
+ for (int i = 0; i < portletDescriptions.size(); i++)
+ {
+ portletDescriptions.get(i).setGroupID("group" + i % 3);
+ }
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/GroupedPortletsServiceDescriptionBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/InitCookieMarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/InitCookieMarkupBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/InitCookieMarkupBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.protocol.v1.behaviors;
+
+import org.gatein.pc.api.Mode;
+import org.gatein.pc.api.WindowState;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.protocol.v1.MarkupBehavior;
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.GetMarkup;
+import org.oasis.wsrp.v1.InvalidCookie;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.RegistrationContext;
+
+import javax.jws.WebParam;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 10610 $
+ * @since 2.6
+ */
+public abstract class InitCookieMarkupBehavior extends MarkupBehavior
+{
+ protected String portletHandle;
+ protected int initCookieCallCount;
+
+ public InitCookieMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ initPortletHandle();
+ registerHandle(portletHandle);
+ }
+
+ protected abstract void initPortletHandle();
+
+
+ protected String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup) throws OperationFailed, InvalidCookie
+ {
+ String handle = getMarkup.getPortletContext().getPortletHandle();
+
+ if (portletHandle.equals(handle))
+ {
+ return getMarkupString(handle);
+ }
+
+ // shouldn't happen
+ throw new OperationFailed();
+ }
+
+ protected String getMarkupString(String handle) throws InvalidCookie, OperationFailed
+ {
+ switch (callCount++)
+ {
+ case 0:
+ // simulate change of configuration between calls: upon receiving this, the
consumer should invoke initCookie
+ throw new InvalidCookie();
+
+ case 1:
+ return handle;
+
+ default:
+ // shouldn't be called more than twice
+ throw new OperationFailed();
+ }
+ }
+
+ @Override
+ public List<Extension> initCookie(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext)
throws InvalidRegistration, AccessDenied, OperationFailed
+ {
+ initCookieCallCount++;
+ return null;
+ }
+
+ public int getInitCookieCallCount()
+ {
+ return initCookieCallCount;
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/InitCookieMarkupBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/InitCookieNotRequiredMarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/InitCookieNotRequiredMarkupBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/InitCookieNotRequiredMarkupBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,65 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.protocol.v1.behaviors;
+
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.RegistrationContext;
+
+import javax.jws.WebParam;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class InitCookieNotRequiredMarkupBehavior extends InitCookieMarkupBehavior
+{
+ public static final String INIT_COOKIE_NOT_REQUIRED_HANDLE =
"InitCookieNotRequired";
+
+ public InitCookieNotRequiredMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ }
+
+ protected void initPortletHandle()
+ {
+ portletHandle = INIT_COOKIE_NOT_REQUIRED_HANDLE;
+ }
+
+ @Override
+ protected String getMarkupString(String handle)
+ {
+ return handle;
+ }
+
+ @Override
+ public List<Extension> initCookie(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext)
throws InvalidRegistration, AccessDenied, OperationFailed
+ {
+ super.initCookie(registrationContext);
+ throw new OperationFailed();
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/InitCookieNotRequiredMarkupBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/NullMarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/NullMarkupBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/NullMarkupBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * 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.protocol.v1.behaviors;
+
+import org.gatein.pc.api.Mode;
+import org.gatein.pc.api.WindowState;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.protocol.v1.MarkupBehavior;
+import org.oasis.wsrp.v1.GetMarkup;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.v1.consumer.producer.NullMarkupBehavior">Chris
+ * Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class NullMarkupBehavior extends MarkupBehavior
+{
+ public static final String PORTLET_HANDLE = "NullMarkup";
+
+
+ public NullMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ registerHandle(PORTLET_HANDLE);
+ }
+
+ public String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
+ {
+ return null;
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/NullMarkupBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/PerGroupInitCookieMarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/PerGroupInitCookieMarkupBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/PerGroupInitCookieMarkupBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,66 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.protocol.v1.behaviors;
+
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.RegistrationContext;
+
+import javax.jws.WebParam;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class PerGroupInitCookieMarkupBehavior extends InitCookieMarkupBehavior
+{
+ public static final String PER_GROUP_INIT_COOKIE_HANDLE =
"PerGroupInitCookie";
+
+ public PerGroupInitCookieMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ }
+
+ protected void initPortletHandle()
+ {
+ portletHandle = PER_GROUP_INIT_COOKIE_HANDLE;
+ }
+
+ @Override
+ public List<Extension> initCookie(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext)
throws InvalidRegistration, AccessDenied, OperationFailed
+ {
+ List<Extension> extensions = super.initCookie(registrationContext);
+
+ if (initCookieCallCount > 3)
+ {
+ throw new OperationFailed("Service description only defines 3 groups so
initCookie should only be called 3 times!",
+ new IllegalStateException("Service description only defines 3 groups so
initCookie should only be called 3 times!"));
+ }
+
+ return extensions;
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/PerGroupInitCookieMarkupBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/PerUserInitCookieMarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/PerUserInitCookieMarkupBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/PerUserInitCookieMarkupBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,44 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.protocol.v1.behaviors;
+
+import org.gatein.wsrp.test.BehaviorRegistry;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class PerUserInitCookieMarkupBehavior extends InitCookieMarkupBehavior
+{
+ public static final String PER_USER_INIT_COOKIE_HANDLE =
"PerUserInitCookie";
+
+ public PerUserInitCookieMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ }
+
+ protected void initPortletHandle()
+ {
+ portletHandle = PER_USER_INIT_COOKIE_HANDLE;
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/PerUserInitCookieMarkupBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/ResourceMarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/ResourceMarkupBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/ResourceMarkupBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,52 @@
+/*
+* 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.protocol.v1.behaviors;
+
+import org.gatein.pc.api.Mode;
+import org.gatein.pc.api.WindowState;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.protocol.v1.MarkupBehavior;
+import org.oasis.wsrp.v1.GetMarkup;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class ResourceMarkupBehavior extends MarkupBehavior
+{
+ public static final String PORTLET_HANDLE = "resource";
+
+
+ public ResourceMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ registerHandle(PORTLET_HANDLE);
+ }
+
+ protected String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
+ {
+ return "<img
src='wsrp_rewrite?wsrp-urlType=resource&wsrp-url=http%3A%2F%2Flocalhost%3A8080"
+
+
"%2Ftest-resource-portlet%2Fgif%2Flogo.gif&wsrp-requiresRewrite=true/wsrp_rewrite'/>";
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/ResourceMarkupBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/SessionMarkupBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/SessionMarkupBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/SessionMarkupBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,127 @@
+/******************************************************************************
+ * 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.protocol.v1.behaviors;
+
+import org.gatein.pc.api.Mode;
+import org.gatein.pc.api.WindowState;
+import org.gatein.wsrp.WSRPTypeFactory;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.protocol.v1.MarkupBehavior;
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.Extension;
+import org.oasis.wsrp.v1.GetMarkup;
+import org.oasis.wsrp.v1.InconsistentParameters;
+import org.oasis.wsrp.v1.InteractionParams;
+import org.oasis.wsrp.v1.InvalidCookie;
+import org.oasis.wsrp.v1.InvalidHandle;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.InvalidSession;
+import org.oasis.wsrp.v1.InvalidUserCategory;
+import org.oasis.wsrp.v1.MarkupParams;
+import org.oasis.wsrp.v1.MarkupResponse;
+import org.oasis.wsrp.v1.MissingParameters;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.PortletContext;
+import org.oasis.wsrp.v1.PortletStateChangeRequired;
+import org.oasis.wsrp.v1.RegistrationContext;
+import org.oasis.wsrp.v1.RuntimeContext;
+import org.oasis.wsrp.v1.SessionContext;
+import org.oasis.wsrp.v1.UnsupportedLocale;
+import org.oasis.wsrp.v1.UnsupportedMimeType;
+import org.oasis.wsrp.v1.UnsupportedMode;
+import org.oasis.wsrp.v1.UnsupportedWindowState;
+import org.oasis.wsrp.v1.UpdateResponse;
+import org.oasis.wsrp.v1.UserContext;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.List;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.gatein.wsrp.v1.consumer.producer.SessionBehavior">Chris
+ * Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class SessionMarkupBehavior extends MarkupBehavior
+{
+ public static final String PORTLET_HANDLE = "SecondPortletHandle";
+ public static final String SESSION_ID = "sessionID";
+ public static final String NS = "ns2";
+
+
+ private int count = 0;
+ private String sessionId;
+
+ public SessionMarkupBehavior(BehaviorRegistry registry)
+ {
+ super(registry);
+ registerHandle(PORTLET_HANDLE);
+ }
+
+ public String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
+ {
+ StringBuffer markupString = new StringBuffer("portlet2:");
+ sessionId = getMarkup.getRuntimeContext().getSessionID();
+
+ // if we have a session, increments count to simulate session usage
+ if (SESSION_ID.equals(sessionId))
+ {
+ count++;
+ }
+ markupString.append(count).append(":");
+
+ markupString.append(mode).append(":").append(windowState);
+ if (navigationalState != null)
+ {
+ markupString.append(":").append(navigationalState);
+ }
+
+ return markupString.toString();
+ }
+
+ @Override
+ public void performBlockingInteraction(@WebParam(name =
"registrationContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RegistrationContext registrationContext,
@WebParam(name = "portletContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") PortletContext portletContext,
@WebParam(name = "runtimeContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") RuntimeContext runtimeContext,
@WebParam(name = "userContext", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") UserContext userContext, @WebParam(name =
"markupParams", targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
MarkupParams markupParams, @WebParam(name = "interactionParams", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") InteractionParams interactionParams,
@WebParam(mode = WebParam.Mode.OUT, name = "updateResponse", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types") Holder<UpdateResponse> updateResponse,
@WebParam(mode = WebParam.Mode.OUT, name = "redirectURL", targe!
tNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<String>
redirectURL, @WebParam(mode = WebParam.Mode.OUT, name = "extensions",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types")
Holder<List<Extension>> extensions) throws UnsupportedMimeType,
UnsupportedMode, UnsupportedWindowState, InvalidCookie, InvalidSession, MissingParameters,
UnsupportedLocale, InconsistentParameters, PortletStateChangeRequired, InvalidHandle,
InvalidRegistration, InvalidUserCategory, AccessDenied, OperationFailed
+ {
+ UpdateResponse ur = WSRPTypeFactory.createUpdateResponse();
+ ur.setNavigationalState(NS);
+ updateResponse.value = ur;
+ }
+
+ public void modifyResponseIfNeeded(MarkupResponse markupResponse)
+ {
+ // fakes creation of a portlet session if not already present
+ if (count == 0 || SESSION_ID.equals(sessionId))
+ {
+ SessionContext sessionContext = WSRPTypeFactory.createSessionContext(SESSION_ID,
30);
+ markupResponse.setSessionContext(sessionContext);
+ }
+ }
+
+
+ protected String getSuffixFor(String handle)
+ {
+ return "2";
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/SessionMarkupBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/interop/LiferayServiceDescriptionBehavior.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/interop/LiferayServiceDescriptionBehavior.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/interop/LiferayServiceDescriptionBehavior.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,77 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.protocol.v1.behaviors.interop;
+
+import org.gatein.wsrp.test.protocol.v1.ServiceDescriptionBehavior;
+import org.oasis.wsrp.v1.LocalizedString;
+import org.oasis.wsrp.v1.PortletDescription;
+
+/**
+ * Liferay behavior as exhibited at
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4162201#...
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class LiferayServiceDescriptionBehavior extends ServiceDescriptionBehavior
+{
+ public LiferayServiceDescriptionBehavior()
+ {
+ /*
+ <portletHandle>98</portletHandle>
+<markupTypes>
+ <mimeType>text/html</mimeType>
+ <modes>wsrp:view</modes>
+ <windowStates>wsrp:normal</windowStates>
+ <windowStates>wsrp:minimized</windowStates>
+ <windowStates>wsrp:maximized</windowStates>
+ <locales>en_US</locales>
+</markupTypes>
+<groupID>98</groupID>
+<shortTitle lang='English'>
+ <value>javax.portlet.short-title.98</value>
+</shortTitle>
+<title lang='English'>
+ <value>Software Catalog</value>
+</title>
+ */
+ PortletDescription pd = createPortletDescription("98", null);
+ pd.getMarkupTypes().get(0).getLocales().set(0, "en_US");
+ LocalizedString locString = pd.getShortTitle();
+ pd.setGroupID("98");
+ String lang = "English";
+ locString.setLang(lang);
+ locString.setValue("javax.portlet.short-title.98");
+ locString = pd.getTitle();
+ locString.setLang(lang);
+ locString.setValue("Software Catalog");
+
+ // add another value that checks that we handle null lang properly
+ PortletDescription pd2 = createPortletDescription("99", null);
+ pd.getMarkupTypes().get(0).getLocales().set(0, "en_US");
+ locString = pd.getShortTitle();
+ locString.setLang(null);
+
+ offeredPortlets.add(pd);
+ offeredPortlets.add(pd2);
+ }
+}
\ No newline at end of file
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/behaviors/interop/LiferayServiceDescriptionBehavior.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/BehaviorBackedServiceFactory.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/BehaviorBackedServiceFactory.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/BehaviorBackedServiceFactory.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,211 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.NotYetImplemented;
+import org.gatein.pc.api.Mode;
+import org.gatein.pc.api.WindowState;
+import org.gatein.wsrp.services.ServiceFactory;
+import org.gatein.wsrp.test.BehaviorRegistry;
+import org.gatein.wsrp.test.protocol.v1.MarkupBehavior;
+import org.oasis.wsrp.v1.AccessDenied;
+import org.oasis.wsrp.v1.GetMarkup;
+import org.oasis.wsrp.v1.InconsistentParameters;
+import org.oasis.wsrp.v1.InvalidCookie;
+import org.oasis.wsrp.v1.InvalidHandle;
+import org.oasis.wsrp.v1.InvalidRegistration;
+import org.oasis.wsrp.v1.InvalidSession;
+import org.oasis.wsrp.v1.InvalidUserCategory;
+import org.oasis.wsrp.v1.MissingParameters;
+import org.oasis.wsrp.v1.OperationFailed;
+import org.oasis.wsrp.v1.UnsupportedLocale;
+import org.oasis.wsrp.v1.UnsupportedMimeType;
+import org.oasis.wsrp.v1.UnsupportedMode;
+import org.oasis.wsrp.v1.UnsupportedWindowState;
+import org.oasis.wsrp.v1.WSRPV1MarkupPortType;
+import org.oasis.wsrp.v1.WSRPV1PortletManagementPortType;
+import org.oasis.wsrp.v1.WSRPV1RegistrationPortType;
+import org.oasis.wsrp.v1.WSRPV1ServiceDescriptionPortType;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 11461 $
+ * @since 2.6
+ */
+public class BehaviorBackedServiceFactory implements ServiceFactory
+{
+ private BehaviorRegistry registry;
+ private final static String MARKUP = "markup";
+ private final static String SD_URL = "sd";
+ private final static String M_URL = "m";
+ private final static String PM_URL = "pm";
+ private final static String R_URL = "r";
+ private boolean initialized = false;
+
+
+ public BehaviorBackedServiceFactory()
+ {
+ registry = new BehaviorRegistry();
+ registry.registerMarkupBehavior(new SimpleMarkupBehavior());
+ }
+
+ public <T> T getService(Class<T> serviceClass) throws Exception
+ {
+ if (WSRPV1ServiceDescriptionPortType.class.isAssignableFrom(serviceClass))
+ {
+ return (T)registry.getServiceDescriptionBehavior();
+ }
+ if (WSRPV1MarkupPortType.class.isAssignableFrom(serviceClass))
+ {
+ return (T)registry.getMarkupBehaviorFor(MARKUP);
+ }
+ if (WSRPV1PortletManagementPortType.class.isAssignableFrom(serviceClass))
+ {
+ return (T)registry.getPortletManagementBehavior();
+ }
+ if (WSRPV1RegistrationPortType.class.isAssignableFrom(serviceClass))
+ {
+ return (T)registry.getRegistrationBehavior();
+ }
+ return null;
+ }
+
+ public BehaviorRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry(BehaviorRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public boolean isAvailable()
+ {
+ if (!initialized)
+ {
+ initialized = true;
+ return false;
+ }
+ return true;
+ }
+
+ public boolean isFailed()
+ {
+ return false;
+ }
+
+ public void setFailed(boolean failed)
+ {
+ // do nothing
+ }
+
+ public String getServiceDescriptionURL()
+ {
+ return SD_URL;
+ }
+
+ public String getMarkupURL()
+ {
+ return M_URL;
+ }
+
+ public String getRegistrationURL()
+ {
+ return R_URL;
+ }
+
+ public String getPortletManagementURL()
+ {
+ return PM_URL;
+ }
+
+ public void setServiceDescriptionURL(String serviceDescriptionURL)
+ {
+ // do nothing
+ }
+
+ public void setMarkupURL(String markupURL)
+ {
+ // do nothing
+ }
+
+ public void setRegistrationURL(String registrationURL)
+ {
+ // do nothing
+ }
+
+ public void setPortletManagementURL(String portletManagementURL)
+ {
+ // do nothing
+ }
+
+ public void create() throws Exception
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void start() throws Exception
+ {
+ // do nothing
+ }
+
+ public void stop()
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void setWsdlDefinitionURL(String wsdlDefinitionURL) throws Exception
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getWsdlDefinitionURL()
+ {
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public void destroy()
+ {
+ throw new NotYetImplemented();
+ }
+
+ private class SimpleMarkupBehavior extends MarkupBehavior
+ {
+ public SimpleMarkupBehavior()
+ {
+ super(BehaviorBackedServiceFactory.this.registry);
+ registerHandle(MARKUP);
+ }
+
+ @Override
+ protected String getMarkupString(Mode mode, WindowState windowState, String
navigationalState, GetMarkup getMarkup)
+ throws UnsupportedWindowState, InvalidCookie, InvalidSession, AccessDenied,
InconsistentParameters,
+ InvalidHandle, UnsupportedLocale, UnsupportedMode, OperationFailed,
MissingParameters, InvalidUserCategory,
+ InvalidRegistration, UnsupportedMimeType
+ {
+ return MARKUP;
+ }
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/BehaviorBackedServiceFactory.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockConsumerRegistry.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockConsumerRegistry.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockConsumerRegistry.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,148 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, 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.ParameterValidation;
+import org.gatein.pc.federation.FederatingPortletInvoker;
+import org.gatein.wsrp.WSRPConsumer;
+import org.gatein.wsrp.api.SessionEventBroadcaster;
+import org.gatein.wsrp.consumer.ConsumerException;
+import org.gatein.wsrp.consumer.EndpointConfigurationInfo;
+import org.gatein.wsrp.consumer.ProducerInfo;
+import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 12693 $
+ * @since 2.6
+ */
+public class MockConsumerRegistry implements ConsumerRegistry
+{
+ private Map consumers = new HashMap(3);
+ public static final String MOCK_SERVICE_DESCRIPTION =
"mock-service-description";
+ public static final String MOCK_MARKUP = "mock-markup";
+ public static final String CONSUMER1 = "inDB";
+ public static final String CONSUMER2 = "inDB2";
+
+ /**
+ * Creates a ConsumerRegistry containing 2 consumers with id '{@link
#CONSUMER1}' and '{@link #CONSUMER2}'
+ * respectively. CONSUMER2 is active and has a service description URL set to {@link
#MOCK_SERVICE_DESCRIPTION} and a
+ * markup URL set to {@link #MOCK_MARKUP}
+ */
+ public MockConsumerRegistry()
+ {
+ reloadConsumers();
+ }
+
+ public List<WSRPConsumer> getConfiguredConsumers()
+ {
+ return new ArrayList<WSRPConsumer>(consumers.values());
+ }
+
+ public WSRPConsumer getConsumer(String id)
+ {
+ return (WSRPConsumer)consumers.get(id);
+ }
+
+ public FederatingPortletInvoker getFederatingPortletInvoker()
+ {
+ return null;
+ }
+
+ public WSRPConsumer createConsumer(String id, Integer expirationCacheSeconds)
+ {
+ MockWSRPConsumer consumer = new MockWSRPConsumer(id);
+ consumer.getProducerInfo().setExpirationCacheSeconds(expirationCacheSeconds);
+ consumers.put(id, consumer);
+ return consumer;
+ }
+
+ public void persistConsumer(WSRPConsumer consumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer,
"WSRPConsumer");
+ consumers.put(consumer.getProducerId(), consumer);
+ }
+
+ public void activateConsumerWith(String id) throws ConsumerException
+ {
+ // do nothing
+ }
+
+ public void updateProducerInfo(ProducerInfo producerInfo)
+ {
+ // do nothing
+ }
+
+ public void deactivateConsumerWith(String id) throws ConsumerException
+ {
+ // do nothing
+ }
+
+ public void registerOrDeregisterConsumerWith(String id, boolean register)
+ {
+ // do nothing
+ }
+
+ public void destroyConsumer(String id)
+ {
+ // do nothing
+ }
+
+ public void reloadConsumers()
+ {
+ consumers.clear();
+ consumers.put(CONSUMER1, new MockWSRPConsumer(CONSUMER1));
+ MockWSRPConsumer consumer = new MockWSRPConsumer(CONSUMER2);
+ consumer.getProducerInfo().setActive(true);
+ EndpointConfigurationInfo info =
consumer.getProducerInfo().getEndpointConfigurationInfo();
+ info.setServiceDescriptionURL(MOCK_SERVICE_DESCRIPTION);
+ info.setMarkupURL(MOCK_MARKUP);
+ consumers.put(CONSUMER2, consumer);
+ }
+
+ public void start() throws Exception
+ {
+ reloadConsumers();
+ }
+
+ public void stop() throws Exception
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setFederatingPortletInvoker(FederatingPortletInvoker
federatingPortletInvoker)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void setSessionEventBroadcaster(SessionEventBroadcaster
sessionEventBroadcaster)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockConsumerRegistry.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
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
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -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/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletRequest.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
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
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -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/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpServletResponse.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
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
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpSession.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -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/consumer/src/test/java/org/gatein/wsrp/test/support/MockHttpSession.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,178 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.pc.api.Portlet;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.api.PortletStateType;
+import org.gatein.pc.api.invocation.PortletInvocation;
+import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
+import org.gatein.pc.api.state.PropertyChange;
+import org.gatein.pc.api.state.PropertyMap;
+import org.gatein.wsrp.WSRPConsumer;
+import org.gatein.wsrp.api.SessionEvent;
+import org.gatein.wsrp.consumer.ProducerInfo;
+import org.gatein.wsrp.consumer.ProducerSessionInformation;
+import org.gatein.wsrp.consumer.RefreshResult;
+import org.gatein.wsrp.services.ServiceFactory;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 8784 $
+ * @since 2.6
+ */
+public class MockWSRPConsumer implements WSRPConsumer
+{
+ private ProducerInfo producerInfo;
+
+ public MockWSRPConsumer(String id)
+ {
+ producerInfo = new ProducerInfo();
+ producerInfo.setId(id);
+ }
+
+ public String getProducerId()
+ {
+ return producerInfo.getId();
+ }
+
+ public void setServiceFactory(ServiceFactory serviceFactory)
+ {
+ }
+
+ public ProducerSessionInformation getProducerSessionInformationFrom(PortletInvocation
invocation)
+ {
+ return null;
+ }
+
+ public ProducerSessionInformation getProducerSessionInformationFrom(HttpSession
session)
+ {
+ return null;
+ }
+
+ public ProducerInfo getProducerInfo()
+ {
+ return producerInfo;
+ }
+
+ public void setProducerInfo(ProducerInfo producerInfo)
+ {
+ }
+
+ public void refreshProducerInfo() throws PortletInvokerException
+ {
+ }
+
+ public void releaseSessions()
+ {
+ }
+
+ public void activate() throws Exception
+ {
+ }
+
+ public void deactivate() throws Exception
+ {
+ }
+
+ public boolean isActive()
+ {
+ return true;
+ }
+
+ public boolean isRefreshNeeded()
+ {
+ return false;
+ }
+
+ public RefreshResult refresh(boolean forceRefresh)
+ {
+ return null;
+ }
+
+ public Set getPortlets() throws PortletInvokerException
+ {
+ return null;
+ }
+
+ public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
+ {
+ return null;
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws
IllegalArgumentException, PortletInvokerException
+ {
+ return null;
+ }
+
+ public PortletContext createClone(PortletStateType stateType, PortletContext
portletContext) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public List destroyClones(List portletContexts) throws IllegalArgumentException,
PortletInvokerException, UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext, Set keys) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public void create() throws Exception
+ {
+ }
+
+ public void start() throws Exception
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public void destroy()
+ {
+ }
+
+ public void onSessionEvent(SessionEvent event)
+ {
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/TestPortletInvocationContext.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/TestPortletInvocationContext.java
(rev 0)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/TestPortletInvocationContext.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -0,0 +1,132 @@
+/******************************************************************************
+ * 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.net.media.MediaType;
+import org.gatein.common.util.MarkupInfo;
+import org.gatein.common.util.ParameterMap;
+import org.gatein.pc.api.ContainerURL;
+import org.gatein.pc.api.StateString;
+import org.gatein.pc.api.URLFormat;
+import org.gatein.pc.api.spi.PortletInvocationContext;
+import org.gatein.pc.portlet.impl.spi.AbstractPortletInvocationContext;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 11068 $
+ * @since 2.4
+ */
+public class TestPortletInvocationContext extends AbstractPortletInvocationContext
implements PortletInvocationContext
+{
+
+ private HttpServletRequest mockRequest;
+ private HttpServletResponse mockResponse;
+
+ public TestPortletInvocationContext()
+ {
+ super(new MarkupInfo(MediaType.TEXT_HTML, "UTF-8")); // character set
same as WSRPConstants.DEFAULT_CHARACTER_SET
+
+ mockRequest = MockHttpServletRequest.createMockRequest(null);
+ mockResponse = MockHttpServletResponse.createMockResponse();
+ }
+
+ public void setMockRequest(HttpServletRequest mockRequest)
+ {
+ this.mockRequest = mockRequest;
+ }
+
+ public void setMockResponse(HttpServletResponse mockResponse)
+ {
+ this.mockResponse = mockResponse;
+ }
+
+ public HttpServletRequest getClientRequest()
+ {
+ if (mockRequest == null)
+ {
+ throw new IllegalStateException();
+ }
+ return mockRequest;
+ }
+
+ public HttpServletResponse getClientResponse()
+ {
+ if (mockResponse == null)
+ {
+ throw new IllegalStateException();
+ }
+ return mockResponse;
+ }
+
+ public String encodeResourceURL(String url)
+ {
+ return null;
+ }
+
+ public String renderURL(ContainerURL containerURL, URLFormat urlFormat)
+ {
+ return null;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return null;
+ }
+
+ public int getContentLength()
+ {
+ return 0;
+ }
+
+ public BufferedReader getReader() throws IOException
+ {
+ return null;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return null;
+ }
+
+ public String getContentType()
+ {
+ return null;
+ }
+
+ public StateString getInteractionState()
+ {
+ return null;
+ }
+
+ public ParameterMap getForm()
+ {
+ return null;
+ }
+}
Property changes on:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/TestPortletInvocationContext.java
___________________________________________________________________
Name: svn:executable
+ *
Modified:
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/handler/MockSOAPMessageContext.java
===================================================================
---
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/handler/MockSOAPMessageContext.java 2009-11-12
12:04:05 UTC (rev 578)
+++
components/wsrp/trunk/test/src/main/java/org/gatein/wsrp/test/handler/MockSOAPMessageContext.java 2009-11-12
12:42:15 UTC (rev 579)
@@ -23,6 +23,7 @@
package org.gatein.wsrp.test.handler;
+import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
@@ -62,9 +63,15 @@
{
return getMessage();
}
- else if ("getProperty".equals(methodName))
+ else if ("get".equals(methodName))
{
- return "http://jboss.com"; // should only be called to get the
endpoint address
+ // should only be called to get the endpoint address
+ if (BindingProvider.ENDPOINT_ADDRESS_PROPERTY.equals(args[0]))
+ {
+ return "http://jboss.com";
+ }
+ throw new IllegalArgumentException("MockSOAPMessageContext.get method
should only be called to retrieve "
+ + BindingProvider.ENDPOINT_ADDRESS_PROPERTY + " value. Requested: "
+ args[0]);
}
else if ("toString".equals(methodName))
{