List of usage examples for java.net URL toURI
public URI toURI() throws URISyntaxException
From source file:au.org.ala.delta.dist.DISTTest.java
private File urlToFile(String urlString) throws Exception { URL url = DISTTest.class.getResource(urlString); File file = new File(url.toURI()); return file;/*from ww w.j ava2 s .c o m*/ }
From source file:eu.matejkormuth.crawler2.PageFetcher.java
private URI toUri(URL url) { try {/*from w w w . ja v a2s . co m*/ return url.toURI(); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
From source file:gov.nih.nci.cacis.ip.mirthconnect.CanonicalModelProcessorClientMCIntegrationTest.java
@Test public void invokeStr() throws Exception, IOException { final URL url = getClass().getClassLoader().getResource(SOAP_MSG_FILENAME); String sampleMessage = FileUtils.readFileToString(new File(url.toURI())); client.acceptCanonical(serviceUrl, sampleMessage); }
From source file:com.gargoylesoftware.htmlunit.libraries.LibraryTestCase.java
/** * Loads an expectation file for the given test in the library folder. * TODO: use browser version specific variations too * @param testName the base name for the file * @return the content of the file/*from ww w . j ava 2s . c o m*/ * @throws Exception in case of error */ protected String loadExpectation(final String testName) throws Exception { // TODO: check first if a file specific to current browserVersion exists first with version number then without final String resource = getLibraryDir() + "/" + testName + ".expected.txt"; final URL url = getClass().getClassLoader().getResource(resource); assertNotNull(url); final File file = new File(url.toURI()); return FileUtils.readFileToString(file, "UTF-8"); }
From source file:gumga.framework.application.template.GumgaFreemarkerTemplateEngineTest.java
@Before public void startup() throws Exception { URL resourceUrl = getClass().getResource("/templates"); Path resourcePath = Paths.get(resourceUrl.toURI()); gumgaFreemarkerTemplateEngineService = new GumgaFreemarkerTemplateEngineService(resourcePath.toString(), "UTF-8"); gumgaFreemarkerTemplateEngineService.init(); assertNotNull(gumgaFreemarkerTemplateEngineService); gumgaFreemarkerTemplateEngineService.init(); createOutputFolder(OUTPUT_FOLDER);/* www . ja va2 s .c o m*/ }
From source file:gov.nih.nci.cacis.ip.mirthconnect.XDSNavChannelMCIntegrationTest.java
@Test public void invokeXDSNavChannel() throws Exception { final URL url = getClass().getClassLoader().getResource("CMP_sample_soap.xml"); String messageXml = FileUtils.readFileToString(new File(url.toURI())); final Node res = invoke(CanonicalModelProcessorMCIntegrationTest.ADDRESS, SoapTransportFactory.TRANSPORT_ID, messageXml.getBytes());//from w w w .j ava 2 s . co m assertNotNull(res); addNamespace("ns2", "http://cacis.nci.nih.gov"); assertValid("//ns2:caCISResponse[@status='SUCCESS']", res); }
From source file:horriblev3.Cloudflare.java
private URI UrlToUri(URL url) { try {/*w w w . jav a 2 s . c o m*/ return url.toURI(); } catch (URISyntaxException e) { return null; } }
From source file:org.duniter.core.client.service.bma.BaseRemoteServiceImpl.java
public URIBuilder getURIBuilder(URL baseUrl, String... path) { try {//from www.ja v a 2 s .c o m return httpService.getURIBuilder(baseUrl.toURI(), path); } catch (URISyntaxException e) { throw new TechnicalException(e); } }
From source file:com.jaspersoft.android.jaspermobile.test.support.TestResource.java
public File asFile() { URL path = getClass().getClassLoader().getResource(fileName); try {/*ww w . j ava 2s.c o m*/ return new File(path.toURI()); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
From source file:com.mulesoft.example.fileconsumer.FileConsumerTestCase.java
@Test public void fileConsumer() throws Exception { MuleClient client = muleContext.getClient(); String sourceFileName = "sourceTestFile.csv"; URL url = IOUtils.getResourceAsUrl(sourceFileName, getClass()); FileUtils.copyFile(new File(url.toURI()), new File(properties.getProperty("FileConsumer.sourceFolder") + "/" + sourceFileName)); FileInputStream file = new FileInputStream(new File(url.toURI())); DataInputStream is = new DataInputStream(file); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line;//from w ww . ja va2 s . co m try { while ((line = br.readLine()) != null) { MuleMessage result = client.request("vm://" + properties.getProperty("FileConsumer.stockDataTopic"), RECEIVE_TIMEOUT); assertNotNull(result); assertFalse(result.getPayload() instanceof NullPayload); String[] split = line.split(","); String payload = result.getPayloadAsString(); for (String item : split) { assertTrue(payload.contains(item)); } } } finally { is.close(); } }