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;
021:
022: import java.util.Locale;
023:
024: import junit.framework.TestCase;
025:
026: public class TextSyntaxTest extends TestCase {
027:
028: public static void main(String[] args) {
029: junit.textui.TestRunner.run(TextSyntaxTest.class);
030: }
031:
032: static {
033: System.out.println("TextSyntax testing...");
034: }
035:
036: TextSyntax ts1, ts2;
037:
038: /*
039: * TextSyntax() constructor testing.
040: */
041: public final void testTextSyntax() {
042: try {
043: String str = null;
044: ts1 = new textSyntax(str, Locale.UK);
045: fail("NullPointerException wasn't trown when expected");
046: } catch (NullPointerException e) {
047: }
048:
049: ts1 = new textSyntax("text", null);
050: assertEquals(Locale.getDefault(), ts1.getLocale());
051: assertEquals("text", ts1.getValue());
052: }
053:
054: /*
055: * hashCode() method testing.
056: */
057: public final void testHashCode() {
058:
059: ts1 = new textSyntax("hello", Locale.UK);
060: ts2 = new textSyntax("hello", Locale.UK);
061: assertEquals(ts1, ts2);
062:
063: ts1 = new textSyntax("", Locale.UK);
064: ts2 = new textSyntax("", Locale.CANADA);
065: assertFalse(ts1 == ts2);
066: }
067:
068: /*
069: * equals(Object object) method testing.
070: */
071: public final void testEqualsObject() {
072:
073: ts1 = new textSyntax("text", Locale.UK);
074: ts2 = new textSyntax("text", Locale.UK);
075: assertTrue(ts1.equals(ts2));
076:
077: ts1 = new textSyntax(" a", Locale.UK);
078: ts2 = new textSyntax("a", Locale.UK);
079: assertFalse(ts1.equals(ts2));
080: }
081:
082: /*
083: * getLocale() method testing.
084: */
085: public final void testGetLocale() {
086: Locale locale = Locale.ITALY;
087: ts1 = new textSyntax("text", locale);
088: assertEquals(locale, ts1.getLocale());
089:
090: ts1 = new textSyntax("text", null);
091: assertNotNull(ts1.getLocale());
092: }
093:
094: /*
095: * getValue() method testing.
096: */
097: public final void testGetValue() {
098: ts1 = new textSyntax("Hello world!", null);
099: assertEquals("Hello world!", ts1.getValue());
100: }
101:
102: /*
103: * toString() method testing.
104: */
105: public final void testToString() {
106: Locale locale = Locale.ITALY;
107: ts1 = new textSyntax(" text ", locale);
108: assertEquals(" text ", ts1.toString());
109: }
110:
111: /*
112: * Auxiliary class
113: */
114: public class textSyntax extends TextSyntax {
115:
116: public textSyntax(String value, Locale locale) {
117: super(value, locale);
118: }
119: }
120:
121: }
|