List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:org.ngrinder.perftest.controller.PerfTestControllerWithRepoTest.java
/** * Locate dumped user1 repo into tempdir. * /*from w ww. ja v a 2 s .c o m*/ * @throws IOException */ @Before public void before() throws IOException { File file = new File(System.getProperty("java.io.tmpdir"), "repo"); FileUtils.deleteQuietly(file); CompressionUtils.unzip(new ClassPathResource("TEST_USER.zip").getFile(), file); repo.setUserRepository(new File(file, getTestUser().getUserId())); }
From source file:org.jbpm.instance.migration.HibernateTestSupport.java
public void setUp() { if (factory == null) { factory = new XmlBeanFactory( new ClassPathResource("/org/jbpm/instance/migration/mock-hibernate-spring.xml")); }/*w ww .j a v a 2 s . c om*/ setUpTransactionManager(); }
From source file:net.gplatform.spring.social.base.JdbcUsersConnectionRepositoryTableCreator.java
public void createTableIfNotExist() { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); try {//from w w w.ja v a 2 s . c o m jdbcTemplate.queryForList("select count(*) from UserConnection"); } catch (Exception e) { LOG.debug("Create table UserConnection"); try { ResourceDatabasePopulator rdp = new ResourceDatabasePopulator(); rdp.addScript(new ClassPathResource( "/org/springframework/social/connect/jdbc/JdbcUsersConnectionRepository.sql")); DatabasePopulatorUtils.execute(rdp, dataSource); } catch (Exception e1) { LOG.error("Error create table UserConnection", e1); } } }
From source file:org.impotch.calcul.impot.cantonal.ge.pp.avant2010.BaremeRevenuSeul2000Test.java
@Parameterized.Parameters public static Collection<Object[]> data() throws IOException { ChargeurFichierEconometre chargeur = new ChargeurFichierEconometre(); chargeur.setFichier(new ClassPathResource("ge/BASEIMP.CSV")); List<Object[]> objets = Arrays.asList(chargeur.charger(2000, false)); // Il y a un arrondi distinct sur la 3me dcimal ! objets.get(1633)[1] = new BigDecimal("299984.611"); // la place de 299984.612 return objets; }
From source file:cz.muni.fi.pv168.project.hotelmanager.RoomManagerImplTest.java
@Before public void setUp() throws SQLException { BasicDataSource bds = new BasicDataSource(); //set JDBC driver and URL bds.setDriverClassName(EmbeddedDriver.class.getName()); bds.setUrl("jdbc:derby:memory:TestRoomManagerDB;create=true"); //populate db with tables and data new ResourceDatabasePopulator(new ClassPathResource("schema-javadb.sql")).execute(bds); this.dataSource = bds; manager = new RoomManagerImpl(bds); }
From source file:de.ingrid.iplug.opensearch.converter.IngridRSSConverterTest.java
public final void testProcessResult() { try {/*from w w w . j a v a2 s. co m*/ Resource resource = new ClassPathResource(XML_INPUT_FILE); IngridHits hits = ingridConverter.processResult("bla", resource.getInputStream(), null); assertTrue(hits.getHits().length > 0); } catch (Exception e) { e.printStackTrace(); fail("Test failed."); } }
From source file:dragonrental.backend.DbConfig.java
public DataSource dataSource() { Properties conf = new Properties(); BasicDataSource ds = new BasicDataSource(); try {/* w w w .j av a 2 s .com*/ conf.load(DbConfig.class.getResourceAsStream("/Properties.properties")); } catch (IOException ex) { //log.error("Loading properties has failed!"); } ds.setUrl(conf.getProperty("db.url")); ds.setDriverClassName(conf.getProperty("db.driver")); ds.setUsername(conf.getProperty("db.user")); ds.setPassword(conf.getProperty("db.password")); DatabaseMetaData metaData; ResultSet tables; try (Connection connection = ds.getConnection()) { metaData = connection.getMetaData(); tables = metaData.getTables(null, null, "%", new String[] { "TABLE" }); //checks wheter there is any tables (will not create new tables if it finds ANY table) if (!tables.next()) { new ResourceDatabasePopulator(new ClassPathResource("schema-javadb.sql"), new ClassPathResource("test-data.sql")).execute(ds); } } catch (SQLException ex) { System.out.println("SQL Ex when checking for tables"); System.out.println(ex.getMessage()); } return ds; }