List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:io.spring.initializr.generator.CustomProjectGeneratorTests.java
@Test public void generateCustomResource() { ProjectRequest request = createProjectRequest(); request.setType("maven-project"); request.setGroupId("com.example.custom"); ProjectAssert project = generateProject(request); project.sourceCodeAssert("custom.txt").equalsTo(new ClassPathResource("project/custom/custom.txt")); }
From source file:org.megam.deccanplato.provider.crm.test.MaluubaAdapterTest.java
@Test public void maluubaTest() { GenericApplicationContext ctx = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx); xmlReader.loadBeanDefinitions(new ClassPathResource("applicationContext.xml")); ctx.refresh();/*from w w w .j a v a2 s . c o m*/ ProviderRegistry registry = (ProviderRegistry) ctx.getBean("registry"); List<String> busiMethod = new ArrayList<String>(); busiMethod.add("normalize"); //busiMethod.add("interpret"); List<String> busiActivity = new ArrayList<String>(); busiActivity.add("norm"); for (String function : busiMethod) { for (String activity : busiActivity) { CommonTest ctest = new CommonTest(); RequestData reqData; reqData = ctest.commonTest(function, activity, MALUUBA); testAdapterAccess(reqData); ctest.testBusinessImpl(); } } }
From source file:py.una.pol.karaku.test.configuration.BaseTestConfiguration.java
@Bean public static TestPropertiesUtil propertiesUtil() { properties = new TestPropertiesUtil(); properties.setLocation(new ClassPathResource(CONFIG_LOCATION)); return properties; }
From source file:org.megam.deccanplato.provider.crm.test.XeroAdapterTest.java
@Test public void xeroTest() { GenericApplicationContext ctx = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx); xmlReader.loadBeanDefinitions(new ClassPathResource("applicationContext.xml")); ctx.refresh();//ww w . j a v a 2 s . co m ProviderRegistry registry = (ProviderRegistry) ctx.getBean("registry"); List<String> oauth = new ArrayList<String>(); //oauth.add("invoice"); //oauth.add("account"); //oauth.add("payment"); //oauth.add("contact"); //oauth.add("item"); //oauth.add("user"); //oauth.add("receipt"); oauth.add("employee"); List<String> oauthList = new ArrayList<String>(); //oauthList.add("list"); //oauthList.add("view"); //oauthList.add("create"); oauthList.add("update"); for (String activity : oauth) { for (String function : oauthList) { CommonTest ctest = new CommonTest(); RequestData reqData; reqData = ctest.commonTest(activity, function, XERO); if (function.equalsIgnoreCase("list") && activity.equalsIgnoreCase("invoice")) { testAdapterAccess(reqData); } ctest.testBusinessImpl(); } } }
From source file:com.ankang.report.config.ReportConfig.java
public static void loadReportConfig(String classPath) { if ((null == classPath || REPORT.equals(classPath)) && !isLoad) { classPath = REPORT;/* w ww . j a v a 2 s . c om*/ isLoad = Boolean.TRUE; } logger.info("load properties " + classPath); ClassPathResource cp = new ClassPathResource(classPath); try { if (cp.exists()) { ps.load(cp.getInputStream()); convertMap((Map) ps); ps.clear(); } } catch (IOException e) { throw new ReportException("File read exception file.[%s]", classPath); } }
From source file:org.flywaydb.core.internal.util.plus.MysqlToH2ConverterTests.java
/** * Read file in class path/*from w ww.j a v a 2s . c o m*/ * * @param path path * @param joiner joiner * @return string in file */ private String readFileInClassPath(String path, String joiner) { try { return Files.lines(Paths.get(new ClassPathResource(path).getURI()), StandardCharsets.UTF_8) .collect(Collectors.joining(joiner)); } catch (IOException e) { throw new IllegalStateException("Failed to read file", e); } }
From source file:nl.flotsam.hamcrest.schema.relaxng.RelaxNGMatchersTest.java
@Test public void shouldDetectErrors() { Resource schema = new ClassPathResource("/sample.rng"); Resource document = new ClassPathResource("/invalid-sample.xml"); assertThat(document, not(RelaxNGMatchers.isValidatedBy(schema))); }
From source file:com.wavemaker.commons.io.ClassPathFileTest.java
@Test public void shouldLoadUsingExactPath() throws Exception { ClassPathResource resource = new ClassPathResource("/com/wavemaker/runtime/core/io/a.txt"); System.out.println(resource.getInputStream()); File file = new ClassPathFile("/com/wavemaker/runtime/core/io/a.txt"); assertThat(file.getContent().asString(), Matchers.is("a")); }
From source file:org.cloudfoundry.tools.io.ClassPathFileTest.java
@Test public void shouldLoadUsingExactPath() throws Exception { ClassPathResource resource = new ClassPathResource("/org/cloudfoundry/tools/io/a.txt"); System.out.println(resource.getInputStream()); File file = new ClassPathFile("/org/cloudfoundry/tools/io/a.txt"); assertThat(file.getContent().asString(), is("a")); }
From source file:org.eclipse.gemini.blueprint.test.provisioning.internal.LocalFileSystemMavenRepositoryTest.java
public void testLocalSettingsFile() throws Exception { repository = new LocalFileSystemMavenRepository(); Resource res = new ClassPathResource( "/org/eclipse/gemini/blueprint/test/provisioning/internal/settings.xml"); String location = repository.getMavenSettingsLocalRepository(res); assertNotNull("location hasn't been picked up", location); assertEquals("wrong location discovered", location, "fake/location"); }