本文整理了Java中org.junit.Rule.<init>
方法的一些代码示例,展示了Rule.<init>
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rule.<init>
方法的具体详情如下:
包路径:org.junit.Rule
类名称:Rule
方法名:<init>
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* 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();
}
代码示例来源:origin: spring-projects/spring-framework
@RunWith(JUnit4.class)
public static abstract class BaseSpringRuleTestCase {
@ClassRule
public static final SpringClassRule springClassRule = new SpringClassRule();
@Rule
public final SpringMethodRule springMethodRule = new SpringMethodRule();
@Test
public void testNothing() {
}
}
代码示例来源:origin: bumptech/glide
@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();
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@RunWith(BlockJUnit4ClassRunner.class)
@Category(AsyncLoggers.class)
public class QueueFullAsyncAppenderTest2 extends QueueFullAbstractTest {
@Rule
public LoggerContextRule context = new LoggerContextRule(
"log4j2-queueFullAsyncAppender.xml");
代码示例来源:origin: googleapis/google-cloud-java
/** 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 )");
}
}
代码示例来源:origin: apache/hbase
@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");
}
}
代码示例来源:origin: apache/geode
@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());
}
}
代码示例来源:origin: bumptech/glide
@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();
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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.
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@RunWith(BlockJUnit4ClassRunner.class)
@Category(AsyncLoggers.class)
public class QueueFullAsyncLoggerConfigTest2 extends QueueFullAbstractTest {
@Rule
public LoggerContextRule context = new LoggerContextRule(
"log4j2-queueFullAsyncLoggerConfig.xml");
代码示例来源:origin: apache/hbase
@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();
代码示例来源:origin: apache/hbase
@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));
}
}
代码示例来源:origin: spring-projects/spring-framework
@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();
}
}
代码示例来源:origin: apache/geode
@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);
}
}
代码示例来源:origin: bumptech/glide
@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();
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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();
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@RunWith(BlockJUnit4ClassRunner.class)
@Category(AsyncLoggers.class)
public class QueueFullAsyncLoggerConfigLoggingFromToStringTest2 extends QueueFullAbstractTest {
@Rule
public LoggerContextRule context = new LoggerContextRule(
"log4j2-queueFullAsyncLoggerConfig.xml");
代码示例来源:origin: apache/hbase
@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);
}
}
代码示例来源:origin: spring-projects/spring-framework
@ClassRule
public static final SpringClassRule springClassRule = new SpringClassRule();
@Rule
public final SpringMethodRule springMethodRule = new SpringMethodRule();
@Rule
public AutowiredTestRule autowiredTestRule;
代码示例来源:origin: apache/geode
/**
* 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);
}
}
内容来源于网络,如有侵权,请联系作者删除!