summaryrefslogtreecommitdiffstats
path: root/src/test/java/com/btr/proxy/search/desktop/win/DLLManagerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/btr/proxy/search/desktop/win/DLLManagerTest.java')
-rw-r--r--src/test/java/com/btr/proxy/search/desktop/win/DLLManagerTest.java78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/test/java/com/btr/proxy/search/desktop/win/DLLManagerTest.java b/src/test/java/com/btr/proxy/search/desktop/win/DLLManagerTest.java
new file mode 100644
index 0000000..0711a8c
--- /dev/null
+++ b/src/test/java/com/btr/proxy/search/desktop/win/DLLManagerTest.java
@@ -0,0 +1,78 @@
+package com.btr.proxy.search.desktop.win;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+import org.junit.AfterClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.btr.proxy.TestUtil;
+
+/*****************************************************************************
+ * Unit tests for DLL loading code.
+ * @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009
+ ****************************************************************************/
+
+@Ignore
+public class DLLManagerTest {
+
+ /*************************************************************************
+ * Reset system property at the end.
+ ************************************************************************/
+ @AfterClass
+ public static void teardown() {
+ System.setProperty(DLLManager.LIB_DIR_OVERRIDE, "");
+ }
+
+ /*************************************************************************
+ * Test method
+ * @throws IOException on error
+ ************************************************************************/
+ @Test
+ public void testFindLibFileOverride() throws IOException {
+ String path = TestUtil.class.getResource("/").getFile() + File.separator+"data"+File.separator+"win";
+ System.setProperty(DLLManager.LIB_DIR_OVERRIDE, path);
+ File actual = DLLManager.findLibFile();
+ assertTrue(actual.getAbsolutePath().contains(path));
+ }
+
+ /*************************************************************************
+ * Test method
+ * @throws IOException on error
+ ************************************************************************/
+ @Test
+ public void testFindLibFileDefault() throws IOException {
+ System.setProperty(DLLManager.LIB_DIR_OVERRIDE, "");
+ File actual = DLLManager.findLibFile();
+ assertTrue(actual.getAbsolutePath().contains("lib"+File.separator));
+ }
+
+ /*************************************************************************
+ * Test method
+ * @throws IOException on error
+ ************************************************************************/
+ @Test
+ public void testCleanupTempFiles() throws IOException {
+ File f1 = File.createTempFile(DLLManager.TEMP_FILE_PREFIX+"_ABC", DLLManager.DLL_EXTENSION);
+ assertTrue(f1.exists());
+ DLLManager.cleanupTempFiles();
+ assertFalse(f1.exists());
+ }
+
+ /*************************************************************************
+ * Test method
+ * @throws IOException on error
+ ************************************************************************/
+// @Test
+// public void testFileCopy() throws IOException {
+// URL originalFile = DLLManagerTest.class.getResource("/lib/proxy_util_w32.dll");
+// File tempFile = File.createTempFile(DLLManager.TEMP_FILE_PREFIX, DLLManager.TEMP_FILE_PREFIX);
+// DLLManager.copy(originalFile.openStream(), new FileOutputStream(tempFile));
+// assertTrue(tempFile.exists() && tempFile.length() == originalFile.length());
+// tempFile.delete();
+// }
+
+}
+