Refine search
public void accept(FrameworkMember member, T value) { Rule rule = member.getAnnotation(Rule.class); if (rule != null) { RuleContainer container = CURRENT_RULE_CONTAINER.get(); if (container != null) { container.setOrder(value, rule.order()); } } result.add(value); } }
@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"); } }
/** * 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(); }
/** * @author Stephane Nicoll */ public abstract class AbstractValueAdaptingCacheTests<T extends AbstractValueAdaptingCache> extends AbstractCacheTests<T> { @Rule public ExpectedException thrown = ExpectedException.none(); protected final static String CACHE_NAME_NO_NULL = "testCacheNoNull"; protected abstract T getCache(boolean allowNull); @Test public void testCachePutNullValueAllowNullFalse() { T cache = getCache(false); String key = createRandomKey(); this.thrown.expect(IllegalArgumentException.class); this.thrown.expectMessage(CACHE_NAME_NO_NULL); this.thrown.expectMessage( "is configured to not allow null values but null was provided"); cache.put(key, null); } }
@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(); } }
/** * Unit tests for {@link GenericPropertiesContextLoader}. * * @author Sam Brannen * @since 4.0.4 */ public class GenericPropertiesContextLoaderTests { private static final String[] EMPTY_STRING_ARRAY = new String[0]; @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public void configMustNotContainAnnotatedClasses() throws Exception { expectedException.expect(IllegalStateException.class); expectedException.expectMessage(containsString("does not support annotated classes")); GenericPropertiesContextLoader loader = new GenericPropertiesContextLoader(); MergedContextConfiguration mergedConfig = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, new Class<?>[] { getClass() }, EMPTY_STRING_ARRAY, loader); loader.loadContext(mergedConfig); } }
@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); } }