Refine search
/** * Abstract base test class that preconfigures the {@link SpringClassRule} and * {@link SpringMethodRule}. * * @author Sam Brannen * @since 5.0 */ public abstract class SpringRuleConfigurer { @ClassRule public static final SpringClassRule springClassRule = new SpringClassRule(); @Rule public final SpringMethodRule springMethodRule = new SpringMethodRule(); }
@RunWith(JUnit4.class) public class EmptySignatureTest { @Rule public final KeyTester keyTester = new KeyTester(); @Test public void testEquals() { keyTester .addEquivalenceGroup( EmptySignature.obtain(), EmptySignature.obtain()) .addEquivalenceGroup(mock(Key.class)) .addEmptyDigestRegressionTest(EmptySignature.obtain()) .test(); } }
/** Integration tests for database admin functionality: DDL etc. */ @Category(IntegrationTest.class) @RunWith(JUnit4.class) public class ITDatabaseTest { @ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv(); @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void badDdl() { expectedException.expect(isSpannerException(ErrorCode.INVALID_ARGUMENT)); expectedException.expectMessage("Syntax error on line 1"); env.getTestHelper().createTestDatabase("CREATE TABLE T ( Illegal Way To Define A Table )"); } }
@Category({ RegionServerTests.class, SmallTests.class }) public class TestReadOnlyConfiguration { @ClassRule public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestReadOnlyConfiguration.class); @Rule public TestName name = new TestName(); @Test public void testAddDefaultResource() { Configuration configuration = new Configuration(); Configuration readOnlyConf = new ReadOnlyConfiguration(configuration); configuration.addDefaultResource("abc.xml"); } }
@Category({GfshTest.class}) public class GfshRuleTest { @Rule public GfshRule gfsh130 = new GfshRule(VersionManager.GEODE_130); @Rule public GfshRule gfshDefault = new GfshRule(); @Test public void checkGfshDefault() { assertThat(gfshDefault.getGfshPath().toString()) .contains(Paths.get("geode-assembly/build/install/apache-geode/bin/gfsh").toString()); } @Test public void checkGfsh130() { assertThat(gfsh130.getGfshPath().toString()) .contains(Paths.get("geode-old-versions/build/apache-geode-1.3.0/bin/gfsh").toString()); } }
@RunWith(JUnit4.class) public class ObjectKeyTest { @Rule public final KeyTester keyTester = new KeyTester(); @Test public void testEqualsHashCodeAndDigest() throws NoSuchAlgorithmException { Object object = new Object(); keyTester .addEquivalenceGroup(new ObjectKey(object), new ObjectKey(object)) .addEquivalenceGroup(new ObjectKey(new Object())) .addEquivalenceGroup(new ObjectKey("test"), new ObjectKey("test")) .addRegressionTest( new ObjectKey("test"), "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08") .test(); } }
/** * This class is an extension of {@link EnabledAndIgnoredSpringRunnerTests} * that has been modified to use {@link SpringClassRule} and * {@link SpringMethodRule}. * * @author Sam Brannen * @since 4.2 */ @RunWith(JUnit4.class) public class EnabledAndIgnoredSpringRuleTests extends EnabledAndIgnoredSpringRunnerTests { @ClassRule public static final SpringClassRule springClassRule = new SpringClassRule(); @Rule public final SpringMethodRule springMethodRule = new SpringMethodRule(); // All tests are in superclass. }
@RunWith(Parameterized.class) @Category({ RegionServerTests.class, SmallTests.class }) public class TestWALConfiguration { private static final Logger LOG = LoggerFactory.getLogger(TestWALConfiguration.class); static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); @ClassRule public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestWALConfiguration.class); @Rule public TestName name = new TestName();
@Category({SmallTests.class}) public class TestRetriesExhaustedWithDetailsException { @ClassRule public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestRetriesExhaustedWithDetailsException.class); @Rule public TestName name = new TestName(); /** * Assert that a RetriesExhaustedException that has RegionTooBusyException outputs region name. */ @Test public void testRegionTooBusyException() { List<Throwable> ts = new ArrayList<>(1); final String regionName = this.name.getMethodName(); ts.add(new RegionTooBusyException(regionName)); List<Row> rows = new ArrayList<>(1); rows.add(Mockito.mock(Row.class)); List<String> hostAndPorts = new ArrayList<>(1); hostAndPorts.add("example.com:1234"); RetriesExhaustedException ree = new RetriesExhaustedWithDetailsException(ts, rows, hostAndPorts); assertTrue(ree.toString().contains(regionName)); } }
@TestExecutionListeners({}) public abstract static class AbstractRepeatedTestCase { @ClassRule public static final SpringClassRule springClassRule = new SpringClassRule(); @Rule public final SpringMethodRule springMethodRule = new SpringMethodRule(); protected void incrementInvocationCount() throws IOException { invocationCount.incrementAndGet(); } }
@Category({LuceneTest.class}) public class LuceneIndexImplJUnitTest { public static final String REGION = "region"; public static final String INDEX = "index"; public static final int MAX_WAIT = 30000; private InternalCache cache; private LuceneIndex index; @Rule public ExpectedException thrown = ExpectedException.none(); @Before public void createLuceneIndex() { cache = Fakes.cache(); index = new LuceneIndexForPartitionedRegion(INDEX, REGION, cache); } }
@RunWith(JUnit4.class) public class MediaStoreSignatureTest { @Rule public final KeyTester keyTester = new KeyTester(); @Test public void equalsHashCodeAndDigest() { keyTester .addEquivalenceGroup( new MediaStoreSignature("first", 100, 1), new MediaStoreSignature("first", 100, 1)) .addEquivalenceGroup(new MediaStoreSignature("second", 100, 1)) .addEquivalenceGroup(new MediaStoreSignature("first", 200, 1)) .addEquivalenceGroup(new MediaStoreSignature("first", 100, 2)) .addRegressionTest( new MediaStoreSignature("first", 100, 1), "04959925006b21081000fd10835cc376343c0e922df0bd7346897ede6f958adf") .test(); } }
/** * This class is an extension of {@link BasicAnnotationConfigWacTests} * that has been modified to use {@link SpringClassRule} and * {@link SpringMethodRule}. * * @author Sam Brannen * @since 4.2 */ @RunWith(JUnit4.class) public class BasicAnnotationConfigWacSpringRuleTests extends BasicAnnotationConfigWacTests { // All tests are in superclass. @ClassRule public static final SpringClassRule springClassRule = new SpringClassRule(); @Rule public final SpringMethodRule springMethodRule = new SpringMethodRule(); }
@Category({MasterTests.class, SmallTests.class}) public class TestRegionState { @ClassRule public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestRegionState.class); @Rule public TestName name = new TestName(); @Test public void testSerializeDeserialize() { final TableName tableName = TableName.valueOf("testtb"); for (RegionState.State state: RegionState.State.values()) { testSerializeDeserialize(tableName, state); } } private void testSerializeDeserialize(final TableName tableName, final RegionState.State state) { RegionState state1 = RegionState.createForTesting(new HRegionInfo(tableName), state); ClusterStatusProtos.RegionState protobuf1 = state1.convert(); RegionState state2 = RegionState.convert(protobuf1); ClusterStatusProtos.RegionState protobuf2 = state1.convert(); assertEquals("RegionState does not match " + state, state1, state2); assertEquals("Protobuf does not match " + state, protobuf1, protobuf2); } }
/** * A unit test of the RegionDirectory class that uses the Directory test case from the lucene code * base. * * This test is still mocking out the underlying cache, rather than using a real region. */ @Category({LuceneTest.class}) public class RegionDirectoryJUnitTest extends BaseDirectoryTestCase { @Rule public SystemPropertiesRestoreRule restoreProps = new SystemPropertiesRestoreRule(); @Override protected Directory getDirectory(Path path) throws IOException { final FileSystemStats stats = mock(FileSystemStats.class); // This is super lame, but log4j automatically sets the system property, and the lucene // test asserts that no system properties have changed. Unfortunately, there is no // way to control the order of rules, so we can't clear this property with a rule // or @After method. Instead, do it in the close method of the directory. return new RegionDirectory(new ConcurrentHashMap(), stats); } }