List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:com.app.test.BaseTestCase.java
protected static void setUpDatabase() throws Exception { String databasePassword = System.getProperty("jdbc.default.password"); String databaseURL = System.getProperty("jdbc.default.url"); String databaseUsername = System.getProperty("jdbc.default.username"); DatabaseUtil.setDatabaseProperties(databaseURL, databaseUsername, databasePassword); Resource resource = new ClassPathResource(_TEST_DATABASE_PATH); ScriptUtils.executeSqlScript(DatabaseUtil.getDatabaseConnection(), resource); }
From source file:com.graphaware.importer.integration.BatchImporterIntegrationTest.java
@Test public void testImport() throws IOException, InterruptedException { TemporaryFolder temporaryFolder = new TemporaryFolder(); temporaryFolder.create();// www . j a va 2 s .c o m String tmpFolder = temporaryFolder.getRoot().getAbsolutePath(); String cp = new ClassPathResource("people.csv").getFile().getAbsolutePath(); String path = cp.substring(0, cp.length() - "people.csv".length()); try { TestBatchImporter.main(new String[] { "-g", tmpFolder + "/graph.db", "-i", path, "-o", tmpFolder, "-r", "neo4j.properties" }); } catch (Throwable t) { fail(); } GraphDatabaseService database = new GraphDatabaseFactory().newEmbeddedDatabase(tmpFolder + "/graph.db"); GraphUnit.assertSameGraph(database, "CREATE " + "(p1:Person {id: 1, name: 'Michal Bachman', role: 'MD at GraphAware', age:30})," + "(p2:Person {id: 2, name: 'Adam George', role: 'Consultant at GraphAware', age:29})," + "(l1:Location {id: 1, name: 'London'})," + "(l2:Location {id: 2, name: 'Watnall'})," + "(l3:Location {id: 3, name: 'Prague'})," + "(c1:Company {name: 'K+N'})," + "(c2:Company {name: 'GraphAware'})," + "(p1)-[:LIVES_IN]->(l1)," + "(p2)-[:LIVES_IN]->(l2)," + "(p1)-[:FRIEND_OF {since:1281654000000}]->(p2)," + "(p1)-[:WORKS_FOR {role: 'Developer'}]->(c1)," + "(p1)-[:WORKS_FOR {role: 'MD'}]->(c2)," + "(p2)-[:WORKS_FOR {role: 'Developer'}]->(c1)," + "(p2)-[:WORKS_FOR {role: 'Consultant'}]->(c2)"); database.shutdown(); temporaryFolder.delete(); }
From source file:de.otto.jsonhome.controller.DocControllerTest.java
@Test public void shouldReturnMarkdownAsHtml() throws IOException { // given//w w w .java 2s. c o m final DocController controller = new DocController(); controller.setRootDir(new ClassPathResource("/test/**")); // when final String markdown = controller .getMarkdownAsHtml(new MockHttpServletRequest("GET", "/test/doc/test.md")); // then assertTrue(markdown.startsWith("<h1>Test</h1>")); }
From source file:com.github.javarch.persistence.orm.test.DataBaseTestBuilder.java
public DataBaseTestBuilder<T> populeData(String script) { resourcesSql.add(new ClassPathResource(script)); return this; }
From source file:org.ligoj.app.plugin.prov.aws.in.CsvForBeanEc2Test.java
@Test public void readNoOs() throws IOException { final BufferedReader reader = new BufferedReader(new InputStreamReader( new ClassPathResource("mock-server/aws/index-small-no-os.csv").getInputStream())); Assertions.assertNull(new CsvForBeanEc2(reader).read()); }
From source file:org.devgateway.toolkit.persistence.spring.CacheConfiguration.java
@Bean public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() { EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean(); ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml")); ehCacheManagerFactoryBean.setShared(true); return ehCacheManagerFactoryBean; }
From source file:org.wso2.carbon.metrics.reporter.JDBCReporterTest.java
@BeforeClass public static void setupDatasource() throws Exception { dataSource = JdbcConnectionPool.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", ""); template = new JdbcTemplate(dataSource); ResourceDatabasePopulator populator = new ResourceDatabasePopulator(); populator.addScript(new ClassPathResource("dbscripts/h2.sql")); populator.populate(dataSource.getConnection()); }
From source file:nl.surfnet.coin.api.client.OpenConextJsonParserTest.java
@Test public void testParseGroup20() throws Exception { final Group20Entry group20Entry = parser .parseGroups20(new ClassPathResource("multiple-groups20.json").getInputStream()); assertEquals(3, group20Entry.getEntry().size()); }
From source file:com.compomics.colims.core.io.colims_to_utilities.ColimsSpectrumMapperTest.java
/** * Test of map method, of class ColimsSpectrumMapper. * @throws java.lang.Exception in case of an exception *//*from ww w .j a va2 s . c o m*/ @Test public void testMap() throws Exception { Spectrum spectrum = new Spectrum(); File inputSpectra = new ClassPathResource("data/input_spectra_Z.mgf.gz").getFile(); byte[] data = Files.readAllBytes(inputSpectra.toPath()); SpectrumFile spectrumFile = new SpectrumFile(); spectrumFile.setContent(data); List<SpectrumFile> spectrumFileList = new ArrayList<>(); spectrumFileList.add(spectrumFile); spectrum.setAccession("fake spectrum 1"); spectrum.setFragmentationType(FragmentationType.CID); spectrum.setIntensity(1233123.32); spectrum.setRetentionTime(2123.1); spectrum.setMzRatio(123.12); spectrum.setCharge(3); spectrum.setSpectrumFiles(spectrumFileList); spectrum.setScanNumber(12L); spectrum.setScanTime(11231.1); spectrum.setPeptides(new ArrayList<>()); MSnSpectrum targetSpectrum = new MSnSpectrum(); colimsSpectrumMapper.map(spectrum, targetSpectrum); Assert.assertEquals(677, targetSpectrum.getPeakList().size()); Assert.assertEquals("12", targetSpectrum.getScanNumber()); Assert.assertEquals(1233123.32, targetSpectrum.getPrecursor().getIntensity(), 0.01); Assert.assertEquals(123.12, targetSpectrum.getPrecursor().getMz(), 0.01); Assert.assertEquals(new Charge(1, 3), targetSpectrum.getPrecursor().getPossibleCharges().get(0)); }
From source file:it.geosolutions.geoserver.decoder.MetadataDecoderTest.java
@Test public void testMetadataDimensionInfo() throws IOException { File coverageFile = new ClassPathResource("testdata/coverageExample.xml").getFile(); String coverageString = FileUtils.readFileToString(coverageFile); RESTCoverage coverage = RESTCoverage.build(coverageString); List<RESTDimensionInfo> list = coverage.getDimensionInfo(); Assert.assertEquals(list.size(), 2); for (RESTDimensionInfo el : list) { if (el.getKey().equals("time")) { Assert.assertEquals(el.getResolution(), null); Assert.assertEquals(el.getPresentation(), "LIST"); Assert.assertEquals(el.getKey(), "time"); Assert.assertEquals(el.isEnabled(), true); }//from w ww . j a v a2 s . co m if (el.getKey().equals("elevation")) { Assert.assertEquals(el.getResolution(), "2"); Assert.assertEquals(el.getPresentation(), "DISCRETE_INTERVAL"); Assert.assertEquals(el.getKey(), "elevation"); Assert.assertEquals(el.isEnabled(), true); } } }