mx4j/src/test/test/javax/management/loading MLetTest.java,1.15,1.16
Simone Bordet <[email protected]> Thu, 14 Oct 2004 07:47:43 +0000
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mx4j/mx4j/src/test/test/javax/management/loading
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14251/src/test/test/javax/management/loading
Modified Files:
MLetTest.java
Log Message:
Fixed bug #1041478: MLet loading libraries and having the library directory in classpath was overwriting library with 0 length file.
Index: MLetTest.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/test/test/javax/management/loading/MLetTest.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** MLetTest.java 4 Sep 2004 15:44:21 -0000 1.15
--- MLetTest.java 14 Oct 2004 07:47:40 -0000 1.16
***************
*** 618,621 ****
--- 618,677 ----
}
+ public void testFindLibraryWithLibraryDirectoryInClassPath() throws Exception
+ {
+ // Prepare the library
+ String library = "mlet";
+ String libraryName = System.mapLibraryName(library);
+ File libraryFile = new File(libraryName);
+ FileOutputStream fos = new FileOutputStream(libraryFile);
+ fos.write("library".getBytes());
+ fos.close();
+
+ assertTrue(libraryFile.exists());
+ assertTrue(libraryFile.length() > 0);
+
+ MLet mlet = new MLet(new URL[]{libraryFile.getCanonicalFile().getParentFile().toURL()});
+ Method method = mlet.getClass().getDeclaredMethod("findLibrary", new Class[]{String.class});
+ method.setAccessible(true);
+ String result = (String)method.invoke(mlet, new Object[]{library});
+
+ assertNotNull(result);
+ assertTrue(libraryFile.exists());
+ assertTrue(libraryFile.length() > 0);
+ }
+
+ public void testFindLibraryWithLibraryDirectoryNotInClassPath() throws Exception
+ {
+ // Prepare the library
+ String library = "mlet";
+ String libraryName = System.mapLibraryName(library);
+ File libraryFile = new File(libraryName);
+ FileOutputStream fos = new FileOutputStream(libraryFile);
+ fos.write("library".getBytes());
+ fos.close();
+
+ assertTrue(libraryFile.exists());
+ assertTrue(libraryFile.length() > 0);
+
+ MLet mlet = new MLet(new URL[]{libraryFile.getCanonicalFile().getParentFile().toURL()});
+
+ // Set the library directory to some temp directory
+ File temp = File.createTempFile("abc", null);
+ temp.deleteOnExit();
+ mlet.setLibraryDirectory(temp.getCanonicalFile().getParentFile().getCanonicalPath());
+
+ Method method = mlet.getClass().getDeclaredMethod("findLibrary", new Class[]{String.class});
+ method.setAccessible(true);
+ String result = (String)method.invoke(mlet, new Object[]{library});
+
+ assertNotNull(result);
+ assertTrue(libraryFile.exists());
+ assertTrue(libraryFile.length() > 0);
+
+ File tempLibrary = new File(mlet.getLibraryDirectory(), libraryName);
+ assertTrue(tempLibrary.exists());
+ assertTrue(tempLibrary.length() > 0);
+ }
+
public interface SimpleMBean
{
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl