Java 类org.junit.rules.TestName 实例源码

项目:bootstrap    文件:TAbstractParallelSeleniumTest.java   
@SuppressWarnings("unchecked")
@Override
protected void prepareDriver() throws Exception {
    testName = Mockito.mock(TestName.class);
    Mockito.when(testName.getMethodName()).thenReturn("mockTest");
    System.clearProperty("test.selenium.remote");
    localDriverClass = WebDriverMock.class.getName();
    remoteDriverClass = WebDriverMock.class.getName();
    scenario = "sc";
    super.prepareDriver();
    mockDriver = Mockito.mock(WebDriverMock.class);
    Mockito.when(((WebDriverMock) mockDriver).getScreenshotAs(ArgumentMatchers.any(OutputType.class))).thenReturn(
            new File(Thread.currentThread().getContextClassLoader().getResource("log4j2.json").toURI()));
    final Options options = Mockito.mock(Options.class);
    Mockito.when(options.window()).thenReturn(Mockito.mock(Window.class));
    Mockito.when(mockDriver.manage()).thenReturn(options);
    final WebElement webElement = Mockito.mock(WebElement.class);
    Mockito.when(mockDriver.findElement(ArgumentMatchers.any(By.class))).thenReturn(webElement);
    Mockito.when(webElement.isDisplayed()).thenReturn(true);
    this.driver = mockDriver;
}
项目:bootstrap    文件:TAbstractSequentialSeleniumTest.java   
@SuppressWarnings("unchecked")
@Override
protected void prepareDriver() throws Exception {
    testName = Mockito.mock(TestName.class);
    Mockito.when(testName.getMethodName()).thenReturn("mockTest");
    System.clearProperty("test.selenium.remote");
    localDriverClass = WebDriverMock.class.getName();
    remoteDriverClass = WebDriverMock.class.getName();
    scenario = "sc";
    super.prepareDriver();
    mockDriver = Mockito.mock(WebDriverMock.class);
    Mockito.when(((WebDriverMock) mockDriver).getScreenshotAs(ArgumentMatchers.any(OutputType.class))).thenReturn(
            new File(Thread.currentThread().getContextClassLoader().getResource("log4j2.json").toURI()));
    final Options options = Mockito.mock(Options.class);
    Mockito.when(options.window()).thenReturn(Mockito.mock(Window.class));
    Mockito.when(mockDriver.manage()).thenReturn(options);
    final WebElement webElement = Mockito.mock(WebElement.class);
    Mockito.when(mockDriver.findElement(ArgumentMatchers.any(By.class))).thenReturn(webElement);
    Mockito.when(webElement.isDisplayed()).thenReturn(true);
    this.driver = mockDriver;
}
项目:hbase    文件:TestMajorCompaction.java   
/** constructor */
public TestMajorCompaction(String compType) {
  super();
  name = new TestName();
  // Set cache flush size to 1MB
  conf.setInt(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, 1024*1024);
  conf.setInt(HConstants.HREGION_MEMSTORE_BLOCK_MULTIPLIER, 100);
  compactionThreshold = conf.getInt("hbase.hstore.compactionThreshold", 3);
  conf.set(CompactingMemStore.COMPACTING_MEMSTORE_TYPE_KEY, String.valueOf(compType));

  secondRowBytes = START_KEY_BYTES.clone();
  // Increment the least significant character so we get to next row.
  secondRowBytes[START_KEY_BYTES.length - 1]++;
  thirdRowBytes = START_KEY_BYTES.clone();
  thirdRowBytes[START_KEY_BYTES.length - 1] =
      (byte) (thirdRowBytes[START_KEY_BYTES.length - 1] + 2);
}
项目:c5    文件:ScanMatchers.java   
public static Matcher<? super Result> isWellFormedUserTable(TestName testName) {
  return new BaseMatcher<Result>() {
    @Override
    public boolean matches(Object o) {
      if (o == null) {
        return false;
      }
      Result result = (Result) o;
      HRegionInfo regioninfo;
      try {
        regioninfo = HRegionInfo.parseFrom(result.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER));
      } catch (DeserializationException e) {
        e.printStackTrace();
        return false;
      }
      return regioninfo.getRegionNameAsString().startsWith("c5:" + testName.getMethodName());
    }

    @Override
    public void describeTo(Description description) {

    }
  };
}
项目:GitHub    文件:BitmapRegressionTester.java   
public BitmapRegressionTester(Class<?> testClass, TestName testName) {
  this.testClass = testClass;
  this.testName = testName;

  if (testClass.getAnnotation(RegressionTest.class) == null) {
    throw new IllegalArgumentException(
        testClass + " must be annotated with " + RegressionTest.class);
  }
}
项目:bootstrap    文件:TAbstractParallelSeleniumTest.java   
/**
 * Run sequentially (one instance) the given runnable instance with an exception.
 */
