Package org.springframework.core.io

Examples of org.springframework.core.io.ByteArrayResource


        engine.setContext((ScriptContext) EasyMock.anyObject());
        EasyMock.expect(engine.eval((Reader) EasyMock.anyObject())).andThrow(new ScriptException("test exception"));
        EasyMock.replay(engine);

        scriptedView.setEngineName("test-engine");
        scriptedView.setScript(new ByteArrayResource("test".getBytes(), "test script"));

        try {
            scriptedView.createControl();
            fail("must throw ScriptExecutionException");
        }
View Full Code Here


            }
            else
            {
                try
                {
                    configResources[i] = new ByteArrayResource(IOUtils.toByteArray(resource.getInputStream()), resource.getResourceName());
                }
                catch (IOException e)
                {
                    throw new RuntimeException(e);
                }
View Full Code Here

  @Override
  protected Resource readInternal(Class<? extends Resource> clazz, HttpInputMessage inputMessage)
      throws IOException, HttpMessageNotReadableException {

    byte[] body = FileCopyUtils.copyToByteArray(inputMessage.getBody());
    return new ByteArrayResource(body);
  }
View Full Code Here

    assertTrue("ResourceScriptSource must report back as being modified if the underlying File resource is reporting a changed lastModified time.", scriptSource.isModified());
    mock.verify();
  }

  public void testLastModifiedWorksWithResourceThatDoesNotSupportFileBasedAccessAtAll() throws Exception {
    Resource resource = new ByteArrayResource(new byte[0]);
    ResourceScriptSource scriptSource = new ResourceScriptSource(resource);
    assertTrue("ResourceScriptSource must start off in the 'isModified' state (it obviously isn't).", scriptSource.isModified());
    scriptSource.getScriptAsString();
    assertFalse("ResourceScriptSource must not report back as being modified if the underlying File resource is not reporting a changed lastModified time.", scriptSource.isModified());
    // Must now continue to report back as not having been modified 'cos the Resource does not support access as a File (and so the lastModified date cannot be determined).
View Full Code Here

    VelocityEngineFactoryBean vefb = new VelocityEngineFactoryBean();
    vefb.setResourceLoaderPath("file:/mydir");
    vefb.setResourceLoader(new ResourceLoader() {
      public Resource getResource(String location) {
        if (location.equals("file:/mydir") || location.equals("file:/mydir/test")) {
          return new ByteArrayResource("test".getBytes(), "test");
        }
        try {
          return new UrlResource(location);
        }
        catch (MalformedURLException ex) {
View Full Code Here

    vc.setResourceLoader(new ResourceLoader() {
      public Resource getResource(String location) {
        if ("file:/yourdir/test".equals(location)) {
          return new DescriptiveResource("");
        }
        return new ByteArrayResource("test".getBytes(), "test");
      }
      public ClassLoader getClassLoader() {
        return getClass().getClassLoader();
      }
    });
View Full Code Here

    fcfb.setResourceLoader(new ResourceLoader() {
      public Resource getResource(String location) {
        if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) {
          throw new IllegalArgumentException(location);
        }
        return new ByteArrayResource("test".getBytes(), "test");
      }
      public ClassLoader getClassLoader() {
        return getClass().getClassLoader();
      }
    });
View Full Code Here

            + "\">"
            + config
            + "</server>";

        XmlBeanFactory factory = new XmlBeanFactory(
                new ByteArrayResource(completeConfig.getBytes()));
       
        return (FtpServer) factory.getBean("server");

    }
View Full Code Here

        return new FileSystemResource(file);
    }

    @Converter
    public static ByteArrayResource toResource(byte[] data) throws IOException {
        return new ByteArrayResource(data);
    }
View Full Code Here

    /**
     * @see org.springframework.web.context.support.XmlWebApplicationContext#loadBeanDefinitions(org.springframework.beans.factory.xml.XmlBeanDefinitionReader)
     */
    protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws BeansException, IOException {
        if ( this.beanDefinition != null ) {
            reader.loadBeanDefinitions(new ByteArrayResource(this.beanDefinition.getBytes("utf-8")));
        }
        super.loadBeanDefinitions(reader);
    }
View Full Code Here

TOP

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

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.