[jboss-svn-commits] JBoss Portal SVN: r5564 - in branches/JBoss_Portal_Branch_2_4: common/src/main/org/jboss/portal/common/util wsrp wsrp/src/main/org/jboss/portal/test/wsrp/deployment wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer wsrp/src/main/org/jboss/portal/wsrp wsrp/src/main/org/jboss/portal/wsrp/deployment wsrp/src/resources/test-deployment-lib-jar

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Nov 2 17:25:46 EST 2006


Author: chris.laprun at jboss.com
Date: 2006-11-02 17:25:39 -0500 (Thu, 02 Nov 2006)
New Revision: 5564

Modified:
   branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/common/util/Version.java
   branches/JBoss_Portal_Branch_2_4/wsrp/build.xml
   branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
   branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
   branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java
   branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
   branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
   branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-deployment-lib-jar/test-wsrp.xml
Log:
- Consumer agent is not hardcoded anymore.
- Updated test case.
- Added creation methods to WSRPTypeFactory.
- Re-activated test cases in build file.
- Minor other improvements.

Modified: branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/common/util/Version.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/common/util/Version.java	2006-11-02 21:35:17 UTC (rev 5563)
+++ branches/JBoss_Portal_Branch_2_4/common/src/main/org/jboss/portal/common/util/Version.java	2006-11-02 22:25:39 UTC (rev 5564)
@@ -106,7 +106,7 @@
       return minor;
    }
 
-   /** Return the pacht. */
+   /** Return the patch. */
    public int getPatch()
    {
       return patch;
@@ -125,11 +125,12 @@
 
    private String buildToString()
    {
-      StringBuffer buffer = new StringBuffer("JBoss Portal ");
-      buffer.append(getMajor()).append('.');
-      buffer.append(getMinor()).append('.');
-      buffer.append(getPatch()).append('-');
-      buffer.append(getQualifier());
+      StringBuffer buffer = new StringBuffer(getName());
+      buffer.append(" ")
+         .append(getMajor()).append('.')
+         .append(getMinor()).append('.')
+         .append(getPatch()).append('-')
+         .append(getQualifier());
       return buffer.toString();
    }
 
@@ -140,6 +141,7 @@
       public static class Prefix
       {
 
+         public static final Prefix SNAPSHOT = new Prefix("SNAPSHOT", false, "Snapshot");
          public static final Prefix ALPHA = new Prefix("ALPHA", true, "Alpha");
          public static final Prefix BETA = new Prefix("BETA", true, "Beta");
          public static final Prefix CR = new Prefix("CR", true, "Candidate for release");

Modified: branches/JBoss_Portal_Branch_2_4/wsrp/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/build.xml	2006-11-02 21:35:17 UTC (rev 5563)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/build.xml	2006-11-02 22:25:39 UTC (rev 5564)
@@ -488,9 +488,9 @@
       <server:start name="default"/>
       <antcall target="agent-deploy"/>
       <antcall target="producer-test"/>
-      <!--<antcall target="consumer-test"/>-->
-      <!--<antcall target="deployment-test"/>-->
-      <!--<antcall target="other-test"/>-->
+      <antcall target="consumer-test"/>
+      <antcall target="deployment-test"/>
+      <antcall target="other-test"/>
       <antcall target="agent-undeploy"/>
       <server:stop name="default"/>
       <antcall target="reports"/>
@@ -507,10 +507,10 @@
    <target name="producer-test" depends="deploy-producer-test">
       <execute-tests>
          <x-test>
-            <!--<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.v1.producer.PortletManagementTestCase"/>-->
+            <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.v1.producer.PortletManagementTestCase"/>
             <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.v1.producer.MarkupTestCase"/>
-            <!--<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.v1.producer.ServiceDescriptionTestCase"/>-->
-            <!--<test name="org.jboss.portal.test.wsrp.v1.producer.RegistrationTestCase"/>-->
+            <test todir="${test.reports}" name="org.jboss.portal.test.wsrp.v1.producer.ServiceDescriptionTestCase"/>
+            <!--<test todir="${test.reports}" name="org.jboss.portal.test.wsrp.v1.producer.RegistrationTestCase"/>-->
          </x-test>
          <x-sysproperty>
 <!--

Modified: branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java	2006-11-02 21:35:17 UTC (rev 5563)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/deployment/DeploymentTestCase.java	2006-11-02 22:25:39 UTC (rev 5564)
@@ -23,6 +23,7 @@
 package org.jboss.portal.test.wsrp.deployment;
 
 import junit.framework.TestCase;
+import org.jboss.portal.wsrp.WSRPConstants;
 import org.jboss.portal.wsrp.WSRPConsumer;
 import org.jboss.portal.wsrp.core.Property;
 import org.jboss.portal.wsrp.core.RegistrationData;
@@ -104,7 +105,7 @@
       RegistrationData registrationData = consumer3.getRegistrationData();
       assertNotNull(registrationData);
       assertEquals("JBoss Portal 2.4 Test", registrationData.getConsumerName());
-      assertEquals("JBoss Portal.2.4", registrationData.getConsumerAgent());
+      assertEquals(WSRPConstants.CONSUMER_AGENT, registrationData.getConsumerAgent());
       Property[] registrationProperties = registrationData.getRegistrationProperties();
       assertNotNull(registrationProperties);
       assertEquals(2, registrationProperties.length);
@@ -120,9 +121,10 @@
       service3 = (WSRPConsumerService)service;
       assertEquals("producer2", service3.getId());
       consumer3 = service3.getConsumer();
-      assertNotNull(consumer3.getRegistrationData());
-      assertEquals("JBoss Portal 2.4 Test", registrationData.getConsumerName());
-      assertEquals("JBoss Portal.2.4", registrationData.getConsumerAgent());
+      registrationData = consumer3.getRegistrationData();
+      assertNotNull(registrationData);
+      assertNotNull(registrationData.getConsumerName());
+      assertEquals(WSRPConstants.CONSUMER_AGENT, registrationData.getConsumerAgent());
    }
 
 }

