Example #1
0
  @Test
  public void testGetMarkupRenderParameters() throws Exception {
    undeploy(DEFAULT_MARKUP_PORTLET_WAR);
    String archiveName = "test-renderparam-portlet.war";
    deploy(archiveName);

    try {
      V1GetMarkup gm = createMarkupRequestForCurrentlyDeployedPortlet();
      V1MarkupResponse res = producer.getMarkup(gm);

      String markupString = res.getMarkupContext().getMarkupString();

      String julienLink = extractLink(markupString, 0);
      WSRPPortletURL julienURL = WSRPPortletURL.create(julienLink);

      ExtendedAssert.assertString1ContainsString2(markupString, "Hello, Anonymous!");
      ExtendedAssert.assertString1ContainsString2(markupString, "Counter: 0");

      ExtendedAssert.assertTrue(julienURL instanceof WSRPRenderURL);
      WSRPRenderURL julienRender = (WSRPRenderURL) julienURL;

      // We're now trying to get a hello for Julien ;)
      gm.getMarkupParams()
          .setNavigationalState(julienRender.getNavigationalState().getStringValue());
      res = producer.getMarkup(gm);
      markupString = res.getMarkupContext().getMarkupString();
      ExtendedAssert.assertString1ContainsString2(markupString, "Hello, Julien!");

      // julien.length() * 2 to bypass second link
      WSRPPortletURL incrementURL =
          WSRPPortletURL.create(extractLink(markupString, julienLink.length() * 2));
      ExtendedAssert.assertTrue(incrementURL instanceof WSRPActionURL);
      WSRPActionURL incrementAction = (WSRPActionURL) incrementURL;

      // let's see now if we can increment the counter
      V1PerformBlockingInteraction performBlockingInteraction =
          createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
      V1InteractionParams interactionParams = performBlockingInteraction.getInteractionParams();
      interactionParams.setInteractionState(incrementAction.getInteractionState().getStringValue());
      producer.performBlockingInteraction(performBlockingInteraction);
      res = producer.getMarkup(gm);
      markupString = res.getMarkupContext().getMarkupString();
      ExtendedAssert.assertString1ContainsString2(markupString, "Counter: 1");
    } finally {
      undeploy(archiveName);
    }
  }
Example #2
0
  private void checkMarkupResponseWithSession(V1MarkupResponse response, int count)
      throws RemoteException, V1InvalidRegistration, V1OperationFailed {
    ExtendedAssert.assertNotNull(response);

    // Markup context
    V1MarkupContext markupContext = response.getMarkupContext();
    ExtendedAssert.assertNotNull(markupContext);
    String markupString = markupContext.getMarkupString();
    ExtendedAssert.assertString1ContainsString2(markupString, "count = " + count);
    // SessionPortlet outputs URLs using toString so *NOT* XML-encoded
    ExtendedAssert.assertString1ContainsString2(
        markupString,
        "<a href='wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=JBPNS_/wsrp_rewrite'>render</a>");

    // checking session
    checkSessionForCurrentlyDeployedPortlet(response);
  }