Exemplo n.º 1
0
  /** Test methods for handling of per-operation information. */
  @Test(timeout = 1000)
  public void testPerMessageInformationHandling() {
    FBindingOperationInputMessage input = new FBindingOperationInputMessage("input");
    FBindingOperationOutputMessage output = new FBindingOperationOutputMessage("output");
    FBindingOperation bindingOperation =
        FBindingOperation.factory.create("foo", FOperationType.ONE_WAY, input, output);

    FExtensibilityElement firstElement =
        new FExtensibilityElement(new UnknownExtensibilityElement());
    FExtensibilityElement secondElement =
        new FExtensibilityElement(new UnknownExtensibilityElement());

    // Test addPerOperationInformation()
    assertEquals(
        "Per-operation information count must be zero.",
        0,
        bindingOperation.perOperationInformationCount());
    bindingOperation.addPerOperationInformation(firstElement);
    assertEquals(
        "Per-operation information count must be one.",
        1,
        bindingOperation.perOperationInformationCount());
    bindingOperation.addPerOperationInformation(secondElement);
    assertEquals(
        "Per-operation information count must be two.",
        2,
        bindingOperation.perOperationInformationCount());

    // Reset binding operation object
    bindingOperation =
        FBindingOperation.factory.create("bar", FOperationType.ONE_WAY, input, output);

    // Test addPerOperationInformations()
    HashSet<FExtensibilityElement> elements = new HashSet<FExtensibilityElement>();
    elements.add(firstElement);
    elements.add(secondElement);
    assertEquals(
        "Per-operation information count must be zero.",
        0,
        bindingOperation.perOperationInformationCount());
    bindingOperation.addPerOperationInformations(elements);
    assertEquals(
        "Per-operation information count must be two.",
        2,
        bindingOperation.perOperationInformationCount());

    // Reset binding operation object
    bindingOperation =
        FBindingOperation.factory.create("foobar", FOperationType.ONE_WAY, input, output);

    // Test setPerOperationInformations()
    assertEquals(
        "Per-operation information count must be zero.",
        0,
        bindingOperation.perOperationInformationCount());
    bindingOperation.setPerOperationInformations(elements);
    assertEquals(
        "Per-operation information count must be two.",
        2,
        bindingOperation.perOperationInformationCount());

    // Test getPerOperationInformations()
    Iterator iterator = bindingOperation.getPerOperationInformations().iterator();
    while (iterator.hasNext()) {
      FExtensibilityElement element = (FExtensibilityElement) iterator.next();

      assertTrue(
          "Binding operation must contain per-operation information that was added previously.",
          elements.contains(element));
    }
  }