Author: chris.laprun(a)jboss.com
Date: 2007-05-11 00:05:30 -0400 (Fri, 11 May 2007)
New Revision: 7243
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java
Removed:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java
Modified:
trunk/wsrp/build.xml
Log:
- Moved *InfoTestCase to a new consumer package.
- Renamed consumer and producer targets to protocolv1-* to distinguish between class tests
and protocol tests.
- Added *consumer* targets.
- Added missing portal-faces-lib.jar (might not be needed if core-admin is deployed).
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2007-05-11 00:46:42 UTC (rev 7242)
+++ trunk/wsrp/build.xml 2007-05-11 04:05:30 UTC (rev 7243)
@@ -235,9 +235,9 @@
<mkdir dir="${build.resources}"/>
<copy todir="${build.resources}">
<filterset>
- <filtersfile file="../build/etc/single.properties"/>
+ <filtersfile file="../build/etc/single.properties"/>
<filter token="portal.datasource.name"
value="${portal.datasource.name}"/>
- </filterset>
+ </filterset>
<fileset dir="${source.resources}"
includes="**/domain.hbm.xml"/>
<fileset dir="${source.resources}"
includes="**/hibernate.cfg.xml"/>
<fileset dir="${source.resources}"
includes="**/jboss-service.xml"/>
@@ -289,6 +289,7 @@
</jar>
<copy todir="${build.resources}/portal-wsrp-war/lib">
<!-- For JSF -->
+ <fileset dir="${jboss.portal-faces.root}/lib"
includes="portal-faces-lib.jar"/>
<fileset dir="../core-admin/src/etc/sun-jsf"
includes="jsf-example.jar"/>
<fileset dir="${facelets.facelets.lib}"
includes="jsf-facelets.jar"/>
<fileset dir="${el.el.lib}"
includes="el-api.jar,el-ri.jar"/>
@@ -373,7 +374,7 @@
</target>
<target name="deploy-producer-test" description="Deploy services
needed to test the WSRP Producer."
- depends="package-producer-test">
+ depends="package-protocolv1-producer-test">
<require file="${jboss.deploy.dir}"/>
<deploy file="${build.lib.test}/test-wsrp-producer.sar"
config="default"/>
</target>
@@ -385,7 +386,7 @@
</target>
<target name="deploy-consumer-test" description="Deploy services
needed to test the WSRP Consumer."
- depends="package-consumer-test">
+ depends="package-protocolv1-consumer-test">
<require file="${jboss.deploy.dir}"/>
<deploy file="${build.lib.test}/test-wsrp-consumer.sar"
config="default"/>
</target>
@@ -421,7 +422,7 @@
</jar>
</target>
- <target name="package-other-test" description="Generates the test
artifacts" depends="compile">
+ <target name="package-other-test" description="Generates the other
test artifacts" depends="compile">
<jar jarfile="${build.lib.test}/test-other-lib.jar">
<fileset dir="${build.classes}/">
<include name="org/jboss/portal/test/wsrp/framework/**"/>
@@ -429,9 +430,18 @@
<include
name="org/jboss/portal/test/wsrp/handler/*.class"/>
</fileset>
</jar>
- </target>
+ </target>
- <target name="package-consumer-test" description="Generates the
consumer test artifacts"
+ <target name="package-consumer-test" description="Generates
Consumer-specific test artifacts" depends="compile">
+ <jar jarfile="${build.lib.test}/test-consumer-lib.jar">
+ <fileset dir="${build.classes}/">
+ <include name="org/jboss/portal/test/wsrp/framework/**"/>
+ <include
name="org/jboss/portal/test/wsrp/consumer/*.class"/>
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="package-protocolv1-consumer-test"
description="Generates the consumer test artifacts"
depends="compile">
<jar jarfile="${build.lib.test}/test-wsrp-consumer-client.jar">
<fileset
dir="${build.resources.test}/test-wsrp-consumer-client"/>
@@ -498,7 +508,7 @@
</target>
<!-- Producer tests -->
- <target name="package-producer-test" description="Generate the
producer test artifacts"
+ <target name="package-protocolv1-producer-test"
description="Generate the producer test artifacts"
depends="package-test-portlets">
<jar jarfile="${build.lib.test}/test-wsrp-producer-client.jar">
<fileset
dir="${build.resources.test}/test-wsrp-producer-client"/>
@@ -602,8 +612,8 @@
</target>
<!-- Packages all the test related artifacts. Note that compilation should have
been already executed -->
- <target name="package-tests" depends="package-consumer-test,
package-deployment-test, package-other-test,
- package-producer-test, package-producer-configuration-test"
+ <target name="package-tests"
depends="package-protocolv1-consumer-test, package-deployment-test,
package-other-test,
+ package-protocolv1-producer-test, package-producer-configuration-test"
description="Packages all the test-related artifacts. Does NOT compile
classes so this should be done before
calling this task."/>
@@ -621,10 +631,11 @@
<target name="tests-local" depends="clean, output">
<server:start name="default"/>
<antcall target="agent-deploy"/>
- <antcall target="producer-test"/>
- <antcall target="consumer-test"/>
+ <antcall target="protocolv1-producer-test"/>
+ <antcall target="protocolv1-consumer-test"/>
<antcall target="deployment-test"/>
<antcall target="other-test"/>
+ <antcall target="consumer-test"/>
<antcall target="producer-configuration-test"/>
<antcall target="agent-undeploy"/>
<server:stop name="default"/>
@@ -632,15 +643,16 @@
</target>
<target name="tests" depends="clean-test">
- <antcall target="producer-test"/>
- <antcall target="consumer-test"/>
+ <antcall target="protocolv1-producer-test"/>
+ <antcall target="protocolv1-consumer-test"/>
<antcall target="deployment-test"/>
<antcall target="other-test"/>
+ <antcall target="consumer-test"/>
<antcall target="producer-configuration-test"/>
</target>
- <!-- WSRP Producer tests -->
- <target name="producer-test"
depends="deploy-producer-test">
+ <!-- WSRP v1 Protocol Producer tests -->
+ <target name="protocolv1-producer-test"
depends="deploy-producer-test">
<execute-tests>
<x-test>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.v1.producer.ServiceDescriptionTestRunner"/>
@@ -669,8 +681,8 @@
<antcall target="undeploy-producer-test"/>
</target>
- <!--WSRP Consumer implementation tests-->
- <target name="consumer-test"
depends="deploy-consumer-test">
+ <!--WSRP v1 Protocol Consumer implementation tests-->
+ <target name="protocolv1-consumer-test"
depends="deploy-consumer-test">
<execute-tests>
<x-test>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.v1.consumer.ServiceDescriptionTestRunner"/>
@@ -746,19 +758,47 @@
</execute-tests>
</target>
+ <!-- Consumer-specific tests -->
+ <target name="consumer-test"
depends="package-consumer-test">
+ <execute-tests>
+ <x-test>
+ <test todir="${test.reports}"
+
name="org.jboss.portal.test.wsrp.consumer.ProducerSessionInformationTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.consumer.EndpointConfigurationInfoTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.consumer.ProducerInfoTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.consumer.RegistrationInfoTestCase"/>
+ <!--<zest todir="${test.reports}"
name="org.jboss.portal.test.wsrp.consumer.ConsumerRegistryTestCase"
+ outfile="TEST-ConsumerRegistryTestCase">
+ <parameter name="ConfigLocation"
value="org/jboss/portal/test/wsrp/consumer/transient-jboss-beans.xml"/>
+ </zest>-->
+ </x-test>
+ <x-sysproperty>
+ <!--<jvmarg value="-Xdebug"/>
+ <jvmarg value="-Xnoagent"/>
+ <jvmarg value="-Djava.compiler=NONE"/>
+ <jvmarg
value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787"/>-->
+ <sysproperty key="test.root"
value="${build.lib}/tests"/>
+ </x-sysproperty>
+ <x-classpath>
+ <fileset dir="${build.lib}"
includes="portal-wsrp-lib.jar"/>
+ <fileset dir="${build.lib.test}"
includes="test-consumer-lib.jar"/>
+ <path refid="jboss.microcontainer.classpath"/>
+ <path refid="library.classpath"/>
+ <path refid="dependentmodule.classpath"/>
+ <path refid="ws.classpath"/>
+ </x-classpath>
+ </execute-tests>
+ </target>
+
<!-- Other WSRP tests-->
<target name="other-test" depends="package-other-test">
<execute-tests>
<x-test>
- <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.ProducerSessionInformationTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.WSRPPortletURLTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.UserContextConverterTestCase"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.EndpointConfigurationInfoTestCase"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.ProducerInfoTestCase"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.RegistrationInfoTestCase"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.other.RegistrationPropertyDescriptionTestCase"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.handler.RequestHeaderClientHandlerTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.wsrp.handler.RequestHeaderClientHandlerTestCase"/>
</x-test>
<x-sysproperty>
<!--<jvmarg value="-Xdebug"/>
Copied:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java
(from rev 7227,
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java)
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java 2007-05-11
04:05:30 UTC (rev 7243)
@@ -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.jboss.portal.test.wsrp.consumer;
+
+import junit.framework.TestCase;
+import org.jboss.portal.test.wsrp.framework.support.BehaviorBackedServiceFactory;
+import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
+import org.jboss.portal.wsrp.services.PerEndpointSOAPInvokerServiceFactory;
+import org.jboss.portal.wsrp.services.RemoteSOAPInvokerServiceFactory;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @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();
+ }
+
+ public void testSetURLs()
+ {
+ info.setServiceDescriptionURL(url);
+ assertEquals(url, info.getServiceDescriptionURL());
+ try
+ {
+ info.getServiceFactory();
+ fail("Missing markup URL: service factory should not be
initialized");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+
+ info.setMarkupURL(url);
+ assertNotNull(info.getServiceFactory());
+ assertEquals(url, info.getServiceFactory().getServiceDescriptionURL());
+ assertEquals(url, info.getServiceFactory().getMarkupURL());
+ assertTrue(info.getServiceFactory().isAvailable());
+ }
+
+ public void testSetWSDLURL()
+ {
+ 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());
+ assertTrue(info.usesWSDL());
+ }
+
+ public void testSetNullWSDLURL()
+ {
+ info.setServiceDescriptionURL(url);
+ info.setMarkupURL(url);
+
+ // it should be possible to set the WSDL to null for Hibernate
+ info.setWsdlDefinitionURL(null);
+ }
+
+ 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());
+ info.refresh();
+ assertFalse(info.isRefreshNeeded());
+ assertTrue(info.isAvailable());
+
+ info.setServiceDescriptionURL(url);
+ assertTrue(info.isRefreshNeeded());
+
+ info.getRegistrationService();
+ assertTrue(info.isRefreshNeeded());
+
+ info.getServiceDescriptionService();
+ assertFalse(info.isRefreshNeeded());
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/EndpointConfigurationInfoTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
(from rev 7227,
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2007-05-11
04:05:30 UTC (rev 7243)
@@ -0,0 +1,160 @@
+/******************************************************************************
+ * 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.jboss.portal.test.wsrp.consumer;
+
+import junit.framework.TestCase;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.test.wsrp.framework.PortletManagementBehavior;
+import org.jboss.portal.test.wsrp.framework.RegistrationBehavior;
+import org.jboss.portal.test.wsrp.framework.ServiceDescriptionBehavior;
+import org.jboss.portal.test.wsrp.framework.support.BehaviorBackedServiceFactory;
+import org.jboss.portal.test.wsrp.framework.support.MockConsumerRegistry;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
+import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import org.jboss.portal.wsrp.core.AccessDeniedFault;
+import org.jboss.portal.wsrp.core.GetPortletDescription;
+import org.jboss.portal.wsrp.core.InconsistentParametersFault;
+import org.jboss.portal.wsrp.core.InvalidHandleFault;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
+import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
+import org.jboss.portal.wsrp.core.MissingParametersFault;
+import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
+
+import java.rmi.RemoteException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @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();
+ 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(new Integer(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 not 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);
+
+ PortletContext portletContext =
PortletContext.createPortletContext("test");
+ Portlet portlet = info.getPortlet(portletContext);
+ assertNotNull(portlet);
+ assertEquals(portletContext, portlet.getContext());
+
+ // 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());
+ }
+
+ public void testRefreshAndRegistration() throws Exception
+ {
+ assertFalse(info.isRegistered());
+ assertNull(info.getRegistrationInfo());
+
+ 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());
+ }
+
+ private static class TestPortletManagementBehavior extends PortletManagementBehavior
+ {
+ public PortletDescriptionResponse getPortletDescription(GetPortletDescription
getPortletDescription)
+ throws AccessDeniedFault, InvalidHandleFault, InvalidUserCategoryFault,
InconsistentParametersFault,
+ MissingParametersFault, InvalidRegistrationFault, OperationFailedFault,
RemoteException
+ {
+ incrementCallCount();
+ return
WSRPTypeFactory.createPortletDescriptionResponse(createPortletDescription("test2",
null));
+ }
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java
(from rev 7227,
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java)
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java 2007-05-11
04:05:30 UTC (rev 7243)
@@ -0,0 +1,221 @@
+/******************************************************************************
+ * 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.jboss.portal.test.wsrp.consumer;
+
+import junit.framework.TestCase;
+import org.apache.commons.httpclient.Cookie;
+import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
+
+/**
+ * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.jboss.portal.test.wsrp.consumer.ProducerSessionInformationTestCase">Chris
+ * Laprun</a>
+ * @version $Revision$
+ * @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:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerSessionInformationTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java
(from rev 7227,
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java)
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java 2007-05-11
04:05:30 UTC (rev 7243)
@@ -0,0 +1,285 @@
+/******************************************************************************
+ * 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.jboss.portal.test.wsrp.consumer;
+
+import junit.framework.TestCase;
+import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.consumer.RefreshResult;
+import org.jboss.portal.wsrp.consumer.RegistrationInfo;
+import org.jboss.portal.wsrp.consumer.RegistrationProperty;
+import org.jboss.portal.wsrp.core.PropertyDescription;
+import org.jboss.portal.wsrp.core.RegistrationContext;
+import org.jboss.portal.wsrp.core.ServiceDescription;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @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());
+
+ 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 testSetGetRegistrationProperty()
+ {
+ String key = "foo";
+ info.setRegistrationPropertyValue(key, "bar");
+ assertNull(info.isConsistentWithProducerExpectations());
+ Map properties = info.getRegistrationProperties();
+ assertFalse(properties.isEmpty());
+ Set names = info.getRegistrationPropertyNames();
+ assertFalse(names.isEmpty());
+ assertTrue(properties.containsKey(key));
+ assertTrue(names.contains(key));
+ assertNotNull(properties.get(key));
+ assertEquals(properties.get(key), info.getRegistrationProperty(key));
+ assertEquals("bar", info.getRegistrationProperty(key).getValue());
+ }
+
+ public void testRefreshNoRegistration()
+ {
+ // no registration expected
+ ServiceDescription sd = createServiceDescription(false, 0);
+ RefreshResult result = info.refresh(sd, producerId, true, false);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isConsistentWithProducerExpectations().booleanValue());
+ assertFalse(info.isRegistrationRequired().booleanValue());
+ assertTrue(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isRegistrationDeterminedRequired());
+ assertTrue(info.isRegistrationValid().booleanValue());
+
+ result = info.refresh(sd, producerId, false, false);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isConsistentWithProducerExpectations().booleanValue());
+ assertFalse(info.isRegistrationRequired().booleanValue());
+ assertTrue(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isRegistrationDeterminedRequired());
+ assertTrue(info.isRegistrationValid().booleanValue());
+ }
+
+ 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);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isRegistrationRequired().booleanValue());
+ assertTrue(info.isRegistrationDeterminedRequired());
+ assertFalse(info.isRegistrationDeterminedNotRequired());
+ assertFalse(info.isRegistrationValid().booleanValue());
+ }
+
+ public void testRefreshRegistrationDefaultRegistrationExtraLocalInfo()
+ {
+ // set a registration property
+ info.setRegistrationPropertyValue("foo", "bar");
+
+ RegistrationInfo.RegistrationRefreshResult result = info.refresh(
+ createServiceDescription(true, 0), producerId, false, false);
+ assertNotNull(result);
+ assertTrue(result.hasIssues());
+ String status = result.getStatus();
+ assertNotNull(status);
+ assertTrue(status.indexOf("foo") != -1);
+ assertEquals(1, info.getRegistrationProperties().size());
+ assertEquals(1, result.getRegistrationProperties().size());
+
+ Map regProps = result.getRegistrationProperties();
+ assertNotNull(regProps);
+
+ RegistrationProperty prop = (RegistrationProperty)regProps.get("foo");
+ assertNotNull(prop);
+ assertEquals("bar", prop.getValue());
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.INEXISTENT_STATUS, prop.getStatus());
+ }
+
+ public void testRefreshRegistrationRegistrationNoLocalInfo()
+ {
+ // producer requests 2 registration properties
+ ServiceDescription sd = createServiceDescription(true, 2);
+
+ RegistrationInfo.RegistrationRefreshResult result = info.refresh(sd, producerId,
false, false);
+ assertNotNull(result);
+ assertTrue(result.hasIssues());
+ String status = result.getStatus();
+ assertNotNull(status);
+ assertTrue(status.indexOf("prop0") != -1 &&
status.indexOf("prop1") != -1);
+ assertEquals(0, info.getRegistrationProperties().size());
+ assertEquals(2, result.getRegistrationProperties().size());
+
+ Map regProps = result.getRegistrationProperties();
+ assertNotNull(regProps);
+
+ RegistrationProperty prop = (RegistrationProperty)regProps.get("prop0");
+ assertNotNull(prop);
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.MISSING_STATUS, prop.getStatus());
+ }
+
+ public void testRefreshRegistrationRegistrationMergeWithLocalInfo()
+ {
+ info.setRegistrationPropertyValue("foo", "bar");
+
+ RegistrationInfo.RegistrationRefreshResult result =
info.refresh(createServiceDescription(true, 2),
+ producerId, true, false);
+ assertNotNull(result);
+ assertTrue(result.hasIssues());
+
+ RegistrationProperty prop = info.getRegistrationProperty("prop0");
+ assertNotNull(prop);
+ assertNull(prop.getValue());
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, prop.getStatus());
+
+ prop = info.getRegistrationProperty("prop1");
+ assertNotNull(prop);
+ assertNull(prop.getValue());
+ assertTrue(prop.isInvalid());
+ assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, 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);
+ assertNotNull(result);
+ assertFalse(result.hasIssues());
+ assertFalse(info.isRegistrationValid().booleanValue());
+
+ // 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);
+ assertTrue(result.hasIssues());
+ assertFalse(info.isRegistrationValid().booleanValue());
+
+ info.removeRegistrationProperty("foo");
+ result = info.refresh(createServiceDescription(true, 0), producerId, false,
false);
+ assertFalse(result.hasIssues());
+ assertFalse(info.isRegistrationValid().booleanValue());
+
+ // producer has changed but we're not forcing refresh so registration should
still be invalid
+ result = info.refresh(createServiceDescription(false, 0), producerId, false,
false);
+ assertFalse(result.hasIssues());
+ assertFalse(info.isRegistrationValid().booleanValue());
+
+ // force refresh, registration should now be valid
+ result = info.refresh(createServiceDescription(false, 0), producerId, false,
true);
+ assertFalse(result.hasIssues());
+ assertTrue(info.isRegistrationValid().booleanValue());
+ }
+
+ 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().booleanValue());
+ assertTrue(info.isRegistrationValid().booleanValue());
+ assertFalse(info.isRefreshNeeded());
+ assertTrue(info.isRegistrationRequired().booleanValue());
+ assertTrue(info.isRegistrationDeterminedRequired());
+ assertFalse(info.isRegistrationDeterminedNotRequired());
+ }
+
+ private ServiceDescription createServiceDescription(boolean requiresRegistration, int
numberOfProperties)
+ {
+ ServiceDescription sd =
WSRPTypeFactory.createServiceDescription(requiresRegistration);
+
+ if (requiresRegistration)
+ {
+ PropertyDescription[] descriptions = new
PropertyDescription[numberOfProperties];
+ for (int i = 0; i < numberOfProperties; i++)
+ {
+ descriptions[i] = WSRPTypeFactory.createPropertyDescription("prop"
+ i, WSRPConstants.XSD_STRING);
+ }
+
sd.setRegistrationPropertyDescription(WSRPTypeFactory.createModelDescription(descriptions));
+ }
+
+ return sd;
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/RegistrationInfoTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java 2007-05-11
00:46:42 UTC (rev 7242)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java 2007-05-11
04:05:30 UTC (rev 7243)
@@ -1,127 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-
-package org.jboss.portal.test.wsrp.other;
-
-import junit.framework.TestCase;
-import org.jboss.portal.test.wsrp.framework.support.BehaviorBackedServiceFactory;
-import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
-import org.jboss.portal.wsrp.services.PerEndpointSOAPInvokerServiceFactory;
-import org.jboss.portal.wsrp.services.RemoteSOAPInvokerServiceFactory;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @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();
- }
-
- public void testSetURLs()
- {
- info.setServiceDescriptionURL(url);
- assertEquals(url, info.getServiceDescriptionURL());
- try
- {
- info.getServiceFactory();
- fail("Missing markup URL: service factory should not be
initialized");
- }
- catch (IllegalStateException expected)
- {
- }
-
- info.setMarkupURL(url);
- assertNotNull(info.getServiceFactory());
- assertEquals(url, info.getServiceFactory().getServiceDescriptionURL());
- assertEquals(url, info.getServiceFactory().getMarkupURL());
- assertTrue(info.getServiceFactory().isAvailable());
- }
-
- public void testSetWSDLURL()
- {
- 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());
- assertTrue(info.usesWSDL());
- }
-
- public void testSetNullWSDLURL()
- {
- info.setServiceDescriptionURL(url);
- info.setMarkupURL(url);
-
- // it should be possible to set the WSDL to null for Hibernate
- info.setWsdlDefinitionURL(null);
- }
-
- 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());
- info.refresh();
- assertFalse(info.isRefreshNeeded());
- assertTrue(info.isAvailable());
-
- info.setServiceDescriptionURL(url);
- assertTrue(info.isRefreshNeeded());
-
- info.getRegistrationService();
- assertTrue(info.isRefreshNeeded());
-
- info.getServiceDescriptionService();
- assertFalse(info.isRefreshNeeded());
- }
-}
Deleted: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java 2007-05-11
00:46:42 UTC (rev 7242)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java 2007-05-11
04:05:30 UTC (rev 7243)
@@ -1,160 +0,0 @@
-/******************************************************************************
- * 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.jboss.portal.test.wsrp.other;
-
-import junit.framework.TestCase;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.test.wsrp.framework.PortletManagementBehavior;
-import org.jboss.portal.test.wsrp.framework.RegistrationBehavior;
-import org.jboss.portal.test.wsrp.framework.ServiceDescriptionBehavior;
-import org.jboss.portal.test.wsrp.framework.support.BehaviorBackedServiceFactory;
-import org.jboss.portal.test.wsrp.framework.support.MockConsumerRegistry;
-import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
-import org.jboss.portal.wsrp.consumer.ProducerInfo;
-import org.jboss.portal.wsrp.core.AccessDeniedFault;
-import org.jboss.portal.wsrp.core.GetPortletDescription;
-import org.jboss.portal.wsrp.core.InconsistentParametersFault;
-import org.jboss.portal.wsrp.core.InvalidHandleFault;
-import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
-import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
-import org.jboss.portal.wsrp.core.MissingParametersFault;
-import org.jboss.portal.wsrp.core.OperationFailedFault;
-import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
-
-import java.rmi.RemoteException;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @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();
- 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(new Integer(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 not 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);
-
- PortletContext portletContext =
PortletContext.createPortletContext("test");
- Portlet portlet = info.getPortlet(portletContext);
- assertNotNull(portlet);
- assertEquals(portletContext, portlet.getContext());
-
- // 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());
- }
-
- public void testRefreshAndRegistration() throws Exception
- {
- assertFalse(info.isRegistered());
- assertNull(info.getRegistrationInfo());
-
- 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());
- }
-
- private static class TestPortletManagementBehavior extends PortletManagementBehavior
- {
- public PortletDescriptionResponse getPortletDescription(GetPortletDescription
getPortletDescription)
- throws AccessDeniedFault, InvalidHandleFault, InvalidUserCategoryFault,
InconsistentParametersFault,
- MissingParametersFault, InvalidRegistrationFault, OperationFailedFault,
RemoteException
- {
- incrementCallCount();
- return
WSRPTypeFactory.createPortletDescriptionResponse(createPortletDescription("test2",
null));
- }
- }
-}
Deleted:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java 2007-05-11
00:46:42 UTC (rev 7242)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerSessionInformationTestCase.java 2007-05-11
04:05:30 UTC (rev 7243)
@@ -1,221 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.test.wsrp.other;
-
-import junit.framework.TestCase;
-import org.apache.commons.httpclient.Cookie;
-import org.jboss.portal.wsrp.WSRPConstants;
-import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
-
-/**
- * @author <a
href="mailto:chris.laprun@jboss.com?subject=org.jboss.portal.test.wsrp.other.ProducerSessionInformationTestCase">Chris
- * Laprun</a>
- * @version $Revision$
- * @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));
- }
-}
Deleted:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java 2007-05-11
00:46:42 UTC (rev 7242)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationInfoTestCase.java 2007-05-11
04:05:30 UTC (rev 7243)
@@ -1,285 +0,0 @@
-/******************************************************************************
- * 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.jboss.portal.test.wsrp.other;
-
-import junit.framework.TestCase;
-import org.jboss.portal.wsrp.WSRPConstants;
-import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.consumer.RefreshResult;
-import org.jboss.portal.wsrp.consumer.RegistrationInfo;
-import org.jboss.portal.wsrp.consumer.RegistrationProperty;
-import org.jboss.portal.wsrp.core.PropertyDescription;
-import org.jboss.portal.wsrp.core.RegistrationContext;
-import org.jboss.portal.wsrp.core.ServiceDescription;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @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());
-
- 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 testSetGetRegistrationProperty()
- {
- String key = "foo";
- info.setRegistrationPropertyValue(key, "bar");
- assertNull(info.isConsistentWithProducerExpectations());
- Map properties = info.getRegistrationProperties();
- assertFalse(properties.isEmpty());
- Set names = info.getRegistrationPropertyNames();
- assertFalse(names.isEmpty());
- assertTrue(properties.containsKey(key));
- assertTrue(names.contains(key));
- assertNotNull(properties.get(key));
- assertEquals(properties.get(key), info.getRegistrationProperty(key));
- assertEquals("bar", info.getRegistrationProperty(key).getValue());
- }
-
- public void testRefreshNoRegistration()
- {
- // no registration expected
- ServiceDescription sd = createServiceDescription(false, 0);
- RefreshResult result = info.refresh(sd, producerId, true, false);
- assertNotNull(result);
- assertFalse(result.hasIssues());
- assertTrue(info.isConsistentWithProducerExpectations().booleanValue());
- assertFalse(info.isRegistrationRequired().booleanValue());
- assertTrue(info.isRegistrationDeterminedNotRequired());
- assertFalse(info.isRegistrationDeterminedRequired());
- assertTrue(info.isRegistrationValid().booleanValue());
-
- result = info.refresh(sd, producerId, false, false);
- assertNotNull(result);
- assertFalse(result.hasIssues());
- assertTrue(info.isConsistentWithProducerExpectations().booleanValue());
- assertFalse(info.isRegistrationRequired().booleanValue());
- assertTrue(info.isRegistrationDeterminedNotRequired());
- assertFalse(info.isRegistrationDeterminedRequired());
- assertTrue(info.isRegistrationValid().booleanValue());
- }
-
- 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);
- assertNotNull(result);
- assertFalse(result.hasIssues());
- assertTrue(info.isRegistrationRequired().booleanValue());
- assertTrue(info.isRegistrationDeterminedRequired());
- assertFalse(info.isRegistrationDeterminedNotRequired());
- assertFalse(info.isRegistrationValid().booleanValue());
- }
-
- public void testRefreshRegistrationDefaultRegistrationExtraLocalInfo()
- {
- // set a registration property
- info.setRegistrationPropertyValue("foo", "bar");
-
- RegistrationInfo.RegistrationRefreshResult result = info.refresh(
- createServiceDescription(true, 0), producerId, false, false);
- assertNotNull(result);
- assertTrue(result.hasIssues());
- String status = result.getStatus();
- assertNotNull(status);
- assertTrue(status.indexOf("foo") != -1);
- assertEquals(1, info.getRegistrationProperties().size());
- assertEquals(1, result.getRegistrationProperties().size());
-
- Map regProps = result.getRegistrationProperties();
- assertNotNull(regProps);
-
- RegistrationProperty prop = (RegistrationProperty)regProps.get("foo");
- assertNotNull(prop);
- assertEquals("bar", prop.getValue());
- assertTrue(prop.isInvalid());
- assertEquals(RegistrationProperty.INEXISTENT_STATUS, prop.getStatus());
- }
-
- public void testRefreshRegistrationRegistrationNoLocalInfo()
- {
- // producer requests 2 registration properties
- ServiceDescription sd = createServiceDescription(true, 2);
-
- RegistrationInfo.RegistrationRefreshResult result = info.refresh(sd, producerId,
false, false);
- assertNotNull(result);
- assertTrue(result.hasIssues());
- String status = result.getStatus();
- assertNotNull(status);
- assertTrue(status.indexOf("prop0") != -1 &&
status.indexOf("prop1") != -1);
- assertEquals(0, info.getRegistrationProperties().size());
- assertEquals(2, result.getRegistrationProperties().size());
-
- Map regProps = result.getRegistrationProperties();
- assertNotNull(regProps);
-
- RegistrationProperty prop = (RegistrationProperty)regProps.get("prop0");
- assertNotNull(prop);
- assertTrue(prop.isInvalid());
- assertEquals(RegistrationProperty.MISSING_STATUS, prop.getStatus());
- }
-
- public void testRefreshRegistrationRegistrationMergeWithLocalInfo()
- {
- info.setRegistrationPropertyValue("foo", "bar");
-
- RegistrationInfo.RegistrationRefreshResult result =
info.refresh(createServiceDescription(true, 2),
- producerId, true, false);
- assertNotNull(result);
- assertTrue(result.hasIssues());
-
- RegistrationProperty prop = info.getRegistrationProperty("prop0");
- assertNotNull(prop);
- assertNull(prop.getValue());
- assertTrue(prop.isInvalid());
- assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, prop.getStatus());
-
- prop = info.getRegistrationProperty("prop1");
- assertNotNull(prop);
- assertNull(prop.getValue());
- assertTrue(prop.isInvalid());
- assertEquals(RegistrationProperty.MISSING_VALUE_STATUS, 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);
- assertNotNull(result);
- assertFalse(result.hasIssues());
- assertFalse(info.isRegistrationValid().booleanValue());
-
- // 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);
- assertTrue(result.hasIssues());
- assertFalse(info.isRegistrationValid().booleanValue());
-
- info.removeRegistrationProperty("foo");
- result = info.refresh(createServiceDescription(true, 0), producerId, false,
false);
- assertFalse(result.hasIssues());
- assertFalse(info.isRegistrationValid().booleanValue());
-
- // producer has changed but we're not forcing refresh so registration should
still be invalid
- result = info.refresh(createServiceDescription(false, 0), producerId, false,
false);
- assertFalse(result.hasIssues());
- assertFalse(info.isRegistrationValid().booleanValue());
-
- // force refresh, registration should now be valid
- result = info.refresh(createServiceDescription(false, 0), producerId, false,
true);
- assertFalse(result.hasIssues());
- assertTrue(info.isRegistrationValid().booleanValue());
- }
-
- 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().booleanValue());
- assertTrue(info.isRegistrationValid().booleanValue());
- assertFalse(info.isRefreshNeeded());
- assertTrue(info.isRegistrationRequired().booleanValue());
- assertTrue(info.isRegistrationDeterminedRequired());
- assertFalse(info.isRegistrationDeterminedNotRequired());
- }
-
- private ServiceDescription createServiceDescription(boolean requiresRegistration, int
numberOfProperties)
- {
- ServiceDescription sd =
WSRPTypeFactory.createServiceDescription(requiresRegistration);
-
- if (requiresRegistration)
- {
- PropertyDescription[] descriptions = new
PropertyDescription[numberOfProperties];
- for (int i = 0; i < numberOfProperties; i++)
- {
- descriptions[i] = WSRPTypeFactory.createPropertyDescription("prop"
+ i, WSRPConstants.XSD_STRING);
- }
-
sd.setRegistrationPropertyDescription(WSRPTypeFactory.createModelDescription(descriptions));
- }
-
- return sd;
- }
-}