01: package edu.iu.uis.eden.services.docelements;
02:
03: import org.jdom.Element;
04:
05: import edu.iu.uis.eden.WorkflowServiceErrorImpl;
06: import edu.iu.uis.eden.services.IDocElement;
07: import edu.iu.uis.eden.services.ServiceErrorConstants;
08:
09: public class TestNameElement extends IDocInterfaceTestTemplate {
10: private NameElement nameEl = new NameElement();
11:
12: public TestNameElement(String s) {
13: super (s);
14: }
15:
16: protected void setUp() {
17: nameEl = new NameElement();
18: }
19:
20: protected void tearDown() {
21: }
22:
23: public IDocElement getIDocElement() {
24: return this .nameEl;
25: }
26:
27: /**
28: * no its not
29: */
30: public void testIsRouteControl() {
31: assertEquals(
32: "name element is returning true to isRouteControl",
33: false, this .nameEl.isRouteControl());
34:
35: //try to set it and recheck
36: this .nameEl.setRouteControl(true);
37: assertEquals(
38: "name element is returning true to isRouteControl",
39: false, this .nameEl.isRouteControl());
40: }
41:
42: /**
43: * we know from GenericStringElement it's making good xml but can
44: * it load from it?
45: */
46: public void testLoadFromXMLContent() {
47: String daNameVal = "ryan";
48: this .nameEl.setName(daNameVal);
49:
50: Element element = this .nameEl.getXMLContent();
51:
52: //is the element the correct name?
53: assertEquals("xml representation element given incorrect name",
54: this .nameEl.getElementName(), element.getName());
55:
56: NameElement aNameEl = new NameElement();
57:
58: try {
59: aNameEl.loadFromXMLContent(element, false);
60: assertEquals(
61: "didn't properly load props from self generated "
62: + "xml", daNameVal, aNameEl.getName());
63: } catch (Exception ex) {
64: fail("threw exception loading from self generated xml");
65: }
66: }
67:
68: /**
69: * is it returning the correct error code.
70: */
71: public void testValidate() {
72: try {
73: WorkflowServiceErrorImpl error = this .nameEl.validate();
74: assertEquals(
75: "NameElement not returning correct error constant",
76: ServiceErrorConstants.NAME_BLANK, error.getKey());
77: } catch (Exception ex) {
78: fail("threw exception validating");
79: }
80: }
81: }
82:
83: /*
84: * Copyright 2003 The Trustees of Indiana University. All rights reserved.
85: *
86: * This file is part of the EDEN software package.
87: * For license information, see the LICENSE file in the top level directory
88: * of the EDEN source distribution.
89: */
|