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:org.jasig.cas.extension.clearpass.integration.uportal.PasswordCachingCasAssertionSecurityContextFactory.java

public PasswordCachingCasAssertionSecurityContextFactory() {
    final Resource resource = new ClassPathResource(DEFAULT_PORTAL_SECURITY_PROPERTY_FILE,
            getClass().getClassLoader());
    final Properties securityProperties = new Properties();
    InputStream inputStream = null;

    try {/*from ww  w . j a  v a  2s  .c om*/
        inputStream = resource.getInputStream();
        securityProperties.load(inputStream);
        this.clearPassUrl = securityProperties.getProperty(CLEARPASS_CAS_URL_PROPERTY);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (final IOException e) {
                //nothing to do
            }
        }
    }
}

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

@Test
public void createIssue() throws Exception {
    mockServer.expect(requestTo("https://api.github.com/repos/klaus/simple/issues"))
            .andExpect(method(HttpMethod.POST)).andExpect(content().contentType(MediaType.APPLICATION_JSON))
            // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
            .andRespond(withSuccess(new ClassPathResource("createIssue.json", getClass()),
                    MediaType.APPLICATION_JSON));

    Issue issue = issuesTemplate.createIssue(new IssueRequest("issueTitle"), "klaus", "simple");

    Assertions.assertThat(issue).isNotNull();
    Assertions.assertThat(issue.getId()).isEqualTo(1);
}

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

@Test
public void listTeams() throws Exception {
    mockServer.expect(requestTo("https://api.github.com/orgs/zalando-stups/teams?per_page=25"))
            .andExpect(method(HttpMethod.GET))
            // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
            .andRespond(withSuccess(new ClassPathResource("listTeams.json", getClass()),
                    MediaType.APPLICATION_JSON));

    List<Team> teamList = teamsTemplate.listTeams("zalando-stups");

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

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

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

From source file:org.projecthdata.social.api.impl.HDataTemplateTest.java

@Test
public void test() {
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.setContentType(MediaType.APPLICATION_XML);

    mockServer.expect(requestTo("http://hstore.com/1234/root.xml")).andExpect(method(GET)).andRespond(
            withResponse(new ClassPathResource("../../resources/root.xml", getClass()), responseHeaders));

    Root root = hDataTemplate.getRootOperations().getRoot();
    assertEquals(5, root.getExtensions().size());
}

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

@Test
public void listAllOrganizations() throws Exception {
    mockServer.expect(requestTo("https://api.github.com/organizations?per_page=100"))
            .andExpect(method(HttpMethod.GET))
            // .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
            .andRespond(withSuccess(new ClassPathResource("listOrgas.json", getClass()),
                    MediaType.APPLICATION_JSON));

    List<Organization> emailList = usersTemplate.listAllOranizations();

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