org.testng.annotations.BeforeGroups Java Examples

The following examples show how to use org.testng.annotations.BeforeGroups. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TapestrySecurityIntegrationTest.java    From tapestry-security with Apache License 2.0 5 votes vote down vote up
@BeforeGroups(groups = "notLoggedIn")
public void checkLoggedIn() throws Exception
{
	openBase();

	if (STATUS_AUTH.equals(getText("status")))
	{
		clickOnBasePage("tynamoLogout");
	}
}
 
Example #2
Source File: HumanTaskPeopleAssignment.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeGroups(groups = {"wso2.bps.task.people.assignment"})
protected void initialize() throws Exception {
	log.info("Initializing HumanTask task creation Test...");
	userManagementClient = new UserManagementClient(backEndUrl, sessionCookie);
	addRoles();
	humanTaskPackageManagementClient = new HumanTaskPackageManagementClient(backEndUrl, sessionCookie);
	log.info("Add users success !");
	deployArtifact();
	requestSender.waitForProcessDeployment(backEndUrl + HumanTaskTestConstants.CLAIM_SERVICE);
}
 
Example #3
Source File: HumanTaskXpathExtensionsTest.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the test by deploying required artifacts.
 * @throws Exception
 */
@BeforeGroups(groups = { "wso2.bps.task.people.assignment" })
protected void initialize() throws Exception {
    log.info("Initializing HumanTask task creation Test...");
    userManagementClient = new UserManagementClient(backEndUrl, sessionCookie);
    addRoles();
    humanTaskPackageManagementClient = new HumanTaskPackageManagementClient(backEndUrl, sessionCookie);
    log.info("Add users success !");
    humanTaskPackageManagementClient
            .unDeployHumanTask(HumanTaskTestConstants.CLAIMS_APPROVAL_PACKAGE_ORG_ENTITY_NAME, "ApproveClaim");
    deployArtifact();
    requestSender.waitForProcessDeployment(backEndUrl + "ClaimService");
}
 
Example #4
Source File: TestNGTestCase.java    From qaf with MIT License 5 votes vote down vote up
@BeforeGroups(alwaysRun = true)
@BeforeClass(alwaysRun = true)
final public void setup(ITestContext context) {

	ConfigurationManager.getBundle().addProperty(ApplicationProperties.CURRENT_TEST_CONTEXT.key, context);
	this.context = context;
}
 
Example #5
Source File: OmidTestBase.java    From phoenix-omid with Apache License 2.0 4 votes vote down vote up
@BeforeGroups(groups = "sharedHBase")
public void beforeGroups(ITestContext context) throws Exception {
    // TSO Setup
    TSOServerConfig tsoConfig = new TSOServerConfig();
    tsoConfig.setPort(1234);
    tsoConfig.setConflictMapSize(1000);
    tsoConfig.setWaitStrategy("LOW_CPU");
    Injector injector = Guice.createInjector(new TSOMockModule(tsoConfig));
    LOG.info("Starting TSO");
    TSOServer tso = injector.getInstance(TSOServer.class);
    hBaseCommitTableConfig = injector.getInstance(HBaseCommitTableConfig.class);
    HBaseTimestampStorageConfig hBaseTimestampStorageConfig = injector.getInstance(HBaseTimestampStorageConfig.class);
    tso.startAndWait();
    TestUtils.waitForSocketListening("localhost", 1234, 100);
    LOG.info("Finished loading TSO");
    context.setAttribute("tso", tso);

    OmidClientConfiguration clientConf = new OmidClientConfiguration();
    clientConf.setConnectionString("localhost:1234");
    context.setAttribute("clientConf", clientConf);

    InMemoryCommitTable commitTable = (InMemoryCommitTable) injector.getInstance(CommitTable.class);
    context.setAttribute("commitTable", commitTable);

    // Create the associated Handler
    TSOClient client = TSOClient.newInstance(clientConf);
    context.setAttribute("client", client);

    // ------------------------------------------------------------------------------------------------------------
    // HBase setup
    // ------------------------------------------------------------------------------------------------------------
    LOG.info("Creating HBase minicluster");
    hbaseConf = HBaseConfiguration.create();
    hbaseConf.setInt("hbase.hregion.memstore.flush.size", 10_000 * 1024);
    hbaseConf.setInt("hbase.regionserver.nbreservationblocks", 1);
    hbaseConf.setInt(HBASE_CLIENT_RETRIES_NUMBER, 3);

    File tempFile = File.createTempFile("OmidTest", "");
    tempFile.deleteOnExit();
    hbaseConf.set("hbase.rootdir", tempFile.getAbsolutePath());
    hbaseConf.setBoolean("hbase.localcluster.assign.random.ports",true);
    hBaseUtils = new HBaseTestingUtility(hbaseConf);
    hbaseCluster = hBaseUtils.startMiniCluster(1);
    connection = ConnectionFactory.createConnection(hbaseConf);
    hBaseUtils.createTable(TableName.valueOf(hBaseTimestampStorageConfig.getTableName()),
            new byte[][]{hBaseTimestampStorageConfig.getFamilyName().getBytes()},
            Integer.MAX_VALUE);
    createTestTable();
    createCommitTable();

    LOG.info("HBase minicluster is up");
}
 
Example #6
Source File: SummationServiceIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@BeforeGroups("positive_tests")
public void runBeforeEachPositiveGroup() {
    numbers.add(1);
    numbers.add(2);
    numbers.add(3);
}
 
Example #7
Source File: SummationServiceIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@BeforeGroups("regression")
public void runBeforeEachRegressionGroup() {
    numbers.add(-11);
    numbers.add(2);
}
 
Example #8
Source File: SummationServiceIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@BeforeGroups("negative_tests")
public void runBeforeEachNegativeGroup() {
    numbers.clear();
}
 
Example #9
Source File: GroupIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@BeforeGroups("database")
public void setupDB() {
    System.out.println("setupDB()");
}
 
Example #10
Source File: ConfigMethodsTest.java    From allure1 with Apache License 2.0 4 votes vote down vote up
@BeforeGroups(groups = {"group1"})
public void configBeforeGroups(XmlTest test) {
    if (test.getName().equals("BeforeGroups")) {
        throw new RuntimeException();
    }
}
 
Example #11
Source File: LoggerTests.java    From aquality-selenium-java with Apache License 2.0 4 votes vote down vote up
@BeforeGroups("messages")
private void initializeLog4jField() throws NoSuchFieldException, IllegalAccessException {
    Field log4jField = Logger.class.getDeclaredField(log4jFieldName);
    log4jField.setAccessible(true);
    log4j = ((ThreadLocal<org.apache.log4j.Logger>) log4jField.get(Logger.getInstance())).get();
}
 
Example #12
Source File: PermissionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@BeforeGroups (groups = {"NoManageProcessPermission"})
public void noPermissionsSetup(){
    Policy.setPolicy(new TestPolicy());
    SecurityManager sm = new SecurityManager();
    System.setSecurityManager(sm);
}
 
Example #13
Source File: PrintStreamHandler.java    From ballerina-message-broker with Apache License 2.0 4 votes vote down vote up
@BeforeGroups("StreamReading")
public static void setPrintStream() {
    System.setErr(errPrintStream);
    System.setOut(outPrintStream);
}
 
Example #14
Source File: CommandHttpTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * GlassFish startup.
 * <p/>
 * Starts GlassFish server for tests.
 */
@SuppressWarnings("SleepWhileInLoop")
@BeforeGroups(groups = {"http-commands"})
public static void startGlassFish() {
    final String METHOD = "startGlassFish";
    LOGGER.log(Level.INFO, METHOD, "startFrame");
    LOGGER.log(Level.INFO, METHOD, "startText");
    LOGGER.log(Level.INFO, METHOD, "startFrame");
    String javaArgsProperty = getGlassFishProperty(GFPROP_JAVA_ARGS);
    String glassFishArgsProperty = getGlassFishProperty(
            GFPROP_GLASSFISH_ARGS);
    List<String> javaArgs = javaArgsProperty != null
            ? Arrays.asList(javaArgsProperty.split(" +"))
            : new ArrayList<String>();
    List<String> glassFishArgs = glassFishArgsProperty != null
            ? Arrays.asList(glassFishArgsProperty.split(" +"))
            : new ArrayList<String>();
    StartupArgsEntity startupArgs = new StartupArgsEntity(
            glassFishArgs,
            javaArgs,
            new HashMap<String, String>(),
            getJdkProperty(JDKPROP_HOME));
    GlassFishServer server = glassFishServer();
    restoreDomain(server, getGlassFishProperty(BACKUP_DOMAIN));
    ResultProcess result = ServerTasks.startServer(server, startupArgs);
    ValueProcess process = result.getValue();
    FetchLog stdOutLog = new FetchLogSimple(process.getProcess()
            .getInputStream());
    FetchLog stdErrLog = new FetchLogSimple(process.getProcess()
            .getErrorStream());
    gfStdOut = new StreamLinesList(stdOutLog);
    gfStdErr = new StreamLinesList(stdErrLog);
    boolean exit = false;
    boolean started = false;
    boolean shutdownOnError = false;
    int emptyCycles = 0;
    while (!exit && emptyCycles++ < 30) {
        String line;                    
        while ((line = gfStdOut.getNext()) != null) {
            Matcher startedMessageMatcher
                    = STARTED_MESSAGE_PATTERN.matcher(line);
            Matcher shutdownMessageMatcher
                    = SHUTDOWN_MESSAGE_PATTERN.matcher(line);
            if (startedMessageMatcher.matches()) {
                started = true;
                exit = true;
            }
            if (shutdownMessageMatcher.matches()) {
                shutdownOnError = true;
            }
            LOGGER.log(Level.INFO, METHOD, "stdout", line);
            emptyCycles = 0;
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ie) {
            fail("FetchLogData command execution failed: "
                    + ie.getMessage());
        }
    }
    assertNotNull(result.getValue());
    assertTrue(started);
    if (shutdownOnError) {
        LOGGER.log(Level.SEVERE, METHOD, "failed");
    }
}
 
Example #15
Source File: CommandRestTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * GlassFish startup.
 * <p/>
 * Starts GlassFish server for tests.
 */
@SuppressWarnings("SleepWhileInLoop")
@BeforeGroups(groups = {"rest-commands"})
public static void startGlassFish() {
    try {
        Thread.sleep(20000);
    } catch (InterruptedException ex) {
        java.util.logging.Logger.getLogger(CommandRestTest.class.getName()).
                log(Level.SEVERE, null, ex);
    }
    final String METHOD = "startGlassFish";
    LOGGER.log(Level.INFO, METHOD, "startFrame");
    LOGGER.log(Level.INFO, METHOD, "startText");
    LOGGER.log(Level.INFO, METHOD, "startFrame");
    String javaArgsProperty = getGlassFishProperty(GFPROP_JAVA_ARGS);
    String glassFishArgsProperty = getGlassFishProperty(
            GFPROP_GLASSFISH_ARGS);
    List<String> javaArgs = javaArgsProperty != null
            ? Arrays.asList(javaArgsProperty.split(" +"))
            : new ArrayList<String>();
    List<String> glassFishArgs = glassFishArgsProperty != null
            ? Arrays.asList(glassFishArgsProperty.split(" +"))
            : new ArrayList<String>();
    StartupArgsEntity startupArgs = new StartupArgsEntity(
            glassFishArgs,
            javaArgs,
            new HashMap<String, String>(),
            getJdkProperty(JDKPROP_HOME));
    GlassFishServer server = glassFishServer();
    // restore domain before starting server
    restoreDomain(server, getGlassFishProperty(BACKUP_DOMAIN));
    ResultProcess result = ServerTasks.startServer(server, startupArgs);
    ValueProcess process = result.getValue();
    FetchLog stdOutLog = new FetchLogSimple(process.getProcess()
            .getInputStream());
    FetchLog stdErrLog = new FetchLogSimple(process.getProcess()
            .getErrorStream());
    gfStdOut = new StreamLinesList(stdOutLog);
    gfStdErr = new StreamLinesList(stdErrLog);
    boolean exit = false;
    boolean started = false;
    boolean shutdownOnError = false;
    int emptyCycles = 0;
    while (!exit && emptyCycles++ < 10) {
        String line;                    
        while ((line = gfStdOut.getNext()) != null) {
            Matcher startedMessageMatcher
                    = STARTED_MESSAGE_PATTERN.matcher(line);
            Matcher shutdownMessageMatcher
                    = SHUTDOWN_MESSAGE_PATTERN.matcher(line);
            if (startedMessageMatcher.matches()) {
                started = true;
                exit = true;
            }
            if (shutdownMessageMatcher.matches()) {
                shutdownOnError = true;
            }
            LOGGER.log(Level.INFO, METHOD, "stdout", line);
            emptyCycles = 0;
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ie) {
            fail("FetchLogData command execution failed: "
                    + ie.getMessage());
        }
    }
    assertNotNull(result.getValue());
    assertTrue(started);
    if (shutdownOnError) {
        LOGGER.log(Level.SEVERE, METHOD, "failed");
    }
}
 
Example #16
Source File: CommandHttpTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Payara startup.
 * <p/>
 * Starts Payara server for tests.
 */
@SuppressWarnings("SleepWhileInLoop")
@BeforeGroups(groups = {"http-commands"})
public static void startPayara() {
    final String METHOD = "startPayara";
    LOGGER.log(Level.INFO, METHOD, "startFrame");
    LOGGER.log(Level.INFO, METHOD, "startText");
    LOGGER.log(Level.INFO, METHOD, "startFrame");
    String javaArgsProperty = getPayaraProperty(PFPROP_JAVA_ARGS);
    String payaraArgsProperty = getPayaraProperty(
            PFPROP_PAYARA_ARGS);
    List<String> javaArgs = javaArgsProperty != null
            ? Arrays.asList(javaArgsProperty.split(" +"))
            : new ArrayList<String>();
    List<String> payaraArgs = payaraArgsProperty != null
            ? Arrays.asList(payaraArgsProperty.split(" +"))
            : new ArrayList<>();
    StartupArgsEntity startupArgs = new StartupArgsEntity(
            payaraArgs,
            javaArgs,
            new HashMap<String, String>(),
            getJdkProperty(JDKPROP_HOME));
    PayaraServer server = payaraServer();
    restoreDomain(server, getPayaraProperty(BACKUP_DOMAIN));
    ResultProcess result = ServerTasks.startServer(server, startupArgs);
    ValueProcess process = result.getValue();
    FetchLog stdOutLog = new FetchLogSimple(process.getProcess()
            .getInputStream());
    FetchLog stdErrLog = new FetchLogSimple(process.getProcess()
            .getErrorStream());
    gfStdOut = new StreamLinesList(stdOutLog);
    gfStdErr = new StreamLinesList(stdErrLog);
    boolean exit = false;
    boolean started = false;
    boolean shutdownOnError = false;
    int emptyCycles = 0;
    while (!exit && emptyCycles++ < 30) {
        String line;                    
        while ((line = gfStdOut.getNext()) != null) {
            Matcher startedMessageMatcher
                    = STARTED_MESSAGE_PATTERN.matcher(line);
            Matcher shutdownMessageMatcher
                    = SHUTDOWN_MESSAGE_PATTERN.matcher(line);
            if (startedMessageMatcher.matches()) {
                started = true;
                exit = true;
            }
            if (shutdownMessageMatcher.matches()) {
                shutdownOnError = true;
            }
            LOGGER.log(Level.INFO, METHOD, "stdout", line);
            emptyCycles = 0;
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ie) {
            fail("FetchLogData command execution failed: "
                    + ie.getMessage());
        }
    }
    assertNotNull(result.getValue());
    assertTrue(started);
    if (shutdownOnError) {
        LOGGER.log(Level.SEVERE, METHOD, "failed");
    }
}
 
Example #17
Source File: CommandRestTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Payara startup.
 * Starts Payara server for tests.
 */
@SuppressWarnings("SleepWhileInLoop")
@BeforeGroups(groups = {"rest-commands"})
public static void startPayara() {
    try {
        Thread.sleep(20000);
    } catch (InterruptedException ex) {
        java.util.logging.Logger.getLogger(CommandRestTest.class.getName()).
                log(Level.SEVERE, null, ex);
    }
    final String METHOD = "startPayara";
    LOGGER.log(Level.INFO, METHOD, "startFrame");
    LOGGER.log(Level.INFO, METHOD, "startText");
    LOGGER.log(Level.INFO, METHOD, "startFrame");
    String javaArgsProperty = getPayaraProperty(PFPROP_JAVA_ARGS);
    String payaraArgsProperty = getPayaraProperty(
            PFPROP_PAYARA_ARGS);
    List<String> javaArgs = javaArgsProperty != null
            ? Arrays.asList(javaArgsProperty.split(" +"))
            : new ArrayList<String>();
    List<String> payaraArgs = payaraArgsProperty != null
            ? Arrays.asList(payaraArgsProperty.split(" +"))
            : new ArrayList<String>();
    StartupArgsEntity startupArgs = new StartupArgsEntity(
            payaraArgs,
            javaArgs,
            new HashMap<String, String>(),
            getJdkProperty(JDKPROP_HOME));
    PayaraServer server = payaraServer();
    // restore domain before starting server
    restoreDomain(server, getPayaraProperty(BACKUP_DOMAIN));
    ResultProcess result = ServerTasks.startServer(server, startupArgs);
    ValueProcess process = result.getValue();
    FetchLog stdOutLog = new FetchLogSimple(process.getProcess()
            .getInputStream());
    FetchLog stdErrLog = new FetchLogSimple(process.getProcess()
            .getErrorStream());
    gfStdOut = new StreamLinesList(stdOutLog);
    gfStdErr = new StreamLinesList(stdErrLog);
    boolean exit = false;
    boolean started = false;
    boolean shutdownOnError = false;
    int emptyCycles = 0;
    while (!exit && emptyCycles++ < 10) {
        String line;                    
        while ((line = gfStdOut.getNext()) != null) {
            Matcher startedMessageMatcher
                    = STARTED_MESSAGE_PATTERN.matcher(line);
            Matcher shutdownMessageMatcher
                    = SHUTDOWN_MESSAGE_PATTERN.matcher(line);
            if (startedMessageMatcher.matches()) {
                started = true;
                exit = true;
            }
            if (shutdownMessageMatcher.matches()) {
                shutdownOnError = true;
            }
            LOGGER.log(Level.INFO, METHOD, "stdout", line);
            emptyCycles = 0;
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ie) {
            fail("FetchLogData command execution failed: "
                    + ie.getMessage());
        }
    }
    assertNotNull(result.getValue());
    assertTrue(started);
    if (shutdownOnError) {
        LOGGER.log(Level.SEVERE, METHOD, "failed");
    }
}
 
Example #18
Source File: AllFeatures.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@BeforeGroups
public void beforeGroups2() throws IOException {
    addImgAttachment();
    addStringAttachment();
}
 
Example #19
Source File: AllFeatures.java    From allure-java with Apache License 2.0 4 votes vote down vote up
@BeforeGroups
public void beforeGroups1() throws IOException {
    addImgAttachment();
}
 
