ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [04/50] [abbrv] incubator-ignite git commit: # ignite-117 : GridIpcSharedMemoryNativeLoaderSelfTest#testLoadIfLibFileWasCorrupted was added
Date Fri, 30 Jan 2015 08:34:36 GMT
# ignite-117 : GridIpcSharedMemoryNativeLoaderSelfTest#testLoadIfLibFileWasCorrupted was added


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/75544b27
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/75544b27
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/75544b27

Branch: refs/heads/ignite-71
Commit: 75544b271e92bf9abc64423a4fd4914265ff19ff
Parents: 1461271
Author: Artem SHutak <ashutak@gridgain.com>
Authored: Tue Jan 27 16:32:49 2015 +0300
Committer: Artem SHutak <ashutak@gridgain.com>
Committed: Tue Jan 27 16:32:49 2015 +0300

----------------------------------------------------------------------
 .../shmem/GridIpcSharedMemoryNativeLoader.java  |  2 +
 ...GridIpcSharedMemoryNativeLoaderSelfTest.java | 45 ++++++++++++++++++++
 2 files changed, 47 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75544b27/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/GridIpcSharedMemoryNativeLoader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/GridIpcSharedMemoryNativeLoader.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/GridIpcSharedMemoryNativeLoader.java
index 2795e03..cb001cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/GridIpcSharedMemoryNativeLoader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/shmem/GridIpcSharedMemoryNativeLoader.java
@@ -61,6 +61,8 @@ public class GridIpcSharedMemoryNativeLoader {
         return name.replaceAll("\\W+", "_");
     }
 
+    static String libFileName(){return LIB_NAME;}
+
     /**
      * @return Platform.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75544b27/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/GridIpcSharedMemoryNativeLoaderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/GridIpcSharedMemoryNativeLoaderSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/GridIpcSharedMemoryNativeLoaderSelfTest.java
new file mode 100644
index 0000000..bf2396c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/ipc/shmem/GridIpcSharedMemoryNativeLoaderSelfTest.java
@@ -0,0 +1,45 @@
+package org.apache.ignite.internal.util.ipc.shmem;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class GridIpcSharedMemoryNativeLoaderSelfTest extends TestCase {
+    private static final String DEFAULT_TMP_DIR = System.getProperty("java.io.tmpdir");
+    public static final String TMP_DIR_FOR_TEST = System.getProperty("user.home");
+    public static final String LOADED_FILE_NAME = System.mapLibraryName(GridIpcSharedMemoryNativeLoader.libFileName());
+
+    @Override
+    public void setUp() throws Exception {
+        System.setProperty("java.io.tmpdir", TMP_DIR_FOR_TEST);
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        System.setProperty("java.io.tmpdir", DEFAULT_TMP_DIR);
+    }
+
+    //TODO linux specific
+    public void testLoadIfLibFileWasCorrupted() throws Exception {
+        createCorruptedLibFile();
+
+        GridIpcSharedMemoryNativeLoader.load();
+    }
+
+    private void createCorruptedLibFile() throws IOException {
+        File loadedFile = new File(System.getProperty("java.io.tmpdir"), LOADED_FILE_NAME);
+
+        if (loadedFile.exists())
+            assertTrue("Could not delete libggshem file.",loadedFile.delete());
+        loadedFile.deleteOnExit();
+
+        assertTrue("Could not create new file.", loadedFile.createNewFile());
+
+        try (FileOutputStream out = new FileOutputStream(loadedFile)){
+            out.write("Corrupted information.\n".getBytes());
+        };
+    }
+}
\ No newline at end of file


Mime
View raw message