@Test(expected = AssertionError.class)
public void testParallelIOE() {
    testName = Mockito.mock(TestName.class);
    Mockito.when(testName.getMethodName()).thenReturn("mockTestIOE");
    super.runParallel();
}
项目:bootstrap    文件:TAbstractParallelSeleniumTest.java   
/**
 * Run asynchronously the given runnable instance with an error.
 */
@Test(expected = AssertionError.class)
public void testParallelRunningError() {
    testName = Mockito.mock(TestName.class);
    Mockito.when(testName.getMethodName()).thenThrow(new AssertionFailedError());
    super.runParallel();
}
项目:bootstrap    文件:TAbstractParallelSeleniumTest.java   
/**
 * Run asynchronously the given runnable instance with an error.
 */
@Test(expected = AssertionError.class)
public void testParallelIOE4() {
    testName = Mockito.mock(TestName.class);
    Mockito.when(testName.getMethodName()).thenReturn("mockTestIOE");
    final DesiredCapabilities mockCapability = Mockito.mock(DesiredCapabilities.class);
    Mockito.when(mockCapability.getBrowserName()).thenThrow(new IllegalStateException());
    repeatedCapabilities = new DesiredCapabilities[] { mockCapability };
    super.runParallel();
}
项目:bootstrap    文件:TAbstractParallelSeleniumTest.java   
/**
 * Run asynchronously the given runnable instance with abnormally long run.
 */
@Test(expected = AssertionError.class)
public void testParallelLong() {
    sleep = 0;
    maxRetry = 3;
    testName = Mockito.mock(TestName.class);
    Mockito.when(testName.getMethodName()).thenReturn("mockTestParallelLong");
    super.runParallel();
}
项目:bootstrap    文件:TAbstractSequentialSeleniumTest.java   
/**
 * Run sequentially (one instance) the given runnable instance with an error.
 */
@Test(expected = AssertionFailedError.class)
public void testSequentialError() {
    testName = Mockito.mock(TestName.class);
    Mockito.when(testName.getMethodName()).thenReturn("mockTestError");
    mockDriver = Mockito.mock(WebDriver.class);
    Mockito.when(mockDriver.manage()).thenThrow(new AssertionFailedError());
    super.runSequential();
}
项目:bootstrap    文件:TAbstractSequentialSeleniumTest.java   
/**
 * Run sequentially the given runnable instance with an error.
 */
@Test(expected = AssertionError.class)
public void testSequentialError2() {
    testName = Mockito.mock(TestName.class);
    Mockito.when(testName.getMethodName()).thenReturn("mockTestError");
    super.runSequential();
}
项目:niotest    文件:FSDescription.java   
public void markHits( TestName testMethodName ) {
    Optional<String> found = bugs.stream().filter( name -> name.equals( testMethodName.getMethodName() ) ).findFirst();

    if( found.isPresent() ) {
        usedBugs.add( found.get() );
        return;
    }

    Optional<String> usedScheme = bugSchemes.stream().filter( scheme -> testMethodName.getMethodName().contains( scheme ) ).findFirst();

    if( usedScheme.isPresent() ) {
        usedSchemes.add( usedScheme.get() );
    }
}
项目:QDrill    文件:TestTools.java   
public static TestRule getTimeoutRule(int timeout) {
  return IS_DEBUG ? new TestName() : new Timeout(timeout);
}
项目:QDrill    文件:TestTools.java   
/**
 * If not enforced, the repeat rule applies only if the test is run in non-debug mode.
 */
