[Nodal-cvs] j-test/src/test/storage/jar Suite.java,NONE,1.1 TestJarRepository.java,NONE,1.1
Status: Pre-Alpha
Brought to you by:
leei
From: Lee I. <le...@us...> - 2004-10-03 19:43:44
|
Update of /cvsroot/nodal/j-test/src/test/storage/jar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12471/src/test/storage/jar Added Files: Suite.java TestJarRepository.java Log Message: First commit separating j-test from j-src --- NEW FILE: Suite.java --- /* * Distributed under the Apache Software License, Version 1.1 * (see below, or the file LICENSE for terms and conditions) * * Copyright (c) 2004 University of British Columbia. All rights reserved. * * Created on Feb 29, 2004 by leei */ package test.storage.jar; import junit.framework.Test; import junit.framework.TestSuite; /** * @author leei */ public class Suite extends TestSuite { /** * */ public Suite() { super(); } public static Test suite() { TestSuite result = new TestSuite ("Test storage.jar"); // Add calls to test cases here! result.addTestSuite(TestJarRepository.class); return result; } public static void main(String[] args) { junit.textui.TestRunner.run (suite()); } } --- NEW FILE: TestJarRepository.java --- /* * Distributed under the Apache Software License, Version 1.1 (see below, or the * file LICENSE for terms and conditions) * * Copyright (c) 2004 University of British Columbia. All rights reserved. * * Created on Feb 29, 2004 by leei */ package test.storage.jar; import java.net.URL; import org.nodal.Nodal; import org.nodal.Repository; import org.nodal.filesystem.Document; import org.nodal.model.Node; import org.nodal.nav.Path; import org.nodal.type.NodeType; import junit.framework.TestCase; /** * @author leei */ public class TestJarRepository extends TestCase { Repository jarRepo; /** * */ public TestJarRepository() { super(); // TODO Auto-generated constructor stub } protected void setUp() { try { Class reClass = Class.forName("gnu.regexp.RE"); URL url = reClass.getClassLoader().getResource("gnu/regexp/RE.class"); jarRepo = Nodal.openRepository(url.toExternalForm()); if (jarRepo == null) { fail ("Unable to find gnu/regexp/RE.class!"); } } catch (ClassNotFoundException e) { e.printStackTrace(System.err); fail("Unable to load org.jdom.Document"); } catch (Path.Failure e) { e.printStackTrace(System.err); fail(); } } protected void tearDown() { if (jarRepo != null) { jarRepo.close(); } } public void testBasic() { try { Document manifest = jarRepo.document("META-INF/MANIFEST.MF"); assertTrue(manifest != null); Node root = manifest.root(); assertTrue(root != null); NodeType rootType = root.nodeType(); assertTrue(rootType != null); System.out.println(manifest); } catch (Path.Failure e) { e.printStackTrace(System.err); fail("Parsing META-INF/MANIFEST.MF"); } } } |