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());
}
}
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();
}
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);
}
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();
}
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());
}
Aggregations