Java Code Examples for org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider

The following examples show how to use org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider. These examples are extracted from open source projects. 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 Project: micro-integrator   Source File: DSSIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
protected File selectSqlFile(String fileName) throws XPathExpressionException {

        String driver = dssContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DRIVER_CLASS_NAME);
        String type = "";
        if (driver.contains("h2")) {
            type = "h2";
        } else if (driver.contains("mysql")) {
            type = "MySql";
        } else if (driver.contains("oracle")) {
            type = "oracle";
        }

        return new File(
                TestConfigurationProvider.getResourceLocation() + "artifacts" + File.separator + "DSS" + File.separator
                        + "sql" + File.separator + type + File.separator + fileName);
    }
 
Example 2
private void secureService(int policyId)
        throws SecurityAdminServiceSecurityConfigExceptionException, RemoteException, InterruptedException,
        XPathExpressionException {
    SecurityAdminServiceClient securityAdminServiceClient = new SecurityAdminServiceClient(
            dssContext.getContextUrls().getBackEndUrl(), sessionCookie);
    if (TestConfigurationProvider.isPlatform()) {
        //todo
        /*securityAdminServiceClient.applySecurity(serviceName, policyId + "", new String[]{"admin"},
                                                 new String[]{userInfo.getDomain().replace('.', '-') + ".jks"},
                                                 userInfo.getDomain().replace('.', '-') + ".jks");*/
    } else {
        securityAdminServiceClient.applySecurity(serviceName, policyId + "", new String[] { "admin" },
                new String[] { "wso2carbon.jks" }, "wso2carbon.jks");
    }
    log.info("Security Scenario " + policyId + " Applied");

    Thread.sleep(1000);

}
 
Example 3
Source Project: product-ei   Source File: DSSIntegrationTest.java    License: Apache License 2.0 6 votes vote down vote up
protected File selectSqlFile(String fileName) throws XPathExpressionException {

        String driver = dssContext.getConfigurationValue(XPathConstants.DATA_SOURCE_DRIVER_CLASS_NAME);
        String type = "";
        if (driver.contains("h2")) {
            type = "h2";
        } else if (driver.contains("mysql")) {
            type = "MySql";
        } else if (driver.contains("oracle")) {
            type = "oracle";
        }

        return new File(TestConfigurationProvider.getResourceLocation() + "artifacts"
                        + File.separator + "DSS" + File.separator + "sql" + File.separator
                        + type + File.separator + fileName);
    }
 
Example 4
Source Project: product-ei   Source File: SecureDataServiceTestCase.java    License: Apache License 2.0 6 votes vote down vote up
private void secureService(int policyId)
        throws SecurityAdminServiceSecurityConfigExceptionException, RemoteException,
               InterruptedException, XPathExpressionException {
    SecurityAdminServiceClient securityAdminServiceClient = new SecurityAdminServiceClient(dssContext.getContextUrls().getBackEndUrl(),sessionCookie);
    if (TestConfigurationProvider.isPlatform()) {
        //todo
        /*securityAdminServiceClient.applySecurity(serviceName, policyId + "", new String[]{"admin"},
                                                 new String[]{userInfo.getDomain().replace('.', '-') + ".jks"},
                                                 userInfo.getDomain().replace('.', '-') + ".jks");*/
    } else {
        securityAdminServiceClient.applySecurity(serviceName, policyId + "", new String[]{"admin"},
                                                 new String[]{"wso2carbon.jks"}, "wso2carbon.jks");
    }
    log.info("Security Scenario " + policyId + " Applied");

    Thread.sleep(1000);

}
 
Example 5
Source Project: product-es   Source File: EmailUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * This method delete all the sent mails. Can be used after a particular test class
 *
 * @throws  MessagingException
 * @throws  IOException
 */
public static void deleteSentMails() throws MessagingException, IOException {
    Properties props = new Properties();
    props.load(new FileInputStream(new File(
            TestConfigurationProvider.getResourceLocation("GREG") + File.separator + "axis2" + File.separator
                    + "smtp.properties")));
    Session session = Session.getDefaultInstance(props, null);
    Store store = session.getStore("imaps");
    store.connect("smtp.gmail.com", emailAddress, java.nio.CharBuffer.wrap(emailPassword).toString());

    Folder sentMail = store.getFolder("[Gmail]/Sent Mail");
    sentMail.open(Folder.READ_WRITE);
    Message[] messages =sentMail.getMessages();
    Flags deleted = new Flags(Flags.Flag.DELETED);
    sentMail.setFlags(messages,deleted,true);
    sentMail.close(true);
    store.close();
}
 
