Package org.jfree.data

Examples of org.jfree.data.ComparableObjectItem


     */
    public void testConstructor() {
        // check null argument 1
        boolean pass = false;
        try {
            /* ComparableObjectItem item1 = */ new ComparableObjectItem(null,
                    "XYZ");
        }
        catch (IllegalArgumentException e) {
            pass = true;
        }
View Full Code Here


    /**
     * Confirm that the equals method can distinguish all the required fields.
     */
    public void testEquals() {
        ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        ComparableObjectItem item2 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        assertTrue(item1.equals(item2));
        assertTrue(item2.equals(item1));

        item1 = new ComparableObjectItem(new Integer(2), "XYZ");
        assertFalse(item1.equals(item2));
        item2 = new ComparableObjectItem(new Integer(2), "XYZ");
        assertTrue(item1.equals(item2));

        item1 = new ComparableObjectItem(new Integer(2), null);
        assertFalse(item1.equals(item2));
        item2 = new ComparableObjectItem(new Integer(2), null);
        assertTrue(item1.equals(item2));
    }
View Full Code Here

    /**
     * Some checks for the clone() method.
     */
    public void testCloning() {
        ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        ComparableObjectItem item2 = null;
        try {
            item2 = (ComparableObjectItem) item1.clone();
        }
        catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        assertTrue(item1 != item2);
        assertTrue(item1.getClass() == item2.getClass());
        assertTrue(item1.equals(item2));
    }
View Full Code Here

    /**
     * Serialize an instance, restore it, and check for equality.
     */
    public void testSerialization() {
        ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        ComparableObjectItem item2 = null;
        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(item1);
            out.close();
View Full Code Here

    /**
     * Some checks for the compareTo() method.
     */
    public void testCompareTo() {
        ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        ComparableObjectItem item2 = new ComparableObjectItem(new Integer(2),
                "XYZ");
        ComparableObjectItem item3 = new ComparableObjectItem(new Integer(3),
                "XYZ");
        ComparableObjectItem item4 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        assertTrue(item2.compareTo(item1) > 0);
        assertTrue(item3.compareTo(item1) > 0);
        assertTrue(item4.compareTo(item1) == 0);
        assertTrue(item1.compareTo(item2) < 0);
    }
View Full Code Here

     */
    public void testConstructor() {
        // check null argument 1
        boolean pass = false;
        try {
            /* ComparableObjectItem item1 = */ new ComparableObjectItem(null,
                    "XYZ");
        }
        catch (IllegalArgumentException e) {
            pass = true;
        }
View Full Code Here

   
    /**
     * Confirm that the equals method can distinguish all the required fields.
     */
    public void testEquals() {
        ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        ComparableObjectItem item2 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        assertTrue(item1.equals(item2));
        assertTrue(item2.equals(item1));

        item1 = new ComparableObjectItem(new Integer(2), "XYZ");
        assertFalse(item1.equals(item2));
        item2 = new ComparableObjectItem(new Integer(2), "XYZ");
        assertTrue(item1.equals(item2));
       
        item1 = new ComparableObjectItem(new Integer(2), null);
        assertFalse(item1.equals(item2));
        item2 = new ComparableObjectItem(new Integer(2), null);
        assertTrue(item1.equals(item2));       
    }
View Full Code Here

    /**
     * Some checks for the clone() method.
     */
    public void testCloning() {
        ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        ComparableObjectItem item2 = null;
        try {
            item2 = (ComparableObjectItem) item1.clone();
        }
        catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        assertTrue(item1 != item2);
        assertTrue(item1.getClass() == item2.getClass());
        assertTrue(item1.equals(item2));
    }
View Full Code Here

    /**
     * Serialize an instance, restore it, and check for equality.
     */
    public void testSerialization() {
        ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        ComparableObjectItem item2 = null;
        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(item1);
            out.close();
View Full Code Here

   
    /**
     * Some checks for the compareTo() method.
     */
    public void testCompareTo() {
        ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        ComparableObjectItem item2 = new ComparableObjectItem(new Integer(2),
                "XYZ");
        ComparableObjectItem item3 = new ComparableObjectItem(new Integer(3),
                "XYZ");
        ComparableObjectItem item4 = new ComparableObjectItem(new Integer(1),
                "XYZ");
        assertTrue(item2.compareTo(item1) > 0);
        assertTrue(item3.compareTo(item1) > 0);
        assertTrue(item4.compareTo(item1) == 0);
        assertTrue(item1.compareTo(item2) < 0);
    }
View Full Code Here

TOP

Related Classes of org.jfree.data.ComparableObjectItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.