Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2007, 2017 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.jemmy.env;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import org.jemmy.JemmyException;
import org.jemmy.action.ActionExecutor;
import org.jemmy.action.DefaultExecutor;
import org.jemmy.control.Wrap;
import org.jemmy.image.ImageCapturer;
import org.jemmy.image.ImageLoader;
import org.jemmy.input.CharBindingMap;
import org.jemmy.interfaces.ControlInterfaceFactory;
import org.jemmy.timing.Waiter;
/**
* @author shura, mrkam, erikgreijus
*/
public class Environment {
public static final String JEMMY_PROPERTIES_FILE_PROPERTY = "jemmy.properties";
public static final String TIMEOUTS_FILE_PROPERTY = "timeouts";
/**
* Information output for Environment class
*/
public static final String OUTPUT = Environment.class.getName() + ".OUTPUT";
private final static Environment env = new Environment(null);
public static Environment getEnvironment() {
return env;
}
static {
env.setOutput(new TestOut(System.in, System.out, System.err));
env.setExecutor(new DefaultExecutor());
}
private HashMap environment = new HashMap();
private Environment parent;
public Environment(Environment parent) {
this.parent = parent;
environment = new HashMap();
if (parent == null) {
loadProperties(System.getProperty(JEMMY_PROPERTIES_FILE_PROPERTY));
}
}
public Environment() {
this(getEnvironment());
}
public Environment getParentEnvironment() {
return parent;
}
public void setParentEnvironment(Environment parent) {
this.parent = parent;
}
public void loadProperties(String propFileName) {
if (propFileName == null || propFileName.length() == 0) {
propFileName = System.getProperty("user.home") + File.separator + ".jemmy.properties";
}
File propFile = new File(propFileName);
System.out.println("Loading jemmy properties from " + propFile);
if (propFile.exists()) {
Properties props = new Properties();
try {
props.load(new FileInputStream(propFile));
} catch (IOException ex) {
throw new JemmyException("Unable to load properties", ex, propFileName);
}
for (String k : props.stringPropertyNames()) {
if (k.equals(TIMEOUTS_FILE_PROPERTY)) {
loadTimeouts(propFile.getParentFile(), props.getProperty(k));
} else {
setProperty(k, props.getProperty(k));
}
}
} else {
System.out.println("Property file " + propFile + " does not exists. Ignoring.");
}
}
private void loadTimeouts(File propDir, String file) {
File timeoutsFile = new File(file);
if (!timeoutsFile.isAbsolute()) {
timeoutsFile = new File(propDir.getAbsolutePath() + File.separator + file);
}
System.out.println("Loading timeouts from " + timeoutsFile.getAbsolutePath());
try {
Properties timeouts = new Properties();
timeouts.load(new FileInputStream(timeoutsFile));
for (String k : timeouts.stringPropertyNames()) {
setTimeout(k, Long.parseLong(timeouts.getProperty(k)));
}
} catch (IOException ex) {
throw new JemmyException("Unable to load timeouts", ex, timeoutsFile.getAbsolutePath());
}
}
public List> get(Class cls) {
Set all = environment.keySet();
ArrayList