use of org.springframework.core.io.ClassPathResource in project spring-boot by spring-projects.
the class ResourceProperties method getFaviconLocations.
public List<Resource> getFaviconLocations() {
List<Resource> locations = new ArrayList<>(this.staticLocations.length + 1);
if (this.resourceLoader != null) {
for (String location : this.staticLocations) {
locations.add(this.resourceLoader.getResource(location));
}
}
locations.add(new ClassPathResource("/"));
return Collections.unmodifiableList(locations);
}
use of org.springframework.core.io.ClassPathResource in project spring-framework by spring-projects.
the class YamlPropertiesFactoryBeanTests method testLoadNonExistentResource.
@Test
public void testLoadNonExistentResource() throws Exception {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResolutionMethod(ResolutionMethod.OVERRIDE_AND_IGNORE);
factory.setResources(new ClassPathResource("no-such-file.yml"));
Properties properties = factory.getObject();
assertThat(properties.size(), equalTo(0));
}
use of org.springframework.core.io.ClassPathResource in project spring-framework by spring-projects.
the class JeeNamespaceHandlerTests method setUp.
@Before
public void setUp() throws Exception {
GenericApplicationContext ctx = new GenericApplicationContext();
new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(new ClassPathResource("jeeNamespaceHandlerTests.xml", getClass()));
ctx.refresh();
this.beanFactory = ctx.getBeanFactory();
this.beanFactory.getBeanNamesForType(ITestBean.class);
}
use of org.springframework.core.io.ClassPathResource in project cas by apereo.
the class AbstractX509LdapTests method populateCertificateRevocationListAttribute.
/**
* Populate certificate revocation list attribute.
* Dynamically set the attribute value to the crl content.
* Encode it as base64 first. Doing this in the code rather
* than in the ldif file to ensure the attribute can be populated
* without dependencies on the classpath and or filesystem.
* @throws Exception the exception
*/
private static void populateCertificateRevocationListAttribute() throws Exception {
final Collection<LdapEntry> col = getDirectory().getLdapEntries();
for (final LdapEntry ldapEntry : col) {
if (ldapEntry.getDn().equals(DN)) {
final LdapAttribute attr = new LdapAttribute(true);
byte[] value = new byte[1024];
IOUtils.read(new ClassPathResource("userCA-valid.crl").getInputStream(), value);
value = EncodingUtils.encodeBase64ToByteArray(value);
attr.setName("certificateRevocationList");
attr.addBinaryValue(value);
LdapTestUtils.modifyLdapEntry(getDirectory().getConnection(), ldapEntry, attr);
}
}
}
use of org.springframework.core.io.ClassPathResource in project cas by apereo.
the class X509CredentialFactoryTests method createX509Credential.
@Test
public void createX509Credential() throws IOException {
final MultiValueMap<String, String> requestBody = new LinkedMultiValueMap<>();
final Scanner scan = new Scanner(new ClassPathResource("ldap-crl.crt").getFile());
final String certStr = scan.useDelimiter("\\Z").next();
scan.close();
requestBody.add("cert", certStr);
final Credential cred = factory.fromRequestBody(requestBody);
assertTrue(cred instanceof X509CertificateCredential);
}
Aggregations