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.net.URI;
023:
024: import junit.framework.TestCase;
025:
026: public class URISyntaxTest extends TestCase {
027:
028: public static void main(String[] args) {
029: junit.textui.TestRunner.run(URISyntaxTest.class);
030: }
031:
032: static {
033: System.out.println("URISyntax testing...");
034: }
035:
036: uriSyntax us1, us2;
037: URI uri1, uri2;
038:
039: /*
040: * URISyntax() constructor testing.
041: */
042: public final void testURISyntax() throws Exception {
043: uri1 = new URI("http://news.ngs.ru/more/14161.shtml");
044: us1 = new uriSyntax(uri1);
045:
046: try {
047: uri1 = null;
048: us1 = new uriSyntax(uri1);
049: fail("NullPointerException wasn't thrown when expected");
050: } catch (NullPointerException e) {
051: }
052:
053: }
054:
055: /*
056: * hashCode() method testing.
057: */
058: public final void testHashCode() throws Exception {
059: uri1 = new URI("http://www.ietf.org/rfc/rfc2396.txt");
060: us1 = new uriSyntax(uri1);
061: assertTrue(us1.hashCode() == us1.hashCode());
062:
063: uri1 = new URI("http://www.ietf.org/rfc/rfc2396.txt");
064: us1 = new uriSyntax(uri1);
065: uri2 = new URI("http://www.ietf.org/rfc/rfc2395.txt");
066: us2 = new uriSyntax(uri2);
067: assertFalse(us1.hashCode() == us2.hashCode());
068: }
069:
070: /*
071: * equals(Object object) method testing.
072: */
073: public final void testEqualsObject() throws Exception {
074: uri1 = new URI("http://www.melodi.ru/main/index.php#");
075: us1 = new uriSyntax(uri1);
076: assertTrue(us1.equals(us1));
077:
078: uri1 = new URI("http://www.ietf.org/rfc/rfc2396.txt");
079: us1 = new uriSyntax(uri1);
080: uri2 = new URI("http://www.ietf.org/rfc/rfc2395.txt");
081: us2 = new uriSyntax(uri2);
082: assertFalse(us1.equals(us2));
083: }
084:
085: /*
086: * getURI() method testing.
087: */
088: public final void testGetURI() throws Exception {
089: uri1 = new URI("http://www.melodi.ru/main/index.php#");
090: us1 = new uriSyntax(uri1);
091: assertEquals(uri1, us1.getURI());
092:
093: uri2 = new URI("http://www.ietf.org/rfc/rfc2395.txt");
094: us2 = new uriSyntax(uri2);
095: assertEquals(uri2, us2.getURI());
096: }
097:
098: /*
099: * Auxiliary class
100: */
101: public class uriSyntax extends URISyntax {
102:
103: public uriSyntax(URI uri) {
104: super(uri);
105: }
106: }
107:
108: }
|