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: TestPropertyValueTemplate.java 3784 2007-06-11 16:44:35Z gbevin $
07: */
08: package com.uwyn.rife.ioc;
09:
10: import com.uwyn.rife.ioc.exceptions.TemplateFactoryUnknownException;
11: import com.uwyn.rife.template.Template;
12: import com.uwyn.rife.template.exceptions.TemplateNotFoundException;
13: import junit.framework.TestCase;
14:
15: public class TestPropertyValueTemplate extends TestCase {
16: public TestPropertyValueTemplate(String name) {
17: super (name);
18: }
19:
20: public void testInstantiation() {
21: PropertyValueTemplate object = new PropertyValueTemplate(
22: "enginehtml", "values");
23: assertNotNull(object);
24: assertFalse(object.isStatic());
25: }
26:
27: public void testGetValue() {
28: PropertyValueTemplate object = new PropertyValueTemplate(
29: "enginehtml", "values");
30: assertNotNull(object.getValue());
31: assertTrue(object.getValue() instanceof Template);
32: }
33:
34: public void testGetValueUnknownFactory() {
35: PropertyValueTemplate object = new PropertyValueTemplate(
36: "blah", "values");
37: try {
38: object.getValue();
39: fail("TemplateFactoryUnknownException wasn't thrown");
40: } catch (TemplateFactoryUnknownException e) {
41: assertEquals("blah", e.getType());
42: }
43: }
44:
45: public void testGetValueUnknownTemplate() {
46: PropertyValueTemplate object = new PropertyValueTemplate(
47: "enginehtml", "blahblihbloh");
48: try {
49: object.getValue();
50: fail("template 'blahblihbloh' shouldn't have been found");
51: } catch (TemplateNotFoundException e) {
52: assertEquals("blahblihbloh", e.getName());
53: }
54: }
55:
56: public void testGetValueString() {
57: PropertyValueTemplate object = new PropertyValueTemplate(
58: "enginehtml", "values");
59: assertEquals(
60: "[!V 'VALUE1'/]<!--V VALUE2/--><r:v name=\"VALUE3\"/>\n",
61: object.getValueString());
62: }
63:
64: public void testToString() {
65: PropertyValueTemplate object = new PropertyValueTemplate(
66: "enginehtml", "values");
67: assertEquals(
68: "[!V 'VALUE1'/]<!--V VALUE2/--><r:v name=\"VALUE3\"/>\n",
69: object.toString());
70: }
71:
72: public void testIsNeglectable() {
73: assertFalse(new PropertyValueTemplate("enginehtml", "values")
74: .isNeglectable());
75: }
76: }
|