001: /*
002: * <copyright>
003: *
004: * Copyright 2001-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026: package org.cougaar.tools.csmart.util;
027:
028: import junit.framework.*;
029:
030: /**
031: * Unit test for class ArgValue.
032: */
033: public class ArgValueTest extends TestCase {
034:
035: private ArgValue av = null;
036: private ArgValue str = null;
037:
038: public ArgValueTest(String name) {
039: super (name);
040: }
041:
042: protected void setUp() {
043: av = new ArgValue("Value", new Integer(34));
044: str = new ArgValue("String:strval", ":");
045: }
046:
047: public void testConstruction() {
048: try {
049: ArgValue tmp = new ArgValue(null, new String());
050: fail("Expected IllegalArgumentException!");
051: } catch (IllegalArgumentException e) {
052: }
053:
054: try {
055: ArgValue tmp = new ArgValue(null, ":");
056: fail("Expected IllegalArgumentException!");
057: } catch (IllegalArgumentException e) {
058: }
059:
060: try {
061: ArgValue tmp = new ArgValue("This,Test", null);
062: fail("Expected IllegalArgumentException!");
063: } catch (IllegalArgumentException e) {
064: }
065:
066: try {
067: ArgValue tmp = new ArgValue("Thistest", ":");
068: fail("Expected IllegalArgumentException!");
069: } catch (IllegalArgumentException e) {
070: }
071:
072: try {
073: ArgValue tmp = new ArgValue(":test", ":");
074: fail("Expected IllegalArgumentException!");
075: } catch (IllegalArgumentException e) {
076: }
077: }
078:
079: public void testGetArg() {
080: assertEquals("1. Test getArg()", "Value", av.getArg());
081: assertEquals("2. Test getArg()", "String", str.getArg());
082: }
083:
084: public void testGetValue() {
085: assertEquals("1. Test getValue()", new Integer(34), av
086: .getValue());
087: assertEquals("2. Test getValue()", "strval", str.getValue());
088: }
089:
090: public void testSetValue() {
091: av.setValue(new String("New Val"));
092: assertEquals("Test setValue", "New Val", av.getValue());
093: }
094:
095: public void testEquals() {
096: ArgValue av1 = new ArgValue("Value1:val1", ":");
097: ArgValue av2 = new ArgValue("Value1:val1", ":");
098:
099: assertTrue("Test equals()", av1.equals(av2));
100: }
101:
102: public static Test suite() {
103: return new TestSuite(ArgValueTest.class);
104: }
105:
106: public static void main(String[] args) {
107: junit.textui.TestRunner.run(suite());
108: }
109: }
|