Search in sources :

Example 41 with ClassPathResource

use of org.springframework.core.io.ClassPathResource in project spring-security-oauth by spring-projects.

the class JwtAccessTokenConverterTests method rsaKeyPair.

@Test
public void rsaKeyPair() throws Exception {
    KeyStoreKeyFactory factory = new KeyStoreKeyFactory(new ClassPathResource("keystore.jks"), "foobar".toCharArray());
    KeyPair keys = factory.getKeyPair("test");
    tokenEnhancer.setKeyPair(keys);
    tokenEnhancer.afterPropertiesSet();
    assertTrue(tokenEnhancer.getKey().get("value").contains("BEGIN PUBLIC"));
}
Also used : KeyPair(java.security.KeyPair) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test)

Example 42 with ClassPathResource

use of org.springframework.core.io.ClassPathResource in project spring-security-oauth by spring-projects.

the class AbstractIntegrationTests method init.

@Before
public void init() {
    String prefix = server.getServletPrefix();
    http.setPort(port);
    http.setPrefix(prefix);
    if (new ClassPathResource("sample.jks").exists()) {
        http.setProtocol("https");
    }
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) Before(org.junit.Before)

Example 43 with ClassPathResource

use of org.springframework.core.io.ClassPathResource in project camel by apache.

the class ResourceConverterTest method testNonNullConversion.

public void testNonNullConversion() throws IOException {
    Resource resource = new ClassPathResource("testresource.txt", ResourceConverterTest.class);
    Assert.assertTrue(resource.exists());
    InputStream inputStream = getResourceTypeConverter().convertTo(InputStream.class, resource);
    byte[] resourceBytes = IOConverter.toBytes(resource.getInputStream());
    byte[] inputStreamBytes = IOConverter.toBytes(inputStream);
    Assert.assertArrayEquals(resourceBytes, inputStreamBytes);
}
Also used : InputStream(java.io.InputStream) ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 44 with ClassPathResource

use of org.springframework.core.io.ClassPathResource in project spring-boot by spring-projects.

the class OriginTrackedYamlLoaderTests method processWithActiveProfile.

@Test
public void processWithActiveProfile() throws Exception {
    Resource resource = new ClassPathResource("test-yaml.yml", getClass());
    this.loader = new OriginTrackedYamlLoader(resource, "development");
    Map<String, Object> result = this.loader.load();
    assertThat(result.get("name").toString()).isEqualTo("Test Name");
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test)

Example 45 with ClassPathResource

use of org.springframework.core.io.ClassPathResource in project spring-boot by spring-projects.

the class TextResourcePropertyOriginTests method toStringWhenLocationIsNullShouldReturnNiceString.

@Test
public void toStringWhenLocationIsNullShouldReturnNiceString() throws Exception {
    ClassPathResource resource = new ClassPathResource("foo.txt");
    TextResourcePropertyOrigin origin = new TextResourcePropertyOrigin(resource, null);
    assertThat(origin.toString()).isEqualTo("class path resource [foo.txt]");
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test)

Aggregations

ClassPathResource (org.springframework.core.io.ClassPathResource)1441 Test (org.junit.jupiter.api.Test)558 Resource (org.springframework.core.io.Resource)314 Test (org.junit.Test)274 lombok.val (lombok.val)159 List (java.util.List)137 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)129 IOException (java.io.IOException)118 InputStream (java.io.InputStream)105 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)104 File (java.io.File)91 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)87 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)78 ArrayList (java.util.ArrayList)77 Bean (org.springframework.context.annotation.Bean)61 FileSystemResource (org.springframework.core.io.FileSystemResource)61 ObjectBundleValidationReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport)60 Path (java.nio.file.Path)51 Map (java.util.Map)47 BeforeEach (org.junit.jupiter.api.BeforeEach)45