Search in sources :

Example 36 with DeltaTestImpl

use of org.apache.geode.DeltaTestImpl in project geode by apache.

the class DeltaPropagationDUnitTest method prepareErroneousDeltasForFromDelta.

public static void prepareErroneousDeltasForFromDelta() {
    for (int i = 0; i < EVENTS_SIZE; i++) {
        deltaPut[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0], new TestObject1("0", 0));
    }
    deltaPut[1].setIntVar(5);
    deltaPut[2].setIntVar(5);
    deltaPut[3].setIntVar(5);
    deltaPut[4].setIntVar(5);
    deltaPut[5].setIntVar(5);
    deltaPut[2].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltaPut[3].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltaPut[4].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltaPut[5].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
    deltaPut[3].setDoubleVar(new Double(5));
    deltaPut[4].setDoubleVar(new Double(5));
    deltaPut[5].setDoubleVar(new Double(5));
    deltaPut[4].setStr("str changed");
    deltaPut[5].setStr(DeltaTestImpl.ERRONEOUS_STRING_FOR_FROM_DELTA);
    deltaPut[5].setIntVar(100);
    deltaPut[5].setTestObj(new TestObject1("CHANGED", 100));
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) TestObject1(org.apache.geode.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1)

Example 37 with DeltaTestImpl

use of org.apache.geode.DeltaTestImpl in project geode by apache.

the class DeltaPropagationStatsDUnitTest method putErrorDeltaForSender.

public static void putErrorDeltaForSender(Integer keys, Long updates, Long errors, Boolean doCreate) {
    Region r = cache.getRegion(REGION_NAME);
    assertTrue("Errors cannot be more than 1/3rd of total updates", (keys * updates) / 3 > errors);
    if (doCreate) {
        for (int i = 0; i < keys; i++) {
            r.create(DELTA_KEY + i, new DeltaTestImpl());
        }
    }
    for (int i = 0; i < keys; i++) {
        for (long j = 0; j < updates; j++) {
            DeltaTestImpl delta = new DeltaTestImpl();
            if (j % 3 == 1) {
                delta.setStr("one");
            } else if (j % 3 == 2) {
                delta.setIntVar(111);
                if (errors != 0) {
                    delta.setIntVar(DeltaTestImpl.ERRONEOUS_INT_FOR_TO_DELTA);
                    errors--;
                }
            } else {
                delta.setByteArr(new byte[] { 11, 22, 33, 44 });
                delta.setDoubleVar(5.7);
            }
            try {
                r.put(DELTA_KEY + i, delta);
                assertTrue("Expected an InvalidDeltaException to be thrown, but it wasn't!", delta.getIntVar() != DeltaTestImpl.ERRONEOUS_INT_FOR_TO_DELTA);
            } catch (InvalidDeltaException ide) {
                assertTrue("InvalidDeltaException not expected.", delta.getIntVar() == DeltaTestImpl.ERRONEOUS_INT_FOR_TO_DELTA);
                cache.getLoggerI18n().fine("Recieved InvalidDeltaException as expected.");
            }
        }
    }
    assertTrue("Error puts not exhausted", errors == 0);
}
Also used : InvalidDeltaException(org.apache.geode.InvalidDeltaException) DeltaTestImpl(org.apache.geode.DeltaTestImpl) Region(org.apache.geode.cache.Region)

Example 38 with DeltaTestImpl

use of org.apache.geode.DeltaTestImpl in project geode by apache.

the class DeltaPropagationDUnitTest method doPuts.

public static void doPuts(Integer num) {
    try {
        Region r = cache.getRegion("/" + regionName);
        assertNotNull(r);
        for (int i = 0; i < num; i++) {
            DeltaTestImpl val = new DeltaTestImpl();
            val.setStr("" + i);
            r.put(DELTA_KEY, val);
        }
        r.put(LAST_KEY, "");
    } catch (Exception ex) {
        org.apache.geode.test.dunit.Assert.fail("failed in createDelta()", ex);
    }
}
Also used : DeltaTestImpl(org.apache.geode.DeltaTestImpl) Region(org.apache.geode.cache.Region) InvalidDeltaException(org.apache.geode.InvalidDeltaException)

Aggregations

DeltaTestImpl (org.apache.geode.DeltaTestImpl)38 Region (org.apache.geode.cache.Region)21 Test (org.junit.Test)10 TestObject1 (org.apache.geode.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1)9 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)9 SerializationTest (org.apache.geode.test.junit.categories.SerializationTest)9 ConflationDUnitTest (org.apache.geode.internal.cache.tier.sockets.ConflationDUnitTest)8 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)8 LocalRegion (org.apache.geode.internal.cache.LocalRegion)7 InvalidDeltaException (org.apache.geode.InvalidDeltaException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInput (java.io.DataInput)1 DataInputStream (java.io.DataInputStream)1 Properties (java.util.Properties)1 DataSerializable (org.apache.geode.DataSerializable)1 Delta (org.apache.geode.Delta)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 EntryEvent (org.apache.geode.cache.EntryEvent)1 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)1 RegionAttributes (org.apache.geode.cache.RegionAttributes)1