/**
   * Tests the {@link AbstractAddAdapterRule#endElement} method
   *
   * @throws Exception if an error occurs
   */
  public void testEndElement() throws Exception {
    // retrieve the pipeline
    XMLPipeline pipeline = dynamicProcess.getPipeline();
    // add a process to the head of the pipeline
    pipeline.addHeadProcess(adapterProcess);

    ExpandedName eName = new ImmutableExpandedName("testNamespace", "testLocalName");

    // call end element on the rule
    rule.endElement(dynamicProcess, eName, adapterProcess);

    // ensure that the process was removed from the pipeline
    assertNotSame(
        "endElement did not remove the adapter process from " + "the pipeline",
        adapterProcess,
        pipeline.getHeadProcess());
  }
  /**
   * Tests that the {@link AbstractAddAdapterRule#endElement} method throws an exception if you
   * attempt to remove a process that is not at the head of the pipeline
   *
   * @throws Exception if an error occurs
   */
  public void testEndElementWithWrongProcess() throws Exception {
    // retrieve the pipeline
    XMLPipeline pipeline = dynamicProcess.getPipeline();
    // add the process to the head of the pipeline
    pipeline.addHeadProcess(adapterProcess);

    // create an expanded name
    ExpandedName eName = new ImmutableExpandedName("testNamespace", "testLocalName");

    try {
      // call end element on the rule
      rule.endElement(dynamicProcess, eName, new MockAdapterProcess());
      fail(
          "endElement did not throw an exception when attempting to "
              + "remove a process that was not at the head of the pipeline");
    } catch (XMLPipelineException e) {
    }
  }