Beispiel #1
0
  /**
   * Sending BadlyStructuredComponent Component
   *
   * <p>TC-BEGIN + Invoke with BadlyStructuredComponent + Invoke TC-END + Reject (mistypedComponent)
   */
  @Test(groups = {"functional.flow"})
  public void BadlyStructuredComponentTest() throws Exception {

    this.client =
        new ClientComponent(this.tcapStack1, peer1Address, peer2Address) {

          @Override
          public void onTCEnd(TCEndIndication ind) {
            super.onTCEnd(ind);

            assertEquals(ind.getComponents().length, 1);
            Component c = ind.getComponents()[0];
            assertEquals(c.getType(), ComponentType.Reject);
            Reject r = (Reject) c;
            assertNull(r.getInvokeId());
            assertEquals(
                r.getProblem().getGeneralProblemType(),
                GeneralProblemType.BadlyStructuredComponent);
            assertFalse(r.isLocalOriginated());
          }
        };

    this.server =
        new ServerComponent(this.tcapStack2, peer2Address, peer1Address) {

          @Override
          public void onTCBegin(TCBeginIndication ind) {
            super.onTCBegin(ind);

            assertEquals(ind.getComponents().length, 2);
            Component c = ind.getComponents()[0];
            assertEquals(c.getType(), ComponentType.Reject);
            Reject r = (Reject) c;
            assertNull(r.getInvokeId());
            assertEquals(
                r.getProblem().getGeneralProblemType(),
                GeneralProblemType.BadlyStructuredComponent);
            assertTrue(r.isLocalOriginated());

            try {
              this.sendEnd(TerminationType.Basic);
            } catch (Exception e) {
              fail("Exception when sendComponent / send message 1", e);
              e.printStackTrace();
            }
          }
        };

    long stamp = System.currentTimeMillis();
    int cnt = 0;
    List<TestEvent> clientExpectedEvents = new ArrayList<TestEvent>();
    TestEvent te = TestEvent.createSentEvent(EventType.Invoke, null, cnt++, stamp);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Begin, null, cnt++, stamp);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.End, null, cnt++, stamp);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.DialogRelease, null, cnt++, stamp);
    clientExpectedEvents.add(te);

    cnt = 0;
    List<TestEvent> serverExpectedEvents = new ArrayList<TestEvent>();
    te = TestEvent.createReceivedEvent(EventType.Begin, null, cnt++, stamp);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Invoke, null, cnt++, stamp);
    serverExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.End, null, cnt++, stamp);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.DialogRelease, null, cnt++, stamp);
    serverExpectedEvents.add(te);

    client.startClientDialog();

    Component badComp = new BadComponentBadlyStructuredComponent();
    badComp.setInvokeId(1L);
    client.dialog.sendComponent(badComp);

    client.addNewInvoke(2L, 10000L);
    client.sendBegin();

    client.waitFor(WAIT_TIME);

    client.compareEvents(clientExpectedEvents);
    server.compareEvents(serverExpectedEvents);
  }
