本文整理汇总了Java中net.anthavio.phanbedder.Phanbedder类的典型用法代码示例。如果您正苦于以下问题:Java Phanbedder类的具体用法?Java Phanbedder怎么用?Java Phanbedder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Phanbedder类属于net.anthavio.phanbedder包,在下文中一共展示了Phanbedder类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSeleniumGhostDriver
import net.anthavio.phanbedder.Phanbedder; //导入依赖的package包/类
@Test
public void testSeleniumGhostDriver() {
File phantomjs = Phanbedder.unpack();
DesiredCapabilities dcaps = new DesiredCapabilities();
dcaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, phantomjs.getAbsolutePath());
PhantomJSDriver driver = new PhantomJSDriver(dcaps);
try {
driver.get("https://www.google.com");
WebElement query = driver.findElement(By.name("q"));
query.sendKeys("Phanbedder");
query.submit();
Assertions.assertThat(driver.getTitle()).contains("Phanbedder");
} finally {
driver.quit();
}
}
示例2: testJavaIoTmpDirectory
import net.anthavio.phanbedder.Phanbedder; //导入依赖的package包/类
@Test
public void testJavaIoTmpDirectory() throws IOException, InterruptedException {
File binary = Phanbedder.unpack();
String javaIoTmpdir = System.getProperty("java.io.tmpdir");
File expectedDir = new File(javaIoTmpdir, "phantomjs-" + Phanbedder.PHANTOMJS_VERSION);
Assertions.assertThat(binary.getParentFile()).isEqualTo(expectedDir);
assertProcessExecution(binary);
long lastModified = binary.lastModified();
File binary2 = Phanbedder.unpack(); //existing file is returned
Assertions.assertThat(binary2.lastModified()).isEqualTo(lastModified); // SAME
assertProcessExecution(binary2);
binary.delete(); //purge cached
Assertions.assertThat(binary.exists()).isFalse();
Thread.sleep(1000); //1 second at least!
File binary3 = Phanbedder.unpack(); //new file must be unpacked
Assertions.assertThat(binary3.lastModified()).isNotEqualTo(lastModified); //DIFF
assertProcessExecution(binary3);
}
示例3: testLocalTargetDirectory
import net.anthavio.phanbedder.Phanbedder; //导入依赖的package包/类
@Test
public void testLocalTargetDirectory() throws IOException, InterruptedException {
String targetDir = "target/phanbedder-test/unpack";
String binaryPath = Phanbedder.unpack(targetDir);
File binary = new File(binaryPath);
String javaUserDir = System.getProperty("user.dir");
Assertions.assertThat(binary.getParentFile()).isEqualTo(new File(javaUserDir, targetDir));
assertProcessExecution(binary);
long lastModified = binary.lastModified();
String binaryPath2 = Phanbedder.unpack(targetDir); //existing file is returned
File binary2 = new File(binaryPath2);
Assertions.assertThat(binary2.lastModified()).isEqualTo(lastModified); // SAME
assertProcessExecution(binary2);
binary.delete(); //purge cached
Assertions.assertThat(binary.exists()).isFalse();
Thread.sleep(1000); //1 second at least!
String binaryPath3 = Phanbedder.unpack(targetDir); //new file must be unpacked
File binary3 = new File(binaryPath3);
Assertions.assertThat(binary3.lastModified()).isNotEqualTo(lastModified); //DIFF
assertProcessExecution(binary3);
}
示例4: assertProcessExecution
import net.anthavio.phanbedder.Phanbedder; //导入依赖的package包/类
private void assertProcessExecution(File binary) throws IOException {
Assertions.assertThat(binary).exists();
Assertions.assertThat(binary).isFile();
Assertions.assertThat(binary.canExecute()).isTrue();
Process process = new ProcessBuilder(binary.getAbsolutePath(), "--version").start();
String sysout = capture(process.getInputStream());
String syserr = capture(process.getErrorStream());
try {
process.waitFor();
} catch (InterruptedException ix) {
System.out.println("Interrupted process.waitFor()");
}
Assertions.assertThat(process.exitValue()).isEqualTo(0);
Assertions.assertThat(syserr).isEmpty();
Assertions.assertThat(sysout).isEqualTo(Phanbedder.PHANTOMJS_VERSION); //phantomjs binary version check!
}
示例5: before
import net.anthavio.phanbedder.Phanbedder; //导入依赖的package包/类
@Override
public void before() {
File phantomjs = Phanbedder.unpack();
DesiredCapabilities dcaps = new DesiredCapabilities();
dcaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, phantomjs.getAbsolutePath());
driver = new PhantomJSDriver(dcaps);
}