Java 类org.testng.annotations.Parameters 实例源码

项目:POM_HYBRID_FRAMEOWRK    文件:FlightReservation_FindFlight_Tests.java   
@Parameters({ "username", "password", "tripType", "noOfPassengers", "departFrom", "departmonth", "departDay",
        "arrivingIn", "arrivingMonth", "arrivingDay", "serviceClass", "airlineName" })
@Test(description = "Mercury Flight Reservation - Find a flight")
public void findANewFlight(String username, String password, String tripType, String noOfPassengers,
        String departFrom, String departmonth, String departDay, String arrivingIn, String arrivingMonth,
        String arrivingDay, String serviceClass, String airlineName, Method method) {

    try {
        initialize();

        boolean testStatus = false;
        String homePageTitle = "Find a Flight: Mercury Tours:";
        boolean loginStatus = loginPage.loginToApplication(username, password, homePageTitle);

        if (loginStatus) {

            testStatus = flightFinderPage.findANewFlight(tripType, noOfPassengers, departFrom, departmonth,
                    departDay, arrivingIn, arrivingMonth, arrivingDay, serviceClass, airlineName);
        }

        BaseClass.reportTestCaseStatus(driver, logger, method.getName(), testStatus);
    } catch (Exception e) {
        BaseClass.reportTestCaseStatus(driver, logger, method.getName(), false);
    }

}
项目:POM_HYBRID_FRAMEOWRK    文件:BaseClass.java   
@Parameters({"baseURL"})
@BeforeSuite
public void beforeSuite(String baseURL) {
    try {

        rpr = ReadPropertyFile.getInstance("./TestResources/TestConfig/test.properties");

        reportFile = rpr.getKey("reportFile");
        emailConfigFile = rpr.getKey("emailConfigFile");
        sendEmail = rpr.getKey("sendEmail");

        // If the we are testing single Web Application. Mention the same in 
        //test.properties file and uncomment below line.

        //baseURL = rpr.getKey("baseURL");

        // Commnet this line if previous line is uncommented
        BaseClass.baseURL = baseURL;
        browserName = rpr.getKey("browserName");
        reporter = ReportManager.getReporter(reportFile, true);

    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Error occured in @BeforeSuite");
    }
}
项目:Rapture    文件:MongoTests.java   
/**
 * Setup TestNG method to create Rapture login object and objects.
 *
 * @param RaptureURL
 *            Passed in from <env>_testng.xml suite file
 * @param RaptureUser
 *            Passed in from <env>_testng.xml suite file
 * @param RapturePassword
 *            Passed in from <env>_testng.xml suite file
 * @return none
 */
@BeforeMethod
@BeforeClass(groups = { "mongo" })
@Parameters({ "RaptureURL", "RaptureUser", "RapturePassword" })
public void setUp(@Optional("http://localhost:8665/rapture") String url, @Optional("rapture") String username, @Optional("rapture") String password) {

    // If running from eclipse set env var -Penv=docker or use the following
    // url variable settings:
    // url="http://192.168.99.101:8665/rapture"; //docker
    // url="http://localhost:8665/rapture";
    System.out.println("Using url " + url);
    raptureLogin = new HttpLoginApi(url, new SimpleCredentialsProvider(username, password));
    raptureLogin.login();
    series = new HttpSeriesApi(raptureLogin);
    document = new HttpDocApi(raptureLogin);
    script = new HttpScriptApi(raptureLogin);
    event = new HttpEventApi(raptureLogin);
    fountain = new HttpIdGenApi(raptureLogin);
    blobApi = new HttpBlobApi(raptureLogin);
    Kernel.initBootstrap();
    context = ContextFactory.getKernelUser();
}
项目:Rapture    文件:SmokeTests.java   
/**
 * Setup TestNG method to create Rapture login object and objects.
 *
 * @param RaptureURL Passed in from <env>_testng.xml suite file
 * @param RaptureUser Passed in from <env>_testng.xml suite file
 * @param RapturePassword Passed in from <env>_testng.xml suite file
 * @return none
 */
@BeforeClass(groups={"smoke"})
@Parameters({"RaptureURL","RaptureUser","RapturePassword"})
public void setUp(@Optional("http://localhost:8665/rapture")String url,
                  @Optional("rapture")String username, @Optional("rapture")String password ) {

    //If running from eclipse set env var -Penv=docker or use the following url variable settings:
    //url="http://192.168.99.101:8665/rapture"; //docker
    //url="http://localhost:8665/rapture";
    System.out.println("Using url " + url);
    raptureLogin = new HttpLoginApi(url, new SimpleCredentialsProvider(username, password));
    raptureLogin.login();
    series = new HttpSeriesApi(raptureLogin);
    document = new HttpDocApi(raptureLogin);
    script = new HttpScriptApi(raptureLogin);
    event = new HttpEventApi(raptureLogin);
    fountain = new HttpIdGenApi(raptureLogin);
}
项目:Rapture    文件:TutorialTests.java   
/**
 * Setup TestNG method to create Rapture login object and objects.
 *
 * @param RaptureURL Passed in from <env>_testng.xml suite file
 * @param RaptureUser Passed in from <env>_testng.xml suite file
 * @param RapturePassword Passed in from <env>_testng.xml suite file
 *
 * @return none
 */