public static TestRule getRepeatRule(final boolean enforce) {
  return enforce || !IS_DEBUG ? new RepeatTestRule() : new TestName();
}
项目:monarch    文件:SerializableTestName.java   
SerializationProxy(final SerializableTestName instance) {
  this.name = (String) readField(TestName.class, instance, FIELD_NAME);
}
项目:monarch    文件:SerializableTestName.java   
private Object readResolve() {
  SerializableTestName instance = new SerializableTestName();
  writeField(TestName.class, instance, FIELD_NAME, this.name);
  return instance;
}
项目:monarch    文件:SerializableTestNameTest.java   
@Test
public void hasOneFields() throws Exception {
  Field[] fields = TestName.class.getDeclaredFields();
  assertThat(fields.length).as("Fields: " + Arrays.asList(fields)).isEqualTo(1);
}
项目:monarch    文件:SerializableTestNameTest.java   
@Test
public void fieldNameShouldExist() throws Exception {
  Field field = TestName.class.getDeclaredField(FIELD_NAME);
  assertThat(field.getType()).isEqualTo(String.class);
}
项目:bootstrap    文件:TAbstractRepeatableSeleniumTest.java   
@org.junit.Test
public void testCloneAndRun() throws Exception {
    testName = Mockito.mock(TestName.class);
    Mockito.when(testName.getMethodName()).thenReturn("mockTest");
    cloneAndRun(new Test(), null, null);
}
项目:dremio-oss    文件:TestTools.java   
public static TestRule getTimeoutRule(int timeout, TimeUnit unit) {
  return IS_DEBUG ? new TestName() : Timeout.builder().withTimeout(timeout, unit).build();
}
项目:dremio-oss    文件:TestTools.java   
/**
 * If not enforced, the repeat rule applies only if the test is run in non-debug mode.
 */
public static TestRule getRepeatRule(final boolean enforce) {
  return enforce || !IS_DEBUG ? new RepeatTestRule() : new TestName();
}
项目:fcrepo-api-x    文件:ServiceBasedTest.java   
protected ExtensionBuilder newExtension(final TestName name) {
    return new ExtensionBuilder(name);
}
项目:fcrepo-api-x    文件:ServiceBasedTest.java   
ExtensionBuilder(final TestName name) {
    this.name = name.getMethodName();
    differentiator = name.getMethodName() + "-" + UUID.randomUUID().toString();
}
项目:drill    文件:TestTools.java   
public static TestRule getTimeoutRule(int timeout) {
  return IS_DEBUG ? new TestName() : new Timeout(timeout);
}
项目:drill    文件:TestTools.java   
/**
 * If not enforced, the repeat rule applies only if the test is run in non-debug mode.
 */
public static TestRule getRepeatRule(final boolean enforce) {
  return enforce || !IS_DEBUG ? new RepeatTestRule() : new TestName();
}
项目:drill    文件:TestTools.java   
public static TestRule getTimeoutRule(int timeout) {
  return IS_DEBUG ? new TestName() : new Timeout(timeout);
}
项目:drill    文件:TestTools.java   
/**
 * If not enforced, the repeat rule applies only if the test is run in non-debug mode.
 */
