コード例 #1
0
  @Test
  public void test1() throws NCLInvalidIdentifierException {
    NCLImportedDocumentBase base = new NCLImportedDocumentBase();
    base.setId("IDb");

    String expResult = "<importedDocumentBase id='IDb'/>\n";
    String result = base.parse(0);
    assertEquals(expResult, result);
  }
コード例 #2
0
  @Test
  public void test2() throws NCLInvalidIdentifierException, URISyntaxException {
    NCLImportedDocumentBase base = new NCLImportedDocumentBase();
    NCLImport imp = new NCLImport(NCLImportType.NCL);
    imp.setAlias("base");
    imp.setDocumentURI("base.ncl");
    base.addImportNCL(imp);

    String expResult =
        "<importedDocumentBase>\n\t<importNCL alias='base' documentURI='base.ncl'/>\n</importedDocumentBase>\n";
    String result = base.parse(0);
    assertEquals(expResult, result);
  }
コード例 #3
0
  @Test
  public void test3() {
    try {
      XMLReader reader = XMLReaderFactory.createXMLReader();

      NCLImportedDocumentBase instance = new NCLImportedDocumentBase(reader, null);
      String expResult = "<importedDocumentBase id='IDb'/>\n";

      reader.setContentHandler(instance);
      reader.parse(new InputSource(new StringReader(expResult)));

      String result = instance.parse(0);
      // System.out.println(result);
      assertEquals(expResult, result);
    } catch (SAXException ex) {
      fail(ex.getMessage());
    } catch (IOException ex) {
      fail(ex.getMessage());
    }
  }