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/15 09:26:54 UTC
svn commit: r1092611 -
/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUnsafe.java
Author: mturk
Date: Fri Apr 15 07:26:54 2011
New Revision: 1092611
URL: http://svn.apache.org/viewvc?rev=1092611&view=rev
Log:
Add Unsafe test
Added:
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUnsafe.java (with props)
Added: 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=1092611&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUnsafe.java (added)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUnsafe.java Fri Apr 15 07:26:54 2011
@@ -0,0 +1,45 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime;
+
+import org.testng.annotations.*;
+import org.testng.Assert;
+import java.lang.reflect.*;
+
+public class TestUnsafe
+{
+ private int i = 12345;
+ private static native int test0(Object o, int off);
+
+ @Test(groups = { "core" })
+ public void isSupported()
+ {
+ if (Unsafe.isSupported())
+ System.out.println("JVM sun.misc.Unsafe is supported");
+ else
+ System.out.println("JVM sun.misc.Unsafe not supported!");
+ }
+
+ @Test(groups = { "private" })
+ public void getDirectNative()
+ throws Exception
+ {
+ int off = Unsafe.objectFieldOffset(TestUnsafe.class.getDeclaredField("i"));
+ Assert.assertEquals(test0(this, off), i);
+ }
+
+}
Propchange: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestUnsafe.java
------------------------------------------------------------------------------
svn:eol-style = native