Modified: branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java	2006-11-02 21:35:17 UTC (rev 5563)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java	2006-11-02 22:25:39 UTC (rev 5564)
@@ -155,8 +155,9 @@
 
    protected RegistrationData createBaseRegData()
    {
-      return new RegistrationData("JBoss", "JBoss Portal 2.4", false, null, null, null, null,
-         new Property[]{new Property("regProp", null, "regValue", null)}, null);
+      RegistrationData regData = WSRPTypeFactory.createDefaultRegistrationData();
+      regData.setRegistrationProperties(new Property[]{new Property("regProp", null, "regValue", null)});
+      return regData;
    }
 
    protected PropertyDescription initRegistrationInfo()

Modified: branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java	2006-11-02 21:35:17 UTC (rev 5563)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java	2006-11-02 22:25:39 UTC (rev 5564)
@@ -23,6 +23,8 @@
 
 package org.jboss.portal.wsrp;
 
+import org.jboss.portal.server.PortalConstants;
+
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Random;
@@ -124,29 +126,16 @@
    /** Default consumer name if none has been provided in the WSRP descriptor (*-wsrp.xml) */
    public static final String DEFAULT_CONSUMER_NAME;
    /** The String identifying the portal consumer agent */
-   public static final String CONSUMER_AGENT = "JBoss Portal.2.4";
+   public static final String CONSUMER_AGENT = PortalConstants.VERSION.getName() + "."
+      + PortalConstants.VERSION.getMajor() + "." + PortalConstants.VERSION.getMinor() + "."
+      + PortalConstants.VERSION.getQualifier();
 
