This project has retired. For details please refer to its
Attic page.
TestCastor xref
1/*2 * Copyright 2000-2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16packageorg.apache.jetspeed.services.registry;
1718import java.io.File;
19import java.io.FileReader;
2021import javax.xml.parsers.DocumentBuilder;
22import javax.xml.parsers.DocumentBuilderFactory;
2324import org.apache.jetspeed.test.JetspeedTestCase;
25import org.exolab.castor.mapping.Mapping;
26import org.exolab.castor.xml.Unmarshaller;
27import org.w3c.dom.Document;
28import org.w3c.dom.Node;
29import org.xml.sax.InputSource;
3031/***32 * TestCastor33 *34 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>35 * @version $Id: TestCastor.java,v 1.1 2004/04/07 22:02:42 jford Exp $36 */37publicclassTestCastorextendsJetspeedTestCase38 {
39publicTestCastor(String name)
40 {
41super(name);
42 }
4344/***45 * Start the tests.46 *47 * @param args the arguments. Not used48 */49publicstaticvoid main(String args[])
50 {
51 junit.awtui.TestRunner.main(new String[] { TestCastor.class.getName() });
52 }
5354publicvoid testUnMarshall()
55 {
56 System.out.println("This Test is for testing compatibility with new versions of Castor as they are released.");
57 String mapFile = "test/conf/registry-mapping.xml";
58 String registryFile = "test/conf/test-registry.xreg";
5960 File map = new File(mapFile);
61try62 {
63 Mapping mapping = new Mapping();
64 InputSource is = new InputSource(new FileReader(map));
65 is.setSystemId(mapFile);
66 mapping.loadMapping(is);
6768 DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
69 DocumentBuilder builder = dbfactory.newDocumentBuilder();
7071 Document d = builder.parse(new File(registryFile));
7273 Unmarshaller unmarshaller = new Unmarshaller(mapping);
74 RegistryFragment fragment = (RegistryFragment) unmarshaller.unmarshal((Node) d);
7576 }
77catch (Exception e)
78 {
79 e.printStackTrace();
80 fail("Error in mapping creation");
81 }
8283 }
8485 }