Beispiel #1
0
  @Test
  public void testPerformBlockingInteractionRedirect() throws Exception {
    V1PerformBlockingInteraction performBlockingInteraction =
        createDefaultPerformBlockingInteraction(getDefaultHandle());
    V1InteractionParams interactionParams = performBlockingInteraction.getInteractionParams();

    // crappy way but this is a test! ;)
    V1NamedString namedString = new V1NamedString();
    namedString.setName("symbol");
    namedString.setValue("HELP");
    interactionParams.getFormParameters().add(namedString);

    V1BlockingInteractionResponse response =
        producer.performBlockingInteraction(performBlockingInteraction);
    ExtendedAssert.assertNotNull(response);

    // this is a redirect...
    String redirectURL = response.getRedirectURL();
    ExtendedAssert.assertNotNull(redirectURL);
    ExtendedAssert.assertEquals(
        "/WEB-INF/jsp/help.jsp", redirectURL); // fix-me: handle URL re-writing

    // no update response
    V1UpdateResponse updateResponse = response.getUpdateResponse();
    ExtendedAssert.assertNull(updateResponse);
  }
Beispiel #2
0
  private String checkPBIAndGetNavigationalState(String symbol) throws Exception {
    V1PerformBlockingInteraction performBlockingInteraction =
        createDefaultPerformBlockingInteraction(getDefaultHandle());
    V1InteractionParams interactionParams = performBlockingInteraction.getInteractionParams();
    interactionParams.getFormParameters().add(createNamedString("symbol", symbol));

    V1BlockingInteractionResponse response =
        producer.performBlockingInteraction(performBlockingInteraction);
    ExtendedAssert.assertNotNull(response);

    // this is not a redirect...
    ExtendedAssert.assertNull(response.getRedirectURL());

    // check update response
    V1UpdateResponse updateResponse = response.getUpdateResponse();
    ExtendedAssert.assertNotNull(updateResponse);
    // request was readOnly so no updated portlet context
    ExtendedAssert.assertNull(updateResponse.getPortletContext());
    // check that no sessionId is getting passed.
    ExtendedAssert.assertNull(updateResponse.getSessionContext());

    String navigationalState = updateResponse.getNavigationalState();
    ExtendedAssert.assertNotNull(navigationalState);
    ExtendedAssert.assertEquals(updateResponse.getNewMode(), WSRPConstants.VIEW_MODE);
    V1MarkupContext markupContext = updateResponse.getMarkupContext();
    ExtendedAssert.assertNull(markupContext); // we don't return markup for now

    return navigationalState;
  }
Beispiel #3
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);
    }
  }