Example 6
Source Project: product-es   Source File: EmailUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * This method delete all the sent mails. Can be used after a particular test class
 *
 * @throws  MessagingException
 * @throws  IOException
 */
public static void deleteSentMails() throws MessagingException, IOException {
    Properties props = new Properties();
    props.load(new FileInputStream(new File(
            TestConfigurationProvider.getResourceLocation("GREG") + File.separator + "axis2" + File.separator
                    + "smtp.properties")));
    Session session = Session.getDefaultInstance(props, null);
    Store store = session.getStore("imaps");
    store.connect("smtp.gmail.com", emailAddress, java.nio.CharBuffer.wrap(emailPassword).toString());

    Folder sentMail = store.getFolder("[Gmail]/Sent Mail");
    sentMail.open(Folder.READ_WRITE);
    Message[] messages =sentMail.getMessages();
    Flags deleted = new Flags(Flags.Flag.DELETED);
    sentMail.setFlags(messages,deleted,true);
    sentMail.close(true);
    store.close();
}
 
Example 7
Source Project: product-es   Source File: EmailUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Update user profile for particular user in order to enable e-mail subscription.
 *
 * @param automationContext
 * @param backendURL        URL of the server.
 * @param session           session cookie obtained after logging in.
 * @throws UserProfileMgtServiceClient
 * @throws IOException
 * @throws XPathExpressionException
 * @throws AutomationUtilException
 */
public static void updateProfileAndEnableEmailConfiguration(AutomationContext automationContext, String backendURL,
        String session)
        throws UserProfileMgtServiceUserProfileExceptionException, IOException, XPathExpressionException,
        AutomationUtilException {
    UserProfileMgtServiceClient userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, session);
    File axis2File = new File(
            TestConfigurationProvider.getResourceLocation("GREG") + File.separator + "axis2" + File.separator
                    + "axis2.xml");
    UserProfileDTO profile = new UserProfileDTO();
    profile.setProfileName("default");

    UserFieldDTO lastName = new UserFieldDTO();
    lastName.setClaimUri("http://wso2.org/claims/lastname");
    lastName.setFieldValue("GregUserFirstName");

    UserFieldDTO givenName = new UserFieldDTO();
    givenName.setClaimUri("http://wso2.org/claims/givenname");
    givenName.setFieldValue("GregUserLastName");

    UserFieldDTO email = new UserFieldDTO();
    email.setClaimUri("http://wso2.org/claims/emailaddress");
    email.setFieldValue(emailAddress);

    UserFieldDTO[] fields = new UserFieldDTO[3];
    fields[0] = lastName;
    fields[1] = givenName;
    fields[2] = email;

    profile.setFieldValues(fields);

    userProfileMgtClient
            .setUserProfile(automationContext.getContextTenant().getContextUser().getUserName(), profile);

    // apply new axis2.xml configuration
    ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(automationContext);
    serverConfigurationManager.applyConfiguration(axis2File);
}
 
Example 8
Source Project: product-es   Source File: EmailUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Update user profile for particular user in order to enable e-mail subscription.
 *
 * @param automationContext
 * @param backendURL        URL of the server.
 * @param session           session cookie obtained after logging in.
 * @throws UserProfileMgtServiceClient
 * @throws IOException
 * @throws XPathExpressionException
 * @throws AutomationUtilException
 */
public static void updateProfileAndEnableEmailConfiguration(AutomationContext automationContext, String backendURL,
        String session)
        throws UserProfileMgtServiceUserProfileExceptionException, IOException, XPathExpressionException,
        AutomationUtilException {
    UserProfileMgtServiceClient userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, session);
    File axis2File = new File(
            TestConfigurationProvider.getResourceLocation("GREG") + File.separator + "axis2" + File.separator
                    + "axis2.xml");
    UserProfileDTO profile = new UserProfileDTO();
    profile.setProfileName("default");

    UserFieldDTO lastName = new UserFieldDTO();
    lastName.setClaimUri("http://wso2.org/claims/lastname");
    lastName.setFieldValue("GregUserFirstName");

    UserFieldDTO givenName = new UserFieldDTO();
    givenName.setClaimUri("http://wso2.org/claims/givenname");
    givenName.setFieldValue("GregUserLastName");

    UserFieldDTO email = new UserFieldDTO();
    email.setClaimUri("http://wso2.org/claims/emailaddress");
    email.setFieldValue(emailAddress);

    UserFieldDTO[] fields = new UserFieldDTO[3];
    fields[0] = lastName;
    fields[1] = givenName;
    fields[2] = email;

    profile.setFieldValues(fields);

    userProfileMgtClient
            .setUserProfile(automationContext.getContextTenant().getContextUser().getUserName(), profile);

    // apply new axis2.xml configuration
    ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(automationContext);
    serverConfigurationManager.applyConfiguration(axis2File);
}
 
