Author: chris.laprun(a)jboss.com
Date: 2007-02-26 15:58:17 -0500 (Mon, 26 Feb 2007)
New Revision: 6412
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
Log:
- Improved state robustness when setters are used. In particular, make sure that Hibernate
can load object properly.
- Added test case.
Added:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java
(rev 0)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java 2007-02-26
20:58:17 UTC (rev 6412)
@@ -0,0 +1,92 @@
+/*
+* 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.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());
+ }
+
+ 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);
+ }
+}
Property changes on:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/EndpointConfigurationInfoTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-02-26
20:55:40 UTC (rev 6411)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-02-26
20:58:17 UTC (rev 6412)
@@ -88,9 +88,7 @@
public boolean usesWSDL()
{
- return serviceFactory instanceof RemoteSOAPInvokerServiceFactory ||
- (wsdlDefinitionURL != null && serviceDescriptionURL == null &&
markupURL == null && portletManagementURL == null
- && registrationURL == null);
+ return serviceFactory instanceof RemoteSOAPInvokerServiceFactory ||
wsdlDefinitionURL != null;
}
public String getWsdlDefinitionURL()
@@ -141,36 +139,53 @@
public void setServiceDescriptionURL(String serviceDescriptionURL)
{
- serviceFactory.setServiceDescriptionURL(serviceDescriptionURL);
+ if (serviceFactory != null)
+ {
+ serviceFactory.setServiceDescriptionURL(serviceDescriptionURL);
+ }
this.serviceDescriptionURL = serviceDescriptionURL;
}
public void setMarkupURL(String markupURL)
{
- serviceFactory.setMarkupURL(markupURL);
+ if (serviceFactory != null)
+ {
+ serviceFactory.setMarkupURL(markupURL);
+ }
this.markupURL = markupURL;
}
public void setRegistrationURL(String registrationURL)
{
- serviceFactory.setRegistrationURL(registrationURL);
+ if (serviceFactory != null)
+ {
+ serviceFactory.setRegistrationURL(registrationURL);
+ }
this.registrationURL = registrationURL;
}
public void setPortletManagementURL(String portletManagementURL)
{
- serviceFactory.setPortletManagementURL(portletManagementURL);
+ if (serviceFactory != null)
+ {
+ serviceFactory.setPortletManagementURL(portletManagementURL);
+ }
this.portletManagementURL = portletManagementURL;
}
public void setWsdlDefinitionURL(String wsdlDefinitionURL)
{
this.wsdlDefinitionURL = wsdlDefinitionURL;
- if (!(serviceFactory instanceof RemoteSOAPInvokerServiceFactory))
+
+ // WSDL url is optional so can be null (and in particular, it is when loaded from
Hibernate most of the time)
+ if (wsdlDefinitionURL != null)
{
- serviceFactory = new RemoteSOAPInvokerServiceFactory();
+ if (!(serviceFactory instanceof RemoteSOAPInvokerServiceFactory))
+ {
+ serviceFactory = new RemoteSOAPInvokerServiceFactory();
+ }
+
((RemoteSOAPInvokerServiceFactory)serviceFactory).setWsdlDefinitionURL(wsdlDefinitionURL);
}
-
((RemoteSOAPInvokerServiceFactory)serviceFactory).setWsdlDefinitionURL(wsdlDefinitionURL);
}
public void initServiceFactoryIfNeeded()
@@ -184,17 +199,24 @@
}
else
{
- serviceFactory = new PerEndpointSOAPInvokerServiceFactory();
- serviceFactory.setServiceDescriptionURL(serviceDescriptionURL);
- serviceFactory.setMarkupURL(markupURL);
- serviceFactory.setPortletManagementURL(portletManagementURL);
- serviceFactory.setRegistrationURL(registrationURL);
+ if (serviceDescriptionURL != null && markupURL != null)
+ {
+ serviceFactory = new PerEndpointSOAPInvokerServiceFactory();
+ serviceFactory.setServiceDescriptionURL(serviceDescriptionURL);
+ serviceFactory.setMarkupURL(markupURL);
+ serviceFactory.setPortletManagementURL(portletManagementURL);
+ serviceFactory.setRegistrationURL(registrationURL);
+ }
+ else
+ {
+ throw new IllegalStateException("Cannot initialize ServiceFactory:
missing either service description or markup URLs!");
+ }
}
}
}
- ServiceFactory getServiceFactory()
+ public ServiceFactory getServiceFactory()
{
initServiceFactoryIfNeeded();
return serviceFactory;