-   // User scopes
-
-   /**
-    * The markup is specific to the userContext for which it was generated. Changes to the data of the UserContext MUST
-    * invalidate the cached markup.
-    */
-   public static final String CACHE_PER_USER = "wsrp:perUser";
-
-   /** The markup is not specific to the UserContext and therefore may be supplied to all users of the Consumer. */
-   public static final String CACHE_FOR_ALL = "wsrp:forAll";
-
-   /** The value of SessionContext.expires if the session will never expire. */
-   public static final int SESSION_NEVER_EXPIRES = -1;
-
    static
    {
       InetAddress localhost = null;
       try
       {
-         localhost = InetAddress.getByAddress(InetAddress.getLocalHost().getAddress());
-
+         localhost = InetAddress.getLocalHost();
       }
       catch (UnknownHostException e)
       {
@@ -159,11 +148,25 @@
       else
       {
          Random random = new Random(System.currentTimeMillis());
-         DEFAULT_CONSUMER_NAME = "JBoss Portal Unconfigured " + random.nextInt();
+         DEFAULT_CONSUMER_NAME = CONSUMER_AGENT + " Unconfigured " + random.nextInt();
       }
    }
 
+   // User scopes
 
+   /**
+    * The markup is specific to the userContext for which it was generated. Changes to the data of the UserContext MUST
+    * invalidate the cached markup.
+    */
+   public static final String CACHE_PER_USER = "wsrp:perUser";
+
+   /** The markup is not specific to the UserContext and therefore may be supplied to all users of the Consumer. */
+   public static final String CACHE_FOR_ALL = "wsrp:forAll";
+
+   /** The value of SessionContext.expires if the session will never expire. */
+   public static final int SESSION_NEVER_EXPIRES = -1;
+
+
    private WSRPConstants()
    {
    }

Modified: branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java	2006-11-02 21:35:17 UTC (rev 5563)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java	2006-11-02 22:25:39 UTC (rev 5564)
@@ -37,6 +37,7 @@
 import org.jboss.portal.wsrp.core.ClientData;
 import org.jboss.portal.wsrp.core.GetMarkup;
 import org.jboss.portal.wsrp.core.GetPortletDescription;
+import org.jboss.portal.wsrp.core.GetPortletProperties;
 import org.jboss.portal.wsrp.core.GetServiceDescription;
 import org.jboss.portal.wsrp.core.InitCookie;
 import org.jboss.portal.wsrp.core.InteractionParams;
@@ -70,7 +71,6 @@
 public class WSRPTypeFactory
 {
    /** ====== WSRP request objects ====== **/
-
    /**
     * registrationContext(RegistrationContext)?, desiredLocales(xsd:string)*
     *
@@ -160,6 +160,19 @@
       return new GetPortletDescription(registrationContext, createPortletContext(portletHandle), null, null);
    }
 
+   /**
+    * registrationContext(RegistrationContext)?, portletContext(PortletContext), userContext(UserContext)?,
+    * desiredLocales(xsd:string)*
+    *
+    * @param registrationContext
+    * @param portletHandle
+    * @return
+    */
+   public static GetPortletProperties createGetPortletProperties(RegistrationContext registrationContext, String portletHandle)
+   {
+      return new GetPortletProperties(registrationContext, createPortletContext(portletHandle), null, null);
+   }
+
    /** ====== WSRP Response objects ====== **/
 
    /**
@@ -455,26 +468,34 @@
     *
     * @param consumerName       A name (preferably unique) that identifies the Consumer [R355] An example of such a name
     *                           would be the Consumer's URL.
-    * @param consumerAgent      Name and version of the Consumer's vendor [R356]. The consumerAgent value MUST start
-    *                           with "productName.majorVersion.minorVersion" where "productName" identifies the product
-    *                           the Consumer installed for its deployment, and majorVersion and minorVersion are
-    *                           vendor-defined indications of the version of its product. This string can then contain
-    *                           any additional characters/words the product or Consumer wish to supply.
     * @param methodGetSupported A flag that tells the Producer whether the Consumer has implemented portlet URLs
     *                           (regardless of whether they are written through Consumer URL rewriting or Producer URL
     *                           writing, see [Section 10.2]) in a manner that supports HTML markup containing forms with
     *                           method="get".
     * @return
     */
-   public static RegistrationData createRegistrationData(String consumerName, String consumerAgent, boolean methodGetSupported)
+   public static RegistrationData createRegistrationData(String consumerName, boolean methodGetSupported)
    {
       ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerName, "consumer name", "RegistrationData");
-      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerAgent, "consumer agent", "RegistrationData");
-      // todo: check consumerAgent format...
-      return new RegistrationData(consumerName, consumerAgent, methodGetSupported, null, null, null, null, null, null);
+      RegistrationData regData = createDefaultRegistrationData();
+      regData.setConsumerName(consumerName);
+      regData.setMethodGetSupported(methodGetSupported);
+      return regData;
    }
 
    /**
+    * Same as createRegistrationData({@link WSRPConstants#DEFAULT_CONSUMER_NAME}, false) using {@link
+    * WSRPConstants#CONSUMER_AGENT} for the consumer agent.
+    *
+    * @return
+    */
+   public static RegistrationData createDefaultRegistrationData()
+   {
+      return new RegistrationData(WSRPConstants.DEFAULT_CONSUMER_NAME, WSRPConstants.CONSUMER_AGENT, false, null, null,
+         null, null, null, null);
+   }
+
+   /**
     * ( stringValue(xsd:string) | any* ), @name(xsd:string), @xml:lang
     *
     * @return
@@ -592,4 +613,15 @@
 
       return new CacheControl(expires, userScope, null, null);
    }
+
+   /**
+    * registrationHandle(xsd:string), registrationState(xsd:base64Binary)?, extensions(Extension)*
+    *
+    * @param registrationHandle
+    * @return
+    */
+   public static RegistrationContext createRegistrationContext(String registrationHandle)
+   {
+      return new RegistrationContext(registrationHandle, null, null);
+   }
 }

