Search in sources :

Example 31 with BeforeTest

use of org.testng.annotations.BeforeTest in project carbon-apimgt by wso2.

the class ConfigurationsAPITestCase method setup.

@BeforeTest
public void setup() throws Exception {
    WorkflowExtensionsConfigBuilder.build(new ConfigProvider() {

        @Override
        public <T> T getConfigurationObject(Class<T> configClass) throws ConfigurationException {
            T workflowConfig = (T) new WorkflowConfig();
            return workflowConfig;
        }

        @Override
        public Object getConfigurationObject(String s) throws ConfigurationException {
            return null;
        }

        public <T> T getConfigurationObject(String s, Class<T> aClass) throws ConfigurationException {
            return null;
        }
    });
    ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
    ServiceReferenceHolder.getInstance().setConfigProvider(configProvider);
}
Also used : WorkflowConfig(org.wso2.carbon.apimgt.core.models.WorkflowConfig) ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) ConfigurationException(org.wso2.carbon.config.ConfigurationException) BeforeTest(org.testng.annotations.BeforeTest)

Example 32 with BeforeTest

use of org.testng.annotations.BeforeTest in project Payara by payara.

the class BaseAdminConsoleTest method loginBeforeTest.

/**
 * This BeforeTest method will verify that the login form is available.  Once
 * it is found, the login form is submitted.  If the login succeeds, then
 * the tests are allowed to continue.  If the login fails, the each test will
 * fail.
 * @param url
 * @throws java.lang.Exception
 */
@BeforeTest
@Parameters({ "admin.console.url", "amx.rmiport" })
public void loginBeforeTest(String url, int port) throws Exception {
    this.adminUrl = url;
    setUpEnvironment(port);
    client = new HttpClient();
    boolean formFound = false;
    int iteration = 0;
    if (!checkForAdminConsoleDirectory()) {
        Assert.fail("The admin console directory was not found at " + this.getDomainRoot().getInstallDir() + GLASSFISH_DIR + CONSOLE_DIR_PATH + ".  Please check your installation.");
    }
    while (!formFound && iteration < AC_TEST_ITERATIONS) {
        iteration++;
        formFound = getUrlAndTestForStrings(adminUrl + "login.jsf", "id=\"Login.username\"");
        if (!formFound) {
            System.err.println("***** Login page not found.  Sleeping to allow app to deploy (" + iteration + " of " + AC_TEST_ITERATIONS + ")...");
            Thread.sleep(AC_TEST_DELAY);
        }
    }
    if (!formFound) {
        Assert.fail("The login form was not found.");
    }
    // The login for was found, so let's now POST the form to authenticate our session.
    PostMethod post = new PostMethod(adminUrl + "j_security_check");
    post.setRequestBody(new NameValuePair[] { new NameValuePair("j_username", "admin"), new NameValuePair("j_password", "") });
    post.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
    int statusCode = client.executeMethod(post);
    if (statusCode == 302) {
        Header locationHeader = post.getResponseHeader("location");
        if (locationHeader != null) {
            Assert.assertTrue(locationHeader.getValue().startsWith(this.adminUrl));
        } else {
            Assert.fail("Failed to login: no redirect header");
        }
    } else if (statusCode != HttpStatus.SC_OK) {
        Assert.fail("Login failed: " + post.getStatusLine() + ": " + statusCode);
    }
}
Also used : NameValuePair(org.apache.commons.httpclient.NameValuePair) Header(org.apache.commons.httpclient.Header) PostMethod(org.apache.commons.httpclient.methods.PostMethod) HttpClient(org.apache.commons.httpclient.HttpClient) Parameters(org.testng.annotations.Parameters) BeforeTest(org.testng.annotations.BeforeTest)

Example 33 with BeforeTest

use of org.testng.annotations.BeforeTest in project Payara by payara.

the class CDIEarTest method beforeTest.

@BeforeTest
public void beforeTest() throws NamingException {
    context = new InitialContext();
    String appJar = APP_JAR;
    if (!SOURCE_HOME.startsWith("$")) {
        appJar = SOURCE_HOME + SOURCE_HOME_APP;
    }
    deployed1 = NucleusTestUtils.nadmin("deploy", appJar);
    Assert.assertTrue(deployed1);
}
Also used : InitialContext(javax.naming.InitialContext) BeforeTest(org.testng.annotations.BeforeTest)

Example 34 with BeforeTest

use of org.testng.annotations.BeforeTest in project atsd-api-test by axibase.

the class SqlPeriodMonthTest method prepareData.

@BeforeTest
public void prepareData() throws Exception {
    Series series = new Series(entity(), TEST_METRIC);
    series.addSamples(Sample.ofDateInteger("2017-01-31T00:00:05Z", 1), Sample.ofDateInteger("2017-02-27T00:00:05Z", 2), Sample.ofDateInteger("2017-03-31T00:00:05Z", 3), Sample.ofDateInteger("2017-04-30T00:00:05Z", 4), Sample.ofDateInteger("2017-05-31T00:00:05Z", 5));
    insertSeriesCheck(series);
}
Also used : Series(com.axibase.tsd.api.model.series.Series) BeforeTest(org.testng.annotations.BeforeTest)

Example 35 with BeforeTest

use of org.testng.annotations.BeforeTest in project athenz by yahoo.

the class SimpleServiceIdentityProviderTest method loadKeys.

@BeforeTest
private void loadKeys() throws IOException {
    Path path = Paths.get("./src/test/resources/fantasy_public_k0.key");
    servicePublicKeyStringK0 = new String(Files.readAllBytes(path));
    path = Paths.get("./src/test/resources/fantasy_private_k0.key");
    k0File = path.toFile();
    path = Paths.get("./src/test/resources/fantasy_public_k1.key");
    servicePublicKeyStringK1 = new String(Files.readAllBytes(path));
    path = Paths.get("./src/test/resources/fantasy_private_k1.key");
    servicePrivateKeyStringK1 = new String(Files.readAllBytes(path));
}
Also used : Path(java.nio.file.Path) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

BeforeTest (org.testng.annotations.BeforeTest)80 HashMap (java.util.HashMap)8 CommandManager (com.sun.identity.cli.CommandManager)6 Path (java.nio.file.Path)6 File (java.io.File)5 Injector (com.google.inject.Injector)4 PinotHelixResourceManager (com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager)4 Series (com.axibase.tsd.api.model.series.Series)3 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)3 ArrayList (java.util.ArrayList)3 Parameters (org.testng.annotations.Parameters)3 SSOException (com.iplanet.sso.SSOException)2 Schema (com.linkedin.pinot.common.data.Schema)2 SegmentGeneratorConfig (com.linkedin.pinot.core.indexsegment.generator.SegmentGeneratorConfig)2 SegmentIndexCreationDriver (com.linkedin.pinot.core.segment.creator.SegmentIndexCreationDriver)2 SegmentIndexCreationDriverImpl (com.linkedin.pinot.core.segment.creator.impl.SegmentIndexCreationDriverImpl)2 ThirdEyeConfigProperties (com.linkedin.thirdeye.hadoop.config.ThirdEyeConfigProperties)2 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)2 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)2 SMSException (com.sun.identity.sm.SMSException)2