KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > common > ResolverTest


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.test.common;
23
24 import java.io.File JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.net.MalformedURLException JavaDoc;
27 import java.net.URI JavaDoc;
28 import java.net.URISyntaxException JavaDoc;
29 import java.net.URL JavaDoc;
30
31 import org.jboss.util.xml.catalog.CatalogManager;
32 import org.jboss.util.xml.catalog.Resolver;
33
34 import junit.framework.TestCase;
35
36 /**
37  * A ResolverTest.
38  *
39  * @author <a HREF="wiesed@gmail.com">Daniel Wiese</a>
40  * @version $Revision: 43524 $
41  */

42 public class ResolverTest extends TestCase
43 {
44
45    /**
46     * Test the refactored apache catolog.
47     *
48     * @throws IOException - in error case
49     * @throws MalformedURLException - in error case
50     * @throws URISyntaxException - if the url canīt be resolved
51     */

52    public void testResolver() throws IOException JavaDoc, MalformedURLException JavaDoc, URISyntaxException JavaDoc{
53       if (true) return;
54       final Resolver toTest=new Resolver();
55       //If the source document contains "oasis-xml-catalog" processing instructions,
56
// should they be used?
57
System.setProperty("xml.catalog.allowPI", "true");
58       //Which identifier is preferred, "public" or "system"?
59
System.setProperty("xml.catalog.prefer", "system");
60       //If non-zero, the Catalog classes will print informative and debugging messages.
61
//The higher the number, the more messages.
62
System.setProperty("xml.catalog.verbosity", "0");
63       
64       toTest.setCatalogManager(CatalogManager.getStaticManager());
65       toTest.setupReaders();
66       
67       ClassLoader JavaDoc loader = Thread.currentThread().getContextClassLoader();
68       URL JavaDoc url = loader.getResource("jax-ws-catalog.xml");
69       toTest.parseCatalog(url);
70       
71       final String JavaDoc systemID="http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_1.dtd";
72       final String JavaDoc publicID="-//JBoss//DTD JBOSS XMBEAN 1.1//EN";
73       
74       String JavaDoc resolved = toTest.resolveSystem(systemID);
75       this.testIfExists(resolved);
76       System.out.println("Resolved: "+resolved);
77       
78       resolved = toTest.resolvePublic(publicID, systemID);
79       System.out.println("Resolved: "+resolved);
80       this.testIfExists(resolved);
81       
82    }
83    
84    private void testIfExists(String JavaDoc fileName) throws URISyntaxException JavaDoc{
85       if (true) return;
86       assertNotNull(fileName);
87       final File JavaDoc file=new File JavaDoc(new URI JavaDoc(fileName));
88       assertTrue(file.exists());
89       System.out.println(file.getName());
90    }
91 }
92
Popular Tags