@BeforeClass(groups={"document"})
@Parameters({"RaptureURL","RaptureUser","RapturePassword"})
public void setUp(@Optional("http://localhost:8665/rapture")String url,
                  @Optional("rapture")String username, @Optional("rapture")String password ) {

    ///If running from eclipse set environment variable -Penv=docker 
    //or use the following:
    //  url="http://localhost:8665/rapture";
    //  url="http://192.168.99.101:8665/rapture"; //docker

    Reporter.log("Using URL: " + url,true);
    raptureLogin = new HttpLoginApi(url, new SimpleCredentialsProvider(username, password));
    try{
        raptureLogin.login();
        document = new HttpDocApi(raptureLogin);
    } catch (RaptureException re) {
        Reporter.log(re.getFormattedMessage(),true);
    }
}
项目:Rapture    文件:OperationApiIntegrationTest.java   
/**
 * Setup TestNG method to create Rapture login object and objects.
 *
 * @param RaptureURL
 *            Passed in from <env>_testng.xml suite file
 * @param RaptureUser
 *            Passed in from <env>_testng.xml suite file
 * @param RapturePassword
 *            Passed in from <env>_testng.xml suite file
 * @return none
 */
@BeforeClass(groups = { "nightly" })
@Parameters({ "RaptureURL", "RaptureUser", "RapturePassword" })
public void setUp(@Optional("http://localhost:8665/rapture") String url, @Optional("rapture") String username, @Optional("rapture") String password) {

    // If running from eclipse set env var -Penv=docker or use the following
    // url variable settings:
    // url="http://192.168.99.101:8665/rapture"; //docker
    // url="http://localhost:8665/rapture";

    helper = new IntegrationTestHelper(url, username, password);
    raptureLogin = helper.getRaptureLogin();
    docApi = helper.getDocApi();
    operationApi = helper.getOperationApi();
    callingContext = raptureLogin.getContext();

    repo = helper.getRandomAuthority(Scheme.DOCUMENT);
    helper.configureTestRepo(repo, "MEMORY");

}
项目:Rapture    文件:ConsistencyTest.java   
/**
 * Setup TestNG method to create Rapture login object and objects.
 *
 * @param RaptureURL
 *            Passed in from <env>_testng.xml suite file
 * @param RaptureUser
 *            Passed in from <env>_testng.xml suite file
 * @param RapturePassword
 *            Passed in from <env>_testng.xml suite file
 * @return none
 */
@BeforeMethod
@BeforeClass(groups = { "mongo" })
@Parameters({ "RaptureURL", "RaptureUser", "RapturePassword" })
public void setUp(@Optional("http://localhost:8665/rapture") String url, @Optional("rapture") String username, @Optional("rapture") String password) {

    // If running from eclipse set env var -Penv=docker or use the following
    // url variable settings:
    // url="http://192.168.99.101:8665/rapture"; //docker
    // url="http://localhost:8665/rapture";

    // System.out.println("Using url " + url);
    // raptureLogin = new HttpLoginApi(url, new SimpleCredentialsProvider(username, password));
    // raptureLogin.login();
    // seriesApi = new HttpSeriesApi(raptureLogin);
    // docApi = new HttpDocApi(raptureLogin);
    // scriptApi = new HttpScriptApi(raptureLogin);
    // eventApi = new HttpEventApi(raptureLogin);
    // fountainApi = new HttpIdGenApi(raptureLogin);
    // blobApi = new HttpBlobApi(raptureLogin);
    // callingContext = raptureLogin.getContext();
    //

}
项目:Rapture    文件:SearchApiIntegrationTest.java   
/**
 * Setup TestNG method to create Rapture login object and objects.
 *
 * @param RaptureURL
 *            Passed in from <env>_testng.xml suite file
 * @param RaptureUser
 *            Passed in from <env>_testng.xml suite file
 * @param RapturePassword
 *            Passed in from <env>_testng.xml suite file
 * @return none
 */
@BeforeClass(groups = { "nightly", "search" })
@Parameters({ "RaptureURL", "RaptureUser", "RapturePassword" })
public void setUp(@Optional("http://localhost:8665/rapture") String url, @Optional("rapture") String username, @Optional("rapture") String password) {

    // If running from eclipse set env var -Penv=docker or use the following
    // url variable settings:
    // url="http://192.168.99.101:8665/rapture"; //docker
    // url="http://localhost:8665/rapture";

    helper = new IntegrationTestHelper(url, username, password);
    raptureLogin = helper.getRaptureLogin();
    seriesApi = helper.getSeriesApi();
    scriptApi = helper.getScriptApi();
    docApi = helper.getDocApi();
    blobApi = helper.getBlobApi();
    searchApi = new HttpSearchApi(raptureLogin);
    callingContext = raptureLogin.getContext();
    forceCleanUp(username);
    if (!username.equals("rapture")) forceCleanUp("rapture");
}
项目:agent-java-testNG    文件:TestNGService.java   
/**
 * Process testResult to create parameters provided via {@link Parameters}
 *
 * @param testResult           TestNG's testResult context
 * @param parametersAnnotation Annotation with parameters
 * @return Step Parameters being sent to Report Portal
 */
private List<ParameterResource> createAnnotationParameters(ITestResult testResult, Parameters parametersAnnotation) {
    List<ParameterResource> params = Lists.newArrayList();
    String[] keys = parametersAnnotation.value();
    Object[] parameters = testResult.getParameters();
    if (parameters.length != keys.length) {
        return params;
    }
    for (int i = 0; i < keys.length; i++) {
        ParameterResource parameter = new ParameterResource();
        parameter.setKey(keys[i]);
        parameter.setValue(parameters[i] != null ? parameters[i].toString() : null);
        params.add(parameter);
    }
    return params;
}
项目:Watson-Work-Services-Java-SDK    文件:ITPostMessage.java   
@Test(enabled = true)
@Parameters({ "appId", "appSecret", "spaceId" })
public void postTestMessageToSpace(String appId, String appSecret, String spaceId)
        throws UnsupportedEncodingException, WWException {
    WWClient client = WWClient.buildClientApplicationAccess(appId, appSecret, new WWAuthenticationEndpoint());
    assert !client.isAuthenticated();
    client.authenticate();
    assert client.isAuthenticated();

    AppMessageBuilder builder = new AppMessageBuilder();
    builder.setActorAvatar("http://gravatar.com/cgu")
            .setActorName("CGU")
            .setActorUrl("http://openntf.org")
            .setColor("#FF0000");
    builder.setMessage("Message from *build process* - Integration Testing").setMessageTitle("IT-Testing");
    AppMessage message = builder.build();
    MessageResponse response = client.postMessageToSpace(message, spaceId);
    assert (response != null);
    assert (!"".equals(response.getId()));
}
项目:Watson-Work-Services-Java-SDK    文件:ITgraphQL.java   
@Test(enabled = true)
@Parameters({ "appId", "appSecret", "conversationId" })
public void testGetConversationGenericMessagesOnly(String appId, String appSecret, String conversationId)
        throws UnsupportedEncodingException, WWException {
    WWClient client = WWClient.buildClientApplicationAccess(appId, appSecret, new WWAuthenticationEndpoint());
    assert !client.isAuthenticated();
    client.authenticate();
    assert client.isAuthenticated();

    ObjectDataSenderBuilder messages = new ObjectDataSenderBuilder(ConversationChildren.MESSAGES.getLabel(), true)
            .addAttribute(ConversationMessageAttributes.ANNOTATION_TYPE, AnnotationType.GENERIC.getLabel())
            .addField(MessageFields.CONTENT);
    ObjectDataSenderBuilder query = new ObjectDataSenderBuilder(Conversation.CONVERSATION_QUERY_OBJECT_NAME)
            .addAttribute(ConversationAttributes.ID, conversationId)
            .addField(ConversationFields.ID)
            .addChild(messages);
    Conversation conversation = client.getConversationWithQuery(new ConversationGraphQLQuery(query));
    assert (conversation != null);
    assert (conversation.getMessages().size() > 0);
}
项目:Watson-Work-Services-Java-SDK    文件:ITgraphQL.java   
@Test(enabled = true)
@Parameters({ "appId", "appSecret", "conversationId", "oldestTimestamp", "mostRecentTimestamp" })
public void testGetConversationTimestampMessages(String appId, String appSecret, String conversationId, Long oldestTimestamp, Long mostRecentTimestamp)
        throws UnsupportedEncodingException, WWException {
    WWClient client = WWClient.buildClientApplicationAccess(appId, appSecret, new WWAuthenticationEndpoint());
    assert !client.isAuthenticated();
    client.authenticate();
    assert client.isAuthenticated();

    ObjectDataSenderBuilder messages = new ObjectDataSenderBuilder(ConversationChildren.MESSAGES.getLabel(), true)
            .addAttribute(ConversationMessageAttributes.OLDEST_TIMESTAMP, oldestTimestamp)
            .addAttribute(ConversationMessageAttributes.MOST_RECENT_TIMESTAMP, mostRecentTimestamp)
            .addField(MessageFields.CONTENT);
    ObjectDataSenderBuilder query = new ObjectDataSenderBuilder(Conversation.CONVERSATION_QUERY_OBJECT_NAME)
            .addAttribute(ConversationAttributes.ID, conversationId)
            .addField(ConversationFields.ID)
            .addChild(messages);
    Conversation conversation = client.getConversationWithQuery(new ConversationGraphQLQuery(query));
    assert (conversation != null);
    assert (conversation.getMessages().size() > 0);
}
项目:Watson-Work-Services-Java-SDK    文件:ITgraphQL.java   
@Test(enabled = true)
@Parameters({ "appId", "appSecret" })
public void testGetSpaceMembers(String appId, String appSecret) throws WWException, UnsupportedEncodingException {
    WWClient client = WWClient.buildClientApplicationAccess(appId, appSecret, new WWAuthenticationEndpoint());
    assert !client.isAuthenticated();
    client.authenticate();
    assert client.isAuthenticated();
    WWGraphQLEndpoint ep = new WWGraphQLEndpoint(client);

    SpacesGraphQLQuery queryObject = SpacesGraphQLQuery.buildStandardGetSpacesQuery();
    ep.setRequest(new GraphQLRequest(queryObject));
    ep.executeRequest();
    List<? extends Space> spacesResult = ep.getResultContainer().getData().getSpaces().getItems();
    assert (spacesResult.size() > 0);
    String spaceId = spacesResult.get(0).getId();
    assert (null != spaceId);
    List<Person> members = client.getSpaceMembersById(spaceId);
    assert (members.size() > 0);
    Space space = client.getSpaceById(spaceId);
    assert (space.getMembers().size() > 0);
}
项目:Watson-Work-Services-Java-SDK    文件:ITgraphQL.java   
@Test(enabled = false)
@Parameters({ "appId", "appSecret", "profileId", "myDisplayName", "myAppName" })
public void testGetPeople(String appId, String appSecret, String profileId, String myDisplayName, String myAppName)
        throws UnsupportedEncodingException, WWException {
    WWClient client = WWClient.buildClientApplicationAccess(appId, appSecret, new WWAuthenticationEndpoint());
    assert !client.isAuthenticated();
    client.authenticate();
    assert client.isAuthenticated();
    WWGraphQLEndpoint ep = new WWGraphQLEndpoint(client);

    ArrayList<String> ids = new ArrayList<String>();
    ids.add(profileId);
    ids.add(appId);

    List<Person> peopleResult = client.getPeople(ids);

    assert (peopleResult.size() == 2);
    assert (myDisplayName.equals(peopleResult.get(0).getDisplayName()));
    assert (myAppName.equals(peopleResult.get(1).getDisplayName()));
}
项目:Watson-Work-Services-Java-SDK    文件:ITgraphQL.java   
@Test(enabled = false)
@Parameters({ "appId", "appSecret" })
public void testGetPeopleFirstTen(String appId, String appSecret) throws UnsupportedEncodingException, WWException {
    WWClient client = WWClient.buildClientApplicationAccess(appId, appSecret, new WWAuthenticationEndpoint());
    assert !client.isAuthenticated();
    client.authenticate();
    assert client.isAuthenticated();
    ObjectDataSenderBuilder query = new ObjectDataSenderBuilder(Person.PEOPLE_QUERY_OBJECT_NAME, true);
    query.addAttribute(BasicPaginationEnum.FIRST.getLabel(), 10);
    query.addField(PersonFields.DISPLAY_NAME);

    WWGraphQLEndpoint ep = new WWGraphQLEndpoint(client);
    ep.setRequest(new GraphQLRequest(new PeopleGraphQLQuery(query)));
    ep.executeRequest();
    System.out.println(ep.getResultContent());
    // Following line throws error
    List<Person> peopleResult = ep.getResultContainer().getData().getPeople().getItems();

    assert (peopleResult.size() == 2);
}
项目:Watson-Work-Services-Java-SDK    文件:ITgraphQL.java   
@Test(enabled = true)
@Parameters({ "appId", "appSecret", "profileId", "myDisplayName" })
public void personTestWithId(String appId, String appSecret, String personId, String myDisplayName)
        throws WWException, UnsupportedEncodingException {
    IWWClient client = WWClient.buildClientApplicationAccess(appId, appSecret, new WWAuthenticationEndpoint());
    assert !client.isAuthenticated();
    client.authenticate();
    assert client.isAuthenticated();
    WWGraphQLEndpoint ep = new WWGraphQLEndpoint(client);
    PersonGraphQLQuery queryObject = PersonGraphQLQuery.buildPersonQueryById(personId);
    ep.setRequest(new GraphQLRequest(queryObject));
    ep.executeRequest();
    assert (null == ep.getResultContainer().getErrors());
    DataContainer container = ep.getResultContainer().getData();
    assert (myDisplayName.equals(container.getPerson().getDisplayName()));
}
项目:Watson-Work-Services-Java-SDK    文件:ITgraphQL.java   
@Test(enabled = true)
@Parameters({ "appId", "appSecret", "profileId", "myDisplayName" })
public void peopleTest(String appId, String appSecret) throws WWException, UnsupportedEncodingException {
    IWWClient client = WWClient.buildClientApplicationAccess(appId, appSecret, new WWAuthenticationEndpoint());
    client.authenticate();
    WWGraphQLEndpoint ep = new WWGraphQLEndpoint(client);
    ObjectDataSenderBuilder personNames = new ObjectDataSenderBuilder(Person.PEOPLE_QUERY_OBJECT_NAME, true);
    personNames.addAttribute(BasicPaginationEnum.FIRST, 10)
            .addField(PersonFields.DISPLAY_NAME)
            .addField(PersonFields.EMAIL)
            .addField(PersonFields.EXT_ID)
            .addField(PersonFields.CREATED)
            .addField(PersonFields.UPDATED)
            .addChild(new BasicCreatedByUpdatedByDataSenderBuilder(PersonChildren.CREATED_BY))
            .addChild(new BasicCreatedByUpdatedByDataSenderBuilder(PersonChildren.UPDATED_BY));
    ep.setRequest(new GraphQLRequest(personNames, "getProfileNames"));
    ep.executeRequest();
    GraphResultContainer results = ep.getResultContainer();
    assert (null != results.getErrors());
    ErrorContainer errors = results.getErrors().get(0);
    assert "500 Internal Server Error".equals(errors.getMessage());
    assert "people".equals(errors.getField().get("name"));
    assert "PersonCollection".equals(errors.getField().get("type"));
}
项目:Watson-Work-Services-Java-SDK    文件:ITgraphQL.java   
@Test(enabled = true)
@Parameters({ "appId", "appSecret" })
public void createSpace(String appId, String appSecret) throws WWException, UnsupportedEncodingException {
    IWWClient client = WWClient.buildClientApplicationAccess(appId, appSecret, new WWAuthenticationEndpoint());
    client.authenticate();
    ArrayList<String> members = new ArrayList<String>();
    members.add("8bf6c84f-961c-43df-836a-85748766912f");
    members.add("5d1bf268-c363-4eea-baec-e2dbeaa2fb72");
    WWGraphQLEndpoint ep = new WWGraphQLEndpoint(client);
    try {
        // This is forbidden for App access
        Space space = ep.createSpace("Hello World", members);
    } catch (Exception e) {
        GraphResultContainer results = ep.getResultContainer();
        assert (null != results.getErrors());
        ErrorContainer errors = results.getErrors().get(0);
        assert "403 Forbidden".equals(errors.getMessage());
    }
}
项目:Watson-Work-Services-Java-SDK    文件:ITgraphQL.java   
@Test(enabled = true)
@Parameters({ "appId", "appSecret" })
public void updateSpace(String appId, String appSecret) throws WWException, UnsupportedEncodingException {
    WWClient client = WWClient.buildClientApplicationAccess(appId, appSecret, new WWAuthenticationEndpoint());
    client.authenticate();
    WWGraphQLEndpoint ep = new WWGraphQLEndpoint(client);
    try {
        Space space = ep.updateSpaceTitle("589390cfe4b0f86a34bbf4ed", "Hello New World");
        assert "Hello New World".equals(space.getTitle());
    } catch (Exception e) {
        GraphResultContainer results = ep.getResultContainer();
        assert (null != results.getErrors());
        ErrorContainer errors = results.getErrors().get(0);
        assert "403 Forbidden".equals(errors.getMessage());
    }
}
项目:communote-server    文件:CommunoteIntegrationTest.java   
/**
 * Drop and recreates the databaseName from the template files.
 *
 * @param skipDatabaseCreation
 *            If set to true, the databaseName creation will be skipped (Default: false).
 *
 * @throws Exception
 *             Exception.
 */
@Parameters({ "skipDatabaseCreation" })
@BeforeClass(dependsOnMethods = { "setupIntegrationTest" }, groups = GROUP_INTEGRATION_TEST_SETUP)
public void setupDatabase(@Optional("false") String skipDatabaseCreation) throws Exception {
    if (BooleanUtils.toBoolean(skipDatabaseCreation)) {
        return;
    }
    LOGGER.info("Using the following JDBC URL for the test database: " + jdbcURL);
    try {
        DatabaseUtils.recreateDatabase(jdbcTempURL, suUsername, suPassword, databaseName,
                databaseType, username);
        initializeDatabaseSchemaAndContent();
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw e;
    }
}
项目:communote-server    文件:CommunoteIntegrationTest.java   
/**
 * Setup credentials for DB access.
 *
 * @param dbUsername
 *            The username to use. (Default: communote).
 * @param dbPassword
 *            The passwort to use for the given user (Default: communote).
 * @param dbSuUsername
 *            name of the user to use for dropping an existing databaseName and creating a new
 *            databaseName. This user also needs to have access to the temp databaseName. If
 *            unset, username will be used.
 * @param dbSuPassword
 *            password of the user identified by suUsername. Will be the password parameter if
 *            suUsername is blank.
 */
@Parameters({ "dbUsername", "dbPassword", "dbSuUsername", "dbSuPassword" })
@BeforeClass(groups = GROUP_INTEGRATION_TEST_SETUP)
public void setupDatabaseUser(@Optional("communote") String dbUsername,
        @Optional("communote") String dbPassword, @Optional("") String dbSuUsername,
        @Optional("") String dbSuPassword) {
    this.username = dbUsername;
    this.password = dbPassword;
    if (StringUtils.isBlank(dbSuUsername)) {
        this.suUsername = dbUsername;
        this.suPassword = dbPassword;
    } else {
        this.suUsername = dbSuUsername;
        this.suPassword = dbSuPassword;
    }
}
项目:communote-server    文件:LdapCommunoteIntegrationTest.java   
/**
 * Setup.
 *
 * @param ldifFile
 *            ldif file as classpath or file URL. Default is to load from classpath.
 * @throws Exception
 *             Exception.
 */
@Parameters({ "ldifFile" })
@BeforeClass(groups = "ldap-test-setup")
public void setup(
        @Optional("classpath:/com/communote/server/test/ldap/test_ldap.ldif") String ldifFile)
        throws Exception {
    server.setPort(getNextFreePort());
    server.start();
    LOG.info("Load ldif from: " + ldifFile);
    URL url;
    if (ldifFile.startsWith("classpath:")) {
        ldifFile = ldifFile.substring(10);
        url = getClass().getResource(ldifFile);
    } else {
        url = new URL(ldifFile);
    }
    try (InputStream in = url.openStream()) {
        server.importLdifFromStream(in);
    }
}
项目:communote-server    文件:BlogManagementTest2.java   
/**
 * Setup.
 *
 * @param numberOfMessages
 *            The number of messages to generate.
 *
 * @throws Exception
 *             Exception.
 */
@Parameters({ "numberOfMessages" })
@BeforeClass(dependsOnGroups = "integration-test-setup")
public void setup(@Optional("1000") String numberOfMessages) throws Exception {
    user = TestUtils.createRandomUser(false);
    blogForDeletion = TestUtils.createRandomBlog(true, true, user);
    blogForMovingFrom = TestUtils.createRandomBlog(true, true, user);
    blogForMovingTo = TestUtils.createRandomBlog(true, true, user);
    this.numberOfMessages = Integer.parseInt(numberOfMessages);
    for (int i = 1; i <= this.numberOfMessages; i++) {
        TestUtils.createAndStoreCommonNote(blogForDeletion, user.getId(), "Message " + i);
        TestUtils.createAndStoreCommonNote(blogForMovingFrom, user.getId(), "Message " + i);
    }
    blogManagement = ServiceLocator.instance().getService(BlogManagement.class);
    noteDao = ServiceLocator.findService(NoteDao.class);
    Assert.assertEquals(noteDao.getNotesForBlog(blogForDeletion.getId(), null, null).size(),
            this.numberOfMessages);
    Assert.assertEquals(noteDao.getNotesForBlog(blogForMovingFrom.getId(), null, null).size(),
            this.numberOfMessages);
}
项目:communote-server    文件:ADTrackingIncrementalRepositoryChangeTrackerTest.java   
/**
 * Setups the group search.
 * 
 * @param searchFilter
 *            The search filter for groups.
 * @param searchBase
 *            The search base for groups.
 * @param searchSubtree
 *            True, when subtrees should be search too.
 * @param propertyMapping
 *            Mapping of properties as String.
 * @param isMemberMode
 *            True, if the mode is "member", false if "memberOf"
 */
