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) 

Source Link

Document

Create a new ClassPathResource for ClassLoader usage.

Usage

From source file:com.mulesoft.example.fileconsumer.FileConsumerTestCase.java

@Override
protected void doSetUp() throws Exception {
    super.doSetUp();
    properties = new Properties();
    ClassPathResource location = new ClassPathResource("fileConsumer.properties");
    properties.load(location.getInputStream());
    location = new ClassPathResource("topicNames.properties");
    properties.load(location.getInputStream());
}

From source file:com.mtt.myapp.common.util.FileDownloadUtilsTest.java

@Test
public void testDownloadFileHttpServletResponseString() throws IOException {
    File downFile = new ClassPathResource("TEST_USER.zip").getFile();
    String filePath = downFile.getAbsolutePath();
    MockHttpServletResponse resp = new MockHttpServletResponse();
    FileDownloadUtil.downloadFile(resp, filePath);
    String lengthHeader = resp.getHeader("Content-Length");

    assertThat(lengthHeader).isEqualTo(String.valueOf(downFile.length()));
}

From source file:com.wavemaker.commons.util.utils.ClassLoaderUtilsTest.java

@Test
public void tempClassLoader_getClassTest() throws Exception {

    File sourceJar = new ClassPathResource("com/wavemaker/commons/foojar.jar").getFile();
    File jar = File.createTempFile("tempClassLoader_getClassTest", ".jar");
    jar.deleteOnExit();/*from   ww w .jav  a  2 s . c o m*/
    FileUtils.copyFile(sourceJar, jar);

    try {
        ClassLoader cl = ClassLoaderUtils.getTempClassLoaderForFile(jar);
        Class<?> klass = ClassLoaderUtils.loadClass("foo.bar.baz.JarType", cl);
        assertNotNull(klass);
    } finally {
        jar.delete();
    }
}

From source file:de.otto.jsonhome.controller.DocControllerTest.java

@Test
public void shouldReturnMarkdown() throws IOException {
    // given//  w w  w . ja v  a2s .co  m
    final DocController controller = new DocController();
    controller.setRootDir(new ClassPathResource("/test/**"));
    // when
    final String markdown = controller.getMarkdown(new MockHttpServletRequest("GET", "/test/doc/test.md"));
    // then
    assertTrue(markdown.startsWith("Test"));
}

From source file:com.consol.citrus.admin.service.report.JUnitTestReportServiceTest.java

@Test
public void testReport() throws Exception {
    Project project = new Project(new ClassPathResource("projects/maven").getFile().getCanonicalPath());

    Assert.assertTrue(service.hasTestResults(project));

    TestReport report = service.getLatest(project);
    Assert.assertEquals(report.getSuiteName(), "Sample test suite");
    Assert.assertEquals(report.getDuration(), 9000L);
    Assert.assertEquals(report.getTotal(), 16L);
    Assert.assertEquals(report.getPassed(), 10L);
    Assert.assertEquals(report.getFailed(), 5L);
    Assert.assertEquals(report.getSkipped(), 1L);
}

From source file:com.consol.citrus.samples.javaee.employee.jms.EmployeeJmsTest.java

@Deployment
public static WebArchive createDeployment() throws IOException {
    return Deployments.employeeJmsRegistry()
            .addAsResource(new ClassPathResource("wsdl/SmsGateway.wsdl").getFile(),
                    new BasicPath("/wsdl/SmsGateway.wsdl"))
            .addAsLibraries(// ww  w . ja va2s . c  om
                    CitrusArchiveBuilder.latestVersion().core().javaDsl().http().mail().ws().jms().build());
}

From source file:com.consol.citrus.admin.service.report.TestNGTestReportServiceTest.java

@Test
public void testReport() throws Exception {
    Project project = new Project(new ClassPathResource("projects/maven").getFile().getCanonicalPath());

    Assert.assertTrue(service.hasTestResults(project));

    TestReport report = service.getLatest(project);
    Assert.assertEquals(report.getSuiteName(), "Sample test suite");
    Assert.assertEquals(report.getDuration(), 9000L);
    Assert.assertEquals(report.getExecutionDate().getTime(), 1451602800000L);
    Assert.assertEquals(report.getTotal(), 16L);
    Assert.assertEquals(report.getPassed(), 10L);
    Assert.assertEquals(report.getFailed(), 5L);
    Assert.assertEquals(report.getSkipped(), 1L);
}

From source file:com.graphaware.neo4j.webexpo.util.FileScannerTest.java

@Test
public void verifyCorrectNumberOfScannedLines() throws IOException {
    assertEquals(4, FileScanner.produceLines(new ClassPathResource("scanner-test.csv").getFile(), 0).size());
}

From source file:org.ngrinder.common.util.FileDownloadUtilTest.java

@Test
public void testDownloadFileHttpServletResponseString() throws IOException {
    File downFile = new ClassPathResource("TEST_USER.zip").getFile();
    String filePath = downFile.getAbsolutePath();
    MockHttpServletResponse resp = new MockHttpServletResponse();
    FileDownloadUtil.downloadFile(resp, filePath);
    String lengthHeader = resp.getHeader("Content-Length");

    assertThat(lengthHeader, is(String.valueOf(downFile.length())));
}

From source file:org.ngrinder.common.util.FileDownloadUtilsTest.java

@Test
public void testDownloadFileHttpServletResponseString() throws IOException {
    File downFile = new ClassPathResource("TEST_USER.zip").getFile();
    String filePath = downFile.getAbsolutePath();
    MockHttpServletResponse resp = new MockHttpServletResponse();
    FileDownloadUtils.downloadFile(resp, filePath);
    String lengthHeader = resp.getHeader("Content-Length");

    assertThat(lengthHeader, is(String.valueOf(downFile.length())));
}