Search in sources :

Example 11 with ClassPathResource

use of org.springframework.core.io.ClassPathResource in project opennms by OpenNMS.

the class ResourceDaoIntegrityIT method createResourceTree.

private void createResourceTree() throws IOException {
    String fileAsString = IOUtils.toString(new ClassPathResource("resource-tree-files.txt").getInputStream());
    String[] resourceTreeFiles = fileAsString.split("\\r?\\n");
    // This should match the number of lines in the file
    assertEquals(31829, resourceTreeFiles.length);
    for (String resourceTreeFile : resourceTreeFiles) {
        // Create the file and its parent directories in the temporary folder
        File entry = new File(m_tempFolder.getRoot(), resourceTreeFile);
        entry.getParentFile().mkdirs();
        assertTrue("Failed to create " + entry, entry.createNewFile());
    }
}
Also used : File(java.io.File) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 12 with ClassPathResource

use of org.springframework.core.io.ClassPathResource in project opennms by OpenNMS.

the class CachingForeignSourceRepositoryTest method createRequisition.

private Requisition createRequisition() throws Exception {
    Requisition r = m_foreignSourceRepository.importResourceRequisition(new ClassPathResource("/requisition-test.xml"));
    m_foreignSourceRepository.save(r);
    m_foreignSourceRepository.flush();
    return r;
}
Also used : Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 13 with ClassPathResource

use of org.springframework.core.io.ClassPathResource in project opennms by OpenNMS.

the class DefaultParameterConversionServiceTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    Resource resource = new ClassPathResource("/opennms-reports-testdata.xml");
    m_dao = new DefaultOnmsReportConfigDao();
    m_dao.setConfigResource(resource);
    m_dao.afterPropertiesSet();
    m_conversionService = new DefaultParameterConversionService();
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) DefaultOnmsReportConfigDao(org.opennms.netmgt.dao.jaxb.DefaultOnmsReportConfigDao) ClassPathResource(org.springframework.core.io.ClassPathResource) BeforeClass(org.junit.BeforeClass)

Example 14 with ClassPathResource

use of org.springframework.core.io.ClassPathResource in project opennms by OpenNMS.

the class QueueingForeignSourceRepositoryTest method createRequisition.

private Requisition createRequisition() throws Exception {
    Requisition r = m_foreignSourceRepository.importResourceRequisition(new ClassPathResource("/requisition-test.xml"));
    m_foreignSourceRepository.save(r);
    m_foreignSourceRepository.flush();
    return r;
}
Also used : Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 15 with ClassPathResource

use of org.springframework.core.io.ClassPathResource in project opennms by OpenNMS.

the class MockSnmpStrategyTest method setUp.

@Before
public void setUp() throws Exception {
    m_strategy = new MockSnmpStrategy();
    MockSnmpStrategy.setDataForAddress(new SnmpAgentAddress(m_agentAddress, m_agentPort), new ClassPathResource("loadSnmpDataTest.properties"));
    m_oldProperty = System.getProperty("org.opennms.snmp.strategyClass");
    System.setProperty("org.opennms.snmp.strategyClass", m_strategy.getClass().getName());
}
Also used : SnmpAgentAddress(org.opennms.netmgt.snmp.SnmpAgentAddress) ClassPathResource(org.springframework.core.io.ClassPathResource) Before(org.junit.Before)

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