@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; }
/** 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); }
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) { } }; }
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); } }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
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() ); } }
public static TestRule getTimeoutRule(int timeout) { return IS_DEBUG ? new TestName() : new Timeout(timeout); }
/** * 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(); }
SerializationProxy(final SerializableTestName instance) { this.name = (String) readField(TestName.class, instance, FIELD_NAME); }
private Object readResolve() { SerializableTestName instance = new SerializableTestName(); writeField(TestName.class, instance, FIELD_NAME, this.name); return instance; }
@Test public void hasOneFields() throws Exception { Field[] fields = TestName.class.getDeclaredFields(); assertThat(fields.length).as("Fields: " + Arrays.asList(fields)).isEqualTo(1); }
@Test public void fieldNameShouldExist() throws Exception { Field field = TestName.class.getDeclaredField(FIELD_NAME); assertThat(field.getType()).isEqualTo(String.class); }
@org.junit.Test public void testCloneAndRun() throws Exception { testName = Mockito.mock(TestName.class); Mockito.when(testName.getMethodName()).thenReturn("mockTest"); cloneAndRun(new Test(), null, null); }
public static TestRule getTimeoutRule(int timeout, TimeUnit unit) { return IS_DEBUG ? new TestName() : Timeout.builder().withTimeout(timeout, unit).build(); }
protected ExtensionBuilder newExtension(final TestName name) { return new ExtensionBuilder(name); }
ExtensionBuilder(final TestName name) { this.name = name.getMethodName(); differentiator = name.getMethodName() + "-" + UUID.randomUUID().toString(); }
public Helper(final TestName testName) { super(); this.testName = testName; }
@Rule private TestRule getRule() { return new TestName(); }
public SpaceQuotaHelperForTests( HBaseTestingUtility testUtil, TestName testName, AtomicLong counter) { this.testUtil = Objects.requireNonNull(testUtil); this.testName = Objects.requireNonNull(testName); this.counter = Objects.requireNonNull(counter); }
public boolean isBug( TestName testMethodName ) { return bugs.contains( testMethodName.getMethodName() ) || bugSchemes.stream().anyMatch( scheme -> testMethodName.getMethodName().contains( scheme ) ); }
@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); }
@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); }
public void assertCompilesToFile(CharSequence source, final TestName testName) throws IOException { new File(REFERENCES_FOLDER).mkdirs(); assertCompilesToFile(source, REFERENCES_FOLDER + testName.getMethodName() + ".java"); }
@SuppressWarnings("unused") @Rule private TestRule getRule() { return new TestName(); }
/** * Gets the current test name * * @return the test name */ @Rule public TestName getTestName() { return testName; }