Java Code Examples for javax.imageio.metadata.IIOMetadataNode#setAttributeNode()

The following examples show how to use javax.imageio.metadata.IIOMetadataNode#setAttributeNode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetAttributeNode.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void test4() {
    String name = "name";
    String correctValue = "correct value";
    String wrongValue = "wrong value";

    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode1 = new MyAttrNode(name, wrongValue);
    MyAttrNode attrNode2 = new MyAttrNode(name, correctValue);

    parent.setAttributeNode(attrNode1);
    parent.setAttributeNode(attrNode2);

    Attr actAttr = parent.getAttributeNode(name);
    String actValue = actAttr.getValue();

    if (!actValue.equals(correctValue)) {
        throw new RuntimeException("Test 4 failed: Return value is: " +
                                   actValue);
    }
}
 
Example 2
Source File: SetAttributeNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void test1() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    IIOMetadataNode elem   = new IIOMetadataNode("elem");

    MyAttrNode attrNode = new MyAttrNode("name", "value");
    elem.setAttributeNode(attrNode);
    attrNode.setOwnerElement(elem);

    try {
        parent.setAttributeNode(attrNode);
    } catch (DOMException e) {
        if (e.code != DOMException.INUSE_ATTRIBUTE_ERR) {
            throw new RuntimeException("Test 1 failed: " +
                                       "Invalid exception code: " +
                                       e.code);
        }
        return;
    }

    throw new RuntimeException("Test 1 failed: DOMException not thrown");
}
 
Example 3
Source File: SetAttributeNode.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void test1() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    IIOMetadataNode elem   = new IIOMetadataNode("elem");

    MyAttrNode attrNode = new MyAttrNode("name", "value");
    elem.setAttributeNode(attrNode);
    attrNode.setOwnerElement(elem);

    try {
        parent.setAttributeNode(attrNode);
    } catch (DOMException e) {
        if (e.code != DOMException.INUSE_ATTRIBUTE_ERR) {
            throw new RuntimeException("Test 1 failed: " +
                                       "Invalid exception code: " +
                                       e.code);
        }
        return;
    }

    throw new RuntimeException("Test 1 failed: DOMException not thrown");
}
 
Example 4
Source File: SetAttributeNode.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void test2() {
    String name = "attr";
    String oldValue = "old value";
    String newValue = "new value";
    Attr retAttr;

    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode1 = new MyAttrNode(name, oldValue);
    MyAttrNode attrNode2 = new MyAttrNode(name, newValue);

    retAttr = parent.setAttributeNode(attrNode1);
    retAttr = parent.setAttributeNode(attrNode2);

    String actName = retAttr.getNodeName();
    String actValue = retAttr.getValue();

    if (!actName.equals(name) || !actValue.equals(oldValue)) {
        throw new RuntimeException("Test 2 failed: Invalid attribute " +
                                   "returned: " +
                                   "(name: " + actName +
                                   ", value: " + actValue + ")");
    }
}
 
Example 5
Source File: SetAttributeNode.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void test1() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    IIOMetadataNode elem   = new IIOMetadataNode("elem");

    MyAttrNode attrNode = new MyAttrNode("name", "value");
    elem.setAttributeNode(attrNode);
    attrNode.setOwnerElement(elem);

    try {
        parent.setAttributeNode(attrNode);
    } catch (DOMException e) {
        if (e.code != DOMException.INUSE_ATTRIBUTE_ERR) {
            throw new RuntimeException("Test 1 failed: " +
                                       "Invalid exception code: " +
                                       e.code);
        }
        return;
    }

    throw new RuntimeException("Test 1 failed: DOMException not thrown");
}
 
Example 6
Source File: SetAttributeNode.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void test4() {
    String name = "name";
    String correctValue = "correct value";
    String wrongValue = "wrong value";

    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode1 = new MyAttrNode(name, wrongValue);
    MyAttrNode attrNode2 = new MyAttrNode(name, correctValue);

    parent.setAttributeNode(attrNode1);
    parent.setAttributeNode(attrNode2);

    Attr actAttr = parent.getAttributeNode(name);
    String actValue = actAttr.getValue();

    if (!actValue.equals(correctValue)) {
        throw new RuntimeException("Test 4 failed: Return value is: " +
                                   actValue);
    }
}
 
Example 7
Source File: SetAttributeNode.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void test2() {
    String name = "attr";
    String oldValue = "old value";
    String newValue = "new value";
    Attr retAttr;

    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode1 = new MyAttrNode(name, oldValue);
    MyAttrNode attrNode2 = new MyAttrNode(name, newValue);

    retAttr = parent.setAttributeNode(attrNode1);
    retAttr = parent.setAttributeNode(attrNode2);

    String actName = retAttr.getNodeName();
    String actValue = retAttr.getValue();

    if (!actName.equals(name) || !actValue.equals(oldValue)) {
        throw new RuntimeException("Test 2 failed: Invalid attribute " +
                                   "returned: " +
                                   "(name: " + actName +
                                   ", value: " + actValue + ")");
    }
}
 
Example 8
Source File: SetAttributeNode.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void test4() {
    String name = "name";
    String correctValue = "correct value";
    String wrongValue = "wrong value";

    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode1 = new MyAttrNode(name, wrongValue);
    MyAttrNode attrNode2 = new MyAttrNode(name, correctValue);

    parent.setAttributeNode(attrNode1);
    parent.setAttributeNode(attrNode2);

    Attr actAttr = parent.getAttributeNode(name);
    String actValue = actAttr.getValue();

    if (!actValue.equals(correctValue)) {
        throw new RuntimeException("Test 4 failed: Return value is: " +
                                   actValue);
    }
}
 
