コード例 #1
0
  /**
   * Test method for {@link
   * net.hyperadapt.pxweave.interpreter.test.OperationInterpreter#interpreteFillComponentByID(java.lang.String,
   * java.lang.String, org.w3c.dom.NodeList, java.util.List)} .
   *
   * @throws XMLWeaverException
   */
  @Test
  public void testInterpreteFillComponentByID() throws XMLWeaverException {
    final Document listTarget = parser.buildDOM(URI.create("testData/bookList.xml"));
    final Document bookSource = parser.buildDOM(URI.create("testData/book.xml"));
    final NodeList joinPoints = xPathEvaluator.evaluateXPath("//book", listTarget);
    final NodeList sourceComps = xPathEvaluator.evaluateXPath("//books:book", bookSource);

    final List<Element> sourceComponents = new ArrayList<Element>();
    sourceComponents.add((Element) sourceComps.item(0));
    sourceComponents.add((Element) sourceComps.item(1));
    sourceComponents.add((Element) sourceComps.item(2));

    oInterpreter.interpreteFillComponentByID("price", "price", joinPoints, sourceComponents);
    NodeList result = xPathEvaluator.evaluateXPath("//book//books:name/text()", listTarget);
    assertTrue(
        "JoinPoints are filled with the correct nodes",
        (result.item(0).getNodeValue().contentEquals("Sam")
                & result.item(1).getNodeValue().contentEquals("M."))
            & result.item(2).getNodeValue().contentEquals("A"));
    oInterpreter.interpreteFillComponentByID("price", "price", joinPoints, sourceComponents);
    result = xPathEvaluator.evaluateXPath("//book//books:name/text()", listTarget);
    assertTrue(
        "Already existing nodes in joinPoints are kept",
        (result.item(0).getNodeValue().contentEquals("Sam")
                & result.item(1).getNodeValue().contentEquals("Sam"))
            & result.item(2).getNodeValue().contentEquals("M."));
  }
コード例 #2
0
  /**
   * Test method for {@link
   * net.hyperadapt.pxweave.interpreter.test.OperationInterpreter#interpreteFillComponentByID(java.lang.String,
   * java.lang.String, org.w3c.dom.NodeList, java.util.List)} .
   *
   * @throws XMLWeaverException
   */
  @Test(expected = XMLWeaverException.class)
  public void testInterpreteFillComponentByIDSameNode() throws XMLWeaverException {
    final Document target = parser.buildDOM(URI.create("testData/bookList.xml"));
    final Document source = target;
    final NodeList joinPoints = xPathEvaluator.evaluateXPath("//book", target);
    final NodeList sourceComps = xPathEvaluator.evaluateXPath("//book", source);

    final List<Element> sourceComponents = new ArrayList<Element>();
    sourceComponents.add((Element) sourceComps.item(0));
    sourceComponents.add((Element) sourceComps.item(1));
    sourceComponents.add((Element) sourceComps.item(2));
    oInterpreter.interpreteFillComponentByID("price", "price", joinPoints, sourceComponents);
  }