Search in sources :

Example 6 with IntValue$$Native

use of net.openhft.lang.values.IntValue$$Native in project HugeCollections-OLD by peter-lawrey.

the class IntValueMapTest method test.

@Test
@Ignore
public void test() throws IOException {
    final SharedHashMap<IntValue, CharSequence> map = new SharedHashMapBuilder().entries(1000).entries(20000).file(getPersistenceFile()).kClass(IntValue.class).vClass(CharSequence.class).create();
    IntValue$$Native value = new IntValue$$Native();
    value.bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);
    value.setValue(1);
    final String expected = "test";
    map.put(value, expected);
    final CharSequence actual = map.get(value);
    assertEquals(expected, actual);
    // this will fail
    map.toString();
}
Also used : ByteBufferBytes(net.openhft.lang.io.ByteBufferBytes) IntValue$$Native(net.openhft.lang.values.IntValue$$Native) IntValue(net.openhft.lang.values.IntValue) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with IntValue$$Native

use of net.openhft.lang.values.IntValue$$Native in project HugeCollections-OLD by peter-lawrey.

the class TCPSocketReplicationIntValueTest method testSoakTestWithRandomData.

@Test
//todo fix this
@Ignore
public void testSoakTestWithRandomData() throws IOException, InterruptedException {
    final long start = System.currentTimeMillis();
    System.out.print("SoakTesting ");
    for (int j = 1; j < 100 * 1000; j++) {
        if (j % 5000 == 0)
            System.out.print(".");
        Random rnd = new Random(j);
        for (int i = 1; i < 10; i++) {
            final int select = rnd.nextInt(2);
            final SharedHashMap<IntValue, CharSequence> map = select > 0 ? map1 : map2;
            switch(rnd.nextInt(2)) {
                case 0:
                    map.put(set(rnd.nextInt(1000)), /* + select * 100 */
                    "test");
                    break;
                case 1:
                    map.remove(set(rnd.nextInt(1000)));
                    break;
            }
        }
    }
    waitTillEqual(5000);
    final long time = System.currentTimeMillis() - start;
    //assertTrue("timeTaken="+time, time < 2200);
    System.out.println("\ntime taken millis=" + time);
}
Also used : Random(java.util.Random) IntValue(net.openhft.lang.values.IntValue) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with IntValue$$Native

use of net.openhft.lang.values.IntValue$$Native in project HugeCollections-OLD by peter-lawrey.

the class SharedHashMapTest method testGetWithNullContainer.

@Test
public void testGetWithNullContainer() throws Exception {
    SharedHashMap<CharSequence, LongValue> map = getSharedMap(10 * 1000, 128, 24);
    map.acquireUsing("key", new LongValue$$Native());
    assertEquals(0, map.getUsing("key", null).getValue());
    map.close();
}
Also used : LongValue(net.openhft.lang.values.LongValue) LongValue$$Native(net.openhft.lang.values.LongValue$$Native) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 LongValue$$Native (net.openhft.lang.values.LongValue$$Native)4 IntValue (net.openhft.lang.values.IntValue)3 LongValue (net.openhft.lang.values.LongValue)3 Ignore (org.junit.Ignore)3 ByteBufferBytes (net.openhft.lang.io.ByteBufferBytes)2 IntValue$$Native (net.openhft.lang.values.IntValue$$Native)2 File (java.io.File)1 InetSocketAddress (java.net.InetSocketAddress)1 Random (java.util.Random)1 Before (org.junit.Before)1