Example 9
Source File: SetAttributeNode.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void test4() {
    String name = "name";
    String correctValue = "correct value";
    String wrongValue = "wrong value";

    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode1 = new MyAttrNode(name, wrongValue);
    MyAttrNode attrNode2 = new MyAttrNode(name, correctValue);

    parent.setAttributeNode(attrNode1);
    parent.setAttributeNode(attrNode2);

    Attr actAttr = parent.getAttributeNode(name);
    String actValue = actAttr.getValue();

    if (!actValue.equals(correctValue)) {
        throw new RuntimeException("Test 4 failed: Return value is: " +
                                   actValue);
    }
}
 
Example 10
Source File: SetAttributeNode.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void test4() {
    String name = "name";
    String correctValue = "correct value";
    String wrongValue = "wrong value";

    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode1 = new MyAttrNode(name, wrongValue);
    MyAttrNode attrNode2 = new MyAttrNode(name, correctValue);

    parent.setAttributeNode(attrNode1);
    parent.setAttributeNode(attrNode2);

    Attr actAttr = parent.getAttributeNode(name);
    String actValue = actAttr.getValue();

    if (!actValue.equals(correctValue)) {
        throw new RuntimeException("Test 4 failed: Return value is: " +
                                   actValue);
    }
}
 
Example 11
Source File: SetAttributeNode.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void test4() {
    String name = "name";
    String correctValue = "correct value";
    String wrongValue = "wrong value";

    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode1 = new MyAttrNode(name, wrongValue);
    MyAttrNode attrNode2 = new MyAttrNode(name, correctValue);

    parent.setAttributeNode(attrNode1);
    parent.setAttributeNode(attrNode2);

    Attr actAttr = parent.getAttributeNode(name);
    String actValue = actAttr.getValue();

    if (!actValue.equals(correctValue)) {
        throw new RuntimeException("Test 4 failed: Return value is: " +
                                   actValue);
    }
}
 
Example 12
Source File: SetAttributeNode.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void test2() {
    String name = "attr";
    String oldValue = "old value";
    String newValue = "new value";
    Attr retAttr;

    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode1 = new MyAttrNode(name, oldValue);
    MyAttrNode attrNode2 = new MyAttrNode(name, newValue);

    retAttr = parent.setAttributeNode(attrNode1);
    retAttr = parent.setAttributeNode(attrNode2);

    String actName = retAttr.getNodeName();
    String actValue = retAttr.getValue();

    if (!actName.equals(name) || !actValue.equals(oldValue)) {
        throw new RuntimeException("Test 2 failed: Invalid attribute " +
                                   "returned: " +
                                   "(name: " + actName +
                                   ", value: " + actValue + ")");
    }
}
 
Example 13
Source File: SetAttributeNode.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void test3() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode = new MyAttrNode("name", "value");
    Attr retAttr = parent.setAttributeNode(attrNode);

    if (retAttr != null) {
        throw new RuntimeException("Test 3 failed: Return value is " +
                                   "non-null");
    }
}
 
Example 14
Source File: SetAttributeNode.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void test3() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode = new MyAttrNode("name", "value");
    Attr retAttr = parent.setAttributeNode(attrNode);

    if (retAttr != null) {
        throw new RuntimeException("Test 3 failed: Return value is " +
                                   "non-null");
    }
}
 
Example 15
Source File: SetAttributeNode.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void test3() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode = new MyAttrNode("name", "value");
    Attr retAttr = parent.setAttributeNode(attrNode);

    if (retAttr != null) {
        throw new RuntimeException("Test 3 failed: Return value is " +
                                   "non-null");
    }
}
 
Example 16
Source File: SetAttributeNode.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void test3() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode = new MyAttrNode("name", "value");
    Attr retAttr = parent.setAttributeNode(attrNode);

    if (retAttr != null) {
        throw new RuntimeException("Test 3 failed: Return value is " +
                                   "non-null");
    }
}
 
Example 17
Source File: SetAttributeNode.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void test3() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode = new MyAttrNode("name", "value");
    Attr retAttr = parent.setAttributeNode(attrNode);

    if (retAttr != null) {
        throw new RuntimeException("Test 3 failed: Return value is " +
                                   "non-null");
    }
}
 
Example 18
Source File: SetAttributeNode.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void test3() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode = new MyAttrNode("name", "value");
    Attr retAttr = parent.setAttributeNode(attrNode);

    if (retAttr != null) {
        throw new RuntimeException("Test 3 failed: Return value is " +
                                   "non-null");
    }
}
 
Example 19
Source File: SetAttributeNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void test3() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode = new MyAttrNode("name", "value");
    Attr retAttr = parent.setAttributeNode(attrNode);

    if (retAttr != null) {
        throw new RuntimeException("Test 3 failed: Return value is " +
                                   "non-null");
    }
}
 
Example 20
Source File: SetAttributeNode.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void test3() {
    IIOMetadataNode parent = new IIOMetadataNode("parent");
    MyAttrNode attrNode = new MyAttrNode("name", "value");
    Attr retAttr = parent.setAttributeNode(attrNode);

    if (retAttr != null) {
        throw new RuntimeException("Test 3 failed: Return value is " +
                                   "non-null");
    }
}