001: package org.springunit.framework.samples.jpetstore.domain;
002:
003: import org.springunit.framework.SpringUnitContext;
004: import org.springunit.framework.SpringUnitTest;
005:
006: /**
007: * Test of the Item domain object in the JPetStore sample application.
008: * @author Ted.Velkoff
009: *
010: */
011: public class ItemTest extends SpringUnitTest {
012:
013: public void testItemId() throws Exception {
014: Item subject = getObject("subject");
015: Integer itemId = getObject("itemId");
016: Integer expected = getObject("expected");
017: subject.setId(itemId);
018: Integer actual = subject.getId();
019: assertTrue(expected.equals(actual));
020: }
021:
022: public void testStatus() throws Exception {
023: Item subject = getObject("subject");
024: String status = getObject("status");
025: String expected = getObject("expected");
026: subject.setStatus(status);
027: String actual = subject.getStatus();
028: assertTrue(expected.equals(actual));
029: }
030:
031: public void testAttribute1() throws Exception {
032: Item subject = getObject("subject");
033: String attr = getObject("attr");
034: String expected = getObject("expected");
035: subject.setAttribute1(attr);
036: String actual = subject.getAttribute1();
037: assertTrue(expected.equals(actual));
038: }
039:
040: public void testAttribute2() throws Exception {
041: Item subject = getObject("subject");
042: String attr = getObject("attr");
043: String expected = getObject("expected");
044: subject.setAttribute2(attr);
045: String actual = subject.getAttribute2();
046: assertTrue(expected.equals(actual));
047: }
048:
049: public void testAttribute3() throws Exception {
050: Item subject = getObject("subject");
051: String attr = getObject("attr");
052: String expected = getObject("expected");
053: subject.setAttribute3(attr);
054: String actual = subject.getAttribute3();
055: assertTrue(expected.equals(actual));
056: }
057:
058: public void testAttribute4() throws Exception {
059: Item subject = getObject("subject");
060: String attr = getObject("attr");
061: String expected = getObject("expected");
062: subject.setAttribute4(attr);
063: String actual = subject.getAttribute4();
064: assertTrue(expected.equals(actual));
065: }
066:
067: public void testAttribute5() throws Exception {
068: Item subject = getObject("subject");
069: String attr = getObject("attr");
070: String expected = getObject("expected");
071: subject.setAttribute5(attr);
072: String actual = subject.getAttribute5();
073: assertTrue(expected.equals(actual));
074: }
075:
076: public void testSupplierId() throws Exception {
077: Item subject = getObject("subject");
078: int supplierId = (Integer) getObject("supplierId");
079: int expected = (Integer) getObject("expected");
080: subject.setSupplierId(supplierId);
081: int actual = subject.getSupplierId();
082: assertEquals(expected, actual);
083: }
084:
085: public void testListPrice() throws Exception {
086: Item subject = getObject("subject");
087: double listPrice = (Double) getObject("listPrice");
088: double expected = (Double) getObject("expected");
089: subject.setListPrice(listPrice);
090: double actual = subject.getListPrice();
091: assertEquals(expected, actual);
092: }
093:
094: public void testUnitCost() throws Exception {
095: Item subject = getObject("subject");
096: double unitCost = (Double) getObject("unitCost");
097: double expected = (Double) getObject("expected");
098: subject.setUnitCost(unitCost);
099: double actual = subject.getUnitCost();
100: assertEquals(expected, actual);
101: }
102:
103: public void testQuantity() throws Exception {
104: Item subject = getObject("subject");
105: int quantity = (Integer) getObject("quantity");
106: int expected = (Integer) getObject("expected");
107: subject.setQuantity(quantity);
108: int actual = subject.getQuantity();
109: assertEquals(expected, actual);
110: }
111:
112: public void testEqualsSame() throws Exception {
113: Item subject = getObject("subject");
114: Item other = getObject("other");
115: assertTrue(subject == other);
116: assertTrue(subject.equals(other));
117: }
118:
119: public void testEqualsNotSame() throws Exception {
120: Item subject = getObject("subject");
121: Item other = getObject("other");
122: assertFalse(subject == other);
123: assertTrue(subject.equals(other));
124: }
125:
126: public void testEqualsTypeMismatch() throws Exception {
127: Item subject = getObject("subject");
128: Integer other = getObject("other");
129: assertTrue(!subject.equals(other));
130: }
131:
132: public void testCompareToLessThan() throws Exception {
133: Item subject = getObject("subject");
134: Item other = getObject("other");
135: assertTrue(subject.compareTo(other) < 0);
136: }
137:
138: public void testCompareToGreaterThan() throws Exception {
139: Item subject = getObject("subject");
140: Item other = getObject("other");
141: assertTrue(subject.compareTo(other) > 0);
142: }
143:
144: public void testCompareToEquals() throws Exception {
145: Item subject = getObject("subject");
146: Item other = getObject("other");
147: assertTrue(subject.compareTo(other) == 0);
148: }
149:
150: public void testHashCodeSame() throws Exception {
151: Item subject = getObject("subject");
152: Item other = getObject("other");
153: assertTrue(subject.hashCode() == other.hashCode());
154: }
155:
156: public void testHashCodeDifferent() throws Exception {
157: Item subject = getObject("subject");
158: Item other = getObject("other");
159: assertTrue(subject.hashCode() != other.hashCode());
160: }
161:
162: public void testToString() throws Exception {
163: Item subject = getObject("subject");
164: String s = subject.toString();
165: }
166:
167: public SpringUnitContext getItemTest() {
168: return this .itemTest;
169: }
170:
171: public void setItemTest(SpringUnitContext itemTest) {
172: this .itemTest = itemTest;
173: }
174:
175: private SpringUnitContext itemTest;
176:
177: }
|