コード例 #1
0
  /**
   * Runs the test case.
   *
   * @throws Throwable Any uncaught exception causes test to fail
   */
  public void runTest() throws Throwable {
    Document doc;
    NamedNodeMap notations;
    DocumentType docType;
    Node retval;
    Element elem;
    doc = (Document) load("hc_staff", true);
    docType = doc.getDoctype();

    if (!(("text/html".equals(getContentType())))) {
      assertNotNull("docTypeNotNull", docType);
      notations = docType.getNotations();
      assertNotNull("notationsNotNull", notations);
      elem = doc.createElementNS("http://www.w3.org/1999/xhtml", "br");

      try {
        retval = notations.setNamedItemNS(elem);
        fail("throw_HIER_OR_NO_MOD_ERR");

      } catch (DOMException ex) {
        switch (ex.code) {
          case 3:
            break;
          case 7:
            break;
          default:
            throw ex;
        }
      }
    }
  }
コード例 #2
0
  /**
   * Runs the test case.
   *
   * @throws Throwable Any uncaught exception causes test to fail
   */
  public void runTest() throws Throwable {
    Document doc;
    DocumentType docType;
    NamedNodeMap entities;
    NamedNodeMap notations;
    Entity entity;
    Notation notation;
    Node newNode;
    String nullNS = null;

    doc = (Document) load("staffNS", true);
    docType = doc.getDoctype();
    entities = docType.getEntities();
    assertNotNull("entitiesNotNull", entities);
    notations = docType.getNotations();
    assertNotNull("notationsNotNull", notations);
    entity = (Entity) entities.getNamedItem("ent1");
    notation = (Notation) notations.getNamedItem("notation1");

    {
      boolean success = false;
      try {
        newNode = entities.setNamedItemNS(entity);
      } catch (DOMException ex) {
        success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
      }
      assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR_entities", success);
    }

    {
      boolean success = false;
      try {
        newNode = notations.setNamedItemNS(notation);
      } catch (DOMException ex) {
        success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
      }
      assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR_notations", success);
    }
  }