001: package edu.iu.uis.eden.services.docelements;
002:
003: import org.jdom.Element;
004:
005: import edu.iu.uis.eden.WorkflowServiceErrorImpl;
006: import edu.iu.uis.eden.services.IDocElement;
007: import edu.iu.uis.eden.services.ServiceErrorConstants;
008:
009: public class TestGenericLongElement extends IDocInterfaceTestTemplate {
010: private GenericLongElement longEl;
011: private String elementName = "longElement";
012: private boolean routeControl = false;
013: private String errorType = ServiceErrorConstants.CHART_BLANK;
014:
015: public TestGenericLongElement(String s) {
016: super (s);
017: }
018:
019: protected void setUp() {
020: longEl = new GenericLongElement(elementName, errorType,
021: routeControl);
022: }
023:
024: protected void tearDown() {
025: }
026:
027: public IDocElement getIDocElement() {
028: return this .longEl;
029: }
030:
031: /**
032: * is this thing building the element with the name we want
033: */
034: public void testGetXMLContent() {
035: this .longEl.setMyValue(1);
036:
037: Element element = this .longEl.getXMLContent();
038: assertNotNull("loaded but returned null on getXMLContent()",
039: element);
040:
041: assertEquals("didn't correctly make xml", this .elementName,
042: element.getName());
043: }
044:
045: /**
046: * this is more flexible than your normal Element and we can set route-control
047: * on and off at will providing implementation flexibility.
048: */
049: public void testIsRouteControl() {
050: assertEquals(
051: "didn't properly set routeControl prop from constructor",
052: this .routeControl, this .longEl.isRouteControl());
053:
054: //set it true and recheck
055: this .longEl.setRouteControl(true);
056: assertTrue(
057: "doesn't allow routeControl to be given a new value",
058: this .longEl.isRouteControl());
059: }
060:
061: public void testIsEmpty() {
062: assertTrue(
063: "empty just intantiated object returned false on isEmpty()",
064: this .longEl.isEmpty());
065:
066: //set a prop and retest
067: this .longEl.setMyValue(1);
068: assertEquals("loaded object returned true on isEmpty()", false,
069: this .longEl.isEmpty());
070: }
071:
072: /**
073: * given valid xml does GenericLongElement load correctly
074: */
075: public void testLoadFromXMLContent() {
076: long daValue = 1;
077: this .longEl.setMyValue(daValue);
078: this .longEl.getXMLContent();
079:
080: //make a new GenericLongElement and test for values
081: new GenericLongElement(this .elementName, this .errorType,
082: this .routeControl);
083:
084: assertEquals(
085: "didn't correctly load props from self generated xml",
086: daValue, this .longEl.getMyValue());
087: }
088:
089: /**
090: * is validate returning the correct error code;
091: */
092: public void testValidate() {
093: try {
094: WorkflowServiceErrorImpl error = this .longEl.validate();
095: assertEquals("didnt' return error code constructed with",
096: this .errorType, error.getKey());
097:
098: //load w/ a value should return null on validate
099: this .longEl.setMyValue(1);
100: assertNull("didn't return null on validate() when valid",
101: this .longEl.validate());
102: } catch (Exception ex) {
103: fail("threw exception validating");
104: }
105: }
106: }
107:
108: /*
109: * Copyright 2003 The Trustees of Indiana University. All rights reserved.
110: *
111: * This file is part of the EDEN software package.
112: * For license information, see the LICENSE file in the top level directory
113: * of the EDEN source distribution.
114: */
|