Ejemplo n.º 1
0
  private boolean addInvokeReturnAssertions(
      ResponseListener monitor, int procedureId, MALMessageHeader expectedFinalHeader)
      throws Exception {
    expectedFinalHeader.setInteractionStage(MALInvokeOperation.INVOKE_ACK_STAGE);

    MALMessageHeader msgHeaderAck;
    MALMessageHeader msgHeaderFinal;

    if ((3 == procedureId) || (6 == procedureId)) {
      expectedFinalHeader.setIsErrorMessage(Boolean.TRUE);
      msgHeaderAck = monitor.invokeAckErrorReceivedMsgHeader;
    } else if (7 == procedureId) {
      expectedFinalHeader.setIsErrorMessage(Boolean.TRUE);
      msgHeaderAck = monitor.invokeAckErrorReceivedMsgHeader;
      expectedFinalHeader.setInteractionStage(MALInvokeOperation.INVOKE_RESPONSE_STAGE);
    } else {
      msgHeaderAck = monitor.invokeAckReceivedMsgHeader;
    }

    AssertionHelper.checkHeader(
        "PatternTest.checkAckHeader", assertions, msgHeaderAck, expectedFinalHeader);

    expectedFinalHeader.setInteractionStage(MALInvokeOperation.INVOKE_RESPONSE_STAGE);

    if ((2 == procedureId) || (5 == procedureId)) {
      expectedFinalHeader.setIsErrorMessage(Boolean.TRUE);
      msgHeaderFinal = monitor.invokeResponseErrorReceivedMsgHeader;
      AssertionHelper.checkHeader(
          "PatternTest.checkFinalHeader", assertions, msgHeaderFinal, expectedFinalHeader);
    } else if ((1 == procedureId) || (4 == procedureId)) {
      msgHeaderFinal = monitor.invokeResponseReceivedMsgHeader;
      AssertionHelper.checkHeader(
          "PatternTest.checkFinalHeader", assertions, msgHeaderFinal, expectedFinalHeader);
    } else {
      // this is so that we return true on return
      msgHeaderFinal = msgHeaderAck;
    }

    LoggingBase.logMessage("PatternTest.testInvoke(" + msgHeaderAck + "," + msgHeaderFinal + ")");

    return (null != msgHeaderFinal);
  }
Ejemplo n.º 2
0
  private boolean addRequestReturnAssertions(
      ResponseListener monitor, int procedureId, MALMessageHeader expectedFinalHeader)
      throws Exception {
    MALMessageHeader msgHeaderFinal = null;

    if ((1 == procedureId) || (3 == procedureId)) {
      msgHeaderFinal = monitor.requestResponseReceivedMsgHeader;
    } else if ((2 == procedureId) || (4 == procedureId)) {
      expectedFinalHeader.setIsErrorMessage(Boolean.TRUE);
      msgHeaderFinal = monitor.requestErrorReceivedMsgHeader;
    }

    expectedFinalHeader.setInteractionStage(MALRequestOperation.REQUEST_RESPONSE_STAGE);
    AssertionHelper.checkHeader(
        "PatternTest.checkFinalHeader", assertions, msgHeaderFinal, expectedFinalHeader);

    LoggingBase.logMessage("PatternTest.testRequest(" + msgHeaderFinal + ")");

    return (null != msgHeaderFinal);
  }