@BeforeMethod(groups = "setupSearchBase")
@Parameters({ "groupSearchFilter", "groupSearchBase", "groupSearchSubtree",
        "groupPropertyMapping", "isMemberMode" })
public void setupGroupSearch(
        @Optional("(objectClass=group)") String searchFilter,
        String searchBase,
        @Optional("true") String searchSubtree,
        @Optional("name=name,alias=cn,membership=memberOf,description=name,uid=cn") String propertyMapping,
        @Optional("false") String isMemberMode) {
    groupSyncConfig = LdapGroupSyncConfiguration.Factory.newInstance();
    groupSyncConfig.setMemberMode(Boolean.parseBoolean(isMemberMode));
    groupSyncConfig.setGroupIdentifierIsBinary(false);
    LdapSearchConfiguration groupSearchConfiguration = LdapSearchConfiguration.Factory
            .newInstance();
    groupSearchConfiguration.setSearchFilter(searchFilter);
    LdapSearchBaseDefinition searchBaseDefinition = LdapSearchBaseDefinition.Factory
            .newInstance(searchBase, Boolean.parseBoolean(searchSubtree));
    groupSearchConfiguration.setSearchBases(new ArrayList<LdapSearchBaseDefinition>());
    groupSearchConfiguration.getSearchBases().add(searchBaseDefinition);
    groupSearchConfiguration.setPropertyMapping(propertyMapping);
    groupSyncConfig.setGroupSearch(groupSearchConfiguration);
}
项目:communote-server    文件:ADTrackingIncrementalRepositoryChangeTrackerTest.java   
/**
 * Setup the LDAP configuration for the ActiveDirectory to use.
 * 
 * @param url
 *            The LDAP URL of the ActiveDirectory server including protocol and port, e.g.
 *            ldap://ad.company.com:389
 * @param bindUserDN
 *            The distinguished name of the bind user which should be used for retrieving users
 *            and groups
 * @param bindUserPassword
 *            The password of the bind user
 */
@BeforeMethod(dependsOnGroups = "setupSearchBase", dependsOnMethods = { "setupProperties",
        "setupUserManagement", "setupExternalUserGroupDao" })
@Parameters({ "url", "bindUserDN", "bindUserPassword" })
public void setupLdap(String url, String bindUserDN, String bindUserPassword) {
    LdapConfiguration ldapConfiguration = LdapConfiguration.Factory.newInstance();
    ldapConfiguration.setUserSearch(userSearchConfiguration);
    ldapConfiguration.setGroupSyncConfig(groupSyncConfig);
    groupSyncConfig.setLdapConfiguration(ldapConfiguration);
    ldapConfiguration.setDynamicMode(false);
    ldapConfiguration.setManagerDN(bindUserDN);
    ldapConfiguration.setManagerPassword(bindUserPassword);
    ldapConfiguration.setUrl(url);
    ldapConfiguration.setSystemId("External");
    tracker = new ADTrackingIncrementalRepositoryChangeTracker(ldapConfiguration,
            pluginProperties, userManagement, externalUserGroupDao, false);
}
项目:communote-server    文件:MessageQueueTest.java   
@BeforeClass
@Parameters({ "cntAuthenticationUsername", "cntAuthenticationPassword", "cntManagerAlias",
        "cntUserAlias", "cntManagerId", "externalGroupId" })
public void setupCommunoteParameters(
        @Optional("sharepoint.system") String cntAuthenticationUsername,
        @Optional("123456") String cntAuthenticationPassword,
        @Optional("kenmei") String communoteManagerAlias,
        @Optional("kenmei") String communoteUserAlias, @Optional String communoteManagerId,
        @Optional("mqTestExternalGroup") String externalGroupId) {

    this.cntAuthenticationUsername = cntAuthenticationUsername;
    this.cntAuthenticationPassword = cntAuthenticationPassword;
    this.setCommunoteManagerAlias(communoteManagerAlias);
    this.setCommunoteUserAlias(communoteUserAlias);
    if (communoteManagerId == null || communoteManagerId.length() == 0) {
        this.setCommunoteManagerId(1L);
    } else {
        this.setCommunoteManagerId(Long.parseLong(communoteManagerId));
    }
    this.externalGroupId = externalGroupId;
}
项目:gluu    文件:GroupServiceTest.java   
@Test
@Parameters({ "test.group.dn", "test.group.dn.ownerDn", "test.group.dn.nonMemberDn" })
public void testIsMemberOrOwner(final String groupDn, final String ownerDn, final String nonMemberDn)
        throws Exception {
    new FacesRequest() {
        @Override
        public void invokeApplication() throws Exception {
            IGroupService groupService = (IGroupService) getInstance("groupService");

            boolean isMemberOrOwner = groupService.isMemberOrOwner(groupDn, ownerDn);
            assertTrue(isMemberOrOwner, String.format("Failed to confirm group '%s' owner '%s'", groupDn, ownerDn));

            boolean isMemberOrOwnerWrong = groupService.isMemberOrOwner(groupDn, nonMemberDn);
            assertFalse(isMemberOrOwnerWrong, "Wrong person recognised as group member");
        }
    }.run();
}
项目:gluu    文件:PersonServiceTest.java   
/**
 * Test search persons by pattern
 * @throws Exception
 */
@Test
@Parameters({ "person.search.pattern" })
public void testSearchPersons(final String pattern) throws Exception {
    new FacesRequest() {

        @Override
        protected void invokeApplication() throws Exception {
            IPersonService personService = (IPersonService) getInstance("personService");

            List<GluuCustomPerson> persons = personService.searchPersons(pattern, OxTrustConstants.searchPersonsSizeLimit);

            assertNotNull(persons, "Failed to find persons");
            assertTrue(persons.size() > 0, "Failed to find persons");
        }
    }.run();
}
项目:deploy-cluster    文件:Mr2InfraTest.java   
@BeforeClass
@Parameters({"ambarihost", "ambariport","username", "password","ambariclustername"
    })
public void mr2InfraSetup(String ambarihost, String ambariport,String username, String password,
        String ambariclustername        
        ) {

    ahost= Common.assignPOMValues("BIambarihost", ambarihost);      
    /*aport=Common.assignPOMValues("BIambariport", ambariport);*/
    user=Common.assignPOMValues("BIusername", username);
    pw=Common.assignPOMValues("BIpassword", password);
    /*clustername=Common.assignPOMValues("BIambariclustername", ambariclustername); */

        System.out.println("\n==============This test checks status of MR2 and it's components===========");
        System.out.println("============Displays the Alerts and some of metrics associated with it============== ") ; 
}
项目:deploy-cluster    文件:YarnInfraTest.java   
@BeforeClass
@Parameters({"ambarihost", "ambariport","username", "password","ambariclustername"
    })
public void yarnInfraSetup(String ambarihost, String ambariport,String username, String password,
        String ambariclustername) throws InterruptedException, JSONException {

    ahost= Common.assignPOMValues("BIambarihost", ambarihost);      
    /*aport=Common.assignPOMValues("BIambariport", ambariport);*/
    user=Common.assignPOMValues("BIusername", username);
    pw=Common.assignPOMValues("BIpassword", password);
    /*clustername=Common.assignPOMValues("BIambariclustername", ambariclustername); */  

        System.out.println("\n==============This test checks status of Yarn and it's components===========");
        System.out.println("============Displays the Alerts and some of metrics associated with yarn============== ") ;         

   }
