From b1aa24d911c75e3646c59dea58b685625f108e5d Mon Sep 17 00:00:00 2001 From: Timothy Wall Date: Mon, 6 May 2013 09:04:02 -0400 Subject: [PATCH] add test for loading from path with unicode characters (fails on XP, at least) --- test/com/sun/jna/JNAUnloadTest.java | 22 ++++++++++++++++++++-- test/com/sun/jna/LastErrorTest.java | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/test/com/sun/jna/JNAUnloadTest.java b/test/com/sun/jna/JNAUnloadTest.java index 1e26357427..6250cb03f0 100644 --- a/test/com/sun/jna/JNAUnloadTest.java +++ b/test/com/sun/jna/JNAUnloadTest.java @@ -18,6 +18,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.util.Properties; import junit.framework.TestCase; @@ -99,7 +100,7 @@ public void testAvoidResourcePathLoading() throws Exception { } } - // Fails under clover + // GC Fails under clover public void testLoadAndUnloadFromJar() throws Exception { ClassLoader loader = new TestLoader(true); Class cls = Class.forName("com.sun.jna.Native", true, loader); @@ -153,7 +154,7 @@ public void testLoadAndUnloadFromJar() throws Exception { } } - // Fails under clover and OpenJDK(linux/ppc) + // GC Fails under clover and OpenJDK(linux/ppc) public void testLoadAndUnloadFromResourcePath() throws Exception { ClassLoader loader = new TestLoader(false); Class cls = Class.forName("com.sun.jna.Native", true, loader); @@ -205,6 +206,23 @@ public void testLoadAndUnloadFromResourcePath() throws Exception { } } + public void testLoadFromUnicodePath() throws Exception { + final String UNICODE = getName() + "-\u0444\u043b\u0441\u0432\u0443"; + File tmpdir = Native.getTempDir(); + File unicodeDir = new File(tmpdir, UNICODE); + unicodeDir.mkdirs(); + Properties props = System.getProperties(); + try { + System.setProperty("jna.tmpdir", unicodeDir.getAbsolutePath()); + ClassLoader loader = new TestLoader(true); + Class cls = Class.forName("com.sun.jna.Native", true, loader); + assertEquals("Wrong class loader", loader, cls.getClassLoader()); + } + finally { + System.setProperties(props); + } + } + public static void main(String[] args) { junit.textui.TestRunner.run(JNAUnloadTest.class); } diff --git a/test/com/sun/jna/LastErrorTest.java b/test/com/sun/jna/LastErrorTest.java index ff7692d975..a900428308 100644 --- a/test/com/sun/jna/LastErrorTest.java +++ b/test/com/sun/jna/LastErrorTest.java @@ -102,7 +102,7 @@ public void testThrowLastErrorDirect() { } catch(LastErrorException e) { assertEquals("Exception should contain error code", ERROR, e.getErrorCode()); - assertTrue("Exception should include error message: " + e.getMessage(), e.getMessage().length() > 10); + assertTrue("Exception should include error message: " + e.getMessage(), e.getMessage().length() > 0); } }