List of usage examples for java.net URL toExternalForm
public String toExternalForm()
From source file:net.sourceforge.dita4publishers.tools.mapreporter.MapBosReporter.java
/** * @throws Exception /*from w w w. j a v a 2 s. c o m*/ * */ private void run() throws Exception { String mapFilepath = commandLine.getOptionValue("i"); File mapFile = new File(mapFilepath); checkExistsAndCanReadSystemExit(mapFile); System.err.println("Processing map \"" + mapFile.getAbsolutePath() + "\"..."); PrintStream outStream = System.out; if (commandLine.hasOption(OUTPUT_OPTION_ONE_CHAR)) { String outputFilepath = commandLine.getOptionValue("o"); File outputFile = new File(outputFilepath); if (!outputFile.getParentFile().canWrite()) { throw new RuntimeException("File " + outputFile.getAbsolutePath() + " cannot be written to."); } outStream = new PrintStream(outputFile); } DitaBosReporter bosReporter = getBosReporter(outStream); KeySpaceReporter keyreporter = getKeyspaceReporter(outStream); Document rootMap = null; BosConstructionOptions bosOptions = new BosConstructionOptions(log, new HashMap<URI, Document>()); if (commandLine.hasOption(MAPTREE_OPTION_ONE_CHAR)) { bosOptions.setMapTreeOnly(true); System.err.println("MapBosReporter: Calculating map tree..."); } else { System.err.println("MapBosReporter: Calculating full map BOS..."); } setupCatalogs(bosOptions); try { URL rootMapUrl = mapFile.toURI().toURL(); rootMap = DomUtil.getDomForUri(new URI(rootMapUrl.toExternalForm()), bosOptions); Date startTime = TimingUtils.getNowTime(); DitaBoundedObjectSet mapBos = DitaBosHelper.calculateMapBos(bosOptions, log, rootMap); System.err.println("Map BOS construction took " + TimingUtils.reportElapsedTime(startTime)); BosReportOptions bosReportOptions = new BosReportOptions(); bosReporter.report(mapBos, bosReportOptions); DitaKeySpace keySpace = mapBos.getKeySpace(); KeyReportOptions reportOptions = new KeyReportOptions(); reportOptions.setAllKeys(true); keyreporter.report(new KeyAccessOptions(), keySpace, reportOptions); } catch (Exception e) { e.printStackTrace(); } finally { outStream.close(); } }
From source file:io.github.mmichaelis.selenium.client.provider.AbstractWebDriverProviderTest.java
@Test public void reset_closes_all_but_one_window() throws Exception { final HtmlUnitDriver testedDriver = new HtmlUnitDriver(true); final URL homePageUrl = Resources.getResource(this.getClass(), "page1.html"); testedDriver.get(homePageUrl.toExternalForm()); testedDriver.manage().addCookie(new Cookie(random(10), random(10))); prepareResetTest(testedDriver);//from w w w . j a va2s. c o m errorCollector.checkThat(testedDriver.getWindowHandles(), hasSize(1)); errorCollector.checkThat(testedDriver.getCurrentUrl(), equalTo(homePageUrl.toExternalForm())); errorCollector.checkThat(testedDriver.manage().getCookies(), empty()); }
From source file:org.jboss.as.test.manualmode.web.valve.authenticator.GlobalAuthenticatorTestCase.java
@Test @InSequence(2)/*w w w . jav a 2 s . c o m*/ @OperateOnDeployment(value = DEPLOYMENT_NAME) public void testValveAuthOne(@ArquillianResource URL url, @ArquillianResource ManagementClient client) throws Exception { String appUrl = url.toExternalForm() + WEB_APP_URL_1; log.debug("Testing url " + appUrl + " against one global valve authenticator named " + CUSTOM_AUTHENTICATOR_1); Header[] valveHeaders = ValveUtil.hitValve(new URL(appUrl)); assertEquals("There was one valve defined - it's missing now", 1, valveHeaders.length); assertEquals("One valve with not defined param expecting default param value", AUTH_VALVE_DEFAULT_PARAM_VALUE, valveHeaders[0].getValue()); }
From source file:org.jboss.as.test.manualmode.web.valve.authenticator.GlobalAuthenticatorTestCase.java
@Test @InSequence(3)//from ww w . j a va2s . co m @OperateOnDeployment(value = DEPLOYMENT_NAME_2) public void testValveAuthTwo(@ArquillianResource URL url, @ArquillianResource ManagementClient client) throws Exception { String appUrl = url.toExternalForm() + WEB_APP_URL_2; log.debug("Testing url " + appUrl + " against one global valve authenticator named " + CUSTOM_AUTHENTICATOR_2); Header[] valveHeaders = ValveUtil.hitValve(new URL(appUrl)); assertEquals("There was one valve defined - it's missing now", 1, valveHeaders.length); assertEquals("One valve with not defined param expecting default param value", GLOBAL_PARAM_VALUE, valveHeaders[0].getValue()); }
From source file:cn.edu.pku.sei.plde.conqueroverfitting.localization.gzoltar.GZoltarSuspiciousProgramStatements.java
protected GZoltarSuspiciousProgramStatements(final URL[] classpath, Collection<String> packageNames, Metric metric, String testSrcPath, String srcPath, List<String> libPath) { try {/*from ww w. java 2 s . co m*/ //gzoltar = new GZoltarJava7(); gzoltar = new WGzoltar(System.getProperty("user.dir"), metric, testSrcPath, srcPath, libPath); } catch (IOException e) { throw new RuntimeException(e); } ArrayList<String> classpaths = new ArrayList<String>(); for (URL url : classpath) { if ("file".equals(url.getProtocol())) { classpaths.add(url.getPath()); } else { classpaths.add(url.toExternalForm()); } } gzoltar.setClassPaths(classpaths); gzoltar.addPackageNotToInstrument("org.junit"); gzoltar.addPackageNotToInstrument("junit.framework"); gzoltar.addTestPackageNotToExecute("junit.framework"); gzoltar.addTestPackageNotToExecute("org.junit"); for (String packageName : packageNames) { gzoltar.addPackageToInstrument(packageName); } for (URL url : classpath) { if (url.getPath().endsWith(".jar")) { gzoltar.addClassNotToInstrument(url.getPath()); gzoltar.addPackageNotToInstrument(url.getPath()); } } }
From source file:org.jasig.cas.support.spnego.authentication.handler.support.JCIFSConfig.java
public void afterPropertiesSet() throws Exception { if (System.getProperty(SYS_PROP_LOGIN_CONF) != null) { log.warn("found login config in system property, may overide : " + System.getProperty(SYS_PROP_LOGIN_CONF)); }/* ww w .j a va2 s . co m*/ URL url = getClass().getResource((this.loginConf == null) ? DEFAULT_LOGIN_CONFIG : this.loginConf); if (url != null) this.loginConf = url.toExternalForm(); if (this.loginConf != null) { System.setProperty(SYS_PROP_LOGIN_CONF, this.loginConf); } else { url = getClass().getResource("/jcifs/http/login.conf"); if (url != null) { System.setProperty(SYS_PROP_LOGIN_CONF, url.toExternalForm()); } } log.debug("configured login configuration path : " + System.getProperty(SYS_PROP_LOGIN_CONF)); }
From source file:org.eclipse.skalli.core.destination.DestinationComponentTest.java
private void assertGetRequest(String protocol, int responseCode, String contentId, String content) throws Exception { URL url = new URL( protocol + "://" + mmus.getHost() + ":" + mmus.getPort() + "/" + contentId + "/" + responseCode); HttpClient client = destinationService.getClient(url); assertNotNull(client);/* ww w . j a v a2s .c om*/ HttpGet method = new HttpGet(url.toExternalForm()); HttpResponse response = client.execute(method); assertEquals(200, response.getStatusLine().getStatusCode()); if (content != null) { String contents = IOUtils.toString(response.getEntity().getContent()); assertEquals(content, contents); } }
From source file:org.jboss.as.test.integration.security.xacml.WebXACMLAuthorizationModuleTestCase.java
/** * Make requests to protected resource and asserts the response code is the expected one. * /*from w w w. j av a 2 s .c o m*/ * @param webAppURL * @throws MalformedURLException * @throws ClientProtocolException * @throws IOException * @throws URISyntaxException */ private void testWebAccess(URL webAppURL) throws MalformedURLException, ClientProtocolException, IOException, URISyntaxException { final URL requestURL = new URL(webAppURL.toExternalForm() + SimpleSecuredServlet.SERVLET_PATH.substring(1)); final String response = Utils.makeCallWithBasicAuthn(requestURL, "jduke", "theduke", 200); assertEquals(SimpleSecuredServlet.RESPONSE_BODY, response); Utils.makeCallWithBasicAuthn(requestURL, "guest", "guest", 403); }
From source file:ijfx.ui.test.DummyCategories.java
@Override public void run() { ExplorableList output = new ExplorableList(); ExplorableList output2 = new ExplorableList(); ExplorableList output3 = new ExplorableList(); for (int i = 0; i != 10; i++) { MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false)); MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false)); MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false)); MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble()); MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble()); Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); output.add(explorable);/* w w w.j a v a 2s .com*/ } for (int i = 0; i != 5; i++) { MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false)); MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false)); MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false)); MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble()); MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble()); Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); output2.add(explorable); } for (int i = 0; i != 3; i++) { MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false)); MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false)); MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false)); MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble()); MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble()); Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); output3.add(explorable); } Pane pane = ctrl.addCategory("Cat 1").setElements("Cat 1", output) //set the element that the first line will contain .addCategory("Cat 2").setElements("Cat 2", output2).setMaxItemPerCategory(8).generate(); // returns the Pane that contains the view ctrl.setElements("Cat 2", output3); ctrl.update(); // updates the pane returned previously Platform.runLater(() -> { Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); Scene scene = new Scene(pane, 550, 600); ////////CSS part/////// URL cssURL = getClass().getResource("/ijfx/ui/flatterfx.css"); if (cssURL != null) { scene.getStylesheets().add(cssURL.toExternalForm()); } stage.setScene(scene); stage.show(); }); }
From source file:org.jodconverter.office.OnlineOfficeManagerPoolEntry.java
private String buildUrl(final String connectionUrl) throws MalformedURLException { // An example URL is like: // http://localhost:9980/lool/convert-to/docx final URL url = new URL(connectionUrl); final String path = url.toExternalForm().toLowerCase(); if (StringUtils.endsWithAny(path, "lool/convert-to", "lool/convert-to/")) { return StringUtils.appendIfMissing(connectionUrl, "/"); } else if (StringUtils.endsWithAny(path, "lool", "lool/")) { return StringUtils.appendIfMissing(connectionUrl, "/") + "convert-to/"; }/* w ww .ja v a2 s. c om*/ return StringUtils.appendIfMissing(connectionUrl, "/") + "lool/convert-to/"; }