com.gemstone.gemfire.internal.cache.OplogEntryIdSetJUnitTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gemfire-junit Show documentation
Show all versions of gemfire-junit Show documentation
SnappyData store based off Pivotal GemFireXD
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* Licensed 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. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire.internal.cache;
import java.io.*;
import java.util.*;
import com.gemstone.gemfire.cache.*;
import com.gemstone.gemfire.internal.Assert;
import com.gemstone.gemfire.distributed.*;
import com.gemstone.gemfire.internal.cache.DiskStoreImpl.OplogEntryIdSet;
import junit.framework.TestCase;
/**
* Tests DiskStoreImpl.OplogEntryIdSet
*
* @author darrel
*
*/
public class OplogEntryIdSetJUnitTest extends TestCase
{
public OplogEntryIdSetJUnitTest(String arg0) {
super(arg0);
}
public void testBasics() {
OplogEntryIdSet s = new OplogEntryIdSet();
for (long i=1; i < 777777; i++) {
assertEquals(false, s.contains(i));
}
for (long i=1; i < 777777; i++) {
s.add(i);
}
for (long i=1; i < 777777; i++) {
assertEquals(true, s.contains(i));
}
try {
s.add(DiskStoreImpl.INVALID_ID);
fail("expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
assertEquals(false, s.contains(0));
assertEquals(false, s.contains(0x00000000FFFFFFFFL));
s.add(0x00000000FFFFFFFFL);
assertEquals(true, s.contains(0x00000000FFFFFFFFL));
for (long i=0x00000000FFFFFFFFL+1; i < 0x00000000FFFFFFFFL+777777; i++) {
assertEquals(false, s.contains(i));
}
for (long i=0x00000000FFFFFFFFL+1; i < 0x00000000FFFFFFFFL+777777; i++) {
s.add(i);
}
for (long i=0x00000000FFFFFFFFL+1; i < 0x00000000FFFFFFFFL+777777; i++) {
assertEquals(true, s.contains(i));
}
for (long i=1; i < 777777; i++) {
assertEquals(true, s.contains(i));
}
assertEquals(false, s.contains(Long.MAX_VALUE));
s.add(Long.MAX_VALUE);
assertEquals(true, s.contains(Long.MAX_VALUE));
assertEquals(false, s.contains(Long.MIN_VALUE));
s.add(Long.MIN_VALUE);
assertEquals(true, s.contains(Long.MIN_VALUE));
}
}