Search in sources :

Example 11 with AfterMethod

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);
    }
}
Also used : BinaryEncoder(org.apache.avro.io.BinaryEncoder) GenericDatumWriter(org.apache.avro.generic.GenericDatumWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) GenericRecord(org.apache.avro.generic.GenericRecord) AfterMethod(org.testng.annotations.AfterMethod)

Example 12 with AfterMethod

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);
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) Augmenter(org.openqa.selenium.remote.Augmenter) Calendar(java.util.Calendar) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) WebDriverException(org.openqa.selenium.WebDriverException) TakesScreenshot(org.openqa.selenium.TakesScreenshot) AfterMethod(org.testng.annotations.AfterMethod)

Example 13 with AfterMethod

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");
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) AfterMethod(org.testng.annotations.AfterMethod)

Example 14 with AfterMethod

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();
}
Also used : File(java.io.File) AfterMethod(org.testng.annotations.AfterMethod)

Example 15 with AfterMethod

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()));
}
Also used : Location(loci.common.Location) AfterMethod(org.testng.annotations.AfterMethod)

Aggregations

AfterMethod (org.testng.annotations.AfterMethod)74 File (java.io.File)16 MifosPage (org.mifos.test.acceptance.framework.MifosPage)10 DateTimeUpdaterRemoteTestingService (org.mifos.test.acceptance.remote.DateTimeUpdaterRemoteTestingService)8 ProtocolStack (org.jgroups.stack.ProtocolStack)6 IOException (java.io.IOException)5 HashSet (java.util.HashSet)4 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)4 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)3 JdbcSession (com.evolveum.midpoint.repo.sqlbase.JdbcSession)2 DispatchManager (com.facebook.presto.dispatcher.DispatchManager)2 OServerAdmin (com.orientechnologies.orient.client.remote.OServerAdmin)2 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)2 RandomAccessFile (java.io.RandomAccessFile)2 Date (java.util.Date)2 ExecutorService (java.util.concurrent.ExecutorService)2 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)2 Parameters (org.testng.annotations.Parameters)2