Example 9
Source Project: micro-integrator   Source File: DSSIntegrationTest.java    License: Apache License 2.0 4 votes vote down vote up
protected String getResourceLocation() throws XPathExpressionException {
    return TestConfigurationProvider.getResourceLocation(PRODUCT_NAME);
}
 
Example 10
Source Project: product-ei   Source File: DSSIntegrationTest.java    License: Apache License 2.0 4 votes vote down vote up
protected String getResourceLocation() throws XPathExpressionException {
    return TestConfigurationProvider.getResourceLocation(PRODUCT_NAME).replace("//", "/");
}
 
Example 11
Source Project: product-es   Source File: ESIntegrationTest.java    License: Apache License 2.0 4 votes vote down vote up
protected String getResourceLocation() throws XPathExpressionException {
    return TestConfigurationProvider.getResourceLocation(ESIntegrationTestConstants.ES_PRODUCT_NAME);
}
 
Example 12
Source Project: product-es   Source File: EmailUtil.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * This method read verification e-mail from Gmail inbox and returns the verification URL.
 *
 * @return  verification redirection URL.
 * @throws  Exception
 */
public static String readGmailInboxForVerification() throws Exception {
    boolean isEmailVerified = false;
    long waitTime = 10000;
    String pointBrowserURL = "";
    Properties props = new Properties();
    props.load(new FileInputStream(new File(
            TestConfigurationProvider.getResourceLocation("GREG") + File.separator + "axis2" + File.separator
                    + "smtp.properties")));
    Session session = Session.getDefaultInstance(props, null);
    Store store = session.getStore("imaps");
    store.connect("smtp.gmail.com", emailAddress, java.nio.CharBuffer.wrap(emailPassword).toString());

    Folder inbox = store.getFolder("inbox");
    inbox.open(Folder.READ_WRITE);
    Thread.sleep(waitTime);
    long startTime = System.currentTimeMillis();
    long endTime = 0;
    int count = 1;
    while (endTime - startTime < 180000 && !isEmailVerified) {
        Message[] messages = inbox.getMessages();

        for (Message message : messages) {
            if (!message.isExpunged()) {
                try {
                    log.info("Mail Subject:- " + message.getSubject());
                    if (message.getSubject().contains("EmailVerification")) {
                        pointBrowserURL = getBodyFromMessage(message);
                        isEmailVerified = true;
                    }

                    // Optional : deleting the mail
                    message.setFlag(Flags.Flag.DELETED, true);
                } catch (MessageRemovedException e){
                    log.error("Could not read the message subject. Message is removed from inbox");
                }
            }
        }
        endTime = System.currentTimeMillis();
        Thread.sleep(waitTime);
        endTime += count*waitTime;
        count++;
    }
    inbox.close(true);
    store.close();
    return pointBrowserURL;
}
 
Example 13
Source Project: product-es   Source File: EmailUtil.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * This method read e-mails from Gmail inbox and find whether the notification of particular type is found.
 *
 * @param   notificationType    Notification types supported by publisher and store.
 * @return  whether email is found for particular type.
 * @throws  Exception
 */
public static boolean readGmailInboxForNotification(String notificationType) throws Exception {
    boolean isNotificationMailAvailable = false;
    long waitTime = 10000;
    Properties props = new Properties();
    props.load(new FileInputStream(new File(
            TestConfigurationProvider.getResourceLocation("GREG") + File.separator + "axis2" + File.separator
                    + "smtp.properties")));
    Session session = Session.getDefaultInstance(props, null);
    Store store = session.getStore("imaps");
    store.connect("smtp.gmail.com", emailAddress, java.nio.CharBuffer.wrap(emailPassword).toString());

    Folder inbox = store.getFolder("inbox");
    inbox.open(Folder.READ_WRITE);
    Thread.sleep(waitTime);

    long startTime = System.currentTimeMillis();
    long endTime = 0;
    int count = 1;
    while (endTime - startTime < 180000 && !isNotificationMailAvailable) {
        Message[] messages = inbox.getMessages();

        for (Message message : messages) {
            if(!message.isExpunged()) {
                try {
                    log.info("Mail Subject:- " + message.getSubject());

                    if (message.getSubject().contains(notificationType)) {
                        isNotificationMailAvailable = true;

                    }
                    // Optional : deleting the  mail
                    message.setFlag(Flags.Flag.DELETED, true);
                } catch (MessageRemovedException e) {
                    log.error("Could not read the message subject. Message is removed from inbox");
                }
            }

        }
        endTime = System.currentTimeMillis();
        Thread.sleep(waitTime);
        endTime += count*waitTime;
        count++;
    }
    inbox.close(true);
    store.close();
    return isNotificationMailAvailable;
}
 
