Skip to content

Commit

Permalink
add test for loading from path with unicode characters (fails on XP, …
Browse files Browse the repository at this point in the history
…at least)
  • Loading branch information
twall committed May 6, 2013
1 parent 198cb1f commit b1aa24d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions test/com/sun/jna/JNAUnloadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Properties;

import junit.framework.TestCase;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion test/com/sun/jna/LastErrorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit b1aa24d

Please sign in to comment.