001: /*BEGIN_COPYRIGHT_BLOCK
002: *
003: * Copyright (c) 2001-2007, JavaPLT group at Rice University (javaplt@rice.edu)
004: * All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions are met:
008: * * Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: * * Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in the
012: * documentation and/or other materials provided with the distribution.
013: * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
014: * names of its contributors may be used to endorse or promote products
015: * derived from this software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
018: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
019: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
020: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
021: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
022: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
023: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
024: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
025: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
026: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028: *
029: * This software is Open Source Initiative approved Open Source Software.
030: * Open Source Initative Approved is a trademark of the Open Source Initiative.
031: *
032: * This file is part of DrJava. Download the current version of this project
033: * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
034: *
035: * END_COPYRIGHT_BLOCK*/
036:
037: package edu.rice.cs.drjava.config;
038:
039: import edu.rice.cs.drjava.DrJavaTestCase;
040:
041: import java.util.ArrayList;
042:
043: /**
044: * Class according to the JUnit protocol. Tests
045: * the proper functionality of the class ForcedChoiceOption.
046: * @version $Id: ForcedChoiceOptionTest.java 4255 2007-08-28 19:17:37Z mgricken $
047: */
048: public final class ForcedChoiceOptionTest extends DrJavaTestCase {
049: /**
050: * @param name The name of this test case.
051: */
052: public ForcedChoiceOptionTest(String name) {
053: super (name);
054: }
055:
056: public void testGetName() {
057: ForcedChoiceOption fco = new ForcedChoiceOption(
058: "javadoc_access", "protected", null);
059:
060: assertEquals("javadoc_access", fco.getName());
061: }
062:
063: public void testParse() {
064: ArrayList<String> aList = new ArrayList<String>(4);
065:
066: aList.add("public");
067: aList.add("protected");
068: aList.add("package");
069: aList.add("private");
070: ForcedChoiceOption fco = new ForcedChoiceOption(
071: "javadoc_access", "protected", aList);
072:
073: assertTrue("Parsing \"private\"", "private".equals(fco
074: .parse("private")));
075: try {
076: fco.parse("Private");
077: fail();
078: } catch (OptionParseException e) {
079: }
080:
081: try {
082: fco.parse("true");
083: fail();
084: } catch (OptionParseException e) {
085: }
086:
087: try {
088: fco.parse(".33");
089: fail();
090: } catch (OptionParseException e) {
091: }
092: }
093:
094: public void testFormat() {
095: ForcedChoiceOption fco = new ForcedChoiceOption(
096: "javadoc_access", "protected", null);
097:
098: assertTrue("Formatting \"private\"", "private".equals(fco
099: .format("private")));
100: assertTrue("Formatting \"public\"", "public".equals(fco
101: .format("public")));
102: }
103: }
|