Example 14
Source Project: product-es   Source File: EmailUtil.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * This method read verification e-mail from Gmail inbox and returns the verification URL.
 *
 * @return  verification redirection URL.
 * @throws  Exception
 */
public static String readGmailInboxForVerification() throws Exception {
    boolean isEmailVerified = false;
    long waitTime = 10000;
    String pointBrowserURL = "";
    Properties props = new Properties();
    props.load(new FileInputStream(new File(
            TestConfigurationProvider.getResourceLocation("GREG") + File.separator + "axis2" + File.separator
                    + "smtp.properties")));
    Session session = Session.getDefaultInstance(props, null);
    Store store = session.getStore("imaps");
    store.connect("smtp.gmail.com", emailAddress, java.nio.CharBuffer.wrap(emailPassword).toString());

    Folder inbox = store.getFolder("inbox");
    inbox.open(Folder.READ_WRITE);
    Thread.sleep(waitTime);
    long startTime = System.currentTimeMillis();
    long endTime = 0;
    int count = 1;
    while (endTime - startTime < 180000 && !isEmailVerified) {
        Message[] messages = inbox.getMessages();

        for (Message message : messages) {
            if (!message.isExpunged()) {
                try {
                    log.info("Mail Subject:- " + message.getSubject());
                    if (message.getSubject().contains("EmailVerification")) {
                        pointBrowserURL = getBodyFromMessage(message);
                        isEmailVerified = true;
                    }

                    // Optional : deleting the mail
                    message.setFlag(Flags.Flag.DELETED, true);
                } catch (MessageRemovedException e){
                    log.error("Could not read the message subject. Message is removed from inbox");
                }
            }
        }
        endTime = System.currentTimeMillis();
        Thread.sleep(waitTime);
        endTime += count*waitTime;
        count++;
    }
    inbox.close(true);
    store.close();
    return pointBrowserURL;
}
 
Example 15
Source Project: product-es   Source File: EmailUtil.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * This method read e-mails from Gmail inbox and find whether the notification of particular type is found.
 *
 * @param   notificationType    Notification types supported by publisher and store.
 * @return  whether email is found for particular type.
 * @throws  Exception
 */
public static boolean readGmailInboxForNotification(String notificationType) throws Exception {
    boolean isNotificationMailAvailable = false;
    long waitTime = 10000;
    Properties props = new Properties();
    props.load(new FileInputStream(new File(
            TestConfigurationProvider.getResourceLocation("GREG") + File.separator + "axis2" + File.separator
                    + "smtp.properties")));
    Session session = Session.getDefaultInstance(props, null);
    Store store = session.getStore("imaps");
    store.connect("smtp.gmail.com", emailAddress, java.nio.CharBuffer.wrap(emailPassword).toString());

    Folder inbox = store.getFolder("inbox");
    inbox.open(Folder.READ_WRITE);
    Thread.sleep(waitTime);

    long startTime = System.currentTimeMillis();
    long endTime = 0;
    int count = 1;
    while (endTime - startTime < 180000 && !isNotificationMailAvailable) {
        Message[] messages = inbox.getMessages();

        for (Message message : messages) {
            if(!message.isExpunged()) {
                try {
                    log.info("Mail Subject:- " + message.getSubject());

                    if (message.getSubject().contains(notificationType)) {
                        isNotificationMailAvailable = true;

                    }
                    // Optional : deleting the  mail
                    message.setFlag(Flags.Flag.DELETED, true);
                } catch (MessageRemovedException e) {
                    log.error("Could not read the message subject. Message is removed from inbox");
                }
            }

        }
        endTime = System.currentTimeMillis();
        Thread.sleep(waitTime);
        endTime += count*waitTime;
        count++;
    }
    inbox.close(true);
    store.close();
    return isNotificationMailAvailable;
}