use of org.springframework.core.io.UrlResource in project cxf by apache.
the class ExternalAttachmentProviderTest method testReadDocumentAttachmentElementWithoutAppliesTo.
@Test
public void testReadDocumentAttachmentElementWithoutAppliesTo() throws MalformedURLException {
ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments2.xml");
String uri = url.toExternalForm();
eap.setLocation(new UrlResource(uri));
eap.readDocument();
assertTrue(eap.getAttachments().isEmpty());
}
use of org.springframework.core.io.UrlResource in project opennms by OpenNMS.
the class ProvisionServiceIT method dwLoadRequisition.
/**
* This test should be set to Ignore until a DNS server can be integrated into unit tests
*
* @throws MalformedURLException
*/
@Test
@Ignore
public void dwLoadRequisition() throws MalformedURLException {
String nodeLabel = "localhost";
int nhash = nodeLabel.hashCode();
int chash = "localhost".hashCode();
Assert.assertEquals(nhash, chash);
Resource resource = new UrlResource("dns://localhost/localhost");
Requisition r = m_provService.loadRequisition(resource);
Assert.assertNotNull(r);
Assert.assertEquals(1, r.getNodeCount());
String foreignId = String.valueOf("localhost".hashCode());
RequisitionNode node = r.getNode(foreignId);
Assert.assertNotNull(node);
RequisitionInterface inf = node.getInterface("127.0.0.1");
Assert.assertNotNull(inf);
}
use of org.springframework.core.io.UrlResource in project opennms by OpenNMS.
the class DnsRequisitionUrlConnectionIT method dwoUrlAsResourceUsingMatchingExpression.
@Test
@JUnitDNSServer(port = 9153, zones = { @DNSZone(name = "example.com", entries = { @DNSEntry(hostname = "www", data = "72.14.204.99"), @DNSEntry(hostname = "monkey", data = "72.14.204.99") }) })
public void dwoUrlAsResourceUsingMatchingExpression() throws IOException, JAXBException {
String urlString = "dns://localhost:9153/example.com/?expression=[Ww]ww.*";
Resource resource = new UrlResource(urlString);
Assert.assertEquals(urlString, resource.getURL().toString());
Requisition req = null;
Assert.assertNotNull(resource);
InputStream resourceStream = resource.getInputStream();
JAXBContext context = JAXBContext.newInstance(Requisition.class);
Unmarshaller um = context.createUnmarshaller();
um.setSchema(null);
req = (Requisition) um.unmarshal(resourceStream);
Assert.assertEquals(1, req.getNodeCount());
resourceStream.close();
}
use of org.springframework.core.io.UrlResource in project opennms by OpenNMS.
the class DnsRequisitionUrlConnectionIT method dwoUrlAsResourceUsingComplexMatchingExpression.
@Test
@JUnitDNSServer(port = 9153, zones = { @DNSZone(name = "example.com", entries = { @DNSEntry(hostname = "www", data = "72.14.204.99") }) })
public void dwoUrlAsResourceUsingComplexMatchingExpression() throws IOException, JAXBException {
String urlString = "dns://localhost:9153/example.com/?expression=(%3Fi)^WWW.EXAM.*";
Resource resource = new UrlResource(urlString);
Assert.assertEquals(urlString, resource.getURL().toString());
Requisition req = null;
Assert.assertNotNull(resource);
InputStream resourceStream = resource.getInputStream();
JAXBContext context = JAXBContext.newInstance(Requisition.class);
Unmarshaller um = context.createUnmarshaller();
um.setSchema(null);
req = (Requisition) um.unmarshal(resourceStream);
Assert.assertEquals(1, req.getNodeCount());
resourceStream.close();
}
use of org.springframework.core.io.UrlResource in project jetty.project by eclipse.
the class SpringConfigurationProcessor method init.
@Override
public void init(URL url, XmlParser.Node config, XmlConfiguration configuration) {
try {
_configuration = configuration;
Resource resource = url != null ? new UrlResource(url) : new ByteArrayResource(("" + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\" \"http://www.springframework.org/dtd/spring-beans.dtd\">" + config).getBytes(StandardCharsets.UTF_8));
_beanFactory = new DefaultListableBeanFactory() {
@Override
protected void applyPropertyValues(String beanName, BeanDefinition mbd, BeanWrapper bw, PropertyValues pvs) {
_configuration.initializeDefaults(bw.getWrappedInstance());
super.applyPropertyValues(beanName, mbd, bw, pvs);
}
};
new XmlBeanDefinitionReader(_beanFactory).loadBeanDefinitions(resource);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations