package tools; import java.io.File; import java.io.IOException; import java.net.URL; import org.ini4j.Ini; import org.ini4j.InvalidFileFormatException; public class Settings { public String siteUrl; public String adminUrl; public String httpUser; public String httpPassword; public String adminLogin; public String adminPassword; public String http; public String httpPath; public Ini ini; public Ini user_ini; public Settings() { try { String userDrive = ""; String userDir = ""; if ("/".equals(System.getProperty("user.dir").substring(0, 1))) { String[] parts = System.getProperty("user.dir").split("/"); userDrive = "/" + parts[1]; if ((new File(userDrive + "/.userinfo.ini").isFile()) == false) { userDrive = userDrive + "/" + parts[2]; } } else { userDrive = System.getProperty("user.dir").substring(0, 2); } userDir = System.getProperty("user.dir").replace("\\", "/"); httpPath = userDir.replace(userDrive+"/public_html", ""); httpPath = httpPath.replace("tests_workspace/selenium_tests", "")+"www/"; this.user_ini = new Ini(new URL("file:///"+userDrive+"/.userinfo.ini")); } catch (InvalidFileFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { this.ini = new Ini(new File("settings.ini")); } catch (InvalidFileFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.http = "http://"; this.siteUrl = this.user_ini.get("user", "devdomain")+httpPath; this.adminUrl = this.siteUrl+"admin/"; this.httpUser = this.ini.get("http_auth", "user"); this.httpPassword = this.ini.get("http_auth", "pass"); this.adminLogin = this.ini.get("admin_auth", "admin");; this.adminPassword = this.ini.get("admin_auth", "pass");; } }