public static TestRule getRepeatRule(final boolean enforce) {
  return enforce || !IS_DEBUG ? new RepeatTestRule() : new TestName();
}
项目:metasfresh    文件:Helper.java   
public Helper(final TestName testName)
{
    super();
    this.testName = testName;
}
项目:sosiefier    文件:TestRuleTest.java   
@Rule
private TestRule getRule() {
    return new TestName();
}
项目:hbase    文件:SpaceQuotaHelperForTests.java   
public SpaceQuotaHelperForTests(
    HBaseTestingUtility testUtil, TestName testName, AtomicLong counter) {
  this.testUtil = Objects.requireNonNull(testUtil);
  this.testName = Objects.requireNonNull(testName);
  this.counter = Objects.requireNonNull(counter);
}
项目:niotest    文件:FSDescription.java   
public boolean isBug( TestName testMethodName ) {
    return bugs.contains( testMethodName.getMethodName() ) ||
            bugSchemes.stream().anyMatch( scheme -> testMethodName.getMethodName().contains( scheme ) );

}
项目:fossil4idea    文件:BaseFossilTest.java   
@Before
public void setUp() throws Exception {
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      try {
        final String key = "idea.load.plugins.id";
        String homePath = System.getProperty(PathManager.PROPERTY_HOME_PATH);
        new File(homePath, "test").mkdirs();
        System.setProperty(key, "fossil4idea");
        final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
        myTempDirTestFixture = fixtureFactory.createTempDirTestFixture();
        myTempDirTestFixture.setUp();

        final String tempDirPath = myTempDirTestFixture.getTempDirPath();
        new File(tempDirPath).mkdirs();
        String name = getClass().getName() + "." + new TestName().getMethodName();

        final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder = IdeaTestFixtureFactory.getFixtureFactory().
                createFixtureBuilder(name);
        myProjectFixture = testFixtureBuilder.getFixture();
        final ModuleFixtureBuilder builder = testFixtureBuilder.
                addModule(EmptyModuleFixtureBuilder.class).addContentRoot(tempDirPath);
        myProjectFixture.setUp();
        myProject = myProjectFixture.getProject();
        //builder.addContentRoot(myProject.getBasePath());

        myLocalFileSystem = LocalFileSystem.getInstance();

        setCorrectFossilPath();
        createRepositoryTreeInside(tempDirPath);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    private void setCorrectFossilPath() {
      if (new File(".\\util\\fossil.exe").exists()) {
        FossilConfiguration.getInstance(myProject).FOSSIL_PATH = new File(".\\util\\fossil.exe").getAbsolutePath();
      }
    }
  });
  startChangeProvider();
  myVcs = FossilVcs.getInstance(myProject);
}
项目:fossil4idea    文件:BaseTwoRootedFossilTest.java   
@Before
public void setUp() throws Exception {
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      try {
        final String key = "idea.load.plugins.id";
        System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, PlatformUtils.IDEA_CE_PREFIX);
        System.setProperty(key, "com.intellij,fossil4idea");
        final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
        myTempDirTestFixture = fixtureFactory.createTempDirTestFixture();
        myTempDirTestFixture.setUp();
        // todo same myTempDirTestFixture, deeper project level
        final String tempDirPath = myTempDirTestFixture.getTempDirPath();
        myContentOne = new File(tempDirPath);
        myContentOne.mkdirs();
        String name = getClass().getName() + "." + new TestName().getMethodName();

        final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder = IdeaTestFixtureFactory.getFixtureFactory().
                createFixtureBuilder(name);
        myProjectFixture = testFixtureBuilder.getFixture();
        final ModuleFixtureBuilder builder = testFixtureBuilder.
                addModule(EmptyModuleFixtureBuilder.class).addContentRoot(tempDirPath);
        myProjectFixture.setUp();
        myProject = myProjectFixture.getProject();
        //builder.addContentRoot(myProject.getBasePath());

        myLocalFileSystem = LocalFileSystem.getInstance();

        if (myTwoProjects) {
          myTempDirTestFixture1 = fixtureFactory.createTempDirTestFixture();
          myTempDirTestFixture1.setUp();

          final String tempDirPath1 = myTempDirTestFixture1.getTempDirPath();
          myContentTwo = new File(tempDirPath1);
          myContentTwo.mkdirs();
          Assert.assertNotSame(myContentOne, myContentTwo);
          String name1 = getClass().getName() + "." + new TestName().getMethodName() + "1";

          final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder1 = IdeaTestFixtureFactory.getFixtureFactory().
                  createFixtureBuilder(name1);
          myProjectFixture1 = testFixtureBuilder1.getFixture();
          final ModuleFixtureBuilder builder1 = testFixtureBuilder1.
                  addModule(EmptyModuleFixtureBuilder.class).addContentRoot(tempDirPath1);
          myProjectFixture1.setUp();
          myProject1 = myProjectFixture1.getProject();
        }

        setCorrectFossilPath();
        createRepositoryTreeInside(tempDirPath);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    private void setCorrectFossilPath() {
      if (new File(".\\util\\fossil.exe").exists()) {
        FossilConfiguration.getInstance(myProject).FOSSIL_PATH = new File(".\\util\\fossil.exe").getAbsolutePath();
        if (myProject1 != null) {
          FossilConfiguration.getInstance(myProject1).FOSSIL_PATH = new File(".\\util\\fossil.exe").getAbsolutePath();
        }
      }
    }
  });
  startChangeProvider();
  myVcs = FossilVcs.getInstance(myProject);
}
项目:test-generation    文件:CompilationTestGoldenMasterHelper.java   
public void assertCompilesToFile(CharSequence source, final TestName testName) throws IOException {
    new File(REFERENCES_FOLDER).mkdirs();
    assertCompilesToFile(source, REFERENCES_FOLDER + testName.getMethodName() + ".java");
}
项目:junit    文件:TestRuleTest.java   
@SuppressWarnings("unused")
@Rule
private TestRule getRule() {
    return new TestName();
}
项目:health-and-care-developer-network    文件:TestRuleTest.java   
@SuppressWarnings("unused")
@Rule
private TestRule getRule() {
    return new TestName();
}
项目:Camel    文件:TestSupport.java   
/**
 * Gets the current test name
 *
 * @return the test name
 */
@Rule
public TestName getTestName() {
    return testName;
}