Java Code Examples for javax.management.Descriptor#clone()

The following examples show how to use javax.management.Descriptor#clone() . 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: DescriptorSupportTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 2
Source File: DescriptorSupportTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 3
Source File: DescriptorSupportTest.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 4
Source File: DescriptorSupportTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 5
Source File: DescriptorSupportTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 6
Source File: DescriptorSupportTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 7
Source File: DescriptorSupportTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 8
Source File: DescriptorSupportTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 9
Source File: DescriptorSupportTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 10
Source File: DescriptorSupportTest.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 11
Source File: DescriptorSupportTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 12
Source File: DescriptorSupportTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}
 
Example 13
Source File: DescriptorSupportTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static boolean caseTest(Descriptor d, String what) {
    boolean ok = true;

    System.out.println("..." + what);

    String[] names = d.getFieldNames();
    if (names.length != 1 || !names[0].equals("NAME")) {
        ok = false;
        System.out.println("...getFieldNames() fails: " +
                           Arrays.asList(names));
    }

    String[] fields = d.getFields();
    if (fields.length != 1 || !fields[0].equals("NAME=blah")) {
        ok = false;
        System.out.println("...getFields() fails: " +
                           Arrays.asList(fields));
    }

    Object value = d.getFieldValue("namE");
    if (!"blah".equals(value)) {
        ok = false;
        System.out.println("...getFieldValue(\"namE\") fails: " + value);
    }

    Object[] values = d.getFieldValues(new String[] {"namE"});
    if (values.length != 1 || !"blah".equals(values[0])) {
        ok = false;
        System.out.println("...getFieldValues({\"namE\"}) fails: " +
                           Arrays.asList(values));
    }

    d.setField("namE", "newblah");
    Object newblah = d.getFieldValue("Name");
    if (!"newblah".equals(newblah)) {
        ok = false;
        System.out.println("...setField value not returned: " + newblah);
    }

    d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"});
    Object newerblah = d.getFieldValue("naMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...setFields value not returned: " +
                           newerblah);
    }

    Descriptor d1 = (Descriptor) d.clone();
    newerblah = d1.getFieldValue("NAMe");
    if (!"newerblah".equals(newerblah)) {
        ok = false;
        System.out.println("...clone incorrect: " + newerblah);
    }

    d.removeField("NAme");
    names = d.getFieldNames();
    if (names.length != 0) {
        ok = false;
        System.out.println("...removeField failed: " +
                           Arrays.asList(names));
    }

    if (ok)
        System.out.println("...succeeded");

    return ok;
}