List of usage examples for java.lang ClassLoader getSystemResource
public static URL getSystemResource(String name)
From source file:org.apache.hadoop.gateway.topology.xml.TopologyRulesModuleTest.java
@Test public void testParseSimpleTopologyXmlInKnoxFormat() throws IOException, SAXException, URISyntaxException { Digester digester = loader.newDigester(); String name = "org/apache/hadoop/gateway/topology/xml/simple-topology-knox-format.xml"; URL url = ClassLoader.getSystemResource(name); assertThat("Failed to find URL for resource " + name, url, notNullValue()); File file = new File(url.getFile()); TopologyBuilder topologyBuilder = digester.parse(url); Topology topology = topologyBuilder.build(); assertThat("Failed to parse resource " + name, topology, notNullValue()); topology.setTimestamp(file.lastModified()); assertThat(topology.getName(), is("topology")); assertThat(topology.getTimestamp(), is(file.lastModified())); assertThat(topology.getServices().size(), is(1)); Service comp = topology.getServices().iterator().next(); assertThat(comp, notNullValue());// w w w . j av a 2 s. co m assertThat(comp.getRole(), is("WEBHDFS")); assertThat(comp.getUrl(), is("http://host:80/webhdfs")); Provider provider = topology.getProviders().iterator().next(); assertThat(provider, notNullValue()); assertThat(provider.isEnabled(), is(true)); assertThat(provider.getRole(), is("authentication")); assertThat(provider.getParams().size(), is(5)); }
From source file:org.n52.sir.IT.solr.OpenSearchTemporalExtensionIT.java
@Before public void insertSensor() throws OwsExceptionReport, XmlException, IOException { File sensor_status = new File(ClassLoader.getSystemResource("Requests/testsensor.xml").getFile()); SensorMLDocument doc = SensorMLDocument.Factory.parse(sensor_status); SOLRInsertSensorInfoDAO dao = new SOLRInsertSensorInfoDAO(); dao.insertSensor(SensorMLDecoder.decode(doc)); }
From source file:com.zenika.dorm.importer.test.MavenRepositoryGenerator.java
public void generate() { File repository = null;/*from w ww . java2s . com*/ try { URL urlSample = ClassLoader.getSystemResource(SAMPLE_JAR_PATH); repository = new File(repositoryPath); File sample = new File(urlSample.toURI()); generateRepository(repository, sample); } catch (URISyntaxException e) { throw new CoreException("Unable to build Uri with this path: " + repository, e); } }
From source file:org.openengsb.openengsbplugin.LicenseCheckTest.java
@Test public void writeHeaderTest() throws Exception { File generatedFile = null;// w w w. java 2 s.c o m try { File f = new File(ClassLoader.getSystemResource("license/header.txt").toURI()); String headerStr = FileUtils.readFileToString(f); generatedFile = Tools.generateTmpFile(headerStr, ".txt"); assertEquals(headerStr, FileUtils.readFileToString(generatedFile)); } finally { FileUtils.deleteQuietly(generatedFile); } }
From source file:org.apache.james.sieverepository.lib.SieveRepositoryManagementTest.java
@Test public void importSieveScriptFileToRepositoryShouldStoreContentAndActivateScript() throws Exception { String userName = "user@domain"; String script = "user_script"; URL sieveResource = ClassLoader.getSystemResource("sieve/my_sieve"); User user = User.fromUsername(userName); ScriptName scriptName = new ScriptName(script); String sieveContent = IOUtils.toString(sieveResource, StandardCharsets.UTF_8); ScriptContent scriptContent = new ScriptContent(sieveContent); sieveRepositoryManagement.addActiveSieveScriptFromFile(userName, script, sieveResource.getFile()); verify(sieveRepository, times(1)).putScript(user, scriptName, scriptContent); verify(sieveRepository, times(1)).setActive(user, scriptName); }
From source file:vista.ArchToxHome.java
@Override public Image getIconImage() { Image retValue = Toolkit.getDefaultToolkit() .getImage(ClassLoader.getSystemResource("imagenes/archtox.png")); return retValue; }
From source file:org.apache.hadoop.gateway.identityasserter.function.UsernameFunctionProcessorTest.java
private static URL getTestResource(String name) { name = UsernameFunctionProcessorTest.class.getName().replaceAll("\\.", "/") + "/" + name; URL url = ClassLoader.getSystemResource(name); return url;/*from w w w . j av a 2s. co m*/ }
From source file:org.apache.james.jmap.json.ParsingWritingObjectsTest.java
@Test public void parsingJsonShouldWorkOnSubMessage() throws Exception { SubMessage expected = SUB_MESSAGE;//from w w w .java 2s . co m SubMessage subMessage = testee.forParsing().readValue( IOUtils.toString(ClassLoader.getSystemResource("json/subMessage.json")), SubMessage.class); assertThat(subMessage).isEqualToComparingFieldByField(expected); }
From source file:org.jboss.pressgang.ccms.contentspec.client.commands.TemplateCommandTest.java
@Before public void setUp() { bindStdOut();//from ww w . ja va2 s . co m command = new TemplateCommand(parser, cspConfig, clientConfig); // Return the test directory as the root directory rootTestDirectory = FileUtils.toFile(ClassLoader.getSystemResource("")); }