Search in sources :

Example 61 with AfterMethod

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

the class BaseSQLRepoTest method afterMethod.

@AfterMethod
public void afterMethod() {
    try {
        Session session = factory.getCurrentSession();
        if (session != null) {
            session.close();
            AssertJUnit.fail("Session is still open, check test code or bug in sql service.");
        }
    } catch (Exception ex) {
        // it's ok
        logger.debug("after test method, checking for potential open session, exception occurred: " + ex.getMessage());
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) Session(org.hibernate.Session) AfterMethod(org.testng.annotations.AfterMethod)

Example 62 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 63 with AfterMethod

use of org.testng.annotations.AfterMethod in project killbill by killbill.

the class TestSubscriptionDao method afterMethod.

// to ignore events
@Override
@AfterMethod(groups = "slow")
public void afterMethod() throws Exception {
    if (hasFailed()) {
        final String externalKey = "12345";
        final DateTime startDate = clock.getUTCNow();
        final DateTime createdDate = startDate.plusSeconds(10);
        final DefaultSubscriptionBaseBundle bundleDef = new DefaultSubscriptionBaseBundle(externalKey, accountId, startDate, startDate, createdDate, createdDate);
        final SubscriptionBaseBundle bundle = dao.createSubscriptionBundle(bundleDef, catalog, true, internalCallContext);
        final List<SubscriptionBaseBundle> result = dao.getSubscriptionBundlesForKey(externalKey, internalCallContext);
        assertEquals(result.size(), 1);
        assertEquals(result.get(0).getExternalKey(), bundle.getExternalKey());
        // Operation succeeds but nothing new got created because bundle is empty
        dao.createSubscriptionBundle(bundleDef, catalog, true, internalCallContext);
        final List<SubscriptionBaseBundle> result2 = dao.getSubscriptionBundlesForKey(externalKey, internalCallContext);
        assertEquals(result2.size(), 1);
        // Create a subscription and this time operation should fail
        final SubscriptionBuilder builder = new SubscriptionBuilder().setId(UUIDs.randomUUID()).setBundleId(bundle.getId()).setBundleExternalKey(bundle.getExternalKey()).setCategory(ProductCategory.BASE).setBundleStartDate(startDate).setAlignStartDate(startDate).setMigrated(false);
        final ApiEventBuilder createBuilder = new ApiEventBuilder().setSubscriptionId(builder.getId()).setEventPlan("shotgun-monthly").setEventPlanPhase("shotgun-monthly-trial").setEventPriceList(DefaultPriceListSet.DEFAULT_PRICELIST_NAME).setEffectiveDate(startDate).setFromDisk(true);
        final SubscriptionBaseEvent creationEvent = new ApiEventCreate(createBuilder);
        final DefaultSubscriptionBase subscription = new DefaultSubscriptionBase(builder);
        testListener.pushExpectedEvents(NextEvent.CREATE);
        final SubscriptionBaseWithAddOns subscriptionBaseWithAddOns = new DefaultSubscriptionBaseWithAddOns(bundle, ImmutableList.<SubscriptionBase>of(subscription));
        dao.createSubscriptionsWithAddOns(ImmutableList.<SubscriptionBaseWithAddOns>of(subscriptionBaseWithAddOns), ImmutableMap.<UUID, List<SubscriptionBaseEvent>>of(subscription.getId(), ImmutableList.<SubscriptionBaseEvent>of(creationEvent)), catalog, internalCallContext);
        assertListenerStatus();
        // Operation Should now fail
        try {
            dao.createSubscriptionBundle(bundleDef, catalog, true, internalCallContext);
            Assert.fail("Should fail to create new subscription bundle with existing key");
        } catch (SubscriptionBaseApiException e) {
            assertEquals(ErrorCode.SUB_CREATE_ACTIVE_BUNDLE_KEY_EXISTS.getCode(), e.getCode());
        }
        return;
    }
    subscriptionTestInitializer.stopTestFramework(testListener, busService, subscriptionBaseService);
}
Also used : ApiEventCreate(org.killbill.billing.subscription.events.user.ApiEventCreate) DefaultSubscriptionBaseWithAddOns(org.killbill.billing.subscription.api.user.DefaultSubscriptionBaseWithAddOns) SubscriptionBaseWithAddOns(org.killbill.billing.subscription.api.SubscriptionBaseWithAddOns) DefaultSubscriptionBaseBundle(org.killbill.billing.subscription.api.user.DefaultSubscriptionBaseBundle) SubscriptionBuilder(org.killbill.billing.subscription.api.user.SubscriptionBuilder) DateTime(org.joda.time.DateTime) ApiEventBuilder(org.killbill.billing.subscription.events.user.ApiEventBuilder) SubscriptionBaseBundle(org.killbill.billing.subscription.api.user.SubscriptionBaseBundle) DefaultSubscriptionBaseBundle(org.killbill.billing.subscription.api.user.DefaultSubscriptionBaseBundle) DefaultSubscriptionBase(org.killbill.billing.subscription.api.user.DefaultSubscriptionBase) SubscriptionBaseEvent(org.killbill.billing.subscription.events.SubscriptionBaseEvent) DefaultSubscriptionBaseWithAddOns(org.killbill.billing.subscription.api.user.DefaultSubscriptionBaseWithAddOns) SubscriptionBaseApiException(org.killbill.billing.subscription.api.user.SubscriptionBaseApiException) AfterMethod(org.testng.annotations.AfterMethod)

Example 64 with AfterMethod

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

the class AbstractColumnStrategyTest 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();
    source.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();
    logger.info("stopped");
    // delete test index
    try {
        client("1").admin().indices().delete(new DeleteIndexRequest(index)).actionGet();
        logger.info("index {} deleted", index);
    } catch (Exception e) {
        logger.warn(e.getMessage());
    }
    stopNodes();
}
Also used : Connection(java.sql.Connection) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) IOException(java.io.IOException) IOException(java.io.IOException) SQLException(java.sql.SQLException) AfterMethod(org.testng.annotations.AfterMethod) Parameters(org.testng.annotations.Parameters)

Example 65 with AfterMethod

use of org.testng.annotations.AfterMethod in project orientdb by orientechnologies.

the class OSBTreeBonsaiWALTest method afterMethod.

@AfterMethod
@Override
public void afterMethod() throws Exception {
    Assert.assertNull(actualAtomicOperationsManager.getCurrentOperation());
    expectedDatabaseDocumentTx.open("admin", "admin");
    expectedDatabaseDocumentTx.drop();
    databaseDocumentTx.open("admin", "admin");
    databaseDocumentTx.drop();
    File ad = new File(actualStorageDir);
    if (ad.exists())
        Assert.assertTrue(ad.delete());
    File ed = new File(expectedStorageDir);
    if (ed.exists())
        Assert.assertTrue(ed.delete());
    File bd = new File(buildDirectory);
    if (bd.exists())
        Assert.assertTrue(bd.delete());
}
Also used : RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) 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