Java Code Examples for java.util.Vector.equals()

The following are Jave code examples for showing how to use equals() of the java.util.Vector class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: jdk8u-jdk   File: SimpleSerialization.java   View Source Code Vote up 7 votes
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 2
Project: openjdk-jdk10   File: SetDataFlavorsTest.java   View Source Code Vote up 7 votes
public void verifyNewMappings() {
    // Enumerate through all DataFlavors
    for (Enumeration e = hashVerify.keys() ; e.hasMoreElements() ;) {
        DataFlavor key = (DataFlavor)e.nextElement();

        java.util.List listNatives = flavorMap.getNativesForFlavor(key);
        Vector vectorFlavors = new Vector(listNatives);

        // Compare the list of Natives
        if ( !vectorFlavors.equals(hashVerify.get(key))) {
            throw new RuntimeException("\n*** Error in verifyNewMappings()" +
                "\nmethod1: setNativesForFlavor(DataFlavor flav, String[] natives)" +
                "\nmethod2: List getNativesForFlavor(DataFlavor flav)" +
                "\nDataFlavor: " + key.getMimeType() +
                "\nThe Returned List did not match the original set of Natives.");
        }
    }
    System.out.println("*** DataFlavor size = " + hashVerify.size());
}
 
Example 3
Project: openjdk-jdk10   File: SetNativesTest.java   View Source Code Vote up 7 votes
public void verifyNewMappings() {
    // Enumerate through all natives
    for (Enumeration e = hashVerify.keys() ; e.hasMoreElements() ;) {
        String key = (String)e.nextElement();

        java.util.List listFlavors = flavorMap.getFlavorsForNative(key);
        Vector vectorFlavors = new Vector(listFlavors);

        // Compare the list of DataFlavors
        if ( !vectorFlavors.equals((Vector)hashVerify.get(key))) {
            throw new RuntimeException("\n*** Error in verifyNewMappings()" +
                "\nmethod1: setFlavorsForNative(String nat, DataFlavors[] flavors)" +
                "\nmethod2: List getFlavorsForNative(String nat)" +
                "\nString native: " + key +
                "\nThe Returned List did not match the original set of DataFlavors.");
        }
    }
    System.out.println("*** native size = " + hashVerify.size());
}
 
Example 4
Project: openjdk-jdk10   File: SimpleSerialization.java   View Source Code Vote up 7 votes
public static void main(final String[] args) throws Exception {
    final Vector<String> v1 = new Vector<>();

    v1.add("entry1");
    v1.add("entry2");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);

    oos.writeObject(v1);
    oos.close();

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bais);

    final Object deserializedObject = ois.readObject();
    ois.close();

    if (false == v1.equals(deserializedObject)) {
        throw new RuntimeException(getFailureText(v1, deserializedObject));
    }
}
 
Example 5
Project: incubator-netbeans   File: KeyMapTest.java   View Source Code Vote up 6 votes
public void testProfileRestore() {
    KeyMapOperator kmo = null;
    boolean closed = true;
    try {
        kmo = KeyMapOperator.invoke();
        closed = false;
        Vector<String> shortcuts = kmo.getAllShortcutsForAction("Preview Design");
        kmo.assignShortcutToAction("Preview Design", true, true, false, KeyEvent.VK_W, true, true);
        if (shortcuts.equals(kmo.getAllShortcutsForAction("Preview Design"))) {
            fail("Problem with assigning shortcut to Preview Design");
        }
        kmo.ok().push();
        closed = true;
        kmo = KeyMapOperator.invoke();
        closed = false;
        kmo.actionSearchByName().setText("Preview Design");
        kmo.restoreProfile("NetBeans");
        Vector<String> sc = kmo.getAllShortcutsForAction("Preview Design");
        if (!shortcuts.equals(sc)) {
            // This test currently fails: http://www.netbeans.org/issues/show_bug.cgi?id=151254
            fail("Problem with restoring NetBeans profile (http://www.netbeans.org/issues/show_bug.cgi?id=151254) - \"Preview Design\" action: " + shortcuts.toString() + " vs. " + sc.toString());
        }
        kmo.ok().push();
        closed = true;
    } finally {
        if (!closed && kmo != null) {
            kmo.cancel().push();
        }
    }
}
 
