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

The following examples show how to use javax.management.Descriptor#getFieldNames() . 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: DcmdMBeanTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 2
Source File: DcmdMBeanTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 3
Source File: DcmdMBeanTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 4
Source File: DcmdMBeanTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 5
Source File: DcmdMBeanTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 6
Source File: MBeanCommand.java    From arthas with Apache License 2.0 5 votes vote down vote up
private void drawDescriptorInfo(String title, DescriptorRead descriptorRead, TableElement table) {
    Descriptor descriptor = descriptorRead.getDescriptor();
    String[] fieldNames = descriptor.getFieldNames();
    if (fieldNames.length > 0) {
        table.row(new LabelElement(title).style(Decoration.bold.fg(Color.yellow)));
        for (String fieldName : fieldNames) {
            Object fieldValue = descriptor.getFieldValue(fieldName);
            table.row(fieldName, fieldValue.toString());
        }
    }
}
 
Example 7
Source File: DcmdMBeanTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 8
Source File: DcmdMBeanTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 9
Source File: DcmdMBeanTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 10
Source File: DcmdMBeanTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void printOperation(MBeanOperationInfo info) {
    System.out.println("Name: "+info.getName());
    System.out.println("Description: "+info.getDescription());
    System.out.println("Return Type: "+info.getReturnType());
    System.out.println("Impact: "+info.getImpact());
    Descriptor desc = info.getDescriptor();
    System.out.println("Descriptor");
    for(int i=0; i<desc.getFieldNames().length; i++) {
        if(desc.getFieldNames()[i].compareTo("dcmd.arguments") == 0) {
            System.out.println("\t"+desc.getFieldNames()[i]+":");
            Descriptor desc2 =
                    (Descriptor)desc.getFieldValue(desc.getFieldNames()[i]);
            for(int j=0; j<desc2.getFieldNames().length; j++) {
                System.out.println("\t\t"+desc2.getFieldNames()[j]+"=");
                Descriptor desc3 =
                        (Descriptor)desc2.getFieldValue(desc2.getFieldNames()[j]);
                for(int k=0; k<desc3.getFieldNames().length; k++) {
                    System.out.println("\t\t\t"+desc3.getFieldNames()[k]+"="
                                       +desc3.getFieldValue(desc3.getFieldNames()[k]));
                }
            }
        } else {
            System.out.println("\t"+desc.getFieldNames()[i]+"="
                    +desc.getFieldValue(desc.getFieldNames()[i]));
        }
    }
}
 
Example 11
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 12
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 13
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 14
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 15
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 16
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 17
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 18
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 19
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 20
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;
}