Package org.springframework.beans

Examples of org.springframework.beans.ResourceTestBean


  }

  public void testResourceAndInputStream() throws IOException {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("resource.xml", getClass()));
    // comes from "resourceImport.xml"
    ResourceTestBean resource1 = (ResourceTestBean) xbf.getBean("resource1");
    // comes from "resource.xml"
    ResourceTestBean resource2 = (ResourceTestBean) xbf.getBean("resource2");

    assertTrue(resource1.getResource() instanceof ClassPathResource);
    StringWriter writer = new StringWriter();
    FileCopyUtils.copy(new InputStreamReader(resource1.getResource().getInputStream()), writer);
    assertEquals("test", writer.toString());
    writer = new StringWriter();
    FileCopyUtils.copy(new InputStreamReader(resource1.getInputStream()), writer);
    assertEquals("test", writer.toString());
    writer = new StringWriter();
    FileCopyUtils.copy(new InputStreamReader(resource2.getResource().getInputStream()), writer);
    assertEquals("test", writer.toString());
    writer = new StringWriter();
    FileCopyUtils.copy(new InputStreamReader(resource2.getInputStream()), writer);
    assertEquals("test", writer.toString());
  }
View Full Code Here


          return new ClassPathResource("test.properties", ClassPathXmlApplicationContextTests.class);
        }
        return super.getResource(location);
      }
    };
    ResourceTestBean resource1 = (ResourceTestBean) ctx.getBean("resource1");
    ResourceTestBean resource2 = (ResourceTestBean) ctx.getBean("resource2");
    assertTrue(resource1.getResource() instanceof ClassPathResource);
    StringWriter writer = new StringWriter();
    FileCopyUtils.copy(new InputStreamReader(resource1.getResource().getInputStream()), writer);
    assertEquals("contexttest", writer.toString());
    writer = new StringWriter();
    FileCopyUtils.copy(new InputStreamReader(resource1.getInputStream()), writer);
    assertEquals("contexttest", writer.toString());
    writer = new StringWriter();
    FileCopyUtils.copy(new InputStreamReader(resource2.getResource().getInputStream()), writer);
    assertEquals("contexttest", writer.toString());
    writer = new StringWriter();
    FileCopyUtils.copy(new InputStreamReader(resource2.getInputStream()), writer);
    assertEquals("contexttest", writer.toString());
    ctx.close();
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.ResourceTestBean

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.