Esempio n. 1
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;
  }
Esempio n. 2
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);
  }
Esempio n. 3
0
  @Test
  public void testGetMarkupMultiValuedFormParams() throws Exception {
    undeploy(DEFAULT_MARKUP_PORTLET_WAR);
    String multiValuedPortletArchive = "test-multivalued-portlet.war";
    deploy(multiValuedPortletArchive);

    V1NamedString namedString = createNamedString("multi", "value1");
    try {
      V1PerformBlockingInteraction action =
          createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
      List<V1NamedString> formParameters = action.getInteractionParams().getFormParameters();
      formParameters.add(namedString);
      V1BlockingInteractionResponse actionResponse = producer.performBlockingInteraction(action);
      V1GetMarkup markupRequest = createMarkupRequestForCurrentlyDeployedPortlet();
      markupRequest
          .getMarkupParams()
          .setNavigationalState(actionResponse.getUpdateResponse().getNavigationalState());
      V1MarkupResponse response = producer.getMarkup(markupRequest);
      checkMarkupResponse(response, "multi: value1");

      formParameters.clear();
      formParameters.add(namedString);
      formParameters.add(createNamedString("multi", "value2"));
      actionResponse = producer.performBlockingInteraction(action);
      markupRequest = createMarkupRequestForCurrentlyDeployedPortlet();
      markupRequest
          .getMarkupParams()
          .setNavigationalState(actionResponse.getUpdateResponse().getNavigationalState());
      response = producer.getMarkup(markupRequest);
      checkMarkupResponse(response, "multi: value1, value2");

      formParameters.clear();
      // TODO: use the WSRP1TypeFactory to create the named string
      formParameters.add(createNamedString("foo", null));
      actionResponse = producer.performBlockingInteraction(action);
      markupRequest = createMarkupRequestForCurrentlyDeployedPortlet();
      markupRequest
          .getMarkupParams()
          .setNavigationalState(actionResponse.getUpdateResponse().getNavigationalState());
      response = producer.getMarkup(markupRequest);
      checkMarkupResponse(response, "multi: ");
    } catch (Exception e) {
      // Print error to the server logs since arquillian can't handle non serialzable errors
      System.out.println("Failure in TestGetMarkupMultiValuedFromParams");
      e.printStackTrace();
      throw new Exception(e);
    } finally {
      undeploy(multiValuedPortletArchive);
    }
  }
Esempio n. 4
0
  @Test
  public void testImplicitCloning() throws Exception {
    undeploy(DEFAULT_MARKUP_PORTLET_WAR);
    String archiveName = "test-implicitcloning-portlet.war";
    deploy(archiveName);

    try {
      // check the initial value
      V1GetMarkup gm = createMarkupRequestForCurrentlyDeployedPortlet();
      V1MarkupResponse res = producer.getMarkup(gm);
      String markupString = res.getMarkupContext().getMarkupString();
      ExtendedAssert.assertEquals("initial", markupString);

      // modify the preference value
      V1PerformBlockingInteraction pbi =
          createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
      pbi.getInteractionParams()
          .setPortletStateChange(V1StateChange.CLONE_BEFORE_WRITE); // request cloning if needed
      String value = "new value";
      pbi.getInteractionParams().getFormParameters().add(createNamedString("value", value));
      V1BlockingInteractionResponse response = producer.performBlockingInteraction(pbi);
      ExtendedAssert.assertNotNull(response);

      // check that we got a new portlet context
      V1PortletContext pc = response.getUpdateResponse().getPortletContext();
      ExtendedAssert.assertNotNull(pc);

      // get the markup again and check that we still get the initial value with the initial portlet
      // context
      res = producer.getMarkup(gm);
      markupString = res.getMarkupContext().getMarkupString();
      ExtendedAssert.assertEquals("initial", markupString);

      // retrieving the markup with the new portlet context should return the new value
      gm.setPortletContext(pc);
      res = producer.getMarkup(gm);
      markupString = res.getMarkupContext().getMarkupString();
      ExtendedAssert.assertEquals(value, markupString);
    } finally {
      undeploy(archiveName);
    }
  }