Author: chris.laprun(a)jboss.com
Date: 2010-08-30 05:03:42 -0400 (Mon, 30 Aug 2010)
New Revision: 3961
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/exports/ExportManager.java
components/wsrp/trunk/producer/src/main/java/org/gatein/exports/impl/ExportManagerImpl.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/v2/WSRP2Producer.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java
Log:
- Fixed typos and other minor improvements.
- GTNWSRP-43: Removed direct call to PortletContext constructor.
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/exports/ExportManager.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/exports/ExportManager.java 2010-08-30
06:47:52 UTC (rev 3960)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/exports/ExportManager.java 2010-08-30
09:03:42 UTC (rev 3961)
@@ -1,61 +1,60 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2010, 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. *
- ******************************************************************************/
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.gatein.exports;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
import org.gatein.exports.data.ExportContext;
-import org.gatein.exports.data.ExportData;
import org.gatein.exports.data.ExportPortletData;
import org.oasis.wsrp.v2.Lifetime;
import org.oasis.wsrp.v2.OperationFailed;
import org.oasis.wsrp.v2.OperationNotSupported;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
/**
* @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
* @version $Revision$
*/
public interface ExportManager
{
- void setPersistanceManager (ExportPersistenceManager exportPersistenceManager);
-
+ void setPersistenceManager(ExportPersistenceManager exportPersistenceManager);
+
ExportPersistenceManager getPersistenceManager();
-
- boolean supportExportByValue();
-
+
+ boolean supportsExportByValue();
+
ExportContext createExportContext(boolean exportByValueRequired, Lifetime lifetime)
throws UnsupportedEncodingException;
-
+
ExportContext createExportContext(byte[] bytes) throws OperationFailed;
-
+
ExportPortletData createExportPortletData(ExportContext exportContextData, String
portletHandle, byte[] portletState) throws UnsupportedEncodingException;
-
+
ExportPortletData createExportPortletData(ExportContext exportContext, Lifetime
lifetime, byte[] bytes) throws OperationFailed;
-
+
byte[] encodeExportPortletData(ExportContext exportContextData, ExportPortletData
exportPortletData) throws UnsupportedEncodingException, IOException;
-
- byte[] encodeExportContextData (ExportContext exportContextData) throws
UnsupportedEncodingException, IOException;
+ byte[] encodeExportContextData(ExportContext exportContextData) throws
UnsupportedEncodingException, IOException;
+
Lifetime setExportLifetime(ExportContext exportContext, Lifetime lifetime) throws
OperationFailed, OperationNotSupported;
void releaseExport(byte[] bytes) throws IOException;
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/exports/impl/ExportManagerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/exports/impl/ExportManagerImpl.java 2010-08-30
06:47:52 UTC (rev 3960)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/exports/impl/ExportManagerImpl.java 2010-08-30
09:03:42 UTC (rev 3961)
@@ -1,43 +1,41 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2010, 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. *
- ******************************************************************************/
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.gatein.exports.impl;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-import org.gatein.common.NotYetImplemented;
import org.gatein.exports.ExportManager;
import org.gatein.exports.ExportPersistenceManager;
import org.gatein.exports.data.ExportContext;
import org.gatein.exports.data.ExportData;
import org.gatein.exports.data.ExportPortletData;
-import org.gatein.exports.data.PersistedExportData;
import org.gatein.wsrp.WSRPExceptionFactory;
import org.oasis.wsrp.v2.Lifetime;
import org.oasis.wsrp.v2.OperationFailed;
import org.oasis.wsrp.v2.OperationNotSupported;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
/**
* @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
* @version $Revision$
@@ -46,64 +44,64 @@
{
protected ExportPersistenceManager exportPersistenceManager;
-
+
//set to true if we prefer to export by value instead of by reference
protected boolean preferExportByValue = false;
-
+
protected boolean supportExportByValue = true;
-
+
public ExportPersistenceManager getPersistenceManager()
{
return exportPersistenceManager;
}
- public void setPersistanceManager(ExportPersistenceManager exportPersistenceManager)
+ public void setPersistenceManager(ExportPersistenceManager exportPersistenceManager)
{
this.exportPersistenceManager = exportPersistenceManager;
}
-
+
public ExportContext createExportContext(boolean exportByValueRequired, Lifetime
lifetime)
- throws UnsupportedEncodingException
+ throws UnsupportedEncodingException
{
boolean useExportByValue = false;
- if (exportByValueRequired || (exportPersistenceManager == null &&
preferExportByValue))
+ if (exportByValueRequired || (exportPersistenceManager == null &&
preferExportByValue))
{
useExportByValue = true;
}
-
+
return new ExportContext(useExportByValue, lifetime);
}
-
- public boolean supportExportByValue()
+
+ public boolean supportsExportByValue()
{
return supportExportByValue;
}
-
+
public void setPreferExportByValue(boolean preferExportByValue)
{
this.preferExportByValue = preferExportByValue;
}
-
+
public ExportContext createExportContext(byte[] bytes) throws OperationFailed
{
try
{
- String type = ExportData.getType(bytes);
- double version = ExportData.getVersion(bytes);
- if (ExportContext.TYPE.equals(type) && ExportContext.VERSION==version)
- {
- byte[] internalBytes = ExportData.getInternalBytes(bytes);
- return ExportContext.create(internalBytes);
+ String type = ExportData.getType(bytes);
+ double version = ExportData.getVersion(bytes);
+ if (ExportContext.TYPE.equals(type) && ExportContext.VERSION ==
version)
+ {
+ byte[] internalBytes = ExportData.getInternalBytes(bytes);
+ return ExportContext.create(internalBytes);
+ }
+ else if (exportPersistenceManager != null &&
exportPersistenceManager.supports(type, version))
+ {
+ return exportPersistenceManager.getExportContext(type, version,
ExportData.getInternalBytes(bytes));
+ }
+ else
+ {
+ throw WSRPExceptionFactory.createWSException(OperationFailed.class,
"Byte array format not compatible.", null);
+ }
}
- else if (exportPersistenceManager != null &&
exportPersistenceManager.supports(type, version))
- {
- return exportPersistenceManager.getExportContext(type, version,
ExportData.getInternalBytes(bytes));
- }
- else
- {
- throw WSRPExceptionFactory.createWSException(OperationFailed.class, "Byte
array format not compatible.", null);
- }
- }
catch (UnsupportedEncodingException e)
{
throw WSRPExceptionFactory.createWSException(OperationFailed.class, "Could
not decode the byte array.", e);
@@ -115,7 +113,7 @@
}
public ExportPortletData createExportPortletData(ExportContext exportContextData,
String portletHandle,
- byte[] portletState) throws UnsupportedEncodingException
+ byte[] portletState) throws
UnsupportedEncodingException
{
return new ExportPortletData(portletHandle, portletState);
}
@@ -126,7 +124,7 @@
{
String type = ExportData.getType(bytes);
double version = ExportData.getVersion(bytes);
- if (ExportPortletData.TYPE.equals(type) &&
ExportPortletData.VERSION==version)
+ if (ExportPortletData.TYPE.equals(type) && ExportPortletData.VERSION ==
version)
{
byte[] internalBytes = ExportData.getInternalBytes(bytes);
return ExportPortletData.create(internalBytes);
@@ -187,7 +185,7 @@
public void releaseExport(byte[] bytes) throws IOException
{
//TODO: since we can't return any errors, we should at least log messages if
this method is called and it can't be completed for some reason.
- if (bytes != null && bytes.length > 0 &&
exportPersistenceManager!= null)
+ if (bytes != null && bytes.length > 0 &&
exportPersistenceManager != null)
{
String type = ExportData.getType(bytes);
double version = ExportData.getVersion(bytes);
@@ -197,7 +195,7 @@
}
}
}
-
-
+
+
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java 2010-08-30
06:47:52 UTC (rev 3960)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/handlers/PortletManagementHandler.java 2010-08-30
09:03:42 UTC (rev 3961)
@@ -526,7 +526,7 @@
//check that the export manager can handle export by value
- if (exportByValueRequired &&
!producer.getExportManager().supportExportByValue())
+ if (exportByValueRequired &&
!producer.getExportManager().supportsExportByValue())
{
//TODO: instead of passing a string here, we should pass a resource so that its
localized
WSRP2ExceptionFactory.throwWSException(ExportByValueNotSupported.class,
"The consumer is requesting portlets to be exported by value, but this consumer only
supports export by reference.", null);
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/v2/WSRP2Producer.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/v2/WSRP2Producer.java 2010-08-30
06:47:52 UTC (rev 3960)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/v2/WSRP2Producer.java 2010-08-30
09:03:42 UTC (rev 3961)
@@ -39,15 +39,15 @@
{
/**
* Retrieves the ExportManager used by this WSRPProducer.
- *
+ *
* @return The ExportManager used by this WSRPProducer to manage exports
*/
ExportManager getExportManager();
-
+
/**
* Sets the ExportManager used by this WSRPProducer
- *
- * @param The ExportManager to be used by this WSRPProducer
+ *
+ * @param exportManager the ExportManager to be used by this WSRPProducer
*/
void setExportManager(ExportManager exportManager);
}
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java 2010-08-30
06:47:52 UTC (rev 3960)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v2/PortletManagementTestCase.java 2010-08-30
09:03:42 UTC (rev 3961)
@@ -1,33 +1,27 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2010, 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. *
- ******************************************************************************/
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.gatein.wsrp.protocol.v2;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.gatein.exports.ExportManager;
import org.gatein.exports.data.ExportContext;
import org.gatein.exports.data.ExportPortletData;
@@ -79,6 +73,12 @@
import org.oasis.wsrp.v2.StateChange;
import org.oasis.wsrp.v2.UserContext;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
/**
* @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
* @version $Revision$
@@ -103,81 +103,81 @@
jar.addClass(TestMockExportPersistenceManager.class);
return jar;
}
-
+
@Before
public void setUp() throws Exception
{
if (System.getProperty("test.deployables.dir") != null)
{
- super.setUp();
- //hack to get around having to have a httpservletrequest when accessing the
producer services
- //I don't know why its really needed, seems to be a dependency where wsrp
connects with the pc module
-
ServletAccess.setRequestAndResponse(MockHttpServletRequest.createMockRequest(null),
MockHttpServletResponse.createMockResponse());
- producer.getExportManager().setPersistanceManager(null);
- ((ExportManagerImpl)(producer.getExportManager())).setPreferExportByValue(true);
+ super.setUp();
+ //hack to get around having to have a httpservletrequest when accessing the
producer services
+ //I don't know why its really needed, seems to be a dependency where wsrp
connects with the pc module
+
ServletAccess.setRequestAndResponse(MockHttpServletRequest.createMockRequest(null),
MockHttpServletResponse.createMockResponse());
+ producer.getExportManager().setPersistenceManager(null);
+
((ExportManagerImpl)(producer.getExportManager())).setPreferExportByValue(true);
}
}
-
+
@After
public void tearDown() throws Exception
{
- if (System.getProperty("test.deployables.dir") != null)
- {
- super.tearDown();
- }
+ if (System.getProperty("test.deployables.dir") != null)
+ {
+ super.tearDown();
+ }
}
-
+
/*TODO:
- * - tests usercontexts (not sure exactly what needs to be tested for this)
- */
-
+ * - tests usercontexts (not sure exactly what needs to be tested for this)
+ */
+
@Test
public void testExport() throws Exception
- {
+ {
String handle = getDefaultHandle();
List<PortletContext> portletContexts = createPortletContextList(handle);
-
+
ExportPortlets exportPortlets = createSimpleExportPortlets(portletContexts);
ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
-
+
checkValidHandle(response, handle);
}
-
+
@Test
public void testExportNonExistantHandle() throws Exception
{
String nonExistantHandle = "123FakeHandle";
List<PortletContext> portletContexts =
createPortletContextList(nonExistantHandle);
-
+
ExportPortlets exportPortlets = createSimpleExportPortlets(portletContexts);
ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
-
+
checkInvalidHandle(response, nonExistantHandle);
}
-
+
@Test
public void testExportNullHandle() throws Exception
{
String nullHandle = null;
List<PortletContext> portletContexts = createPortletContextList(nullHandle);
-
+
ExportPortlets exportPortlets = createSimpleExportPortlets(portletContexts);
-
+
ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
-
+
checkInvalidHandle(response, nullHandle);
}
-
+
@Test
public void testExportNoRegistrationWhenRequired() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
-
+
String handle = getDefaultHandle();
List<PortletContext> portletContexts = createPortletContextList(handle);
-
+
ExportPortlets exportPortlets = createSimpleExportPortlets(portletContexts);
-
+
try
{
ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
@@ -193,16 +193,16 @@
public void testExportBadRegistrationHandle() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
-
+
RegistrationContext registrationContext =
WSRPTypeFactory.createRegistrationContext("foo123");
-
+
List<PortletContext> portletContexts =
createPortletContextList(getDefaultHandle());
-
+
boolean exportByValueRequired = true;
Lifetime lifetime = null;
UserContext userContext = null;
- ExportPortlets exportPortlets =
WSRPTypeFactory.createExportPortlets(registrationContext, portletContexts, userContext,
lifetime, exportByValueRequired);
-
+ ExportPortlets exportPortlets =
WSRPTypeFactory.createExportPortlets(registrationContext, portletContexts, userContext,
lifetime, exportByValueRequired);
+
try
{
ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
@@ -218,19 +218,19 @@
public void testExportRegistrationRequired() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
-
+
RegistrationData registrationData =
WSRPTypeFactory.createRegistrationData("CONSUMER", true);
RegistrationContext registrationContext = producer.register(registrationData);
-
+
List<PortletContext> portletContexts =
createPortletContextList(getDefaultHandle());
-
+
boolean exportByValueRequired = true;
Lifetime lifetime = null;
UserContext userContext = null;
- ExportPortlets exportPortlets =
WSRPTypeFactory.createExportPortlets(registrationContext, portletContexts, userContext,
lifetime, exportByValueRequired);
-
+ ExportPortlets exportPortlets =
WSRPTypeFactory.createExportPortlets(registrationContext, portletContexts, userContext,
lifetime, exportByValueRequired);
+
ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
-
+
checkValidHandle(response, getDefaultHandle());
}
@@ -248,7 +248,7 @@
//expected
}
}
-
+
@Test
public void testExportNullExportPortlets() throws Exception
{
@@ -262,7 +262,7 @@
//expected
}
}
-
+
@Test
public void testExports() throws Exception
{
@@ -270,31 +270,31 @@
String nonExistantHandle = "123FakeHandle";
String handle = getDefaultHandle();
List<PortletContext> portletContexts = createPortletContextList(nullHandle,
nonExistantHandle, handle);
-
+
ExportPortlets exportPortlets = createSimpleExportPortlets(portletContexts);
-
+
ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
-
+
assertNotNull(response.getExportContext());
assertNull(response.getLifetime());
assertFalse(response.getExportedPortlet().isEmpty());
assertFalse(response.getFailedPortlets().isEmpty());
-
+
assertEquals(1, response.getExportedPortlet().size());
-
+
//Should provide the same error code and so should only produce on set of
FailedPortlets
assertEquals(1, response.getFailedPortlets().size());
-
+
ExportedPortlet exportPortlet = response.getExportedPortlet().get(0);
assertEquals(handle, exportPortlet.getPortletHandle());
-
+
FailedPortlets failedPortlets = response.getFailedPortlets().get(0);
-
assertEquals("InvalidHandle",failedPortlets.getErrorCode().getLocalPart());
+ assertEquals("InvalidHandle",
failedPortlets.getErrorCode().getLocalPart());
assertEquals(2, failedPortlets.getPortletHandles().size());
assertTrue(failedPortlets.getPortletHandles().contains(nullHandle));
assertTrue(failedPortlets.getPortletHandles().contains(nonExistantHandle));
}
-
+
protected void checkInvalidHandle(ExportPortletsResponse response, String handle)
throws Exception
{
assertNotNull(response.getExportContext());
@@ -303,7 +303,7 @@
assertEquals(1, response.getFailedPortlets().size());
FailedPortlets failedPortlet = response.getFailedPortlets().get(0);
assertTrue(failedPortlet.getPortletHandles().contains(handle));
-
assertEquals("InvalidHandle",failedPortlet.getErrorCode().getLocalPart());
+ assertEquals("InvalidHandle",
failedPortlet.getErrorCode().getLocalPart());
}
protected void checkValidHandle(ExportPortletsResponse response, String handle) throws
Exception
@@ -319,26 +319,25 @@
protected List<PortletContext> createPortletContextList(String...
portletHandles)
{
List<PortletContext> portletContexts = new
ArrayList<PortletContext>();
-
+
for (String portletHandle : portletHandles)
{
- PortletContext portletContext = new PortletContext();
- portletContext.setPortletHandle(portletHandle);
+ PortletContext portletContext =
WSRPTypeFactory.createPortletContext(portletHandle);
portletContexts.add(portletContext);
}
return portletContexts;
}
-
- protected ExportPortlets createSimpleExportPortlets (List<PortletContext>
portletContexts)
+
+ protected ExportPortlets createSimpleExportPortlets(List<PortletContext>
portletContexts)
{
boolean exportByValueRequired = true;
Lifetime lifetime = null;
UserContext userContext = null;
RegistrationContext registrationContext = null;
-
+
return WSRPTypeFactory.createExportPortlets(registrationContext, portletContexts,
userContext, lifetime, exportByValueRequired);
}
-
+
@Test
public void testImport() throws Exception
{
@@ -347,19 +346,19 @@
List<String> portletList = new ArrayList<String>();
portletList.add(getDefaultHandle());
byte[] importContext = new ExportContext().encodeAsBytes();
-
+
ImportPortlet importPortlet = createSimpleImportPortlet(importID,
getDefaultHandle());
-
+
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
-
+
ImportPortlets importPortlets = createSimpleImportPortlets(importContext,
importPortletsList);
- ImportPortletsResponse response = producer.importPortlets(importPortlets);
-
- assertEquals(1,response.getImportedPortlets().size());
+ ImportPortletsResponse response = producer.importPortlets(importPortlets);
+
+ assertEquals(1, response.getImportedPortlets().size());
ImportedPortlet portlet = response.getImportedPortlets().get(0);
-
+
assertEquals(importID, portlet.getImportID());
-
+
PortletContext portletContext = portlet.getNewPortletContext();
//check that the new portlet handle is valid and we can access the portlet
@@ -368,22 +367,22 @@
assertNotNull(markupResponse.getMarkupContext());
assertEquals("<p>symbol unset stock value: value unset</p>",
new String(markupResponse.getMarkupContext().getItemString()));
}
-
+
@Test
public void testImportNoRegistrationWhenRequired() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
-
+
String importID = "foo";
List<String> portletList = new ArrayList<String>();
portletList.add(getDefaultHandle());
byte[] importContext = new ExportContext().encodeAsBytes();
-
+
ImportPortlet importPortlet = createSimpleImportPortlet(importID,
getDefaultHandle());
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
ImportPortlets importPortlets = createSimpleImportPortlets(importContext,
importPortletsList);
-
+
try
{
ImportPortletsResponse response = producer.importPortlets(importPortlets);
@@ -394,66 +393,66 @@
//expected
}
}
-
+
@Test
public void testImportRegistrationRequired() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
RegistrationData registrationData =
WSRPTypeFactory.createRegistrationData("CONSUMER", true);
RegistrationContext registrationContext = producer.register(registrationData);
-
+
String importID = "foo";
-
+
Lifetime lifetime = null;
UserContext userContext = null;
-
+
List<String> portletList = new ArrayList<String>();
portletList.add(getDefaultHandle());
ExportContext exportContextData = new ExportContext();
byte[] importContext = exportContextData.encodeAsBytes();
-
+
ImportPortlet importPortlet = createSimpleImportPortlet(importID,
getDefaultHandle());
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
-
+
ImportPortlets importPortlets =
WSRPTypeFactory.createImportPortlets(registrationContext, importContext,
importPortletsList, userContext, lifetime);
- ImportPortletsResponse response = producer.importPortlets(importPortlets);
-
- assertEquals(1,response.getImportedPortlets().size());
+ ImportPortletsResponse response = producer.importPortlets(importPortlets);
+
+ assertEquals(1, response.getImportedPortlets().size());
ImportedPortlet portlet = response.getImportedPortlets().get(0);
-
+
assertEquals(importID, portlet.getImportID());
-
+
PortletContext portletContext = portlet.getNewPortletContext();
-
+
//check that the new portlet handle is valid and we can access the portlet
GetMarkup markup = createMarkupRequest(portletContext.getPortletHandle());
markup.setRegistrationContext(registrationContext);
-
+
MarkupResponse markupResponse = producer.getMarkup(markup);
assertNotNull(markupResponse.getMarkupContext());
assertEquals("<p>symbol unset stock value: value unset</p>",
new String(markupResponse.getMarkupContext().getItemString()));
}
-
+
@Test
public void testImportBadRegistration() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
RegistrationContext registrationContext =
WSRPTypeFactory.createRegistrationContext("FAkeREgistrationHAndle");
-
+
String importID = "foo";
-
+
Lifetime lifetime = null;
UserContext userContext = null;
-
+
List<String> portletList = new ArrayList<String>();
portletList.add(getDefaultHandle());
ExportContext exportContextData = new ExportContext();
byte[] importContext = exportContextData.encodeAsBytes();
-
+
ImportPortlet importPortlet = createSimpleImportPortlet(importID,
getDefaultHandle());
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
-
+
ImportPortlets importPortlets =
WSRPTypeFactory.createImportPortlets(registrationContext, importContext,
importPortletsList, userContext, lifetime);
try
{
@@ -465,19 +464,19 @@
//expected
}
}
-
+
@Test
public void testImportNullImportContext() throws Exception
{
String importId = "importInvalidPortletContext";
-
+
ImportPortlet importPortlet = createSimpleImportPortlet(importId,
getDefaultHandle());
-
+
byte[] importContext = null;
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
-
+
ImportPortlets importPortlets = createSimpleImportPortlets(importContext,
importPortletsList);
-
+
try
{
producer.importPortlets(importPortlets);
@@ -488,19 +487,19 @@
//expected
}
}
-
- @Test
+
+ @Test
public void testImportInvalidImportContext() throws Exception
{
String importId = "importInvalidPortletContext";
-
+
ImportPortlet importPortlet = createSimpleImportPortlet(importId,
getDefaultHandle());
-
- byte[] importContext = new
byte[]{1,2,3,'f','a','k','e'};
+
+ byte[] importContext = new byte[]{1, 2, 3, 'f', 'a', 'k',
'e'};
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
-
+
ImportPortlets importPortlets = createSimpleImportPortlets(importContext,
importPortletsList);
-
+
try
{
producer.importPortlets(importPortlets);
@@ -511,186 +510,186 @@
//expected
}
}
-
+
@Test
public void testImportNullExportData() throws Exception
{
String importId = "nullExportData";
-
+
ImportPortlet importPortlet = new ImportPortlet();
importPortlet.setExportData(null);
importPortlet.setImportID(importId);
-
+
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
-
+
byte[] importContext = new ExportContext().encodeAsBytes();
-
+
ImportPortlets importPortlets = createSimpleImportPortlets(importContext,
importPortletsList);
-
+
ImportPortletsResponse response = producer.importPortlets(importPortlets);
-
+
assertNotNull(response.getImportFailed());
assertEquals(1, response.getImportFailed().size());
-
+
assertEquals(importId, response.getImportFailed().get(0).getImportID().get(0));
assertEquals("OperationFailed",
response.getImportFailed().get(0).getErrorCode().getLocalPart());
}
-
+
@Test
public void testImportInvalidExportData() throws Exception
{
String importId = "invalidExportData";
-
+
ImportPortlet importPortlet = new ImportPortlet();
importPortlet.setExportData("fake_export_data_123".getBytes());
importPortlet.setImportID(importId);
-
+
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
-
+
ExportContext exportContextData = new ExportContext();
byte[] importContext = exportContextData.encodeAsBytes();
-
+
ImportPortlets importPortlets = createSimpleImportPortlets(importContext,
importPortletsList);
-
+
ImportPortletsResponse response = producer.importPortlets(importPortlets);
-
+
assertNotNull(response.getImportFailed());
assertEquals(1, response.getImportFailed().size());
-
+
assertEquals(importId, response.getImportFailed().get(0).getImportID().get(0));
assertEquals("OperationFailed",
response.getImportFailed().get(0).getErrorCode().getLocalPart());
}
-
+
@Test
public void testImportNonExistantPortletData() throws Exception
{
String importId = "invalidExportData";
-
+
ExportManager exportManager = new ExportManagerImpl();
ExportPortletData exportPortletData = exportManager.createExportPortletData(null,
"non_existant_portlet_handle", null);
byte[] exportData = exportPortletData.encodeAsBytes();
-
+
ImportPortlet importPortlet = WSRPTypeFactory.createImportPortlet(importId,
exportData);
-
+
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
-
+
ExportContext exportContextData = new ExportContext();
byte[] importContext = exportContextData.encodeAsBytes();
-
+
ImportPortlets importPortlets = createSimpleImportPortlets(importContext,
importPortletsList);
-
+
ImportPortletsResponse response = producer.importPortlets(importPortlets);
-
+
assertNotNull(response.getImportFailed());
assertEquals(1, response.getImportFailed().size());
-
+
assertEquals(importId, response.getImportFailed().get(0).getImportID().get(0));
assertEquals("InvalidHandle",
response.getImportFailed().get(0).getErrorCode().getLocalPart());
}
-
+
@Test
public void testImports() throws Exception
{
String importID = "foo";
String nullImportID = "null";
String invalidImportID = "invalid";
-
+
ExportManager exportManager = new ExportManagerImpl();
ExportPortletData exportPortletData = exportManager.createExportPortletData(null,
getDefaultHandle(), null);
byte[] exportData = exportPortletData.encodeAsBytes();
-
+
byte[] nullExportData = null;
-
+
ExportPortletData invalidExportPortletData =
exportManager.createExportPortletData(null, "InvalidHandle", null);
byte[] invalidExportData = invalidExportPortletData.encodeAsBytes();
-
+
Lifetime lifetime = null;
UserContext userContext = null;
RegistrationContext registrationContext = null;
-
+
List<String> portletList = new ArrayList<String>();
portletList.add(getDefaultHandle());
ExportContext exportContextData = new ExportContext();
byte[] importContext = exportContextData.encodeAsBytes();
-
+
ImportPortlet nullPortlet = new ImportPortlet();
nullPortlet.setImportID(nullImportID);
nullPortlet.setExportData(nullExportData);
ImportPortlet importPortlet = WSRPTypeFactory.createImportPortlet(importID,
exportData);
ImportPortlet invalidPortlet = WSRPTypeFactory.createImportPortlet(invalidImportID,
invalidExportData);
-
+
List<ImportPortlet> importPortletsList = new
ArrayList<ImportPortlet>();
importPortletsList.add(invalidPortlet);
importPortletsList.add(importPortlet);
importPortletsList.add(nullPortlet);
-
+
ImportPortlets importPortlets =
WSRPTypeFactory.createImportPortlets(registrationContext, importContext,
importPortletsList, userContext, lifetime);
- ImportPortletsResponse response = producer.importPortlets(importPortlets);
-
+ ImportPortletsResponse response = producer.importPortlets(importPortlets);
+
assertEquals(2, response.getImportFailed().size());
-
- assertEquals(1,response.getImportedPortlets().size());
-
+
+ assertEquals(1, response.getImportedPortlets().size());
+
ImportedPortlet portlet = response.getImportedPortlets().get(0);
assertEquals(importID, portlet.getImportID());
-
+
PortletContext portletContext = portlet.getNewPortletContext();
-
+
//check that the new portlet handle is valid and we can access the portlet
GetMarkup markup = createMarkupRequest(portletContext.getPortletHandle());
MarkupResponse markupResponse = producer.getMarkup(markup);
assertNotNull(markupResponse.getMarkupContext());
assertEquals("<p>symbol unset stock value: value unset</p>",
new String(markupResponse.getMarkupContext().getItemString()));
}
-
+
@Test
public void testExportWithState() throws Exception
{
undeploy(TEST_BASIC_PORTLET_WAR);
String sessionPortletArchive = "test-portletstate-portlet.war";
deploy(sessionPortletArchive);
-
+
try
{
String originalHandle = getHandleForCurrentlyDeployedArchive();
-
+
//check the session portlet to make sure its at the inital state
checkStatePortlet(originalHandle, "initial");
-
+
PortletContext portletContext =
performBlockingInteractionOnSessionPortlet(originalHandle, "new value",
StateChange.CLONE_BEFORE_WRITE);
//check that we have a new portlet context
ExtendedAssert.assertFalse(originalHandle.equals(portletContext.getPortletHandle()));
-
+
checkStatePortlet(portletContext.getPortletHandle(), "new value");
-
+
List<PortletContext> portletContexts =
createPortletContextList(portletContext.getPortletHandle());
ExportPortlets exportPortlets = createSimpleExportPortlets(portletContexts);
ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
-
+
ExtendedAssert.assertFalse(response.getExportedPortlet().isEmpty());
-
+
List<PortletContext> portletContextsFromExport =
getPortletContext(response);
-
+
ExtendedAssert.assertNotNull(portletContextsFromExport.isEmpty());
- ExtendedAssert.assertEquals(1,portletContexts.size());
-
+ ExtendedAssert.assertEquals(1, portletContexts.size());
+
PortletContext portletContextFromExport = portletContextsFromExport.get(0);
//we should be getting the handle of the stateless portlet
assertEquals(originalHandle, portletContextFromExport.getPortletHandle());
//assert that we have a portlet state returned
assertNotNull(portletContextFromExport.getPortletState());
-
+
//quick check that the imported portlet has the right state
ImportPortletsResponse importResponse =
createImportPortletsResponse("foo", portletContextFromExport);
checkStatePortlet(importResponse.getImportedPortlets().get(0).getNewPortletContext().getPortletHandle(),
"new value");
-
+
}
finally
{
undeploy(sessionPortletArchive);
}
}
-
+
//Tests the situation in which we have a stateful export from one server and importing
into another
@Test
public void testImportWithState() throws Exception
@@ -712,20 +711,20 @@
ExportPortletData exportPortletData = new
ExportPortletData(getHandleForCurrentlyDeployedArchive(), portletState);
byte[] exportData = exportPortletData.encodeAsBytes();
- ImportPortlet importPortlet = WSRPTypeFactory.createImportPortlet(importID,
exportData);
+ ImportPortlet importPortlet = WSRPTypeFactory.createImportPortlet(importID,
exportData);
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
ImportPortlets importPortlets = createSimpleImportPortlets(importContext,
importPortletsList);
- ImportPortletsResponse response = producer.importPortlets(importPortlets);
+ ImportPortletsResponse response = producer.importPortlets(importPortlets);
ImportedPortlet importedPortlet = response.getImportedPortlets().get(0);
-
+
//since its a stateful, the portlet handles shouldn't be the same
assertNotSame(getHandleForCurrentlyDeployedArchive(),
importedPortlet.getNewPortletContext().getPortletHandle());
//the pc should be storing the state, so it shouldn't appear in the imported
portlet context
assertNull(importedPortlet.getNewPortletContext().getPortletState());
-
+
checkStatePortlet(importedPortlet.getNewPortletContext().getPortletHandle(),
importStringValue);
}
@@ -734,57 +733,57 @@
undeploy(sessionPortletArchive);
}
}
-
+
protected ImportPortletsResponse createImportPortletsResponse(String importID,
PortletContext portletContext) throws Exception
{
byte[] importContext = new ExportContext().encodeAsBytes();
ExportPortletData exportPortletData = new
ExportPortletData(portletContext.getPortletHandle(), portletContext.getPortletState());
byte[] exportData = exportPortletData.encodeAsBytes();
- ImportPortlet importPortlet = WSRPTypeFactory.createImportPortlet(importID,
exportData);
+ ImportPortlet importPortlet = WSRPTypeFactory.createImportPortlet(importID,
exportData);
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
ImportPortlets importPortlets = createSimpleImportPortlets(importContext,
importPortletsList);
return producer.importPortlets(importPortlets);
}
-
+
protected byte[] createSessionByteValue(String portletHandle, String value) throws
Exception
{
- ProducerPortletInvoker ppinvoker = (ProducerPortletInvoker)
producer.getPortletInvoker();
+ ProducerPortletInvoker ppinvoker =
(ProducerPortletInvoker)producer.getPortletInvoker();
Map<String, List<String>> properties = new HashMap<String,
List<String>>();
List<String> values = new ArrayList<String>();
values.add(value);
properties.put("name", values);
-
+
PropertyMap property = new SimplePropertyMap(properties);
PortletState sstate = new PortletState(portletHandle, property);
return ppinvoker.getStateConverter().marshall(PortletStateType.OPAQUE, sstate);
}
-
+
@Test
public void testExportWithoutSession() throws Exception
{
undeploy(TEST_BASIC_PORTLET_WAR);
String sessionPortletArchive = "test-portletstate-portlet.war";
deploy(sessionPortletArchive);
-
+
try
{
String originalHandle = getHandleForCurrentlyDeployedArchive();
-
+
//check the session portlet to make sure its at the inital state
checkStatePortlet(originalHandle, "initial");
-
+
//export the cloned portlet context we get from the performBlockingInteraction
List<PortletContext> portletContexts =
createPortletContextList(originalHandle);
ExportPortlets exportPortlets = createSimpleExportPortlets(portletContexts);
ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
-
+
ExtendedAssert.assertFalse(response.getExportedPortlet().isEmpty());
-
+
List<PortletContext> portletContextsFromExport =
getPortletContext(response);
-
+
ExtendedAssert.assertNotNull(portletContextsFromExport.isEmpty());
- ExtendedAssert.assertEquals(1,portletContexts.size());
-
+ ExtendedAssert.assertEquals(1, portletContexts.size());
+
PortletContext portletContextFromExport = portletContextsFromExport.get(0);
assertEquals(originalHandle, portletContextFromExport.getPortletHandle());
}
@@ -793,32 +792,32 @@
undeploy(sessionPortletArchive);
}
}
-
+
@Test
public void testReleaseExportsThrowsNoErrors() throws Exception
{
//NOTE: this test should never cause any errors
//TODO: once the export by reference is done, we need to write tests that this
works
-
+
//null releaseExport
producer.releaseExport(null);
-
+
//empty releaseExport
ReleaseExport releaseExport = new ReleaseExport();
producer.releaseExport(releaseExport);
-
+
//empty releaseExport with a bad export context
releaseExport = new ReleaseExport();
releaseExport.setExportContext(new byte[]{-12, 12, 25, 21, 53});
producer.releaseExport(releaseExport);
-
+
//bad registration handle
releaseExport = new ReleaseExport();
RegistrationContext registrationContext = new RegistrationContext();
registrationContext.setRegistrationHandle("badRegistrationHandle");
releaseExport.setRegistrationContext(registrationContext);
producer.releaseExport(releaseExport);
-
+
//bad user context
releaseExport = new ReleaseExport();
UserContext userContext = new UserContext();
@@ -826,77 +825,77 @@
releaseExport.setUserContext(userContext);
producer.releaseExport(releaseExport);
}
-
+
@Test
public void testReleaseExportsNoErrorsRequiresRegistraion() throws Exception
{
producer.getConfigurationService().getConfiguration().getRegistrationRequirements().setRegistrationRequired(true);
this.testReleaseExportsThrowsNoErrors();
}
-
+
@Test
public void testExportPortletPM() throws Exception
- {
- exportPortletToPM();
+ {
+ exportPortletToPM();
}
-
- @Test
+
+ @Test
public void testReleaseExportPM() throws Exception
{
- ExportPortletsResponse response = exportPortletToPM();
-
+ ExportPortletsResponse response = exportPortletToPM();
+
ReleaseExport releaseExport = WSRPTypeFactory.createReleaseExport(null,
response.getExportContext(), null);
producer.releaseExport(releaseExport);
-
+
//Test that doing a release export actually removed the stored RefId
TestMockExportPersistenceManager persistenceManager =
(TestMockExportPersistenceManager)producer.getExportManager().getPersistenceManager();
ExtendedAssert.assertEquals(0,
persistenceManager.getExportContexts().keySet().size());
}
-
- @Test
+
+ @Test
public void testImportPortletPM() throws Exception
{
ExportPortletsResponse response = exportPortletToPM();
-
- String importID = "foo";
+
+ String importID = "foo";
ImportPortlet importPortlet = WSRPTypeFactory.createImportPortlet(importID,
response.getExportedPortlet().get(0).getExportData());
-
+
List<ImportPortlet> importPortletsList =
createImportPortletList(importPortlet);
-
+
ImportPortlets importPortlets =
createSimpleImportPortlets(response.getExportContext(), importPortletsList);
ImportPortletsResponse importResponse = producer.importPortlets(importPortlets);
-
+
ExtendedAssert.assertEquals(1, importResponse.getImportedPortlets().size());
ExtendedAssert.assertEquals(importID,
importResponse.getImportedPortlets().get(0).getImportID());
ExtendedAssert.assertNotNull(importResponse.getImportedPortlets().get(0).getNewPortletContext().getPortletHandle());
}
-
+
protected ExportPortletsResponse exportPortletToPM() throws Exception
{
TestMockExportPersistenceManager persistenceManager = new
TestMockExportPersistenceManager();
- producer.getExportManager().setPersistanceManager(persistenceManager);
+ producer.getExportManager().setPersistenceManager(persistenceManager);
((ExportManagerImpl)producer.getExportManager()).setPreferExportByValue(false);
-
+
String handle = getDefaultHandle();
List<PortletContext> portletContexts = createPortletContextList(handle);
-
+
ExportPortlets exportPortlets = createSimpleExportPortlets(portletContexts);
exportPortlets.setExportByValueRequired(false);
-
+
//Test that we don't have anything in the PM before doing an export
ExtendedAssert.assertEquals(0,
persistenceManager.getExportContexts().keySet().size());
-
+
ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
-
+
//Test that we have an entry in the PM after doing an export
ExtendedAssert.assertEquals(1,
persistenceManager.getExportContexts().keySet().size());
-
+
return response;
}
-
+
@Test
public void testSetExportLifetimeNull() throws Exception
- {
+ {
try
{
producer.setExportLifetime(null);
@@ -907,10 +906,10 @@
//expected
}
}
-
+
@Test
public void testSetExportLifetimeInvalidExportContext() throws Exception
- {
+ {
try
{
SetExportLifetime setExportLifetime =
WSRPTypeFactory.createSetExportLifetime(null, new byte[]{-10, 24, 24, 54, 'a',
'f', 'g'}, null, null);
@@ -922,21 +921,21 @@
//expected
}
}
-
+
@Test
public void testSetExport() throws Exception
{
String handle = getDefaultHandle();
List<PortletContext> portletContexts = createPortletContextList(handle);
-
+
ExportPortlets exportPortlets = createSimpleExportPortlets(portletContexts);
ExportPortletsResponse response = producer.exportPortlets(exportPortlets);
-
+
try
{
PersistedExportData exportData = new PersistedExportData("foo",
"bar");
-
- SetExportLifetime setExportLifetime =
WSRPTypeFactory.createSetExportLifetime(null,exportData.encodeAsBytes(), null, null);
+
+ SetExportLifetime setExportLifetime =
WSRPTypeFactory.createSetExportLifetime(null, exportData.encodeAsBytes(), null, null);
producer.setExportLifetime(setExportLifetime);
ExtendedAssert.fail();
}
@@ -945,16 +944,16 @@
//expected
}
}
-
+
protected List<PortletContext> getPortletContext(ExportPortletsResponse
exportPortletsResponse) throws Exception
{
List<PortletContext> portletContexts = new
ArrayList<PortletContext>();
-
+
ExportManager exportManager = new ExportManagerImpl();
ExportContext exportContext =
exportManager.createExportContext(exportPortletsResponse.getExportContext());
-
+
List<ExportedPortlet> exportedPortlets =
exportPortletsResponse.getExportedPortlet();
-
+
for (ExportedPortlet exportPortlet : exportedPortlets)
{
ExportPortletData exportPortletData =
exportManager.createExportPortletData(exportContext, exportPortletsResponse.getLifetime(),
exportPortlet.getExportData());
@@ -962,64 +961,57 @@
byte[] portletState = exportPortletData.getPortletState();
portletContexts.add(WSRPTypeFactory.createPortletContext(portletHandle,
portletState));
}
-
+
return portletContexts;
}
-
+
protected void checkStatePortlet(String handle, String expectedValue) throws
Exception
{
GetMarkup getMarkupOriginalStateless = createMarkupRequest(handle);
MarkupResponse responseOriginalStateless =
producer.getMarkup(getMarkupOriginalStateless);
ExtendedAssert.assertEquals(expectedValue,
responseOriginalStateless.getMarkupContext().getItemString());
}
-
+
protected PortletContext performBlockingInteractionOnSessionPortlet(String handle,
String value, StateChange stateChange) throws Exception
{
//perform a blocking interaction to set a state on the portlet;
PerformBlockingInteraction pbi =
WSRPTypeFactory.createDefaultPerformBlockingInteraction(handle);
pbi.getInteractionParams().setPortletStateChange(stateChange);
-
pbi.getInteractionParams().getFormParameters().add(createNamedString("value",
value));
+ NamedString namedString = WSRPTypeFactory.createNamedString("value",
value);
+ pbi.getInteractionParams().getFormParameters().add(namedString);
BlockingInteractionResponse response = producer.performBlockingInteraction(pbi);
PortletContext portletContext = response.getUpdateResponse().getPortletContext();
-
+
return portletContext;
}
- private NamedString createNamedString(String name, String value)
- {
- NamedString namedString = new NamedString();
- namedString.setName(name);
- namedString.setValue(value);
- return namedString;
- }
-
protected ImportPortlet createSimpleImportPortlet(String importId, String handle)
throws IOException
{
ExportPortletData exportPortletData = new ExportPortletData(handle, null);
byte[] exportData = exportPortletData.encodeAsBytes();
return WSRPTypeFactory.createImportPortlet(importId, exportData);
}
-
+
protected List<ImportPortlet> createImportPortletList(ImportPortlet...
importPortlets)
{
List<ImportPortlet> importPortletList = new
ArrayList<ImportPortlet>();
-
+
for (ImportPortlet importPortlet : importPortlets)
{
importPortletList.add(importPortlet);
}
return importPortletList;
}
-
+
protected ImportPortlets createSimpleImportPortlets(byte[] importContext,
List<ImportPortlet> importPortletsList)
{
Lifetime lifetime = null;
UserContext userContext = null;
RegistrationContext registrationContext = null;
-
+
return WSRPTypeFactory.createImportPortlets(registrationContext, importContext,
importPortletsList, userContext, lifetime);
}
-
+
protected String getMostUsedPortletWARFileName()
{
return TEST_BASIC_PORTLET_WAR;