Modified: branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java	2006-11-02 21:35:17 UTC (rev 5563)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java	2006-11-02 22:25:39 UTC (rev 5564)
@@ -22,7 +22,6 @@
  ******************************************************************************/
 package org.jboss.portal.wsrp.deployment;
 
-import org.jboss.portal.wsrp.WSRPConstants;
 import org.jboss.portal.wsrp.WSRPTypeFactory;
 import org.jboss.portal.wsrp.consumer.WSRPConsumerImpl;
 import org.jboss.portal.wsrp.core.Property;
@@ -114,8 +113,7 @@
       }
       else if ("registration-data".equals(localName))
       {
-         registrationData = WSRPTypeFactory.createRegistrationData(WSRPConstants.DEFAULT_CONSUMER_NAME,
-            WSRPConstants.CONSUMER_AGENT, false);
+         registrationData = WSRPTypeFactory.createDefaultRegistrationData();
       }
 
       if (serviceFactory != null)

Modified: branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-deployment-lib-jar/test-wsrp.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-deployment-lib-jar/test-wsrp.xml	2006-11-02 21:35:17 UTC (rev 5563)
+++ branches/JBoss_Portal_Branch_2_4/wsrp/src/resources/test-deployment-lib-jar/test-wsrp.xml	2006-11-02 22:25:39 UTC (rev 5564)
@@ -73,9 +73,7 @@
             <registration-url>registration-3</registration-url>
             <portlet-management-url>portlet-management-3</portlet-management-url>
          </endpoint-config>
-         <registration-data>
-            <consumer-name>JBoss Portal 2.4 Test</consumer-name>
-         </registration-data>
+         <registration-data/>
       </wsrp-producer>
    </deployment>
 </deployments>
\ No newline at end of file




More information about the jboss-svn-commits mailing list