Example usage for org.springframework.util ClassUtils addResourcePathToPackagePath

List of usage examples for org.springframework.util ClassUtils addResourcePathToPackagePath

Introduction

In this page you can find the example usage for org.springframework.util ClassUtils addResourcePathToPackagePath.

Prototype

public static String addResourcePathToPackagePath(Class<?> clazz, String resourceName) 

Source Link

Document

Return a path suitable for use with ClassLoader.getResource (also suitable for use with Class.getResource by prepending a slash ('/') to the return value).

Usage

From source file:ru.net.romikk.sandbox.DataSourceInitializer.java

/**
 * Main method as convenient entry point.
 * //from w  w w  .ja  v a2 s . c  om
 * @param args
 */
public static void main(String... args) {
    new ClassPathXmlApplicationContext(ClassUtils.addResourcePathToPackagePath(DataSourceInitializer.class,
            DataSourceInitializer.class.getSimpleName() + "-context.xml"));
}

From source file:jp.primecloud.auto.util.JSchUtilsTest.java

@Test
@Ignore/*  w w  w  .ja  v  a  2s.  c o m*/
public void testExecuteCommand2() throws Exception {
    // ????
    File privateKeyFile = new ClassPathResource(
            ClassUtils.addResourcePathToPackagePath(getClass(), "key01.pem")).getFile();
    String privateKey = FileUtils.readFileToString(privateKeyFile, "UTF-8");

    Session session = JSchUtils.createSessionByPrivateKey("user01", privateKey, "172.22.0.23");

    JSchResult result = JSchUtils.executeCommand(session, "env", "UTF-8");
    assertEquals(0, result.getExitStatus());

    result = JSchUtils.executeCommand(session, "ls -l /etc", "UTF-8");
    assertEquals(0, result.getExitStatus());

    session.disconnect();
}

From source file:jp.primecloud.auto.util.JSchUtilsTest.java

@Test
@Ignore/*from  w  ww .ja  v a  2 s . co  m*/
public void testExecuteCommand3() throws Exception {
    // ???
    File privateKeyFile = new ClassPathResource(
            ClassUtils.addResourcePathToPackagePath(getClass(), "key02.pem")).getFile();
    String privateKey = FileUtils.readFileToString(privateKeyFile, "UTF-8");

    Session session = JSchUtils.createSessionByPrivateKey("user01", privateKey, "passw0rd", "172.22.0.23");

    JSchResult result = JSchUtils.executeCommand(session, "env", "UTF-8");
    assertEquals(0, result.getExitStatus());

    result = JSchUtils.executeCommand(session, "ls -l /etc", "UTF-8");
    assertEquals(0, result.getExitStatus());

    session.disconnect();
}

From source file:org.springframework.batch.admin.BootstrapTests.java

@Test
public void testBootstrapConfiguration() throws Exception {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            new String[] { ClassUtils.addResourcePathToPackagePath(getClass(), "dummy-context.xml"),
                    "classpath:/META-INF/spring/batch/bootstrap/**/*.xml" });
    assertTrue(context.containsBean("jobRepository"));
    context.close();/*from  w  w  w.  j av a2 s .  co m*/
}

From source file:org.springframework.batch.test.DataSourceInitializer.java

/**
 * Main method as convenient entry point.
 * //  w w  w . j  a v  a2s  . co m
 * @param args
 */
@SuppressWarnings("resource")
public static void main(String... args) {
    new ClassPathXmlApplicationContext(ClassUtils.addResourcePathToPackagePath(DataSourceInitializer.class,
            DataSourceInitializer.class.getSimpleName() + "-context.xml"));
}

From source file:org.springframework.boot.logging.java.JavaLoggerSystemTests.java

@Test
public void testSystemPropertyInitializesFormat() throws Exception {
    System.setProperty("PID", "1234");
    this.loggingSystem.initialize(
            "classpath:" + ClassUtils.addResourcePathToPackagePath(getClass(), "logging.properties"));
    this.logger.info("Hello world");
    this.logger.info("Hello world");
    String output = this.output.toString().trim();
    assertTrue("Wrong output:\n" + output, output.contains("Hello world"));
    assertTrue("Wrong output:\n" + output, output.contains("1234 INFO ["));
}

From source file:org.springframework.boot.logging.java.JavaLoggingSystemTests.java

@Test
public void testSystemPropertyInitializesFormat() throws Exception {
    System.setProperty("PID", "1234");
    this.loggingSystem.beforeInitialize();
    this.loggingSystem.initialize(null,
            "classpath:" + ClassUtils.addResourcePathToPackagePath(getClass(), "logging.properties"), null);
    this.logger.info("Hello world");
    this.logger.info("Hello world");
    String output = this.output.toString().trim();
    assertTrue("Wrong output:\n" + output, output.contains("Hello world"));
    assertTrue("Wrong output:\n" + output, output.contains("1234 INFO ["));
}