项目:deploy-cluster    文件:ZookeeperTests.java   
@Test
@Parameters({"hostname", "username", "password","service"})
public static void stopZookeeperService  (
                                           String host, 
                                           String user, 
                                           String pass,
                                           String serv 
                                           ) throws InterruptedException, JSONException 
{
    hostname= Common.assignPOMValues("BIambarihost", host);     
    username=Common.assignPOMValues("BIusername", user);
    password=Common.assignPOMValues("BIpassword", pass);
    service=Common.assignPOMValues("BIservice", serv);
    StopService.stopService(hostname, username, password, service);

}
项目:iot-server-appliances    文件:DeviceManagementDAOTests.java   
@BeforeClass
@Parameters("dbType")
public void setUpDB(String dbTypeStr) throws Exception {
    DBTypes dbType = DBTypes.valueOf(dbTypeStr);
    TestDBConfiguration dbConfig = getTestDBConfiguration(dbType);

    switch (dbType) {
        case H2:
            PoolProperties properties = new PoolProperties();
            properties.setUrl(dbConfig.getConnectionUrl());
            properties.setDriverClassName(dbConfig.getDriverClass());
            properties.setUsername(dbConfig.getUserName());
            properties.setPassword(dbConfig.getPwd());
            dataSource = new org.apache.tomcat.jdbc.pool.DataSource(properties);
            this.initSQLScript();
            DeviceManagementDAOFactory.init(dataSource);
        default:
    }
}
项目:iot-server-appliances    文件:DeviceManagementBaseTest.java   
@BeforeClass(alwaysRun = true)
@Parameters("dbType")
public void setupDatabase(String dbTypeName) throws Exception {
    DBTypes type = DBTypes.valueOf(dbTypeName);
    TestDBConfiguration config = getTestDBConfiguration(type);
    switch (type) {
        case H2:
            PoolProperties properties = new PoolProperties();
            properties.setUrl(config.getConnectionUrl());
            properties.setDriverClassName(config.getDriverClass());
            properties.setUsername(config.getUserName());
            properties.setPassword(config.getPwd());
            dataSource = new org.apache.tomcat.jdbc.pool.DataSource(properties);
            this.initSQLScript();
        default:
    }
}
项目:carbon-metrics    文件:ReporterTest.java   
@Parameters("server-port")
@BeforeClass
private void init(String serverPort) throws ConfigurationException {
    if (logger.isInfoEnabled()) {
        logger.info("Creating the DAS Test Receiver");
    }
    this.serverPort = Integer.parseInt(serverPort);
    testServer.start("localhost", this.serverPort);

    if (logger.isInfoEnabled()) {
        logger.info("Creating MetricService");
    }
    System.setProperty("metrics.dataagent.conf", TEST_RESOURCES_DIR + File.separator + "data.agent.config.yaml");
    metrics = new Metrics(TestUtils.getConfigProvider("metrics.yaml"));
    metrics.activate();
    metricService = metrics.getMetricService();
    metricManagementService = metrics.getMetricManagementService();
}
项目:java-http-signature    文件:HttpSignatureRequestInterceptorTest.java   
@Parameters({"useNativeCodeToSign"})
@BeforeClass
@SuppressWarnings("deprecation")
public void beforeClass(@Optional Boolean useNativeCodeToSign) throws IOException, NoSuchAlgorithmException {
    if (useNativeCodeToSign == null) {
        this.useNativeCodeToSign = true;
    } else {
        this.useNativeCodeToSign = useNativeCodeToSign;
    }

    this.signer = new ThreadLocalSigner(this.useNativeCodeToSign);
    // Removes any existing instances - so that we can reset state
    this.signer.remove();
    this.testKeyPair = SignerTestUtil.testKeyPair("rsa_2048");
    this.testKeyFingerprint = SignerTestUtil.testKeyMd5Fingerprint("rsa_2048");
    credentials = new UsernamePasswordCredentials("username", testKeyFingerprint);

    this.authScheme = new HttpSignatureAuthScheme(testKeyPair, this.useNativeCodeToSign);
    this.interceptor = new HttpSignatureRequestInterceptor(authScheme, credentials,
            this.useNativeCodeToSign);
}
项目:concurrentlinkedhashmap    文件:EfficiencyBenchmark.java   
@Test(groups = "efficiency")
@Parameters({"capacity", "passes", "generatorMultipler", "workingSetMultiplier"})
public void benchmark(int capacity, int passes, int generatorMultipler,
    int workingSetMultiplier) {
  Generator generator = new ScrambledZipfianGenerator(generatorMultipler * capacity);
  List<List<String>> workingSets = Lists.newArrayList();
  for (int i = 1; i <= passes; i++) {
    int size = i * workingSetMultiplier * capacity;
    workingSets.add(createWorkingSet(generator, size));
  }

  Set<Policy> seen = EnumSet.noneOf(Policy.class);
  for (CacheType cache : CacheType.values()) {
    if (!seen.add(cache.policy())) {
      continue;
    }
    Map<String, String> map = new CacheFactory()
        .maximumCapacity(capacity)
        .makeCache(cache);
    System.out.println(cache.policy().toString() + ":");
    for (List<String> workingSet : workingSets) {
      System.out.println(determineEfficiency(map, workingSet));
    }
  }
}
项目:concurrentlinkedhashmap    文件:PerfHashBenchmark.java   
@Test(groups = "perfHash")
@Parameters({"readRatio", "threadMin", "threadMax", "threadIncrement",
  "hashTableSize", "hashTableImpl"})
public static void benchmark(String readRatio, String threadMin, String threadMax,
    String threadIncrement, String hashTableSize, @Optional("0") String hashTableImpl)
    throws Exception {
  String[] args = {
    readRatio,
    threadMin,
    threadMax,
    threadIncrement,
    hashTableSize,
    hashTableImpl
  };
  main(args);
}