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 TestRuleIdElement extends IDocInterfaceTestTemplate {
010: private RuleIdElement ruleId;
011:
012: public TestRuleIdElement(String s) {
013: super (s);
014: }
015:
016: protected void setUp() {
017: ruleId = new RuleIdElement();
018: }
019:
020: protected void tearDown() {
021: }
022:
023: public IDocElement getIDocElement() {
024: return this .ruleId;
025: }
026:
027: /**
028: * set a value get the xml and load another ruleIdElement from that it shouldn't
029: * throw exceptions and it should have the same value.
030: */
031: public void testLoadFromXMLContent() {
032: long valueToTest = 1;
033: this .ruleId.setRuleId(valueToTest);
034:
035: Element element = this .ruleId.getXMLContent();
036:
037: RuleIdElement aruleId = new RuleIdElement();
038:
039: try {
040: aruleId.loadFromXMLContent(element, false);
041: assertEquals(
042: "didn't properly load props from self generated xml",
043: valueToTest, aruleId.getRuleId());
044: } catch (Exception ex) {
045: fail("threw exception loading from self generated XML");
046: }
047: }
048:
049: /**
050: * when empty it shoul come back w/ the correct type
051: */
052: public void testValidate() {
053: try {
054: WorkflowServiceErrorImpl err = this .ruleId.validate();
055: assertEquals(
056: "DocElementError returning incorrect Error Constant",
057: ServiceErrorConstants.RULE_ID_BLANK, err.getKey());
058:
059: //load with value shouldn't return an error on validate
060: this .ruleId.setRuleId(1);
061: assertNull("Valid object returned error", this .ruleId
062: .validate());
063: } catch (Exception ex) {
064: fail("threw exception validating");
065: }
066: }
067:
068: /**
069: * no it's not
070: */
071: public void testIsRouteControl() {
072: assertEquals("ruleId is not a route control", false,
073: this .ruleId.isRouteControl());
074:
075: //try to set and retest
076: this .ruleId.setRouteControl(true);
077: assertEquals("ruleId allows routeControl to be set true",
078: false, this .ruleId.isRouteControl());
079: }
080:
081: /**
082: * just check that the correct root element is being returned
083: * GenericLongElement guarantees the rest
084: */
085: public void testGetXMLContent() {
086: this .ruleId.setRuleId(1);
087:
088: //check the root tag name
089: Element element = this .ruleId.getXMLContent();
090: assertEquals("ruleId Element is the wrong name", this .ruleId
091: .getElementName(), element.getName());
092: }
093: }
094:
095: /*
096: * Copyright 2003 The Trustees of Indiana University. All rights reserved.
097: *
098: * This file is part of the EDEN software package.
099: * For license information, see the LICENSE file in the top level directory
100: * of the EDEN source distribution.
101: */
|