01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: TestPropertyValueList.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.ioc;
09:
10: import com.uwyn.rife.database.Datasources;
11: import junit.framework.TestCase;
12:
13: public class TestPropertyValueList extends TestCase {
14: public TestPropertyValueList(String name) {
15: super (name);
16: }
17:
18: public void testInstantiation() {
19: PropertyValueList list = new PropertyValueList();
20: assertNotNull(list);
21: assertEquals(0, list.size());
22: }
23:
24: public void testSingleNonNeglectable() {
25: PropertyValueList list = new PropertyValueList();
26: PropertyValueParticipant value = new PropertyValueParticipant(
27: "ParticipantDatasources", new PropertyValueObject(
28: "unittestspgsql"));
29: list.add(value);
30: assertEquals(1, list.size());
31: assertSame(value, list.makePropertyValue());
32: }
33:
34: public void testOneNoneNeglectableOtherNeglectables() {
35: PropertyValueParticipant value = new PropertyValueParticipant(
36: "ParticipantDatasources", new PropertyValueObject(
37: "unittestspgsql"));
38: PropertyValueList list;
39: list = new PropertyValueList();
40: list.add(new PropertyValueObject(" "));
41: list.add(value);
42: list.add(new PropertyValueObject(" "));
43: list.add(new PropertyValueObject(""));
44: assertEquals(4, list.size());
45: assertSame(value, list.makePropertyValue());
46: }
47:
48: public void testOneNoneNeglectableOtherNonNeglectable() {
49: PropertyValueParticipant value = new PropertyValueParticipant(
50: "ParticipantDatasources", new PropertyValueObject(
51: "unittestspgsql"));
52: PropertyValueList list;
53: list = new PropertyValueList();
54: list.add(new PropertyValueObject(" "));
55: list.add(value);
56: list.add(new PropertyValueObject(" "));
57: list.add(new PropertyValueObject("testing"));
58: assertEquals(4, list.size());
59:
60: PropertyValue result = list.makePropertyValue();
61: assertNotSame(value, result);
62: assertEquals(Datasources.getRepInstance().getDatasource(
63: "unittestspgsql")
64: + " testing", result.getValueString());
65: }
66: }
|