コード例 #1
0
 protected void checkTransactionId(MALMessageHeader msgHeader) {
   LoggingBase.logMessage(
       loggingName
           + " received T["
           + msgHeader.getTransactionId()
           + " : "
           + msgHeader.getInteractionType().getOrdinal()
           + " : "
           + msgHeader.getInteractionStage().getValue()
           + "]");
 }
コード例 #2
0
  private void transmitBrokenMessage(MALMessageHeader srcHdr, IPTestTransitionType transitionType)
      throws Exception {
    boolean isError = false;

    if ((IPTestTransitionType.ACK_ERROR == transitionType)
        || (IPTestTransitionType.UPDATE_ERROR == transitionType)
        || (IPTestTransitionType.RESPONSE_ERROR == transitionType)) {
      isError = true;
    }

    MALMessageHeader brokenHeader =
        new TestMessageHeader(
            srcHdr.getURIFrom(),
            srcHdr.getAuthenticationId(),
            srcHdr.getURITo(),
            srcHdr.getTimestamp(),
            srcHdr.getQoSlevel(),
            srcHdr.getPriority(),
            srcHdr.getDomain(),
            srcHdr.getNetworkZone(),
            srcHdr.getSession(),
            srcHdr.getSessionName(),
            srcHdr.getInteractionType(),
            transitionTypeToInteractionStage(transitionType, srcHdr.getInteractionType()),
            srcHdr.getTransactionId(),
            srcHdr.getServiceArea(),
            srcHdr.getService(),
            srcHdr.getOperation(),
            srcHdr.getAreaVersion(),
            isError);

    MALMessage brokenMessage;
    if (isError) {
      brokenMessage =
          ep.createTestMessage(
              brokenHeader,
              new MALStandardError(MALHelper.INTERNAL_ERROR_NUMBER, null),
              new HashMap());
    } else {
      brokenMessage = ep.createTestMessage(brokenHeader, (Element) null, new HashMap());
    }
    LoggingBase.logMessage("Sending brokenMessage = " + brokenMessage);

    ep.receive(brokenMessage);
  }
コード例 #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;
  }