List of usage examples for org.springframework.core.io ClassPathResource ClassPathResource
public ClassPathResource(String path)
From source file:mbg.test.ib2j5.hierarchical.AbstractHierarchicalJava5Test.java
public void setUp() throws Exception { super.setUp(); factory = new GenericApplicationContext(); Resource res = new ClassPathResource("/mbg/test/ib2j5/hierarchical/SpringBeans.xml"); XmlBeanDefinitionReader r = new XmlBeanDefinitionReader(factory); r.loadBeanDefinitions(res);/*from w w w. j a v a 2 s.co m*/ }
From source file:com.wavemaker.common.util.ClassLoaderUtilsTest.java
public void testTempClassLoader_getResource() throws Exception { File sourceJar = new ClassPathResource("com/wavemaker/common/foojar.jar").getFile(); File jar = File.createTempFile("testTempClassLoader_getClass", ".jar"); jar.deleteOnExit();//from w ww. j a va 2 s. c o m FileUtils.copyFile(sourceJar, jar); try { ClassLoader cl = ClassLoaderUtils.getTempClassLoaderForFile(jar); InputStream is = ClassLoaderUtils.getResourceAsStream("foo/bar/baz/JarType.java", cl); assertNotNull(is); assertTrue(is.available() > 0); is.close(); } finally { jar.delete(); } }
From source file:org.kew.rmf.reconciliation.config.MvcConfig.java
static @Bean public PropertySourcesPlaceholderConfigurer myPropertySourcesPlaceholderConfigurer() { PropertySourcesPlaceholderConfigurer p = new PropertySourcesPlaceholderConfigurer(); Resource[] resourceLocations = new Resource[] { new ClassPathResource("/META-INF/spring/reconciliation-service.properties") }; p.setLocations(resourceLocations);// w w w . j a va 2 s. c o m return p; }
From source file:com.github.javarch.persistence.orm.test.DataBaseTestBuilder.java
public DataBaseTestBuilder<T> destroyData(String script) { destroySql.add(new ClassPathResource(script)); return this; }
From source file:org.cloudfoundry.identity.api.web.ApiControllerTests.java
@Test public void testWithUser() throws Exception { controller.setInfo(new ClassPathResource("info.tmpl")); HashMap<String, Object> model = new HashMap<String, Object>(); View view = controller.info(model, new UsernamePasswordAuthenticationToken("marissa", "<NONE>")); MockHttpServletResponse response = new MockHttpServletResponse(); view.render(model, new MockHttpServletRequest(), response); String content = response.getContentAsString(); assertTrue("Wrong content: " + content, content.contains("\n \"user\": \"marissa\"")); }
From source file:com.geoapi.api.server.services.implementations.WebViewService.java
@GET @Path("/doc/") public String doc() { ClassPathResource classPathResource = new ClassPathResource("com/geoapi/webview/doc.html"); try {/*from ww w. j av a 2s. c o m*/ File file = classPathResource.getFile(); return readFileAsString(file); } catch (IOException e) { e.printStackTrace(); } String homepage = readFileAsString(classPathResource.getPath()); return homepage; }
From source file:com.octo.captcha.engine.bufferedengine.QuartzBufferedEngineContainerTest.java
public void testMockFillingDisk() throws Exception { Resource ressource = new ClassPathResource("testFillDiskMockQuartzBufferedEngine.xml"); ConfigurableBeanFactory bf = new XmlBeanFactory(ressource); BufferedEngineContainer container = (BufferedEngineContainer) bf.getBean("container"); Object scheduler = bf.getBean("quartz"); Thread.sleep(100000);//w w w. j a v a 2 s .c om }
From source file:de.extra.client.starter.ClientArgumentsTest.java
@Test public void testClientArguments() throws Exception { final Resource globalConfigDir = new ClassPathResource("testglobalconfig"); final String globalConfigPath = globalConfigDir.getFile().getAbsolutePath(); final Resource configDir = new ClassPathResource("testconfig"); final String configPath = configDir.getFile().getAbsolutePath(); final Resource logDir = new ClassPathResource("testlog"); final String logPath = logDir.getFile().getAbsolutePath(); final String[] args = { "-m", MANDANT_NAME, "-g", globalConfigPath, "-c", configPath, "-l", logPath, "-oc", "xxx", "-of", "yyy" }; final ClientArgumentParser arguments = new ClientArgumentParser(args, EXITER); final ExtraClientParameters parameters = arguments.parseArgs(); assertEquals(MANDANT_NAME, parameters.getMandant()); assertEquals(globalConfigDir.getFile(), parameters.getGlobalConfigurationDirectory()); assertEquals(configDir.getFile(), parameters.getConfigurationDirectory()); assertEquals(logDir.getFile(), parameters.getLogDirectory()); assertEquals("xxx", parameters.getOutputConfirm()); assertEquals("yyy", parameters.getOutputFailure()); }
From source file:org.jasig.springframework.security.portlet.authentication.PortletXmlMappableAttributesRetrieverTest.java
@Test public void testTwoWithAttributes() throws Exception { final PortletXmlMappableAttributesRetriever portletXmlMappableAttributesRetriever = new PortletXmlMappableAttributesRetriever(); final ResourceLoader resourceLoader = mock(ResourceLoader.class); when(resourceLoader.getResource("/WEB-INF/portlet.xml")).thenReturn(new ClassPathResource( "/org/jasig/springframework/security/portlet/authentication/portlet_2_with_attributes.xml")); portletXmlMappableAttributesRetriever.setResourceLoader(resourceLoader); portletXmlMappableAttributesRetriever.afterPropertiesSet(); final Set<String> mappableAttributes = portletXmlMappableAttributesRetriever.getMappableAttributes(); final Set<String> expected = ImmutableSet.of("name1", "name2", "name3"); assertEquals(expected, mappableAttributes); }
From source file:org.eclipse.hono.service.auth.impl.StandaloneAuthServerTest.java
/** * Sets up the server.//from w w w. j a v a2s. co m * * @param ctx The vertx test context. */ @BeforeClass public static void prepareServer(final TestContext ctx) { AuthTokenHelper tokenHelper = AuthTokenHelperImpl.forSharedSecret(SIGNING_SECRET, 5); ServiceConfigProperties props = new ServiceConfigProperties(); props.setInsecurePortEnabled(true); props.setInsecurePort(0); server = new SimpleAuthenticationServer(); server.setConfig(props); server.setSaslAuthenticatorFactory(new HonoSaslAuthenticatorFactory(vertx, tokenHelper)); server.addEndpoint(new AuthenticationEndpoint(vertx)); AuthenticationServerConfigProperties serviceProps = new AuthenticationServerConfigProperties(); serviceProps.getSigning().setTokenExpiration(5); serviceProps.getSigning().setSharedSecret(SIGNING_SECRET); serviceProps.setPermissionsPath(new ClassPathResource("authentication-service-test-permissions.json")); FileBasedAuthenticationService authServiceImpl = new FileBasedAuthenticationService(); authServiceImpl.setConfig(serviceProps); authServiceImpl.setTokenFactory(tokenHelper); Async startup = ctx.async(); Future<String> serverTracker = Future.future(); serverTracker.setHandler(ctx.asyncAssertSuccess(s -> startup.complete())); Future<String> serviceTracker = Future.future(); vertx.deployVerticle(authServiceImpl, serviceTracker.completer()); serviceTracker.compose(s -> { vertx.deployVerticle(server, ctx.asyncAssertSuccess(d -> serverTracker.complete(d))); }, serverTracker); startup.await(2000); AuthenticationServerClientConfigProperties clientProps = new AuthenticationServerClientConfigProperties(); clientProps.setHost("127.0.0.1"); clientProps.setName("test-client"); clientProps.setPort(server.getInsecurePort()); clientProps.getValidation().setSharedSecret(SIGNING_SECRET); ConnectionFactory clientFactory = new ConnectionFactoryImpl(vertx, clientProps); client = new AuthenticationServerClient(vertx, clientFactory); }