Ejemplo n.º 3
0
  public boolean
      patternInitiationForWithMultiWithEmptyBodyAndQosAndSessionAndTransistionsAndBehaviourIdTest(
          String pattern,
          boolean callMultiVersion,
          boolean callEmptyVersion,
          String qosLevel,
          String sessionType,
          String[] transistions,
          int procedureId)
          throws Exception {
    LoggingBase.logMessage(
        "PatternTest("
            + pattern
            + ", "
            + callMultiVersion
            + ", "
            + qosLevel
            + ", "
            + sessionType
            + ", "
            + procedureId
            + ")");
    resetAssertions();

    QoSLevel qos = ParseHelper.parseQoSLevel(qosLevel);
    SessionType session = ParseHelper.parseSessionType(sessionType);
    Identifier sessionName = PubSubTestCaseHelper.getSessionName(session);

    initConsumer(session, sessionName, qos);
    IPTestStub ipTest = ipTestConsumer.getStub();

    ep = TransportInterceptor.instance().getEndPoint(ipTestConsumer.getConsumer().getURI());

    MALMessageHeader expectedInitialHeader =
        new TestMessageHeader(
            ipTestConsumer.getConsumer().getURI(),
            HeaderTestProcedure.AUTHENTICATION_ID,
            ipTestConsumer.getConsumer().getURI(),
            new Time(System.currentTimeMillis()),
            qos,
            HeaderTestProcedure.PRIORITY,
            HeaderTestProcedure.DOMAIN,
            HeaderTestProcedure.NETWORK_ZONE,
            session,
            sessionName,
            InteractionType.PUBSUB,
            new UOctet(MALPubSubOperation._REGISTER_STAGE),
            null, // transaction id not checked here (see below)
            MALPrototypeHelper.MALPROTOTYPE_AREA_NUMBER,
            IPTestHelper.IPTEST_SERVICE_NUMBER,
            IPTestHelper.MONITOR_OP.getNumber(),
            MALPrototypeHelper.MALPROTOTYPE_AREA.getVersion(),
            Boolean.FALSE);

    MALMessageHeader expectedFinalHeader =
        new TestMessageHeader(
            ipTestConsumer.getConsumer().getURI(),
            TestServiceProvider.IP_TEST_AUTHENTICATION_ID,
            ipTestConsumer.getConsumer().getURI(),
            new Time(System.currentTimeMillis()),
            qos,
            HeaderTestProcedure.PRIORITY,
            HeaderTestProcedure.DOMAIN,
            HeaderTestProcedure.NETWORK_ZONE,
            session,
            sessionName,
            InteractionType.PUBSUB,
            new UOctet(MALPubSubOperation._REGISTER_STAGE),
            null, // transaction id not checked here (see below)
            MALPrototypeHelper.MALPROTOTYPE_AREA_NUMBER,
            IPTestHelper.IPTEST_SERVICE_NUMBER,
            IPTestHelper.MONITOR_OP.getNumber(),
            MALPrototypeHelper.MALPROTOTYPE_AREA.getVersion(),
            Boolean.FALSE);

    IPTestTransitionList transList = new IPTestTransitionList();
    List initialFaultyTransList = new LinkedList();
    List finalFaultyTransList = new LinkedList();

    boolean seenGoodTransition = false;
    int expectedTransitionCount = 0;
    for (String trans : transistions) {
      IPTestTransitionType transition = IPTestTransitionTypeFromString(trans);

      if (trans.startsWith("_")) {
        if (seenGoodTransition) {
          finalFaultyTransList.add(transition);
        } else {
          ++expectedTransitionCount;
          initialFaultyTransList.add(transition);
        }

        // there should be no more transitions after a faulty one
        break;
      } else {
        if (initialFaultyTransList.isEmpty()) {
          seenGoodTransition = true;
          ++expectedTransitionCount;
        }
      }

      transList.add(new IPTestTransition(transition, null));
    }

    IPTestDefinition testDef =
        new IPTestDefinition(
            String.valueOf(procedureId),
            ipTestConsumer.getConsumer().getURI(),
            HeaderTestProcedure.AUTHENTICATION_ID,
            qos,
            HeaderTestProcedure.PRIORITY,
            HeaderTestProcedure.DOMAIN,
            HeaderTestProcedure.NETWORK_ZONE,
            session,
            sessionName,
            transList,
            new Time(System.currentTimeMillis()));

    ResponseListener monitor = new ResponseListener("PatternTest", expectedTransitionCount);

    setupInitialFaultyTransitions(initialFaultyTransList);

    if ("SUBMIT".equalsIgnoreCase(pattern)) {
      expectedInitialHeader.setInteractionType(InteractionType.SUBMIT);
      expectedInitialHeader.setInteractionStage(MALSubmitOperation.SUBMIT_STAGE);
      if (callMultiVersion) {
        expectedInitialHeader.setOperation(IPTestHelper.SUBMITMULTI_OP.getNumber());
      } else {
        expectedInitialHeader.setOperation(IPTestHelper.TESTSUBMIT_OP.getNumber());
      }
      testSubmit(monitor, ipTest, callMultiVersion, testDef);
    } else if ("REQUEST".equalsIgnoreCase(pattern)) {
      expectedInitialHeader.setInteractionType(InteractionType.REQUEST);
      expectedInitialHeader.setInteractionStage(MALRequestOperation.REQUEST_STAGE);
      if (callMultiVersion) {
        expectedInitialHeader.setOperation(IPTestHelper.REQUESTMULTI_OP.getNumber());
      } else {
        if (callEmptyVersion) {
          expectedInitialHeader.setOperation(IPTestHelper.TESTREQUESTEMPTYBODY_OP.getNumber());
        } else {
          expectedInitialHeader.setOperation(IPTestHelper.REQUEST_OP.getNumber());
        }
      }
      testRequest(monitor, ipTest, callMultiVersion, callEmptyVersion, testDef);
    } else if ("INVOKE".equalsIgnoreCase(pattern)) {
      expectedInitialHeader.setInteractionType(InteractionType.INVOKE);
      expectedInitialHeader.setInteractionStage(MALInvokeOperation.INVOKE_STAGE);
      if (callMultiVersion) {
        expectedInitialHeader.setOperation(IPTestHelper.INVOKEMULTI_OP.getNumber());
      } else {
        if (callEmptyVersion) {
          expectedInitialHeader.setOperation(IPTestHelper.TESTINVOKEEMPTYBODY_OP.getNumber());
        } else {
          expectedInitialHeader.setOperation(IPTestHelper.INVOKE_OP.getNumber());
        }
      }
      testInvoke(monitor, ipTest, callMultiVersion, callEmptyVersion, testDef);
    } else if ("PROGRESS".equalsIgnoreCase(pattern)) {
      expectedInitialHeader.setInteractionType(InteractionType.PROGRESS);
      expectedInitialHeader.setInteractionStage(MALProgressOperation.PROGRESS_STAGE);
      if (callMultiVersion) {
        expectedInitialHeader.setOperation(IPTestHelper.PROGRESSMULTI_OP.getNumber());
      } else {
        if (callEmptyVersion) {
          expectedInitialHeader.setOperation(IPTestHelper.TESTPROGRESSEMPTYBODY_OP.getNumber());
        } else {
          expectedInitialHeader.setOperation(IPTestHelper.PROGRESS_OP.getNumber());
        }
      }
      testProgress(monitor, ipTest, callMultiVersion, callEmptyVersion, testDef);
    }

    MALMessageHeader msgHeader = addInitialHeaderAssertions(expectedInitialHeader);

    expectedFinalHeader.setInteractionType(expectedInitialHeader.getInteractionType());
    expectedFinalHeader.setOperation(expectedInitialHeader.getOperation());
    expectedFinalHeader.setURIFrom(msgHeader.getURITo());
    expectedFinalHeader.setTransactionId(msgHeader.getTransactionId());

    sendInitialFaultyTransitions(initialFaultyTransList, expectedFinalHeader);

    boolean retVal = false;

    try {
      LoggingBase.logMessage("PatternTest.waiting for responses");
      retVal = monitor.cond.waitFor(10000);
    } catch (InterruptedException ex) {
      // do nothing, we are expecting this
    }

    LoggingBase.logMessage("PatternTest.waiting(" + retVal + ")");
    if (retVal) {
      sendFinalFaultyTransitions(finalFaultyTransList, expectedFinalHeader);

      if ("SUBMIT".equalsIgnoreCase(pattern)) {
        retVal = addSubmitReturnAssertions(monitor, procedureId, expectedFinalHeader);
      } else if ("REQUEST".equalsIgnoreCase(pattern)) {
        retVal = addRequestReturnAssertions(monitor, procedureId, expectedFinalHeader);
      } else if ("INVOKE".equalsIgnoreCase(pattern)) {
        retVal = addInvokeReturnAssertions(monitor, procedureId, expectedFinalHeader);
      } else if ("PROGRESS".equalsIgnoreCase(pattern)) {
        retVal = addProgressReturnAssertions(monitor, procedureId, expectedFinalHeader);
      }
    }

    LoggingBase.logMessage("PatternTest" + pattern + "(" + retVal + ")");

    correctNumberOfTransistions = monitor.checkCorrectNumberOfReceivedMessages();

    return retVal;
  }