Beispiel #2
0
  /**
   * Testing diplicateInvokeId case All Invokes are with a little invokeTimeout(removed before an
   * answer from a Server) !!!
   *
   * <p>TC-BEGIN + Invoke (invokeId==1) TC-CONTINUE + ReturnResult (invokeId==1) TC-CONTINUE +
   * Reject(unrecognizedInvokeId) + Invoke (invokeId==1) TC-CONTINUE + Reject (duplicateInvokeId)
   * TC-CONTINUE + Invoke (invokeId==2) TC-CONTINUE + ReturnResultLast (invokeId==1) + ReturnError
   * (invokeId==2) TC-CONTINUE + Invoke (invokeId==1, for this message we will invoke
   * processWithoutAnswer()) + Invoke (invokeId==2) TC-CONTINUE TC-CONTINUE + Invoke (invokeId==1) +
   * Invoke (invokeId==2) * TC-END + Reject (duplicateInvokeId for invokeId==2)
   */
  @Test(groups = {"functional.flow"})
  public void DuplicateInvokeIdTest() throws Exception {

    this.client =
        new ClientComponent(this.tcapStack1, peer1Address, peer2Address) {

          @Override
          public void onTCContinue(TCContinueIndication ind) {
            super.onTCContinue(ind);

            step++;

            try {
              switch (step) {
                case 1:
                  assertEquals(ind.getComponents().length, 1);
                  Component c = ind.getComponents()[0];
                  assertEquals(c.getType(), ComponentType.Reject);
                  Reject r = (Reject) c;
                  assertEquals((long) r.getInvokeId(), 1);
                  assertEquals(
                      r.getProblem().getReturnResultProblemType(),
                      ReturnResultProblemType.UnrecognizedInvokeID);
                  assertTrue(r.isLocalOriginated());

                  this.addNewInvoke(1L, 5L);
                  this.sendContinue();
                  break;

                case 2:
                  assertEquals(ind.getComponents().length, 1);
                  c = ind.getComponents()[0];
                  assertEquals(c.getType(), ComponentType.Reject);
                  r = (Reject) c;
                  assertEquals((long) r.getInvokeId(), 1);
                  assertEquals(
                      r.getProblem().getInvokeProblemType(), InvokeProblemType.DuplicateInvokeID);
                  assertFalse(r.isLocalOriginated());

                  this.addNewInvoke(2L, 5L);
                  this.sendContinue();
                  break;

                case 3:
                  assertEquals(ind.getComponents().length, 2);
                  c = ind.getComponents()[0];
                  assertEquals(c.getType(), ComponentType.Reject);
                  r = (Reject) c;
                  assertEquals((long) r.getInvokeId(), 1);
                  assertEquals(
                      r.getProblem().getReturnResultProblemType(),
                      ReturnResultProblemType.UnrecognizedInvokeID);
                  assertTrue(r.isLocalOriginated());

                  c = ind.getComponents()[1];
                  assertEquals(c.getType(), ComponentType.Reject);
                  r = (Reject) c;
                  assertEquals((long) r.getInvokeId(), 2);
                  assertEquals(
                      r.getProblem().getReturnErrorProblemType(),
                      ReturnErrorProblemType.UnrecognizedInvokeID);
                  assertTrue(r.isLocalOriginated());

                  this.addNewInvoke(1L, 5L);
                  this.addNewInvoke(2L, 5L);
                  this.sendContinue();
                  break;

                case 4:
                  this.addNewInvoke(1L, 10000L);
                  this.addNewInvoke(2L, 10000L);
                  this.sendContinue();
                  break;
              }
            } catch (Exception e) {
              fail("Exception when sendComponent / send message 2", e);
              e.printStackTrace();
            }
          }

          @Override
          public void onTCEnd(TCEndIndication ind) {
            super.onTCEnd(ind);

            try {
              assertEquals(ind.getComponents().length, 1);
              Component c = ind.getComponents()[0];
              assertEquals(c.getType(), ComponentType.Reject);
              Reject r = (Reject) c;
              assertEquals((long) r.getInvokeId(), 2);
              assertEquals(
                  r.getProblem().getInvokeProblemType(), InvokeProblemType.DuplicateInvokeID);
              assertFalse(r.isLocalOriginated());
            } catch (Exception e) {
              fail("Exception when sendComponent / send message 3", e);
              e.printStackTrace();
            }
          }
        };

    this.server =
        new ServerComponent(this.tcapStack2, peer2Address, peer1Address) {

          @Override
          public void onTCBegin(TCBeginIndication ind) {
            super.onTCBegin(ind);

            // waiting for Invoke timeout at a client side
            client.waitFor(MINI_WAIT_TIME);

            try {

              this.addNewReturnResult(1L);
              this.sendContinue();
            } catch (Exception e) {
              fail("Exception when sendComponent / send message 1", e);
              e.printStackTrace();
            }
          }

          @Override
          public void onTCContinue(TCContinueIndication ind) {
            super.onTCContinue(ind);

            // waiting for Invoke timeout at a client side
            client.waitFor(MINI_WAIT_TIME);

            step++;

            try {
              switch (step) {
                case 1:
                  assertEquals(ind.getComponents().length, 2);

                  Component c = ind.getComponents()[0];
                  assertEquals(c.getType(), ComponentType.Reject);
                  Reject r = (Reject) c;
                  assertEquals((long) r.getInvokeId(), 1);
                  assertEquals(
                      r.getProblem().getReturnResultProblemType(),
                      ReturnResultProblemType.UnrecognizedInvokeID);
                  assertFalse(r.isLocalOriginated());

                  c = ind.getComponents()[1];
                  assertEquals(c.getType(), ComponentType.Reject);
                  r = (Reject) c;
                  assertEquals((long) r.getInvokeId(), 1);
                  assertEquals(
                      r.getProblem().getInvokeProblemType(), InvokeProblemType.DuplicateInvokeID);
                  assertTrue(r.isLocalOriginated());

                  this.sendContinue();
                  break;

                case 2:
                  this.addNewReturnResultLast(1L);
                  this.addNewReturnError(2L);
                  this.sendContinue();
                  break;

                case 3:
                  this.dialog.processInvokeWithoutAnswer(1L);

                  this.sendContinue();
                  break;

                case 4:
                  assertEquals(ind.getComponents().length, 2);

                  c = ind.getComponents()[1];
                  assertEquals(c.getType(), ComponentType.Reject);
                  r = (Reject) c;
                  assertEquals((long) r.getInvokeId(), 2);
                  assertEquals(
                      r.getProblem().getInvokeProblemType(), InvokeProblemType.DuplicateInvokeID);
                  assertTrue(r.isLocalOriginated());

                  this.sendEnd(TerminationType.Basic);
                  break;
              }
            } catch (Exception e) {
              fail("Exception when sendComponent / send message 2", e);
              e.printStackTrace();
            }
          }
        };

    long stamp = System.currentTimeMillis();
    int cnt = 0;
    List<TestEvent> clientExpectedEvents = new ArrayList<TestEvent>();
    TestEvent te = TestEvent.createSentEvent(EventType.Invoke, null, cnt++, stamp);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Begin, null, cnt++, stamp);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.InvokeTimeout, null, cnt++, stamp);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp + MINI_WAIT_TIME);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Invoke, null, cnt++, stamp + MINI_WAIT_TIME);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME);
    clientExpectedEvents.add(te);
    te =
        TestEvent.createReceivedEvent(EventType.InvokeTimeout, null, cnt++, stamp + MINI_WAIT_TIME);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 2);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp + MINI_WAIT_TIME * 2);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Invoke, null, cnt++, stamp + MINI_WAIT_TIME * 2);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 2);
    clientExpectedEvents.add(te);
    te =
        TestEvent.createReceivedEvent(
            EventType.InvokeTimeout, null, cnt++, stamp + MINI_WAIT_TIME * 2);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Invoke, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Invoke, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    clientExpectedEvents.add(te);
    te =
        TestEvent.createReceivedEvent(
            EventType.InvokeTimeout, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    clientExpectedEvents.add(te);
    te =
        TestEvent.createReceivedEvent(
            EventType.InvokeTimeout, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 4);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Invoke, null, cnt++, stamp + MINI_WAIT_TIME * 4);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Invoke, null, cnt++, stamp + MINI_WAIT_TIME * 4);
    clientExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 4);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.End, null, cnt++, stamp + MINI_WAIT_TIME * 5);
    clientExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp + MINI_WAIT_TIME * 5);
    clientExpectedEvents.add(te);
    te =
        TestEvent.createReceivedEvent(
            EventType.DialogRelease, null, cnt++, stamp + MINI_WAIT_TIME * 5);
    clientExpectedEvents.add(te);

    cnt = 0;
    List<TestEvent> serverExpectedEvents = new ArrayList<TestEvent>();
    te = TestEvent.createReceivedEvent(EventType.Begin, null, cnt++, stamp);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Invoke, null, cnt++, stamp);
    serverExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.ReturnResult, null, cnt++, stamp + MINI_WAIT_TIME);
    serverExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp + MINI_WAIT_TIME);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp + MINI_WAIT_TIME);
    serverExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 2);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 2);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Invoke, null, cnt++, stamp + MINI_WAIT_TIME * 2);
    serverExpectedEvents.add(te);
    te =
        TestEvent.createSentEvent(
            EventType.ReturnResultLast, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    serverExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.ReturnError, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    serverExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Invoke, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Invoke, null, cnt++, stamp + MINI_WAIT_TIME * 3);
    serverExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 4);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Continue, null, cnt++, stamp + MINI_WAIT_TIME * 4);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Invoke, null, cnt++, stamp + MINI_WAIT_TIME * 4);
    serverExpectedEvents.add(te);
    te = TestEvent.createReceivedEvent(EventType.Reject, null, cnt++, stamp + MINI_WAIT_TIME * 4);
    serverExpectedEvents.add(te);
    te = TestEvent.createSentEvent(EventType.End, null, cnt++, stamp + MINI_WAIT_TIME * 5);
    serverExpectedEvents.add(te);
    te =
        TestEvent.createReceivedEvent(
            EventType.DialogRelease, null, cnt++, stamp + MINI_WAIT_TIME * 5);
    serverExpectedEvents.add(te);

    client.startClientDialog();
    client.addNewInvoke(1L, 5L);
    client.sendBegin();

    client.waitFor(WAIT_TIME * 2);

    client.compareEvents(clientExpectedEvents);
    server.compareEvents(serverExpectedEvents);
  }