下面列出了怎么用org.testng.annotations.AfterTest的API类实例代码及写法,或者点击链接到github查看源代码。
@AfterTest(alwaysRun = true)
public void unDeployServices() throws Exception {
if (axis2Server1 != null && axis2Server1.isStarted()) {
axis2Server1.stop();
} else {
if (TestConfigurationProvider.isPlatform() && asContext != null) {
int deploymentDelay = TestConfigurationProvider.getServiceDeploymentDelay();
String serviceName = ESBTestConstant.SIMPLE_AXIS2_SERVICE;
String studentServiceName = ESBTestConstant.STUDENT_REST_SERVICE;
ServiceDeploymentUtil deployer = new ServiceDeploymentUtil();
String sessionCookie = new LoginLogoutClient(asContext).login();
deployer.unDeployArrService(asContext.getContextUrls().getBackEndUrl(), sessionCookie, serviceName,
deploymentDelay);
deployer.unDeployArrService(asContext.getContextUrls().getBackEndUrl(), sessionCookie,
studentServiceName, deploymentDelay);
}
}
}
@AfterTest(alwaysRun = true)
public void unDeployServices()
throws IOException, LoginAuthenticationExceptionException, ExceptionException, XPathExpressionException,
URISyntaxException, SAXException, XMLStreamException, AutomationUtilException {
if (TestConfigurationProvider.isIntegration() && axis2Server1 != null && axis2Server1.isStarted()) {
axis2Server1.stop();
} else {
AutomationContext asContext = new AutomationContext("AS", TestUserMode.SUPER_TENANT_ADMIN);
int deploymentDelay = TestConfigurationProvider.getServiceDeploymentDelay();
String serviceName = "SecureStockQuoteServiceScenario";
ServiceDeploymentUtil deployer = new ServiceDeploymentUtil();
LoginLogoutClient loginLogoutClient = new LoginLogoutClient(asContext);
for (int i = 1; i < 9; i++) {
deployer.unDeployArrService(asContext.getContextUrls().getBackEndUrl(), loginLogoutClient.login(),
serviceName + i, deploymentDelay);
}
}
}
static void invokeTestNgAfterMethods(Object testInstance)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException {
if (testInstance != null) {
List<Method> afterMethods = new ArrayList<>();
collectCallbacks(testInstance.getClass(), afterMethods, (Class<? extends Annotation>) testInstance.getClass()
.getClassLoader().loadClass(AfterMethod.class.getName()));
collectCallbacks(testInstance.getClass(), afterMethods, (Class<? extends Annotation>) testInstance.getClass()
.getClassLoader().loadClass(AfterTest.class.getName()));
for (Method m : afterMethods) {
// we don't know the values for parameterized methods that TestNG allows, we just skip those
if (m.getParameterCount() == 0) {
m.setAccessible(true);
m.invoke(testInstance);
}
}
}
}
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@AfterTest(alwaysRun = true)
public void unDeployServices()
throws MalformedURLException, LoginAuthenticationExceptionException, ExceptionException, RemoteException {
if (axis2Server1 != null && axis2Server1.isStarted()) {
axis2Server1.stop();
}
}
@AfterTest(alwaysRun = true)
public void tearDown()
{
assertThatNoBlackHoleTableIsCreated();
queryRunner.close();
queryRunner = null;
}
@AfterTest
public void tearDownClient() {
ConfigProviderResolver cpr = ConfigProviderResolver.instance();
try {
Config old = cpr.getConfig();
cpr.releaseConfig(old);
} catch (IllegalStateException ignored) {
}
}
@AfterTest
public void tearDownClient() {
ConfigProviderResolver cpr = ConfigProviderResolver.instance();
try {
Config old = cpr.getConfig();
cpr.releaseConfig(old);
} catch (IllegalStateException ignored) {
}
}
@AfterTest(groups = { "unit" })
public void afterMethod() {
// set back default locale before test
if (defaultLocale != null) {
Locale.setDefault(defaultLocale);
} else {
Locale.setDefault(Locale.US);
}
}
@AfterTest
public void Teardown() {
try {
if (driver != null)
driver.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
@AfterTest
public void Teardown() {
try {
if (driver != null)
driver.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
@AfterTest
public void Teardown() {
try {
if (driver != null)
driver.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
@AfterTest
public void Teardown() {
try {
if(driver != null)
driver.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
@AfterTest
public void Teardown() {
try {
if (driver != null)
driver.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
@AfterTest
void printIfError() {
if (asserted) {
System.setOut(originalOut);
System.setErr(originalErr);
System.out.println(outContent.toString());
System.err.println(errContent.toString());
}
}
@AfterTest(alwaysRun = true)
public void cleanUp() throws Exception {
GreenMailServer.stopServer();
}
@AfterTest(alwaysRun = true)
public void cleanUp() throws Exception {
greenMailServer.stopServer();
}
@AfterTest(alwaysRun = true)
public void destroy() throws Exception {
carbonLogReader.stop();
Utils.undeploySynapseConfiguration("inbound1", "inbound-endpoints", false);
Utils.undeploySynapseConfiguration("inbound2", "inbound-endpoints", true);
}
@AfterTest(alwaysRun = true)
public void stop() throws Exception {
client.destroy();
tomcatServerManager.stop();
super.cleanup();
}
@AfterTest(alwaysRun = true)
public void destroy() throws Exception {
super.cleanup();
}
@AfterTest(alwaysRun = true)
public void cleanupEnvironment() throws Exception {
super.cleanup();
}
@AfterTest(alwaysRun = true)
public void cleanupEnvironment() throws Exception {
super.cleanup();
}
@AfterTest(alwaysRun = true)
public void cleanupEnvironment() throws Exception {
super.cleanup();
}
@AfterTest(alwaysRun = true)
public void cleanupEnvironment() throws Exception {
super.cleanup();
}
@AfterTest(alwaysRun = true)
public void close() throws Exception {
serverConfigurationManager.restoreToLastMIConfiguration();
}
@AfterTest(alwaysRun = true)
public void destroy() throws Exception {
super.cleanup();
}
@AfterTest(alwaysRun = true)
public void destroy() throws Exception {
super.cleanup();
}
@AfterTest
public void tearDown() throws Exception {
System.getProperties().remove(USER_CONTEXT_EXPIRY_IN_SECONDS);
userContextStore = null;
}
@AfterTest
public void shutdown() {
executor.shutdown();
}
@AfterTest
public void cleanup() {
executor.shutdown();
}
@AfterTest
public void shutdown() {
executor.shutdown();
}