use of de.herrlock.manga.util.configuration.DownloadConfiguration in project Manga by herrlock.
the class TestUtils method testCreateHttpGet.
@Test
public void testCreateHttpGet() throws MalformedURLException {
URL url = new URL("http", "localhost", 1337, "/");
Properties p = new Properties();
p.setProperty(Configuration.URL, url.toExternalForm());
DownloadConfiguration conf = DownloadConfiguration.create(p);
HttpGet httpGet = Utils.createHttpGet(url, conf);
URI uri = httpGet.getURI();
Assert.assertEquals("http://localhost:1337/", uri.toString());
}
use of de.herrlock.manga.util.configuration.DownloadConfiguration in project Manga by herrlock.
the class TestUtils method testExecuteHttpGet.
@Test
public void testExecuteHttpGet() throws ClientProtocolException, IOException {
final String MAGIC_SUPER_SECRET_STRING = "somethingRandom";
HttpRequestHandler requestHandler = new SetStringHttpRequestHandler(MAGIC_SUPER_SECRET_STRING);
HttpServer server = ServerBootstrap.bootstrap().setListenerPort(1337).registerHandler("/", requestHandler).create();
URL url = new URL("http", "localhost", 1337, "/");
Properties p = new Properties();
p.setProperty(Configuration.URL, url.toExternalForm());
DownloadConfiguration conf = DownloadConfiguration.create(p);
ResponseHandler<Boolean> responseHandler = new ResponseEqualsStringResponseHandler(MAGIC_SUPER_SECRET_STRING);
server.start();
Utils.getDataAndExecuteResponseHandler(url, conf, responseHandler);
server.stop();
}
use of de.herrlock.manga.util.configuration.DownloadConfiguration in project Manga by herrlock.
the class Main method startCliDownloader.
private static void startCliDownloader(final CommandLine commandline) {
logger.traceEntry("Commandline: {}", commandline);
if (commandline.hasOption("hoster")) {
logger.info("Printing all Hoster:");
PrintAllHoster.printHoster(System.out);
} else {
Properties properties = //
Utils.newPropertiesBuilder().setProperty(Configuration.URL, //
commandline.getOptionValue("url")).setProperty(Configuration.PROXY, //
commandline.getOptionValue("proxy")).setProperty(Configuration.PATTERN, //
commandline.getOptionValue("pattern")).setProperty(Configuration.TIMEOUT, //
commandline.getOptionValue("timeout")).setProperty(Configuration.HEADLESS, //
String.valueOf(commandline.hasOption('i'))).build();
if (commandline.hasOption("list")) {
logger.info("Creating index");
IndexerConfiguration conf = IndexerConfiguration.create(properties);
logger.info(conf);
IndexerMain.writeIndex(conf);
} else {
logger.info("Starting Commandline-Downloader:");
DownloadConfiguration conf = DownloadConfiguration.create(properties);
logger.info(conf);
ConsoleDownloader downloader = new ConsoleDownloader(conf, conf.isHeadless());
DownloadProcessor.getInstance().addDownload(downloader);
}
}
}
use of de.herrlock.manga.util.configuration.DownloadConfiguration in project Manga by herrlock.
the class SettingsFileDownloader method execute.
public static void execute() {
logger.traceEntry();
Properties p = new Properties();
// load properties
try (InputStream fIn = new FileInputStream(Constants.SETTINGS_FILE)) {
p.load(fIn);
} catch (IOException ex) {
throw new MDRuntimeException(ex);
}
// properties loaded successful
DownloadConfiguration conf = DownloadConfiguration.create(p);
SettingsFileDownloader dlImpl = new SettingsFileDownloader(conf);
DownloadProcessor.getInstance().addDownload(dlImpl);
}
Aggregations