package net.openhft.chronicle.core;

import org.junit.Test;

import javax.naming.ConfigurationException;
import java.nio.ByteBuffer;

import static org.junit.Assert.assertEquals;

/**
 * Created by peter_2 on 26/02/2016.
 */
public class JvmTest {

    @Test(expected = ConfigurationException.class)
    public void testRethrow() throws Exception {
        Jvm.rethrow(new ConfigurationException());
    }

    @Test
    public void testTrimStackTrace() throws Exception {
        // TODO: 26/02/2016
    }

    @Test
    public void testTrimFirst() throws Exception {
        // TODO: 26/02/2016

    }

    @Test
    public void testTrimLast() throws Exception {
        // TODO: 26/02/2016

    }

    @Test
    public void testIsInternal() throws Exception {
        // TODO: 26/02/2016

    }

    @Test
    public void testIsDebug() throws Exception {
        // TODO: 26/02/2016

    }

    @Test
    public void testPause() throws Exception {
        // TODO: 26/02/2016

    }

    @Test
    public void testBusyWaitMicros() throws Exception {
        // TODO: 26/02/2016

    }

    @Test
    public void testGetField() throws Exception {
        // TODO: 26/02/2016

    }

    @Test
    public void testGetValue() throws Exception {
        // TODO: 26/02/2016

    }

    @Test
    public void testLockWithStack() throws Exception {
        // TODO: 26/02/2016

    }

    @Test
    public void testUsedDirectMemory() throws Exception {
        long used = Jvm.usedDirectMemory();
        ByteBuffer.allocateDirect(4 << 10);
        assertEquals(used + (4 << 10), Jvm.usedDirectMemory());
    }

    @Test
    public void testUsedNativeMemory() throws Exception {

    }

    @Test
    public void testMaxDirectMemory() throws Exception {

    }
}
@@ -52,16 +52,48 @@
 it.Test;
+%0Aimport sun.nio.ch.DirectBuffer;
 %0A%0Aimport
@@ -190,28 +190,17 @@
 .Assert.
-assertEquals
+*
 ;%0A%0A/**%0A 
@@ -221,10 +221,8 @@
 eter
-_2
  on 
@@ -787,123 +787,118 @@
     
-// TODO: 26/02/2016%0A
+assertTrue(Jvm.isInternal(String.class.getName()));
 %0A    
-%7D%0A%0A
     
-@Test%0A    public void testIsDebug() throws Exception %7B%0A        // TODO: 26/02/2016%0A
+assertFalse(Jvm.isInternal(getClass().getName()));
 %0A   
@@ -1080,33 +1080,32 @@
 ODO: 26/02/2016%0A
-%0A
     %7D%0A%0A    @Test
@@ -1259,35 +1259,177 @@
         
-// TODO: 26/02/2016
+ByteBuffer bb = ByteBuffer.allocateDirect(128);%0A        long address = Jvm.getValue(bb, %22address%22);%0A        assertEquals(((DirectBuffer) bb).address(), address);
 %0A%0A    %7D%0A
@@ -1791,18 +1791,17 @@
 test
-UsedNative
+MaxDirect
 Memo
@@ -1828,83 +1828,102 @@
 n %7B%0A
-%0A
     
-%7D%0A%0A    @Test%0A    public void testMaxDirectMemory() throws Exception %7B%0A
+    long maxDirectMemory = Jvm.maxDirectMemory();%0A        assertTrue(maxDirectMemory %3E 0);
 %0A   

Fix support for Java 8 update 74