Example #20
Source File: PlanDefinitionApplyOperationTest.java    From FHIR with Apache License 2.0 4 votes vote down vote up
@BeforeGroups(groups = { TEST_GROUP_NAME })
public void loadTestData() throws Exception {
    // Subject - Patient
    final String PATIENT_JSON = "Patient_DavidOrtiz.json";
    WebTarget target = getWebTarget();

    // Build a new Patient and then call the 'create' API.
    Patient patient = TestUtil.readLocalResource(PATIENT_JSON);
    Entity<Patient> entity = Entity.entity(patient, FHIRMediaType.APPLICATION_FHIR_JSON);
    Response response = target.path("Patient").request().post(entity, Response.class);
    assertResponse(response, Response.Status.CREATED.getStatusCode());

    // Get the patient's logical id value.
    patientId = getLocationLogicalId(response);
    if (DEBUG_APPLY) {
        System.out.println("Patient ID => [" + patientId + "]");
    }

    // Subject - Practitioner
    Practitioner doctor = TestUtil.readLocalResource("DrStrangelove.json");
    Entity<Practitioner> entity1 = Entity.entity(doctor, FHIRMediaType.APPLICATION_FHIR_JSON);
    response = target.path("Practitioner").request().post(entity1, Response.class);
    assertResponse(response, Response.Status.CREATED.getStatusCode());

    // Get the practitioner's logical id value.
    practitionerId = getLocationLogicalId(response);
    if (DEBUG_APPLY) {
        System.out.println("Practitioner ID => [" + practitionerId + "]");
    }

    // ActivityDefinition 1
    ActivityDefinition ad = TestUtil.readLocalResource("ActivityDefinition-1.json");
    Entity<ActivityDefinition> entity2 = Entity.entity(ad, FHIRMediaType.APPLICATION_FHIR_JSON);
    response = target.path("ActivityDefinition").request().post(entity2, Response.class);
    assertResponse(response, Response.Status.CREATED.getStatusCode());

    // Get the practitioner's logical id value.
    adId = getLocationLogicalId(response);
    if (DEBUG_APPLY) {
        System.out.println("ActivityDefinition ID => [" + adId + "]");
    }

    // ActivityDefinition 2
    ActivityDefinition ad2 = TestUtil.readLocalResource("ActivityDefinition-2.json");
    Entity<ActivityDefinition> entity3 = Entity.entity(ad2, FHIRMediaType.APPLICATION_FHIR_JSON);
    response = target.path("ActivityDefinition").request().post(entity3, Response.class);
    assertResponse(response, Response.Status.CREATED.getStatusCode());

    // Get the practitioner's logical id value.
    adId2 = getLocationLogicalId(response);
    if (DEBUG_APPLY) {
        System.out.println("ActivityDefinition ID => [" + adId2 + "]");
    }

    // Many need to create
    // Subject - Organization
    // Subject - Location
    // Subject - Device
    // Subject - Group
    // Subject - Invalid Resource Type (Negative Test)

    /*
     * Create PlanDefinitions
     */
    PlanDefinition planDefinition = TestUtil.readLocalResource("PlanDefinition-1.json");
    Entity<PlanDefinition> entityPd = Entity.entity(planDefinition, FHIRMediaType.APPLICATION_FHIR_JSON);
    response = target.path("PlanDefinition").request().post(entityPd, Response.class);
    assertResponse(response, Response.Status.CREATED.getStatusCode());

    // Get the practitioner's logical id value.
    planDefinitionId = getLocationLogicalId(response);
    if (DEBUG_APPLY) {
        System.out.println("PlanDefinition ID => [" + planDefinitionId + "]");
    }

    // Store the Plan Definition
    response = target.path("PlanDefinition/" + planDefinitionId).request().get(Response.class);

    assertResponse(response, Response.Status.OK.getStatusCode());
    planDefinitionResource = response.readEntity(PlanDefinition.class);

}