Example 6
Project: AgentWorkbench   File: BasicGraphGuiProperties.java   View Source Code Vote up 6 votes
/**
 * Checks if the current settings have changed.
 * @return true, if the data model was changed
 */
private boolean hasChanged() {
	
	boolean changed = false;
	NetworkComponentAdapter4DataModel nca4dm = this.getNetworkComponentAdapter4DataModel();
	if (nca4dm!=null) {
		nca4dm.save();
		this.newDataModel = nca4dm.getDataModel();
		this.newDataModelBase64 = nca4dm.getDataModelBase64Encoded(this.newDataModel);
		Vector<Integer> newHashCodes = this.getHashCodeVectorFromDataModel(newDataModelBase64);
		changed = !newHashCodes.equals(this.dataModelInitialHashCodes);
	}
	return changed;
}
 
Example 7
Project: openjdk-jdk10   File: GetNativesForNewFlavorTest.java   View Source Code Vote up 6 votes
public void doTest() throws Exception {
    // Initialize DataFlavors and arrays used for test data
    initMappings();

    boolean passed = true;
    flavorMap = (SystemFlavorMap)SystemFlavorMap.getDefaultFlavorMap();

    // Get all the native strings and preferred DataFlavor mappings
    hash = new Hashtable(flavorMap.getFlavorsForNatives(null));
    hashSize = hash.size();

    // GetNativesForFlavor using unknown DataFlavor (verify 2-way mapping)
    //
    // If a new DataFlavor is specified, the method should establish a mapping
    // in both directions between specified DataFlavor and an encoded
    // version of its MIME type as its native.
    System.out.println("GetNativesForFlavor using new DataFlavor");

    comp1 = new Vector(Arrays.asList(test_natives_set));
    comp2 = new Vector(flavorMap.getNativesForFlavor(test_flavor1));

    comp3 = new Vector(Arrays.asList(test_flavors_set));
    comp4 = new Vector(flavorMap.getFlavorsForNative(test_encoded));

    if ( !comp1.equals(comp2) || !comp3.equals(comp4) ) {
        throw new RuntimeException("\n*** After passing a new DataFlavor" +
            "\nwith getNativesForFlavor(DataFlavor flav)" +
            "\nthe mapping in both directions was not established.");
    }
    else
       System.out.println("GetNativesForFlavor using new DataFlavor: Test Passes");
}
 
Example 8
Project: incubator-netbeans   File: KeyMapTest.java   View Source Code Vote up 5 votes
public void testAddDuplicateCancel() {
    KeyMapOperator kmo = null;
    boolean closed = true;
    try {
        kmo = KeyMapOperator.invoke();
        closed = false;
        kmo.selectProfile(PROFILE_DEFAULT);
        Vector<String> shortcuts = kmo.getAllShortcutsForAction("select line");
        kmo.assignShortcutToAction("select line", false, true, true, KeyEvent.VK_F9, true, false);
        shortcuts.equals(kmo.getAllShortcutsForAction("select line"));
        kmo.ok().push();
        closed = true;
        kmo = KeyMapOperator.invoke();
        closed = false;
        kmo.selectProfile(PROFILE_DEFAULT);
        kmo.assignShortcutToAction("select line", false, true, true, KeyEvent.VK_F9, true, true);
        kmo.ok().push();
        closed = true;
        new EventTool().waitNoEvent(2000);
        editor.requestFocus();
        new EventTool().waitNoEvent(100);
        // Check ALT+Shift+G works for select line
        editor.setCaretPosition(55, 1);
        ValueResolver vr = new ValueResolver() {

            @Override
            public Object getValue() {
                editor.pushKey(KeyEvent.VK_F9, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
                String selected = editor.txtEditorPane().getSelectedText();
                new EventTool().waitNoEvent(100);
                if (selected == null) {
                    return false;
                }
                return selected.startsWith("public class Main {");
            }
        };
        waitMaxMilisForValue(3000, vr, Boolean.TRUE);
        String text = editor.txtEditorPane().getSelectedText();
        assertEquals("public class Main {", text.trim());
    } catch (Exception e) {
        System.out.println("ERROR: testAddDuplicateCancel");
        e.printStackTrace(System.out);
        fail(e);
    } finally {
        if (!closed && kmo != null) {
            kmo.cancel().push();
            editor.close(false);
        }
    }
}