001: /*
002: * $Id: BaseRowTest.java,v 1.1 2004/08/19 02:18:49 ahimanikya Exp $
003: * =======================================================================
004: * Copyright (c) 2003 Axion Development Team. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above
011: * copyright notice, this list of conditions and the following
012: * disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * 3. The names "Tigris", "Axion", nor the names of its contributors may
020: * not be used to endorse or promote products derived from this
021: * software without specific prior written permission.
022: *
023: * 4. Products derived from this software may not be called "Axion", nor
024: * may "Tigris" or "Axion" appear in their names without specific prior
025: * written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
030: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
032: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
033: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
034: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
035: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
036: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
037: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
038: * =======================================================================
039: */
040:
041: package org.axiondb.engine.rows;
042:
043: import junit.framework.TestCase;
044:
045: import org.axiondb.Row;
046:
047: /**
048: * @version $Revision: 1.1 $ $Date: 2004/08/19 02:18:49 $
049: * @author Rod Waldhoff
050: */
051: public abstract class BaseRowTest extends TestCase {
052:
053: //------------------------------------------------------------ Conventional
054:
055: public BaseRowTest(String testName) {
056: super (testName);
057: }
058:
059: public abstract Row makeRow(Object[] values);
060:
061: //------------------------------------------------------------------- Tests
062:
063: public void testToString() throws Exception {
064: assertNotNull(makeRow(STRINGS_ONE).toString());
065: }
066:
067: public void testEqualsAndHashCode() throws Exception {
068: Row row = makeRow(STRINGS_ONE);
069: assertEquals(row, row);
070: assertEquals(row.hashCode(), row.hashCode());
071:
072: assertEquals(row, makeRow(STRINGS_ONE));
073: assertEquals(row.hashCode(), makeRow(STRINGS_ONE).hashCode());
074:
075: assertTrue(!row.equals(null));
076:
077: assertTrue(!row.equals(makeRow(STRINGS_TWO)));
078: assertTrue(!makeRow(STRINGS_TWO).equals(row));
079: assertTrue(row.hashCode() != makeRow(STRINGS_TWO).hashCode());
080:
081: assertTrue(!row.equals(makeRow(STRINGS_THREE)));
082: assertTrue(!makeRow(STRINGS_THREE).equals(row));
083: assertTrue(row.hashCode() != makeRow(STRINGS_THREE).hashCode());
084:
085: assertTrue(!row.equals(makeRow(INTS_ONE)));
086: assertTrue(!makeRow(INTS_ONE).equals(row));
087: assertTrue(row.hashCode() != makeRow(INTS_ONE).hashCode());
088:
089: assertTrue(!row.equals(makeRow(MIXED_ONE)));
090: assertTrue(!makeRow(MIXED_ONE).equals(row));
091: assertTrue(row.hashCode() != makeRow(MIXED_ONE).hashCode());
092:
093: assertEquals(makeRow(STRINGS_TWO), makeRow(STRINGS_TWO));
094: assertEquals(makeRow(STRINGS_THREE), makeRow(STRINGS_THREE));
095: assertEquals(makeRow(MIXED_ONE), makeRow(MIXED_ONE));
096: assertEquals(makeRow(INTS_ONE), makeRow(INTS_ONE));
097:
098: assertTrue(!row.equals(makeRow(NULLS)));
099: assertTrue(!makeRow(NULLS).equals(row));
100: assertTrue(row.hashCode() != makeRow(NULLS).hashCode());
101:
102: }
103:
104: private static final Object[] STRINGS_ONE = { "one", "two",
105: "three", "four" };
106: private static final Object[] STRINGS_TWO = { "1", "2", "3", "4" };
107: private static final Object[] STRINGS_THREE = { "one", "two",
108: "three" };
109: private static final Object[] INTS_ONE = { new Integer(1),
110: new Integer(2), new Integer(3), new Integer(4) };
111: private static final Object[] MIXED_ONE = { new Integer(1), "2",
112: null, "4" };
113: private static final Object[] NULLS = { null, null, null, null };
114: }
|