You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/04/16 09:13:34 UTC
svn commit: r1093940 - in /commons/sandbox/runtime/trunk: ./
src/main/java/org/apache/commons/runtime/
src/main/java/org/apache/commons/runtime/io/
src/main/java/org/apache/commons/runtime/platform/unix/
src/main/native/os/unix/ src/main/native/os/win3...
Author: mturk
Date: Sat Apr 16 07:13:33 2011
New Revision: 1093940
URL: http://svn.apache.org/viewvc?rev=1093940&view=rev
Log:
Misc fixes
Modified:
commons/sandbox/runtime/trunk/build.xml
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexImpl.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SemaphoreImpl.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Utils.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutexImpl.java
commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestArray.java
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestDirectByteBuffer.java
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMain.java
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMemory.java
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestReflect.java
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestSemaphore.java
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestString.java
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUnsafe.java
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUtils.java
Modified: commons/sandbox/runtime/trunk/build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/build.xml?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/build.xml (original)
+++ commons/sandbox/runtime/trunk/build.xml Sat Apr 16 07:13:33 2011
@@ -394,7 +394,7 @@ The Apache Software Foundation (http://w
<!-- Unit tests -->
<!-- =================================================================== -->
<target name="test" depends="tests">
- <runtest groups="init,core,private"/>
+ <runtest groups="init,core,private,${systemid.os}"/>
</target>
<target name="testsemaphore" depends="tests">
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java Sat Apr 16 07:13:33 2011
@@ -31,11 +31,9 @@ public abstract class Mutex
}
private static final MutexImpl impl;
- private static native MutexImpl impl0()
- throws OutOfMemoryError;
static {
- impl = impl0();
+ impl = MutexImpl.get();
}
protected String name;
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexImpl.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexImpl.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MutexImpl.java Sat Apr 16 07:13:33 2011
@@ -25,10 +25,23 @@ package org.apache.commons.runtime;
public abstract class MutexImpl
{
+ private static final MutexImpl impl;
+ private static native MutexImpl init0()
+ throws OutOfMemoryError;
+
+ static {
+ impl = init0();
+ }
+
protected MutexImpl()
{
// No Instance
}
+
+ public static final MutexImpl get()
+ {
+ return impl;
+ }
public abstract Mutex create(MutexType type, String name)
throws IllegalAccessException,
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java Sat Apr 16 07:13:33 2011
@@ -31,22 +31,36 @@ public abstract class Semaphore
}
private static final SemaphoreImpl impl;
- private static native SemaphoreImpl impl0()
- throws OutOfMemoryError;
static {
- impl = impl0();
+ impl = SemaphoreImpl.get();
}
protected String name;
protected boolean owner;
- public static final SemaphoreImpl getImpl()
- throws UnsupportedOperationException
+ public static Semaphore create(String name, int value)
+ throws IllegalAccessException,
+ IllegalArgumentException,
+ AlreadyExistsException,
+ UnsupportedOperationException,
+ SystemException
{
if (impl == null)
throw new UnsupportedOperationException(Local.sm.get("semaphore.ENOTIMPL"));
- return impl;
+ return impl.create(name, value);
+ }
+
+ public static Semaphore open(String name)
+ throws IllegalAccessException,
+ IllegalArgumentException,
+ NoSuchObjectException,
+ UnsupportedOperationException,
+ SystemException
+ {
+ if (impl == null)
+ throw new UnsupportedOperationException(Local.sm.get("semaphore.ENOTIMPL"));
+ return impl.open(name);
}
private static native boolean unlink0(String name);
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SemaphoreImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SemaphoreImpl.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SemaphoreImpl.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SemaphoreImpl.java Sat Apr 16 07:13:33 2011
@@ -24,12 +24,28 @@ package org.apache.commons.runtime;
*/
public abstract class SemaphoreImpl
{
+ private static final SemaphoreImpl impl;
+ private static native SemaphoreImpl init0()
+ throws OutOfMemoryError;
+
+ static {
+ impl = init0();
+ }
protected SemaphoreImpl()
{
// No Instance
}
+ public static final SemaphoreImpl get()
+ throws UnsupportedOperationException
+ {
+ if (impl == null)
+ throw new UnsupportedOperationException(Local.sm.get("semaphore.ENOTIMPL"));
+ return impl;
+ }
+
+
public abstract Semaphore create(String name, int value)
throws IllegalAccessException,
IllegalArgumentException,
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Utils.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Utils.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Utils.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Utils.java Sat Apr 16 07:13:33 2011
@@ -19,7 +19,7 @@
package org.apache.commons.runtime.io;
import java.io.FileDescriptor;
-class Utils
+public final class Utils
{
private Utils()
{
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutexImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutexImpl.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutexImpl.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixMutexImpl.java Sat Apr 16 07:13:33 2011
@@ -32,18 +32,18 @@ import org.apache.commons.runtime.System
final class PosixMutexImpl extends MutexImpl
{
- public PosixMutexImpl()
+ private PosixMutexImpl()
{
// No Instance
}
- private static native int dt0();
- private static final MutexType mtype;
- static
+ private PosixMutexImpl(int type)
{
- mtype = MutexType.valueOf(dt0());
+ mtype = MutexType.valueOf(type);
}
+ private static MutexType mtype;
+
public Mutex create(MutexType type, String name)
throws IllegalAccessException,
IllegalArgumentException,
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c Sat Apr 16 07:13:33 2011
@@ -75,9 +75,31 @@ typedef struct semblock_t {
acr_uint32_t value; /* Maximum semaphore value */
} semblock_t;
-ACR_UNX_EXPORT(jint, PosixMutexImpl, dt0)(JNI_STDARGS)
-{
- return _DEFAULT_MUTEX_TYPE;
+J_DECLARE_CLAZZ = {
+ INVALID_FIELD_OFFSET,
+ 0,
+ 0,
+ 0,
+ ACR_UNX_CP "PosixMutexImpl"
+};
+
+J_DECLARE_M_ID(0000) = {
+ 0,
+ "<init>",
+ "(I)V"
+};
+
+ACR_JNI_EXPORT(jobject, MutexImpl, init0)(JNI_STDARGS)
+{
+ if (_clazzn.u == 1)
+ return (*env)->NewObject(env, _clazzn.i, J4MID(0000), (jint)_DEFAULT_MUTEX_TYPE);
+ if (AcrLoadClass(env, &_clazzn, 0) != 0) {
+ ACR_THROW_MSG(ACR_EX_EINSTANCE, "PosixMutexImpl not initialized");
+ return 0;
+ }
+ R_LOAD_METHOD(0000, 0);
+ _clazzn.u = 1;
+ return (*env)->NewObject(env, _clazzn.i, J4MID(0000), (jint)_DEFAULT_MUTEX_TYPE);
}
ACR_UNX_EXPORT(jint, SysVMutex, create0)(JNI_STDARGS, jstring name)
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c Sat Apr 16 07:13:33 2011
@@ -48,7 +48,7 @@ J_DECLARE_M_ID(0000) = {
"()V"
};
-ACR_JNI_EXPORT(jobject, Semaphore, impl0)(JNI_STDARGS)
+ACR_JNI_EXPORT(jobject, SemaphoreImpl, init0)(JNI_STDARGS)
{
if (_clazzn.u == 1)
return (*env)->NewObject(env, _clazzn.i, J4MID(0000));
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c Sat Apr 16 07:13:33 2011
@@ -33,7 +33,7 @@ J_DECLARE_M_ID(0000) = {
"()V"
};
-ACR_JNI_EXPORT(jobject, Semaphore, impl0)(JNI_STDARGS)
+ACR_JNI_EXPORT(jobject, SemaphoreImpl, init0)(JNI_STDARGS)
{
if (_clazzn.u == 1)
return (*env)->NewObject(env, _clazzn.i, J4MID(0000));
Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestArray.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestArray.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestArray.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestArray.java Sat Apr 16 07:13:33 2011
@@ -35,8 +35,8 @@ public class TestArray
Array.copy(ia, 1, ba, 0, 3);
// bytes 0 .. 3 contains integer[1] (2)
// ### Assertion works on LSB machines only
- Assert.assertEquals(2, (int)ba[0] & 0xff);
- Assert.assertEquals(3, (int)ba[4] & 0xff);
- Assert.assertEquals(4, (int)ba[8] & 0xff);
+ Assert.assertEquals((int)ba[0] & 0xff, 2);
+ Assert.assertEquals((int)ba[4] & 0xff, 3);
+ Assert.assertEquals((int)ba[8] & 0xff, 4);
}
}
Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestDirectByteBuffer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestDirectByteBuffer.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestDirectByteBuffer.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestDirectByteBuffer.java Sat Apr 16 07:13:33 2011
@@ -26,33 +26,33 @@ import java.nio.ByteBuffer;
public class TestDirectByteBuffer
{
- public void malloc()
+ public void mallocDirectByteBuffer()
throws Exception
{
ByteBuffer bb = DirectByteBuffer.allocate(1000);
Assert.assertTrue(bb.isDirect());
- Assert.assertEquals(1000, bb.capacity());
+ Assert.assertEquals(bb.capacity(), 1000);
DirectByteBuffer.free(bb);
}
- public void calloc()
+ public void callocDirectByteBuffer()
throws Exception
{
ByteBuffer bb = DirectByteBuffer.allocateAndClear(1000);
Assert.assertTrue(bb.isDirect());
- Assert.assertEquals(1000, bb.capacity());
+ Assert.assertEquals(bb.capacity(), 1000);
DirectByteBuffer.free(bb);
}
- public void pointer()
+ public void allocateDirectByteBuffer()
throws Exception
{
// ptr, bb1 and bb2 share the same memory
Pointer ptr = Memory.malloc(1000);
ByteBuffer bb = DirectByteBuffer.allocate(ptr);
Assert.assertTrue(bb.isDirect());
- Assert.assertEquals(1000, bb.capacity());
+ Assert.assertEquals(bb.capacity(), 1000);
/*
* Call to the free crashes the JVM !
* Also call to the any operation on any
@@ -71,7 +71,7 @@ public class TestDirectByteBuffer
Pointer ptr = Memory.malloc(1000);
ByteBuffer bb = DirectByteBuffer.allocate(ptr);
Assert.assertTrue(bb.isDirect());
- Assert.assertEquals(1000, bb.capacity());
+ Assert.assertEquals(bb.capacity(), 1000);
try {
boolean test_me = Native.HAS_MAINTAINER_MODE;
ptr.free();
@@ -86,20 +86,20 @@ public class TestDirectByteBuffer
}
}
- public void memset()
+ public void memsetDirectByteBuffer()
throws Exception
{
ByteBuffer bb = DirectByteBuffer.allocate(1000);
Assert.assertTrue(bb.isDirect());
bb.putInt(0xcafebabe);
bb.rewind();
- Assert.assertEquals(0xcafebabe, bb.getInt());
+ Assert.assertEquals(bb.getInt(), 0xcafebabe);
DirectByteBuffer.set(bb, 0x55, 1000);
- Assert.assertEquals(0x55555555, bb.getInt());
+ Assert.assertEquals(bb.getInt(), 0x55555555);
DirectByteBuffer.free(bb);
}
- public void copy()
+ public void copyDirectByteBuffer()
throws Exception
{
ByteBuffer sb = DirectByteBuffer.allocate(1000);
@@ -109,7 +109,7 @@ public class TestDirectByteBuffer
sb.putInt(0xcafebabe);
DirectByteBuffer.copy(sb, 0, db, 4, 996);
Assert.assertEquals(0, db.getInt());
- Assert.assertEquals(0xcafebabe, db.getInt());
+ Assert.assertEquals(db.getInt(), 0xcafebabe);
DirectByteBuffer.free(sb);
DirectByteBuffer.free(db);
}
Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMain.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMain.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMain.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMain.java Sat Apr 16 07:13:33 2011
@@ -19,20 +19,20 @@ package org.apache.commons.runtime;
import org.testng.annotations.*;
import org.testng.Assert;
-
-@Test(groups = { "init" })
public class TestMain
{
- @BeforeSuite
+ @BeforeSuite(groups = { "init" })
public void setUp()
{
Assert.assertTrue(Loader.load());
+ System.out.flush();
}
- @AfterSuite
+ @AfterSuite(groups = { "init" })
public void shutDown()
{
Native.terminate();
+ System.out.flush();
}
}
Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMemory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMemory.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMemory.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMemory.java Sat Apr 16 07:13:33 2011
@@ -43,12 +43,12 @@ public class TestMemory
public void align()
throws Exception
{
- Assert.assertEquals(4, Memory.align(3, 4));
- Assert.assertEquals(8, Memory.align(3));
- Assert.assertEquals(0, Memory.align(0));
- Assert.assertEquals(0, Memory.align(-3));
- Assert.assertEquals(-8, Memory.align(-8));
- Assert.assertEquals(16L, Memory.align(1L, 16));
+ Assert.assertEquals(Memory.align(3, 4), 4);
+ Assert.assertEquals(Memory.align(3), 8);
+ Assert.assertEquals(Memory.align(0), 0);
+ Assert.assertEquals(Memory.align(-3), 0);
+ Assert.assertEquals(Memory.align(-8), -8);
+ Assert.assertEquals(Memory.align(1L, 16), 16);
}
@Test(groups = { "private" }, expectedExceptions={ NullPointerException.class })
@@ -98,8 +98,8 @@ public class TestMemory
Memory.set(p, 0, 1000, 0xFF);
byte[] b = Memory.toByteArray(p, 0, 1000);
Assert.assertNotNull(b);
- Assert.assertEquals(1000, b.length);
- Assert.assertEquals((byte)0xFF, b[0]);
+ Assert.assertEquals(b.length, 1000);
+ Assert.assertEquals(b[0], (byte)0xFF);
p.free();
}
Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestReflect.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestReflect.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestReflect.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestReflect.java Sat Apr 16 07:13:33 2011
@@ -28,21 +28,21 @@ public class TestReflect
{
// Uses JNI class naming.
Class c1 = Reflect.findClass("Ljava/lang/System;");
- Assert.assertEquals("java.lang.System", c1.getCanonicalName());
+ Assert.assertEquals(c1.getCanonicalName(), "java.lang.System");
Class c2 = Reflect.findClass("java.lang.System");
- Assert.assertEquals("java.lang.System", c1.getCanonicalName());
+ Assert.assertEquals(c1.getCanonicalName(), "java.lang.System");
}
public void allocObject()
throws Exception
{
Class sc = Reflect.findClass("java/lang/String");
- Assert.assertEquals("java.lang.String", sc.getCanonicalName());
+ Assert.assertEquals(sc.getCanonicalName(), "java.lang.String");
Object o = Reflect.allocObject(sc);
Assert.assertNotNull(o);
// Returns empty string since object was not initialized
// only allocated.
- Assert.assertEquals("", o.toString());
+ Assert.assertEquals(o.toString(), "");
}
public void reflectedClass()
@@ -50,7 +50,7 @@ public class TestReflect
{
// Uses JNI class naming.
ReflectedClass cl = new ReflectedClass("java/lang/System");
- Assert.assertEquals("java.lang.System", cl.toString());
+ Assert.assertEquals(cl.toString(), "java.lang.System");
ReflectedMethod m = cl.getStaticMethod("load", "(Ljava/lang/String;)V");
Assert.assertNotNull(m);
}
Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestSemaphore.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestSemaphore.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestSemaphore.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestSemaphore.java Sat Apr 16 07:13:33 2011
@@ -26,19 +26,13 @@ public class TestSemaphore
private static final String semname = "acrSemop23";
- @Test(groups = { "private" })
- public void factory()
- {
- SemaphoreImpl si = Semaphore.getImpl();
- Assert.assertNotNull(si);
- }
-
@Test(groups = { "semaphore.parent" })
public void checkSemaphore()
throws Exception
{
+ System.out.flush();
try {
- Semaphore s = Semaphore.getImpl().create(semname, 0);
+ Semaphore s = Semaphore.create(semname, 0);
s.close();
} catch (Exception ex) {
System.out.println("Removing stalled semaphore " + semname);
@@ -50,9 +44,13 @@ public class TestSemaphore
public void createSemaphore()
throws Exception
{
- Semaphore s = Semaphore.getImpl().create(semname, 0);
+ Semaphore s = Semaphore.create(semname, 0);
Assert.assertNotNull(s);
+ System.out.println("Waiting for a child to attach");
+ System.out.flush();
s.acquire();
+ System.out.println("Parent done.");
+ System.out.flush();
s.release();
s.close();
}
@@ -61,11 +59,13 @@ public class TestSemaphore
public void openSemaphore()
throws Exception
{
+ System.out.println("Attaching child semaphore");
+ System.out.flush();
Semaphore s = null;
int step = 125;
while (step <= 2000) {
try {
- s = Semaphore.getImpl().open(semname);
+ s = Semaphore.open(semname);
break;
} catch (Exception x) {
@@ -76,6 +76,8 @@ public class TestSemaphore
Assert.assertNotNull(s);
s.release();
s.close();
+ System.out.println("Child done.");
+ System.out.flush();
}
}
Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestString.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestString.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestString.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestString.java Sat Apr 16 07:13:33 2011
@@ -33,7 +33,7 @@ public class TestString
throws Exception
{
String s = new String(gUIF, 0, gUIF.length, "utf-8");
- Assert.assertEquals(6, test0(s));
+ Assert.assertEquals(test0(s), 6);
}
@Test(groups = { "private" })
@@ -41,7 +41,7 @@ public class TestString
throws Exception
{
String s = new String(gUIF, 0, gUIF.length, "UtF-8");
- Assert.assertEquals(5, test1(s));
+ Assert.assertEquals(test1(s), 5);
}
}
Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUnsafe.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUnsafe.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUnsafe.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUnsafe.java Sat Apr 16 07:13:33 2011
@@ -19,6 +19,8 @@ package org.apache.commons.runtime;
import org.testng.annotations.*;
import org.testng.Assert;
import java.lang.reflect.*;
+import java.io.FileDescriptor;
+import org.apache.commons.runtime.io.Utils;
public class TestUnsafe
{
@@ -42,4 +44,13 @@ public class TestUnsafe
Assert.assertEquals(test0(this, off), i);
}
+ @Test(groups = { "private" })
+ public void nativeFileDescriptor()
+ throws Exception
+ {
+ int fd = Utils.getFd(FileDescriptor.out);
+ long fh = Utils.getHandle(FileDescriptor.out);
+ Assert.assertTrue(0 != (fd + fh));
+ }
+
}
Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUtils.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUtils.java?rev=1093940&r1=1093939&r2=1093940&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUtils.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUtils.java Sat Apr 16 07:13:33 2011
@@ -46,9 +46,9 @@ public class TestUtils
throws IOException
{
int i = -1;
- Assert.assertEquals("ffffffff", Utils.hex(i));
+ Assert.assertEquals(Utils.hex(i), "ffffffff");
i = 0xcafebabe;
- Assert.assertEquals("cafebabe", Utils.hex(i));
+ Assert.assertEquals(Utils.hex(i), "cafebabe");
}
@Test(groups = { "core" })
@@ -56,9 +56,9 @@ public class TestUtils
throws IOException
{
long l = -1;
- Assert.assertEquals("ffffffffffffffff", Utils.hex(l));
+ Assert.assertEquals(Utils.hex(l), "ffffffffffffffff");
l = 0xcafebabedeadbeefL;
- Assert.assertEquals("cafebabedeadbeef", Utils.hex(l));
+ Assert.assertEquals(Utils.hex(l), "cafebabedeadbeef");
}
@Test(groups = { "core" })