Skip to content

Instantly share code, notes, and snippets.

@glennmartinez
Created November 5, 2012 06:05
Show Gist options
  • Select an option

  • Save glennmartinez/4015594 to your computer and use it in GitHub Desktop.

Select an option

Save glennmartinez/4015594 to your computer and use it in GitHub Desktop.
Code Guru
package com.atlassian.confluence.sanity;
import com.atlassian.confluence.it.User;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class WebDriverConfiguration
{
private static Properties testProperties;
protected User ADMIN_USER;
protected User TEST_USER;
static {
try{
testProperties = loadProperties();
getInstanceProperties();
}
catch(IOException ex){
System.out.print(ex.toString());
}
}
public static User SMOKE_ADMIN = new User(testProperties.getProperty("confluence.test.user.username", ""),
testProperties.getProperty("confluence.test.user.password", ""),
testProperties.getProperty("confluence.test.user.full.name", ""),
testProperties.getProperty("confluence.test.user.email", ""));
public static User SMOKE_TEST = new User(testProperties.getProperty("confluence.test.user2.username", ""),
testProperties.getProperty("confluence.test.user2.password", ""),
testProperties.getProperty("confluence.test.user2.full.name", ""),
testProperties.getProperty("confluence.test.user2.email", ""));
private static final int DEFAULT_HTTP_PORT = 8080;
private static final String DEFAULT_CONTEXT_PATH = "/confluence";
public static final String DEFAULT_BASEURL = "http://localhost:8080/confluence";
public static final String SMOKE_SPACE_KEY = System.getProperty("confluence.test.spacke.key","Test");
private static final String BASE_URL = System.getProperty("confluence.base.url.confluence", DEFAULT_BASEURL);
private static final int PORT = Integer.getInteger("http.confluence.port", DEFAULT_HTTP_PORT);
private static final String CONTEXT_PATH = System.getProperty("context.confluence.path", DEFAULT_CONTEXT_PATH);
public static String getBaseUrl()
{
return BASE_URL;
}
public static int getHttpPort()
{
return PORT;
}
public static String getContextPath()
{
return CONTEXT_PATH;
}
public static void getInstanceProperties() {
System.setProperty("baseurl", testProperties.getProperty("confluence.base.url"));
System.setProperty("anonymousaccess", testProperties.getProperty("confluence.capability.anonymousaccess"));
System.setProperty("signup", testProperties.getProperty("confluence.capability.signup"));
System.setProperty("calendar", testProperties.getProperty("confluence.capability.calendar"));
System.setProperty("rsvp", testProperties.getProperty("confluence.capability.rsvp"));
System.setProperty("vote", testProperties.getProperty("confluence.capability.vote"));
System.setProperty("copyspace", testProperties.getProperty("confluence.capability.copyspace"));
System.setProperty("balsamiq", testProperties.getProperty("confluence.capability.balsamiq"));
System.setProperty("gliffy", testProperties.getProperty("confluence.capability.gliffy"));
System.setProperty("flowchart", testProperties.getProperty("confluence.capability.flowchart"));
System.setProperty("eacdashboard", testProperties.getProperty("confluence.capability.eacdashboard"));
System.setProperty("ual", testProperties.getProperty("confluence.capability.ual"));
System.setProperty("jiraservers", testProperties.getProperty("confluence.capability.jiraservers"));
System.setProperty("websudo", testProperties.getProperty("confluence.capability.websudo"));
System.setProperty("adminaccess", testProperties.getProperty("confluence.capability.adminaccess"));
System.setProperty("studio", testProperties.getProperty("confluence.capability.studio"));
System.setProperty("studioui", testProperties.getProperty("confluence.capability.studioui"));
System.setProperty("htmlmacros", testProperties.getProperty("confluence.capability.htmlmacros"));
System.setProperty("flushindex", testProperties.getProperty("confluence.capability.flushindex"));
System.setProperty("skipgadgets", testProperties.getProperty("confluence.capability.skipgadgets"));
System.setProperty("remoteapps", testProperties.getProperty("confluence.capability.remoteapps"));
System.setProperty("runexports", testProperties.getProperty("confluence.capability.runexports"));
System.setProperty("local", testProperties.getProperty("confluence.capability.local"));
System.setProperty("stableversion", testProperties.getProperty("confluence.capability.stableversion"));
System.setProperty("sourceeditor", testProperties.getProperty("confluence.capability.sourceeditor"));
System.setProperty("linkfixer", testProperties.getProperty("confluence.capability.linkfixer"));
System.setProperty("publishing", testProperties.getProperty("confluence.capability.publishing"));
System.setProperty("jsplugin", testProperties.getProperty("confluence.capability.jsplugin"));
System.setProperty("onDemandMode", testProperties.getProperty("confluence.capability.onDemandMode"));
System.setProperty("ldapMode", testProperties.getProperty("confluence.capability.ldapMode"));
System.setProperty("jira.baseurl", testProperties.getProperty("confluence.capability.jira.baseurl"));
setOptionalPropertyFromCapability("indra.baseurl", "confluence.capability.indra.baseurl");
// translateFlavourForConfluenceTestProperties(getSelectedFlavour());
}
private static void setOptionalPropertyFromCapability(String propertyKey, String capabilityPropertyKey)
{
String value = testProperties.getProperty(capabilityPropertyKey);
if (value == null)
System.clearProperty(propertyKey); // This ensures confluence-test-support's defaults are unset
else
System.setProperty(propertyKey, value);
}
private static Properties loadProperties() throws IOException {
InputStream testPropertiesInput = WebDriverConfiguration.class.getClassLoader().getResourceAsStream("smoketest.properties");
Properties testProperties = new Properties();
if (null != testProperties) {
try{
testProperties.load(testPropertiesInput);
} finally {
IOUtils.closeQuietly(testPropertiesInput);
}
}
return testProperties;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment