[Nodal-cvs] j-test/src/test/storage/file Suite.java,NONE,1.1 TestFileRepository.java,NONE,1.1
Status: Pre-Alpha
Brought to you by:
leei
From: Lee I. <le...@us...> - 2004-10-03 19:50:23
|
Update of /cvsroot/nodal/j-test/src/test/storage/file In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12471/src/test/storage/file Added Files: Suite.java TestFileRepository.java Log Message: First commit separating j-test from j-src --- NEW FILE: Suite.java --- package test.storage.file; import junit.framework.Test; import junit.framework.TestSuite; /** JUnit TestSuite. * @testfamily JUnit * @testkind testsuite * @testsetup Default TestSuite * @testpackage test.storage*/ public class Suite extends TestSuite { public Suite(String name) { super (name); } public static Test suite() { TestSuite result = new TestSuite ("Test storage.file"); // Add calls to test cases here! result.addTestSuite(TestFileRepository.class); return result; } public static void main(String[] args) { junit.textui.TestRunner.run (suite()); } } --- NEW FILE: TestFileRepository.java --- /* * Created on Nov 26, 2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package test.storage.file; import java.io.IOException; import java.net.JarURLConnection; import java.net.URL; import java.util.Iterator; import org.nodal.Nodal; import org.nodal.Repository; import org.nodal.filesystem.Directory; import org.nodal.filesystem.Document; import org.nodal.filesystem.DocumentFormat; import org.nodal.model.Node; import org.nodal.model.NodeContent; import org.nodal.nav.Path; import org.nodal.nav.Paths; import org.nodal.nav.Path.Failure; import org.nodal.util.Name; import junit.framework.TestCase; /** * @author leei */ public class TestFileRepository extends TestCase { /** * */ public TestFileRepository(String name) { super(name); } protected void setUp() { } protected void tearDown() { } public void testFiles() { URL url = Nodal.class.getClassLoader().getResource("baseTypes.nls"); if (url.getProtocol().equals("jar")) { try { JarURLConnection conn = (JarURLConnection) url.openConnection(); URL jarFile = conn.getJarFileURL(); url = new URL(jarFile, "../extras/baseTypes.nls"); System.out.println("Load baseTypes from " + url); } catch (IOException e1) { fail(); } } String fname = url.toExternalForm(); try { Path path = Paths.parse(fname); Repository r = Nodal.openRepository(path); assertNotNull(r); Path rel = r.path().difference(path); System.out.println("Repo: " + r.path()); System.out.println("Rel : " + rel); Document doc = r.document(rel); assertNotNull(doc); DocumentFormat format = doc.format(); assertNotNull(format); System.out.println("baseTypes.nls: format = " + format); Node root = doc.root(); System.out.println("baseTypes.nls: root = " + root); assertNotNull(root); NodeContent content = root.content(); System.out.println("baseTypes.nls: content = " + content); assertNotNull(content); Directory dir = r.document(".").asDirectory(); System.out.println("/: dir = " + dir); assertNotNull(dir); Iterator e = dir.entries(); while (e.hasNext()) { Name nm = (Name) e.next(); Document d1 = dir.get(nm.string()); System.out.println("Document: "+d1); } } catch (Failure e) { fail(); } } } |