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 MediaNameTest extends TestCase {
027:
028: public static void main(String[] args) {
029: junit.textui.TestRunner.run(MediaNameTest.class);
030: }
031:
032: static {
033: System.out.println("MediaName testing...");
034: }
035:
036: mediaName name;
037:
038: /*
039: * MediaName constructor testing.
040: */
041: public final void testMediaName() {
042: name = new mediaName(11);
043: assertEquals(11, name.getValue());
044: assertEquals("11", name.toString());
045:
046: name = new mediaName(1111);
047: assertEquals(1111, name.getValue());
048: assertEquals("1111", name.toString());
049: }
050:
051: /*
052: * getStringTable() method testing.
053: */
054: public void testGetStringTable() {
055: int quantity = 0;
056: mediaName mn = new mediaName(1);
057: String[] str = mn.getStringTableEx();
058: String[] str1 = { "na-letter-white", "na-letter-transparent",
059: "iso-a4-white", "iso-a4-transparent" };
060: for (int j = 0; j < str.length; j++) {
061: quantity++;
062: assertEquals(str1[j], str[j]);
063: }
064: assertEquals(4, quantity);
065: }
066:
067: /*
068: * getEnumValueTable() method testing.
069: */
070: public final void testGetEnumValueTable() {
071: int quantity = 0;
072: mediaName mn = new mediaName(1);
073: EnumSyntax[] table = mn.getEnumValueTableEx();
074: assertEquals(4, table.length);
075: }
076:
077: /*
078: * Checks that enumTable and stringTable are immutable for
079: * MediaName class
080: */
081: public final void testGetEnumValueTable1() {
082: name = new mediaName(1);
083: String[] str = name.getStringTableEx();
084: EnumSyntax[] table = name.getEnumValueTableEx();
085: str[1] = "media1";
086: table[1] = new mediaName(10);
087: //System.out.println(name.getEnumValueTable()[1]);
088: assertFalse(name.getEnumValueTableEx()[1].equals("media"));
089: assertFalse(name.getEnumValueTableEx()[1].equals(table[1]));
090: }
091:
092: /*
093: * Auxiliary class
094: */
095: public class mediaName extends MediaName {
096:
097: public mediaName(int value) {
098: super (value);
099: }
100:
101: public String[] getStringTableEx() {
102: return getStringTable();
103: }
104:
105: public EnumSyntax[] getEnumValueTableEx() {
106: return getEnumValueTable();
107: }
108: }
109: }
|