Search in sources :

Example 31 with AfterMethod

use of org.testng.annotations.AfterMethod in project elasticsearch-jdbc by jprante.

the class AbstractSourceTest method afterMethod.

@AfterMethod
@Parameters({ "stopurl", "user", "password", "delete" })
public void afterMethod(String stopurl, String user, String password, @Optional String resourceName) throws Exception {
    logger.info("remove table {}", resourceName);
    if (resourceName == null || "".equals(resourceName)) {
        return;
    }
    // before dropping tables, open read connection must be closed to avoid hangs in mysql/postgresql
    logger.debug("closing reads...");
    source.closeReading();
    logger.debug("connecting for close...");
    Connection connection = source.getConnectionForWriting();
    if (connection == null) {
        throw new IOException("no connection");
    }
    logger.debug("cleaning...");
    // clean up tables
    sqlScript(connection, resourceName);
    logger.debug("closing writes...");
    source.closeWriting();
    // we can drop database by a magic 'stop' URL
    source = newSource().setUrl(stopurl).setUser(user).setPassword(password).setLocale(Locale.getDefault()).setTimeZone(TimeZone.getDefault());
    try {
        logger.info("connecting to stop URL...");
        // activate stop URL
        source.getConnectionForWriting();
    } catch (Exception e) {
    // exception is expected, ignore
    }
    // close open write connection
    source.closeWriting();
}
Also used : Connection(java.sql.Connection) IOException(java.io.IOException) SQLException(java.sql.SQLException) IOException(java.io.IOException) AfterMethod(org.testng.annotations.AfterMethod) Parameters(org.testng.annotations.Parameters)

Example 32 with AfterMethod

use of org.testng.annotations.AfterMethod in project rest.li by linkedin.

the class TestD2Config method teardown.

@AfterMethod
public void teardown() throws IOException, InterruptedException {
    for (LoadBalancerEchoServer echoServer : _echoServerList) {
        try {
            echoServer.stopServer();
            _log.info("Executed echoserver shutdown. ");
        } catch (Exception e) {
            _log.info("echoserver shutdown failed. EchoServer:" + echoServer);
            e.printStackTrace();
        }
    }
    try {
        _zkclient.shutdown();
        _log.info("Executed cli shutdown. ");
    } catch (Exception e) {
        _log.info("zkclient shutdown failed.");
    }
    try {
        _zkServer.shutdown();
        _log.info("Executed zkServer shutdown. ");
    } catch (Exception e) {
        _log.info("zk server shutdown failed.");
    }
}
Also used : LoadBalancerEchoServer(com.linkedin.d2.balancer.util.LoadBalancerEchoServer) URISyntaxException(java.net.URISyntaxException) PartitionAccessException(com.linkedin.d2.balancer.util.partitions.PartitionAccessException) PropertyStoreException(com.linkedin.d2.discovery.stores.PropertyStoreException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) AfterMethod(org.testng.annotations.AfterMethod)

Example 33 with AfterMethod

use of org.testng.annotations.AfterMethod in project incubator-atlas by apache.

the class AbstractGraphDatabaseTest method removeVertices.

@AfterMethod
public void removeVertices() {
    for (AtlasVertex vertex : newVertices) {
        if (vertex.exists()) {
            getGraph().removeVertex(vertex);
        }
    }
    getGraph().commit();
    newVertices.clear();
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AfterMethod(org.testng.annotations.AfterMethod)

Example 34 with AfterMethod

use of org.testng.annotations.AfterMethod in project midpoint by Evolveum.

the class AbstractIntegrationTest method finishTestContext.

/**
 * Finish and destroy the test context, output duration and store the operation trace.
 * This implementation fully overrides (without use) the one from {@link AbstractSpringTest}.
 */
@Override
@AfterMethod
public void finishTestContext(ITestResult testResult) {
    MidpointTestContextWithTask context = MidpointTestContextWithTask.get();
    displayTestFooter(context.getTestName(), testResult);
    // let's destroy it before anything else in this method
    MidpointTestContextWithTask.destroy();
    Task task = context.getTask();
    if (task != null) {
        OperationResult result = context.getResult();
        if (result != null) {
            result.computeStatusIfUnknown();
            if (result.isTraced()) {
                display("Storing the trace.");
                tracer.storeTrace(task, result, null);
            }
            task.getResult().computeStatusIfUnknown();
        }
    }
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AfterMethod(org.testng.annotations.AfterMethod)

Example 35 with AfterMethod

use of org.testng.annotations.AfterMethod in project rest.li by linkedin.

the class TestRestLiFilterChain method resetMocks.

@AfterMethod
protected void resetMocks() {
    reset(_mockFilterChainDispatcher, _mockFilterChainCallback, _mockFilterRequestContext, _mockFilterResponseContext, _mockRestLiRequestData, _mockRestLiResponseData);
    _filters = new CountFilter[] { new CountFilter(), new CountFilter(), new CountFilter() };
}
Also used : CountFilter(com.linkedin.restli.internal.server.filter.testfilters.CountFilter) 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