001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Elena V. Sayapina
019: * @version $Revision: 1.3 $
020: */package javax.print.attribute.standard;
021:
022: import javax.print.attribute.EnumSyntax;
023:
024: import junit.framework.TestCase;
025:
026: /*
027: * @author esayapin
028: */
029:
030: public class PrinterStateReasonTest extends TestCase {
031:
032: public static void main(String[] args) {
033: junit.textui.TestRunner.run(PrinterStateReasonTest.class);
034: }
035:
036: static {
037: System.out.println("PrinterStateReason testing...");
038: }
039:
040: printerStateReason reason;
041:
042: /*
043: * JobStateReason constructor testing.
044: */
045: public final void testFinishings() {
046:
047: reason = new printerStateReason(0);
048: assertEquals(0, reason.getValue());
049:
050: reason = new printerStateReason(300);
051: assertEquals(300, reason.getValue());
052: assertEquals("300", reason.toString());
053: }
054:
055: /*
056: * getEnumValueTable(), getStringTable() methods testing.
057: */
058: public final void testGetStringTable() {
059:
060: int quantity = 0;
061: reason = new printerStateReason(1);
062: String[] str = reason.getStringTableEx();
063: EnumSyntax[] table = reason.getEnumValueTableEx();
064: assertEquals(str.length, table.length);
065: assertEquals(33, table.length);
066:
067: //Tests that StringTable isn't changed for PrinterStateReason
068: str = reason.getStringTableEx();
069: str[1] = "reason1";
070: //System.out.println(reason.getStringTable()[1]);
071: assertFalse(reason.getStringTableEx()[1].equals("reason1"));
072: }
073:
074: /*
075: * getCategory() method testing.
076: */
077: public final void testGetCategory() {
078: PrinterStateReason r = PrinterStateReason.DEVELOPER_LOW;
079: assertEquals(PrinterStateReason.class, r.getCategory());
080: }
081:
082: /*
083: * getName() method testing.
084: */
085: public final void testGetName() {
086: PrinterStateReason r = PrinterStateReason.COVER_OPEN;
087: assertEquals("printer-state-reason", r.getName());
088: }
089:
090: /*
091: * Auxiliary class
092: */
093: public class printerStateReason extends PrinterStateReason {
094:
095: public printerStateReason(int value) {
096: super (value);
097: }
098:
099: public String[] getStringTableEx() {
100: return getStringTable();
101: }
102:
103: public EnumSyntax[] getEnumValueTableEx() {
104: return getEnumValueTable();
105: }
106: }
107:
108: }
|