Example usage for org.springframework.core.io ClassPathResource ClassPathResource

List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource

Introduction

In this page you can find the example usage for org.springframework.core.io ClassPathResource ClassPathResource.

Prototype

public ClassPathResource(String path, @Nullable Class<?> clazz) 

Source Link

Document

Create a new ClassPathResource for Class usage.

Usage

From source file:com.springsource.greenhouse.database.GreenhouseTestDatabaseBuilder.java

public GreenhouseTestDatabaseBuilder invite() {
    populator.addScript(new ClassPathResource("install/Invite.sql", DatabaseUpgrader.class));
    return this;
}

From source file:gaderian.test.utilities.TestSpringObjectProvider.java

public void testSpringIntegration() throws Exception {
    // Spring setup

    ClassPathResource springBeansResource = new ClassPathResource("SpringBeans.xml",
            TestSpringLookupFactory.class);

    BeanFactory beanFactory = new XmlBeanFactory(springBeansResource);

    Registry r = buildFrameworkRegistry("SpringProvider.xml", false);

    SpringBeanFactoryHolder h = (SpringBeanFactoryHolder) r
            .getService("gaderian.utilities.DefaultSpringBeanFactoryHolder", SpringBeanFactoryHolder.class);

    h.setBeanFactory(beanFactory);//from   w  ww  .  j a  v  a 2 s.co  m

    SimpleService a = (SimpleService) r.getService("gaderian.test.utilities.Adder", SimpleService.class);

    assertEquals(17, a.add(9, 8));
}

From source file:org.obiba.onyx.engine.StageManagerTest.java

@Test
public void testAddStage() throws Exception {
    StageManagerImpl stageManager = new StageManagerImpl();
    ClassPathResource stageDescriptor = new ClassPathResource("testStages.xml", StageManagerTest.class);
    stageManager.setStageDescriptor(stageDescriptor);
    stageManager.afterPropertiesSet();//from  w w w .ja  v a 2s  .  c o  m

    Stage stage = new Stage();
    stage.setName("NewStage");
    stage.setModule("Module1");
    ModuleDependencyCondition dependencyCondition = new ModuleDependencyCondition();
    dependencyCondition.setModuleName("Module2");
    dependencyCondition.setModuleRegistry(new ModuleRegistry());
    stage.setStageDependencyCondition(dependencyCondition);
    stageManager.addStage(stageManager.getStages().size(), stage);

    Assert.assertEquals(7, stageManager.getStages().size());
    Assert.assertNotNull(stageManager.getStage("NewStage"));

}

From source file:org.imsglobal.basiclti.consumersecret.impl.PropertiesConsumerSecretServiceImplTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    propertiesConsumerSecretServiceImpl/* ww  w.ja v a 2 s. com*/
            .setLocation(new ClassPathResource("test_secrets.properties", getClass()));
}

From source file:me.philnate.textmanager.utils._WordCount.java

@Test
public void testMiddleDoc() throws FileNotFoundException, IOException {
    assertEquals(66, WordCount.countFile(new ClassPathResource("docs/middle.doc", loader).getFile()));
}

From source file:org.zalando.github.spring.UsersTemplateTest.java

@Test
public void getEmails() throws Exception {
    mockServer.expect(requestTo("https://api.github.com/user/emails")).andExpect(method(HttpMethod.GET))
            // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
            .andRespond(withSuccess(new ClassPathResource("listEmails.json", getClass()),
                    MediaType.APPLICATION_JSON));

    List<Email> emailList = usersTemplate.listEmails();

    Assertions.assertThat(emailList).isNotNull();
    Assertions.assertThat(emailList.size()).isEqualTo(1);
}

From source file:net.solarnetwork.node.dao.jdbc.test.DatabaseSetupTest.java

@Test
public void createDatabaseSetup() {
    DatabaseSetup setup = new DatabaseSetup();
    setup.setDataSource(dataSource);//  www  . j  a v  a  2  s.  c  om
    setup.setInitSqlResource(new ClassPathResource("derby-init.sql", DatabaseSetup.class));
    setup.init();

    JdbcOperations jdbcOps = new JdbcTemplate(dataSource);
    Map<String, ?> results = jdbcOps.queryForMap("SELECT * FROM solarnode.sn_settings WHERE skey = ?",
            "solarnode.sn_settings.version");
    log.debug("Got sn_settings.version record {}", results);
    assertNotNull(results);
    assertEquals("Should have key, value, type, flags, and modified values", 5, results.size());
    assertEquals("5", results.get("svalue"));
}

From source file:org.zalando.github.spring.UsersTemplatePublicKeyTest.java

@Test
public void getPublicKeys() throws Exception {
    mockServer.expect(requestTo("https://api.github.com/user/keys")).andExpect(method(HttpMethod.GET))
            // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
            .andRespond(withSuccess(new ClassPathResource("listPublicKeys.json", getClass()),
                    MediaType.APPLICATION_JSON));

    List<ExtPubKey> publicKeyList = usersTemplate.listPublicKeys();

    Assertions.assertThat(publicKeyList).isNotNull();
    Assertions.assertThat(publicKeyList.size()).isEqualTo(1);
    Assertions.assertThat(publicKeyList.get(0).getKey()).isEqualTo("ssh-rsa AAA...");
}

From source file:com.springsource.greenhouse.database.GreenhouseTestDatabaseBuilder.java

public GreenhouseTestDatabaseBuilder venue() {
    populator.addScript(new ClassPathResource("install/Venue.sql", DatabaseUpgrader.class));
    return this;
}

From source file:biz.c24.io.spring.integration.samples.transform.TransformTest.java

byte[] loadCsvBytes() throws Exception {

    ClassPathResource resource = new ClassPathResource("valid-1.txt", this.getClass());
    byte[] valid1 = FileCopyUtils.copyToByteArray(resource.getInputStream());

    return valid1;
}