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.HashAttributeSet;
023:
024: import junit.framework.TestCase;
025:
026: public class MediaTest extends TestCase {
027:
028: public static void main(String[] args) {
029: junit.textui.TestRunner.run(MediaTest.class);
030: }
031:
032: static {
033: System.out.println("Media testing...");
034: }
035:
036: /*
037: * equals(Object object) method testing.
038: */
039: public final void testEqualsObject() {
040: Media name = MediaName.NA_LETTER_WHITE;
041: Media sizename = MediaSizeName.INVOICE;
042: assertTrue(name.equals(MediaName.NA_LETTER_WHITE));
043: assertFalse(name.equals(sizename));
044:
045: name = new mediaName(1);
046: Media tray = new mediaTray(1);
047: assertFalse(name.equals(tray));
048:
049: sizename = null;
050: assertFalse(name.equals(sizename));
051: }
052:
053: /*
054: * getCategory() method testing.
055: */
056: public final void testGetCategory() {
057: Media m = new media(1);
058: assertEquals(Media.class, m.getCategory());
059: }
060:
061: /*
062: * getName() method testing.
063: */
064: public final void testGetName() {
065: Media m = new media(1);
066: assertEquals("media", m.getName());
067: }
068:
069: /*
070: * Test that MadiaName, MediaSizeName, MediaTray are
071: * fall into the Media attribute Category
072: */
073: public final void testMediaCategory() {
074:
075: HashAttributeSet aset = new HashAttributeSet();
076:
077: MediaSizeName msn = MediaSizeName.ISO_A3;
078: aset.add(msn);
079: assertEquals(msn, aset.get(Media.class));
080: assertNull(aset.get(MediaSizeName.class));
081:
082: MediaTray mt = MediaTray.BOTTOM;
083: aset.add(mt);
084: assertEquals(mt, aset.get(Media.class));
085: assertNull(aset.get(MediaTray.class));
086:
087: MediaName mn = MediaName.ISO_A4_WHITE;
088: aset.add(mn);
089: assertEquals(mn, aset.get(Media.class));
090: assertNull(aset.get(MediaName.class));
091: }
092:
093: /*
094: * Auxiliary class
095: */
096: public class media extends Media {
097:
098: public media(int value) {
099: super (value);
100: }
101: }
102:
103: /*
104: * Auxiliary class
105: */
106: public class mediaName extends MediaName {
107:
108: public mediaName(int value) {
109: super (value);
110: }
111: }
112:
113: /*
114: * Auxiliary class
115: */
116: public class mediaTray extends MediaTray {
117:
118: public mediaTray(int value) {
119: super(value);
120: }
121: }
122: }
|