use of org.platformlayer.http.jre.JreHttpStrategy in project platformlayer by platformlayer.
the class ConfigurationOptions method buildPlatformLayerClient.
private HttpPlatformLayerClient buildPlatformLayerClient(Properties properties, boolean debug) {
HttpStrategy httpStrategy = new JreHttpStrategy();
// HttpStrategy httpStrategy = new ApacheCommonsHttpStrategy();
HttpPlatformLayerClient client = HttpPlatformLayerClient.buildUsingProperties(httpStrategy, properties);
if (debug) {
client.setDebug(System.err);
} else {
// We don't want debug messages to interfere with our output
// TODO: Fix this so debug output doesn't interfere (stderr?)
// TODO: Maybe output the debug info only in case of failure?
ByteArrayOutputStream baos = new ByteArrayOutputStream();
client.setDebug(new PrintStream(baos));
}
return client;
}
use of org.platformlayer.http.jre.JreHttpStrategy in project platformlayer by platformlayer.
the class PlatformLayerTestContext method buildPlatformLayerClient.
public PlatformLayerClient buildPlatformLayerClient() throws IOException, OpsException {
PlatformLayerClient client;
if (configFile == null) {
throw new IllegalArgumentException("Config file is required");
}
InputStream is = null;
try {
if (!configFile.exists()) {
throw new FileNotFoundException("Configuration file not found: " + configFile);
}
is = new FileInputStream(configFile);
Properties properties = new Properties();
try {
properties.load(is);
} catch (IOException e) {
throw new IOException("Error reading configuration file", e);
}
HttpStrategy httpStrategy = new JreHttpStrategy();
client = HttpPlatformLayerClient.buildUsingProperties(httpStrategy, properties);
} finally {
if (is != System.in) {
IoUtils.safeClose(is);
}
}
return client;
}
Aggregations