001: /**
002: * Copyright (C) 2006 NetMind Consulting Bt.
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 3 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */package hu.netmind.persistence;
018:
019: import java.util.List;
020:
021: /**
022: * Create special objects which the second part of test will modify.
023: * @author Brautigam Robert
024: * @version Revision: $Revision$
025: */
026: public class ClassModificationTests extends AbstractPersistenceTest {
027: public ClassModificationTests(String name) throws Exception {
028: super (name);
029: }
030:
031: public void testAllAttributesChanged() {
032: // All attributes changed, so all objects should be removed
033: List result = store.find("find testobject1");
034: assertEquals(0, result.size());
035: // Save new class
036: store.save(new TestObject1());
037: result = store.find("find testobject1");
038: assertEquals(1, result.size());
039: assertEquals("test", ((TestObject1) result.get(0))
040: .getStrattrother());
041: }
042:
043: public void testSomeAttributesChanged() {
044: // Save new class
045: store.save(new TestObject2());
046: List result = store
047: .find("find testobject2 where intattr = 'test2'");
048: assertTrue(result.size() > 0);
049: }
050:
051: public void testStringToNumber() {
052: // Save new class
053: store.save(new TestObject3());
054: List result = store.find("find testobject3 where strattr = 3");
055: assertTrue(result.size() > 0);
056: }
057:
058: public void testNumberToString() {
059: // Save new class
060: store.save(new TestObject4());
061: List result = store
062: .find("find testobject4 where intattr = 'test4'");
063: assertTrue(result.size() > 0);
064: }
065:
066: public void testPreserveUnchanged() {
067: // Check object
068: store.save(new TestObject5());
069: List result = store.find("find testobject5");
070: assertTrue(result.size() > 0);
071: }
072:
073: public void testAttributeDeleted() {
074: // Save new class
075: store.save(new TestObject6());
076: List result = store
077: .find("find testobject6 where strattr = 'test6-mod'");
078: assertTrue(result.size() > 0);
079: }
080:
081: public void testAttributeAdded() {
082: // Save new class
083: store.save(new TestObject7());
084: List result = store
085: .find("find testobject7 where strattr2 = 'test7-2'");
086: assertTrue(result.size() > 0);
087: }
088:
089: public void testNewPrimitiveAttributes() throws Exception {
090: // Select the old object
091: List result = store.find("find testobject8");
092: assertEquals(1, result.size());
093: // Check primitive attributes
094: TestObject8 t = (TestObject8) result.get(0);
095: assertEquals(0, t.getIntegerAttr());
096: assertEquals(0, t.getShortAttr());
097: assertEquals(0, t.getLongAttr());
098: assertEquals('\u0000', t.getCharAttr());
099: assertEquals(0, t.getByteAttr());
100: assertFalse(t.getBooleanAttr());
101: assertEquals(0, (int) t.getDoubleAttr());
102: assertEquals(0, (int) t.getFloatAttr());
103: }
104:
105: public void testContainerModification() throws Exception {
106: dropTables("containerobject1");
107: store.save(new ContainerObject1());
108: }
109:
110: }
|