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: public class FinishingsTest extends TestCase {
027:
028: public static void main(String[] args) {
029: junit.textui.TestRunner.run(FinishingsTest.class);
030: }
031:
032: static {
033: System.out.println("Finishings testing...");
034: }
035:
036: finishings fin;
037:
038: /*
039: * Finishings constructor testing.
040: */
041: public final void testFinishings() {
042:
043: Finishings finishings = new finishings(20);
044: assertEquals(20, finishings.getValue());
045:
046: fin = new finishings(40);
047: assertEquals(40, fin.getValue());
048:
049: finishings = Finishings.BIND;
050: assertEquals("bind", finishings.toString());
051: assertTrue(finishings.getValue() < 18);
052: assertTrue(finishings.getValue() > 0);
053:
054: }
055:
056: /*
057: * getCategory() method testing.
058: */
059: public final void testGetCategory() {
060:
061: Finishings finishings = Finishings.NONE;
062: assertEquals(Finishings.class, finishings.getCategory());
063: }
064:
065: /*
066: * getName() method testing.
067: */
068: public final void testGetName() {
069: Finishings finishings = Finishings.SADDLE_STITCH;
070: assertEquals("finishings", finishings.getName());
071: }
072:
073: /*
074: * getStringTable() method testing.
075: */
076: public final void testGetStringTable() {
077:
078: int quantity = 0;
079: fin = new finishings(20);
080: String[] str = fin.getStringTableEx();
081: for (int i = 0; i < str.length; i++) {
082: if (str[i] != null) {
083: quantity++;
084: }
085: //System.out.println(str[i]);
086: }
087: assertEquals(18, quantity);
088:
089: //Tests that StringTable isn't changed for Finishings
090: fin = new finishings(3);
091: str[3] = "finishings3";
092: //System.out.println((fin.getStringTableEx()[3]);
093: assertFalse(fin.getStringTableEx()[3].equals("finishings3"));
094:
095: Finishings finishings = Finishings.STAPLE_TOP_LEFT;
096: assertEquals("staple-top-left", finishings.toString());
097: }
098:
099: /*
100: * getEnumValueTable() method testing.
101: */
102: public final void testGetEnumValueTable() {
103: int quantity = 0;
104: fin = new finishings(20);
105: EnumSyntax[] table = fin.getEnumValueTableEx();
106: for (int i = 0; i < table.length; i++) {
107: if (table[i] != null) {
108: quantity++;
109: }
110: }
111: assertEquals(18, quantity);
112: }
113:
114: /*
115: * getOffset() method testing.
116: */
117: public final void testGetOffset() {
118: fin = new finishings(5);
119: assertEquals(3, fin.getOffsetEx());
120: }
121:
122: /*
123: * Auxiliary class
124: */
125: public class finishings extends Finishings {
126:
127: public finishings(int value) {
128: super (value);
129: }
130:
131: public String[] getStringTableEx() {
132: return getStringTable();
133: }
134:
135: public EnumSyntax[] getEnumValueTableEx() {
136: return getEnumValueTable();
137: }
138:
139: public int getOffsetEx() {
140: return getOffset();
141: }
142: }
143:
144: }
|