[Nodal-cvs] j-test/src/test/storage/file TestFileRepository.java,1.1,1.2
Status: Pre-Alpha
Brought to you by:
leei
From: Lee I. <le...@us...> - 2005-01-08 00:55:03
|
Update of /cvsroot/nodal/j-test/src/test/storage/file In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1818/src/test/storage/file Modified Files: TestFileRepository.java Log Message: Reflect IOException throws from Repository and Document access. Index: TestFileRepository.java =================================================================== RCS file: /cvsroot/nodal/j-test/src/test/storage/file/TestFileRepository.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestFileRepository.java 3 Oct 2004 19:42:25 -0000 1.1 --- TestFileRepository.java 8 Jan 2005 00:54:50 -0000 1.2 *************** *** 9,12 **** --- 9,13 ---- import java.io.IOException; import java.net.JarURLConnection; + import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; *************** *** 21,25 **** import org.nodal.nav.Path; import org.nodal.nav.Paths; - import org.nodal.nav.Path.Failure; import org.nodal.util.Name; --- 22,25 ---- *************** *** 31,36 **** public class TestFileRepository extends TestCase { /** ! * */ public TestFileRepository(String name) { --- 31,39 ---- public class TestFileRepository extends TestCase { + private URL url; + private URL dirUrl; + /** ! * */ public TestFileRepository(String name) { *************** *** 39,42 **** --- 42,51 ---- protected void setUp() { + url = Nodal.class.getClassLoader().getResource("baseTypes.nls"); + try { + dirUrl = new URL(url, "."); + } catch (MalformedURLException e) { + fail("Accessing directory of baseTypes.nls"); + } } *************** *** 45,50 **** public void testFiles() { - URL url = Nodal.class.getClassLoader().getResource("baseTypes.nls"); - if (url.getProtocol().equals("jar")) { try { --- 54,57 ---- *************** *** 83,94 **** 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(); } } ! } --- 90,119 ---- Iterator e = dir.entries(); while (e.hasNext()) { ! Name nm = (Name) e.next(); ! Document d1 = dir.get(nm.string()); ! System.out.println("Document: " + d1); } ! } catch (Path.Failure e) { ! fail(); ! } catch (IOException e) { fail(); } } ! public void testWrite() { ! Directory.Editor dir = null; ! try { ! String dirString = dirUrl.toExternalForm(); ! Repository r = Nodal.openRepository(dirString); ! dir = r.document(dirString).asDirectory().edit(); ! Document newText = dir.createDocument("test.txt", "text/plain"); ! System.out.println("Created " + newText.path().toURLString()); ! } catch (Path.Failure e) { ! fail(); ! } catch (IOException e) { ! fail(); ! } finally { ! dir.unlink("test.txt"); ! } ! } ! } \ No newline at end of file |