[armedbear-cvs] r12424 - in trunk/abcl/test: lisp/abcl src/org/armedbear/lisp

Mark Evenson mevenson at common-lisp.net
Sat Feb 6 15:22:48 UTC 2010


Author: mevenson
Date: Sat Feb  6 10:22:47 2010
New Revision: 12424

Log:
Further tests for jar pathnames.

jar-file.lisp now has network based FASL loads.

Additional associated Java unit tests.



Added:
   trunk/abcl/test/src/org/armedbear/lisp/UtilitiesTest.java
Modified:
   trunk/abcl/test/lisp/abcl/jar-file.lisp
   trunk/abcl/test/src/org/armedbear/lisp/PathnameTest.java
   trunk/abcl/test/src/org/armedbear/lisp/StreamTest.java

Modified: trunk/abcl/test/lisp/abcl/jar-file.lisp
==============================================================================
--- trunk/abcl/test/lisp/abcl/jar-file.lisp	(original)
+++ trunk/abcl/test/lisp/abcl/jar-file.lisp	Sat Feb  6 10:22:47 2010
@@ -128,6 +128,50 @@
       (load "jar:file:baz.jar!/a/b/eek.lisp"))
   t)
 
+;;; wrapped in PROGN for easy disabling without a network connection
+;;; XXX come up with a better abstraction
+(progn 
+  (deftest jar-file.load.11
+      (load "jar:http://abcl-dynamic-install.googlecode.com/files/baz.jar!/foo")
+    t)
+
+  (deftest jar-file.load.12
+      (load "jar:http://abcl-dynamic-install.googlecode.com/files/baz.jar!/bar")
+    t)
+
+  (deftest jar-file.load.13
+      (load "jar:http://abcl-dynamic-install.googlecode.com/files/baz.jar!/bar.abcl")
+    t)
+
+  (deftest jar-file.load.14
+      (load "jar:http://abcl-dynamic-install.googlecode.com/files/baz.jar!/eek")
+    t)
+
+  (deftest jar-file.load.15
+      (load "jar:http://abcl-dynamic-install.googlecode.com/files/baz.jar!/eek.lisp")
+    t)
+
+  (deftest jar-file.load.16
+      (load "jar:http://abcl-dynamic-install.googlecode.com/files/baz.jar!/a/b/foo")
+    t)
+
+  (deftest jar-file.load.17
+      (load "jar:http://abcl-dynamic-install.googlecode.com/files/baz.jar!/a/b/bar")
+    t)
+
+  (deftest jar-file.load.18
+      (load "jar:http://abcl-dynamic-install.googlecode.com/files/baz.jar!/a/b/bar.abcl")
+    t)
+
+  (deftest jar-file.load.19
+      (load "jar:http://abcl-dynamic-install.googlecode.com/files/baz.jar!/a/b/eek")
+    t)
+
+  (deftest jar-file.load.20
+      (load "jar:http://abcl-dynamic-install.googlecode.com/files/baz.jar!/a/b/eek.lisp")
+    t))
+
+
 (deftest jar-file.probe-file.1
     (with-jar-file-init
         (probe-file "jar:file:baz.jar!/eek.lisp"))
@@ -164,7 +208,7 @@
 
 (deftest jar-file.merge-pathnames.2
     (merge-pathnames 
-     "/bar.abcl" #p"jar:file:baz.jar!/foo/")
+     "bar.abcl" #p"jar:file:baz.jar!/foo/")
   #p"jar:file:baz.jar!/foo/bar.abcl")
 
 (deftest jar-file.merge-pathnames.3
@@ -172,6 +216,11 @@
      "jar:file:baz.jar!/foo" "bar")
   #p"jar:file:baz.jar!/foo")
 
+(deftest jar-file.merge-pathnames.4
+    (merge-pathnames 
+     "jar:file:baz.jar!/foo" "/a/b/c")
+  #p"jar:file:/a/b/baz.jar!/foo")
+
 (deftest jar-file.truename.1
     (signals-error (truename "jar:file:baz.jar!/foo")
                    'file-error)

Modified: trunk/abcl/test/src/org/armedbear/lisp/PathnameTest.java
==============================================================================
--- trunk/abcl/test/src/org/armedbear/lisp/PathnameTest.java	(original)
+++ trunk/abcl/test/src/org/armedbear/lisp/PathnameTest.java	Sat Feb  6 10:22:47 2010
@@ -38,7 +38,7 @@
   
   @Test
   public void getInputStream() throws IOException {
-    File file = File.createTempFile("foo", "lisp");
+    File file = File.createTempFile("foo", ".lisp");
     FileWriter output = new FileWriter(file);
     String contents = "(defun foo () 42)";
     output.append(contents);
@@ -53,6 +53,52 @@
       result.append(buffer, 0, i);
     }
     assertEquals(contents, result.toString());
+    input.close();
     file.delete();
   }
+
+  @Test
+  public void copyConstructor() {
+      Pathname orig = new Pathname("/a/b/c/d/e/foo.lisp");
+      Pathname copy = new Pathname(orig.getNamestring());
+      assertTrue(orig.getNamestring().equals(copy.getNamestring()));
+  }
+
+  @Test
+  public void mergePathnames1() {
+      Pathname p = new Pathname("a/b/c/d/foo.lisp");
+      Pathname d = new Pathname("/foo/bar/there");
+      Pathname r = Pathname.mergePathnames(p, d);
+      String s = r.getNamestring();
+      assertTrue(s.equals("/foo/bar/a/b/c/d/foo.lisp"));
+  }
+
+  @Test
+  public void mergePathnames2() {
+      Pathname p = new Pathname("/a/b/c/d/foo.lisp");
+      Pathname d = new Pathname("/foo/bar/there");
+      Pathname r = Pathname.mergePathnames(p, d);
+      assertTrue(r.getNamestring().equals("/a/b/c/d/foo.lisp"));
+  }
+
+  @Test
+  public void mergePathnames3() {
+      LispObject args = Lisp.NIL;
+      args = args.push(Keyword.TYPE);
+      args = args.push(new SimpleString("abcl-tmp"));
+      args = args.nreverse();
+      Pathname p = Pathname.makePathname(args);
+      Pathname d = new Pathname("/foo/bar.abcl");
+      Pathname r = Pathname.mergePathnames(p, d);
+      assertTrue(r.getNamestring().equals("/foo/bar.abcl-tmp"));
+  }
+
+  @Test
+  public void mergePathnames4() {
+      Pathname p = new Pathname("jar:file:foo.jar!/bar.abcl");
+      Pathname d = new Pathname("/a/b/c/");
+      Pathname r = Pathname.mergePathnames(p, d);
+      String s = r.getNamestring();
+      assertTrue(s.equals("jar:file:/a/b/c/foo.jar!/bar.abcl"));
+  }
 }

Modified: trunk/abcl/test/src/org/armedbear/lisp/StreamTest.java
==============================================================================
--- trunk/abcl/test/src/org/armedbear/lisp/StreamTest.java	(original)
+++ trunk/abcl/test/src/org/armedbear/lisp/StreamTest.java	Sat Feb  6 10:22:47 2010
@@ -26,6 +26,7 @@
     Stream in = new Stream(Symbol.SYSTEM_STREAM, pathname.getInputStream(), Symbol.CHARACTER);
     LispObject o = in.read(false, Lisp.EOF, false, LispThread.currentThread());
     assertFalse(o.equals(Lisp.NIL));
+    in._close();
     file.delete();
   }
 }   
\ No newline at end of file

Added: trunk/abcl/test/src/org/armedbear/lisp/UtilitiesTest.java
==============================================================================
--- (empty file)
+++ trunk/abcl/test/src/org/armedbear/lisp/UtilitiesTest.java	Sat Feb  6 10:22:47 2010
@@ -0,0 +1,53 @@
+package org.armedbear.lisp;
+
+import java.io.FileNotFoundException;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import org.junit.Test;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import org.junit.Before;
+
+public class UtilitiesTest
+{
+   File zipFile;
+
+
+   @Before
+   public void setup() {
+       // XXX currently created by the ABCL Lisp based tests
+       zipFile = new File("test/lisp/abcl/baz.jar");
+       assertTrue(zipFile.canRead());
+   }
+
+
+  @Test
+  public void getZipEntry() throws FileNotFoundException, IOException {
+      FileInputStream inputFile = new FileInputStream(zipFile);
+      ZipInputStream input = new ZipInputStream(inputFile);
+      ZipEntry entry = Utilities.getEntry(input, "a/b/bar.abcl");
+      assertNotNull(entry);
+      input.close();
+      inputFile.close();
+  }
+
+  @Test
+  public void getZipInputStreamZipEntry() throws FileNotFoundException, IOException {
+      JarFile jar = new JarFile(zipFile);
+      Pathname pathname = new Pathname("a/b/bar.abcl");
+      InputStream entryInputStream = Utilities.getInputStream(jar, pathname);
+      assertNotNull(entryInputStream);
+      ZipInputStream zip = new ZipInputStream(entryInputStream);
+      assertNotNull(zip);
+      ZipEntry entry = Utilities.getEntry(zip, "bar._");
+      assertNotNull(entry);
+  }
+    
+}   
\ No newline at end of file




More information about the armedbear-cvs mailing list