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: TestPropertyValueParticipant.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.ioc;
09:
10: import junit.framework.TestCase;
11:
12: import com.uwyn.rife.ioc.exceptions.ParticipantUnknownException;
13:
14: public class TestPropertyValueParticipant extends TestCase {
15: public TestPropertyValueParticipant(String name) {
16: super (name);
17: }
18:
19: public void testInstantiation() {
20: PropertyValueParticipant object = new PropertyValueParticipant(
21: "ParticipantConfig", new PropertyValueObject(
22: "IOC_CONFIG"));
23: assertNotNull(object);
24: assertFalse(object.isStatic());
25: }
26:
27: public void testGetValue() {
28: PropertyValueParticipant object = new PropertyValueParticipant(
29: "ParticipantConfig", new PropertyValueObject(
30: "IOC_CONFIG"));
31: assertNotNull(object.getValue());
32: }
33:
34: public void testGetValueUnknownParticipant() {
35: PropertyValueParticipant object = new PropertyValueParticipant(
36: "unknown", new PropertyValueObject("IOC_CONFIG"));
37: try {
38: object.getValue();
39: fail("ParticipantUnknownException wasn't thrown");
40: } catch (ParticipantUnknownException e) {
41: assertEquals("unknown", e.getName());
42: }
43: }
44:
45: public void testGetValueUnknownKey() {
46: PropertyValueParticipant object = new PropertyValueParticipant(
47: "ParticipantConfig", new PropertyValueObject("blubber"));
48: assertNull(object.getValue());
49: }
50:
51: public void testGetValueString() {
52: PropertyValueParticipant object = new PropertyValueParticipant(
53: "ParticipantConfig", new PropertyValueObject(
54: new PropertyValueParticipant(
55: "ParticipantConfig",
56: new PropertyValueObject("IOC_CONFIG"))));
57: assertEquals("pgsql", object.getValueString());
58: }
59:
60: public void testToString() {
61: PropertyValueParticipant object = new PropertyValueParticipant(
62: "ParticipantConfig", new PropertyValueObject(
63: "IOC_CONFIG"));
64: assertEquals("IOC_DATABASE", object.toString());
65: }
66:
67: public void testIsNeglectable() {
68: assertFalse(new PropertyValueParticipant("ParticipantConfig",
69: new PropertyValueObject("IOC_CONFIG")).isNeglectable());
70: }
71: }
|