01: /*
02: * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
03: *
04: * This file is part of TransferCM.
05: *
06: * TransferCM is free software; you can redistribute it and/or modify it under the
07: * terms of the GNU General Public License as published by the Free Software
08: * Foundation; either version 2 of the License, or (at your option) any later
09: * version.
10: *
11: * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
12: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14: * details.
15: *
16: * You should have received a copy of the GNU General Public License along with
17: * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
18: * Fifth Floor, Boston, MA 02110-1301 USA
19: */
20:
21: package com.methodhead.aikp;
22:
23: import java.util.*;
24: import junit.framework.*;
25: import org.apache.log4j.*;
26: import org.apache.commons.beanutils.*;
27: import com.methodhead.persistable.*;
28:
29: public class IntKeyTest extends TestCase {
30:
31: public IntKeyTest(String name) {
32: super (name);
33: BasicConfigurator.configure(new WriterAppender());
34: }
35:
36: protected void setUp() {
37: }
38:
39: protected void tearDown() {
40: }
41:
42: public void testContructors() {
43: IntKey key = new IntKey(666);
44:
45: assertEquals(666, key.value_);
46:
47: key = new IntKey("666");
48:
49: assertEquals(666, key.value_);
50:
51: key = new IntKey((Object) "666");
52:
53: assertEquals(666, key.value_);
54: }
55:
56: public void testGetWhereClause() {
57: IntKey key = new IntKey(666);
58:
59: assertEquals("id=666", key.getWhereClause());
60: }
61:
62: public void testSetPropertyValues() {
63: try {
64: IntKey key = new IntKey(666);
65:
66: DynaProperty[] dynaProperties = new DynaProperty[] { new DynaProperty(
67: "id", Integer.class), };
68:
69: DynaClass dynaClass = new BasicDynaClass("persistable",
70: BasicDynaClass.class, dynaProperties);
71:
72: Persistable persistable = new Persistable(dynaClass);
73:
74: key.setProperties(persistable);
75:
76: assertEquals(666, persistable.getInt("id"));
77: } catch (Exception e) {
78: fail(e.getMessage());
79: }
80: }
81: }
|