Package org.springframework.core.io

Examples of org.springframework.core.io.UrlResource


     *
     * @param scriptURL the URL used to load the script
     * @return the builder
     */
    public static ScriptBuilder ruby(URL scriptURL) {
        return new ScriptBuilder("jruby", new UrlResource(scriptURL));
    }
View Full Code Here


    assertTrue(lbf.getBean("testBean") instanceof NestedTestBean);
  }

  public void testArrayPropertyWithAutowiring() throws MalformedURLException {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));
    bf.registerSingleton("resource2", new UrlResource("http://localhost:9090"));

    RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class, RootBeanDefinition.AUTOWIRE_BY_TYPE);
    bf.registerBeanDefinition("arrayBean", rbd);
    ArrayBean ab = (ArrayBean) bf.getBean("arrayBean");

    assertEquals(new UrlResource("http://localhost:8080"), ab.getResourceArray()[0]);
    assertEquals(new UrlResource("http://localhost:9090"), ab.getResourceArray()[1]);
  }
View Full Code Here

  public void testDoubleArrayConstructorWithAutowiring() throws MalformedURLException {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    bf.registerSingleton("integer1", new Integer(4));
    bf.registerSingleton("integer2", new Integer(5));
    bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));
    bf.registerSingleton("resource2", new UrlResource("http://localhost:9090"));

    RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
    bf.registerBeanDefinition("arrayBean", rbd);
    ArrayBean ab = (ArrayBean) bf.getBean("arrayBean");

    assertEquals(new Integer(4), ab.getIntegerArray()[0]);
    assertEquals(new Integer(5), ab.getIntegerArray()[1]);
    assertEquals(new UrlResource("http://localhost:8080"), ab.getResourceArray()[0]);
    assertEquals(new UrlResource("http://localhost:9090"), ab.getResourceArray()[1]);
  }
View Full Code Here

    assertEquals(new UrlResource("http://localhost:9090"), ab.getResourceArray()[1]);
  }

  public void testDoubleArrayConstructorWithOptionalAutowiring() throws MalformedURLException {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    bf.registerSingleton("resource1", new UrlResource("http://localhost:8080"));
    bf.registerSingleton("resource2", new UrlResource("http://localhost:9090"));

    RootBeanDefinition rbd = new RootBeanDefinition(ArrayBean.class, RootBeanDefinition.AUTOWIRE_CONSTRUCTOR);
    bf.registerBeanDefinition("arrayBean", rbd);
    ArrayBean ab = (ArrayBean) bf.getBean("arrayBean");
View Full Code Here

    xbf.getBean("resource2", ResourceTestBean.class);
  }

  public void testUrlResourceWithImport() {
    URL url = getClass().getResource("resource.xml");
    XmlBeanFactory xbf = new XmlBeanFactory(new UrlResource(url));
    // comes from "resourceImport.xml"
    xbf.getBean("resource1", ResourceTestBean.class);
    // comes from "resource.xml"
    xbf.getBean("resource2", ResourceTestBean.class);
  }
View Full Code Here

    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());

    ClassPathResource archive = new ClassPathResource("/org/springframework/orm/jpa/jpa-archive.jar");
    String newRoot = "jar:" + archive.getURL().toExternalForm() + "!/META-INF/persist.xml";
    Resource insideArchive = new UrlResource(newRoot);
    // make sure the location actually exists
    assertTrue(insideArchive.exists());
    URL url = reader.determinePersistenceUnitRootUrl(insideArchive);
    assertTrue("the archive location should have been returned", archive.getURL().sameFile(url));
  }
View Full Code Here

    factory.setBasePath("classpath:org/springframework/webflow/");
    assertEquals("the/path/on/the/file/system", factory.getFlowId(resource));
  }

  public void testGetFlowIdUrlResource() throws MalformedURLException {
    Resource resource = new UrlResource(
        "file:/the/path/on/the/file/system/org/springframework/webflow/sample/sample-flow.xml");
    factory.setBasePath("classpath:org/springframework/webflow/");
    assertEquals("sample", factory.getFlowId(resource));
  }
View Full Code Here

    factory.setBasePath("classpath:org/springframework/webflow/");
    assertEquals("sample", factory.getFlowId(resource));
  }

  public void testGetFlowIdUrlResourceNoBasePathMatch() throws MalformedURLException {
    Resource resource = new UrlResource("file:/the/path/on/the/file/system/sample-flow.xml");
    factory.setBasePath("classpath:org/springframework/webflow/");
    assertEquals("the/path/on/the/file/system", factory.getFlowId(resource));
  }
View Full Code Here

        GenericApplicationContext appContext = new GenericApplicationContext(busApplicationContext);
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
        List<URL> urls = ClassLoaderUtils.getResources("META-INF/cxf/java2wsbeans.xml",
                                                       SpringServiceBuilderFactory.class);
        for (URL url : urls) {
            reader.loadBeanDefinitions(new UrlResource(url));
        }
       
        for (String pathname : additionalFilePathnames) {
            try {
                reader.loadBeanDefinitions(new FileSystemResource(pathname));
View Full Code Here

    public void testReadDocumentNotExisting() throws MalformedURLException {
        ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
        URL url = ExternalAttachmentProviderTest.class.getResource("resources/attachments1.xml");
        String uri = url.toExternalForm();
        uri = uri.replaceAll("attachments1.xml", "attachments0.xml");
        eap.setLocation(new UrlResource(uri));
        try {
            eap.readDocument();
            fail("Expected PolicyException not thrown.");
        } catch (PolicyException ex) {
            assertTrue(ex.getCause() instanceof FileNotFoundException);
View Full Code Here

TOP

Related Classes of org.springframework.core.io.UrlResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.