Author: mturk
Date: Fri Apr 17 08:10:41 2009
New Revision: 765896

URL: http://svn.apache.org/viewvc?rev=765896&view=rev
Log:
Test native Pointer class management

Modified:
    commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
    
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testcase.c?rev=765896&r1=765895&r2=765896&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Fri Apr 17 
08:10:41 2009
@@ -222,3 +222,15 @@
     
     return  ACR_PointerCreate(_E, (void *)d, callback);
 }
+
+ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test018)(ACR_JNISTDARGS, jobject p)
+{
+    
+    return  ACR_PointerCleanup(_E, p);
+}
+
+ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test019)(ACR_JNISTDARGS, jobject p)
+{
+    void *v = ACR_PointerGet(_E, p);
+    return v != NULL;
+}

Modified: 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java?rev=765896&r1=765895&r2=765896&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
 Fri Apr 17 08:10:41 2009
@@ -58,6 +58,8 @@
     private static native String[] test015(int d);
     private static native int   test016(int d);
     private static native Pointer test017(int d);
+    private static native int   test018(Pointer p);
+    private static native int   test019(Pointer p);
 
 
     protected void setUp()
@@ -256,4 +258,42 @@
         Thread.sleep(200);
     }
 
+    public void testPointerNativeClr()
+        throws Throwable
+    {
+        Pointer p = test017(0xcafebabe);
+        assertNotNull("Pointer",p);
+        int r = test018(p);
+        assertEquals("Result ", 0, r);
+        int c = test018(p);
+        // 70008 is ACR_INCLOMPLETE */
+        assertEquals("Result ", 70008, c);
+
+        p.free();
+        p = null;
+        System.gc();
+        // This should be enough for a gc
+        // from Pointer.finalize()
+        Thread.sleep(200);
+    }
+
+    public void testPointerNativePtrGet()
+        throws Throwable
+    {
+        Pointer p = test017(0xcafebabe);
+        assertNotNull("Pointer",p);
+        int r = test019(p);
+        assertEquals("Result ", 1, r);
+        p.free();
+        int c = test019(p);
+        // Second call must return NULL
+        assertEquals("Result ", 0, c);
+
+        p = null;
+        System.gc();
+        // This should be enough for a gc
+        // from Pointer.finalize()
+        Thread.sleep(200);
+    }
+
 }


Reply via email to