Ejemplo n.º 4
0
  private boolean addProgressReturnAssertions(
      ResponseListener monitor, int procedureId, MALMessageHeader expectedFinalHeader)
      throws Exception {
    expectedFinalHeader.setInteractionStage(MALProgressOperation.PROGRESS_ACK_STAGE);

    MALMessageHeader msgHeaderAck;
    MALMessageHeader msgHeaderUpdate1;
    MALMessageHeader msgHeaderUpdate2;
    MALMessageHeader msgHeaderFinal = null;

    if ((3 == procedureId) || (9 == procedureId)) {
      expectedFinalHeader.setIsErrorMessage(Boolean.TRUE);
      msgHeaderAck = monitor.progressAckErrorReceivedMsgHeader;
    } else if ((10 == procedureId) || (11 == procedureId) || (12 == procedureId)) {
      expectedFinalHeader.setIsErrorMessage(Boolean.TRUE);
      msgHeaderAck = monitor.progressAckErrorReceivedMsgHeader;
      if (12 == procedureId) {
        expectedFinalHeader.setInteractionStage(MALProgressOperation.PROGRESS_RESPONSE_STAGE);
      } else {
        expectedFinalHeader.setInteractionStage(MALProgressOperation.PROGRESS_UPDATE_STAGE);
      }
    } else {
      msgHeaderAck = monitor.progressAckReceivedMsgHeader;
    }

    AssertionHelper.checkHeader(
        "PatternTest.checkAckHeader", assertions, msgHeaderAck, expectedFinalHeader);

    expectedFinalHeader.setInteractionStage(MALProgressOperation.PROGRESS_UPDATE_STAGE);

    if ((4 == procedureId) || (5 == procedureId) || ((13 <= procedureId) && (14 >= procedureId))) {
      msgHeaderUpdate1 = monitor.progressUpdate1ReceivedMsgHeader;
      msgHeaderUpdate2 = monitor.progressUpdate2ReceivedMsgHeader;
      AssertionHelper.checkHeader(
          "PatternTest.checkUpdate1Header", assertions, msgHeaderUpdate1, expectedFinalHeader);
      AssertionHelper.checkHeader(
          "PatternTest.checkUpdate2Header", assertions, msgHeaderUpdate2, expectedFinalHeader);
    } else {
      // this is so that we return true on return
      msgHeaderUpdate1 = msgHeaderAck;
      msgHeaderUpdate2 = msgHeaderAck;
    }

    if ((5 == procedureId) || (13 == procedureId)) {
      expectedFinalHeader.setIsErrorMessage(Boolean.TRUE);
      msgHeaderFinal = monitor.progressUpdateErrorReceivedMsgHeader;
      AssertionHelper.checkHeader(
          "PatternTest.checkFinalHeader", assertions, msgHeaderFinal, expectedFinalHeader);
    }

    expectedFinalHeader.setInteractionStage(MALProgressOperation.PROGRESS_RESPONSE_STAGE);

    if ((2 == procedureId) || (6 == procedureId) || (8 == procedureId) || (14 == procedureId)) {
      expectedFinalHeader.setIsErrorMessage(Boolean.TRUE);
      msgHeaderFinal = monitor.progressResponseErrorReceivedMsgHeader;
      AssertionHelper.checkHeader(
          "PatternTest.checkFinalHeader", assertions, msgHeaderFinal, expectedFinalHeader);
    } else if ((1 == procedureId) || (4 == procedureId) || (7 == procedureId)) {
      msgHeaderFinal = monitor.progressResponseReceivedMsgHeader;
      AssertionHelper.checkHeader(
          "PatternTest.checkFinalHeader", assertions, msgHeaderFinal, expectedFinalHeader);
    } else if ((5 != procedureId) || (12 != procedureId) || (13 != procedureId)) {
      // this is so that we return true on return
      msgHeaderFinal = msgHeaderAck;
    }

    LoggingBase.logMessage(
        "PatternTest.testProgress("
            + msgHeaderAck
            + ","
            + msgHeaderUpdate1
            + ","
            + msgHeaderUpdate2
            + ","
            + msgHeaderFinal
            + ")");

    return (null != msgHeaderFinal);
  }