use of org.testng.annotations.AfterMethod in project incubator-gobblin by apache.
the class AvroGenericRecordAccessorTest method serializeRecord.
@AfterMethod
public void serializeRecord(ITestResult result) throws IOException {
if (result.isSuccess() && result.getThrowable() == null) {
/* Serialize the GenericRecord; this can catch issues in set() that the underlying GenericRecord
* may not catch until serialize time
*/
DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<>(recordSchema);
ByteArrayOutputStream bOs = new ByteArrayOutputStream();
BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(bOs, null);
datumWriter.write(record, encoder);
encoder.flush();
bOs.flush();
Assert.assertTrue(bOs.toByteArray().length > 0);
}
}
use of org.testng.annotations.AfterMethod in project selenium_java by sergueik.
the class BaseTest method tearDown.
@AfterMethod
public void tearDown(ITestResult result, ITestContext context) throws Exception {
Throwable t = result.getThrowable();
if (t instanceof WebDriverException || t instanceof AssertionError) {
// System.out.println("WebDriver or Assert Exception");
// get filename
Calendar cal = Calendar.getInstance();
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
// concat prefix with current time and return
String filename = result.getTestClass().getName() + "." + result.getMethod().getMethodName() + "." + sf.format(cal.getTime()) + ".png";
WebDriver augmentedDriver = new Augmenter().augment(driver);
File scrFile = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File(context.getOutputDirectory() + separator + filename));
Reporter.setCurrentTestResult(result);
Reporter.log("<a href=\"" + filename + "\">Screenshot</a>");
}
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
Assert.fail(verificationErrorString);
}
}
use of org.testng.annotations.AfterMethod in project incubator-pulsar by apache.
the class ProxyAuthenticationTest method cleanup.
@AfterMethod
protected void cleanup() throws Exception {
ExecutorService executor = newFixedThreadPool(1);
try {
executor.submit(() -> {
try {
consumeClient.stop();
produceClient.stop();
log.info("proxy clients are stopped successfully");
} catch (Exception e) {
log.error(e.getMessage());
}
}).get(2, TimeUnit.SECONDS);
} catch (Exception e) {
log.error("failed to close clients ", e);
}
executor.shutdownNow();
super.internalCleanup();
service.close();
proxyServer.stop();
log.info("Finished Cleaning Up Test setup");
}
use of org.testng.annotations.AfterMethod in project incubator-pulsar by apache.
the class FileSinkTest method after.
@AfterMethod
public void after() {
fileSink.close();
for (File file : tmpDir.listFiles()) {
file.delete();
}
tmpDir.delete();
}
use of org.testng.annotations.AfterMethod in project bioformats by openmicroscopy.
the class FakeReaderTest method tearDown.
@AfterMethod
public void tearDown() throws Exception {
reader.close();
deleteTemporaryDirectoryOnExit(new Location(wd.toFile()));
}
Aggregations