Package org.springframework.core.io

Examples of org.springframework.core.io.ByteArrayResource


    @Test
    public void testLoadWithJobThatIsNotAStepLocatorNoStepRegistry() throws DuplicateJobException {
        final JobLoader loader = new DefaultJobLoader(jobRegistry);
        GenericApplicationContextFactory factory = new GenericApplicationContextFactory(
                new ByteArrayResource(BASIC_JOB_XML.getBytes()));
        try {
            loader.load(factory);
        } catch (UnsupportedOperationException e) {
            fail("Should not have failed with a [" + UnsupportedOperationException.class.getName() + "] as " +
                    "stepRegistry is not available for this JobLoader instance.");
View Full Code Here


  private final static String FOOS = "<foos> <foo value=\"1\"/> <foo value=\"2\"/> <foo value=\"3\"/> <foo value=\"4\"/> <foo value=\"5\"/> </foos>";

    @Override
  protected ItemReader<Foo> getItemReader() throws Exception {
    StaxEventItemReader<Foo> reader = new StaxEventItemReader<Foo>();
    reader.setResource(new ByteArrayResource(FOOS.getBytes()));
    reader.setFragmentRootElementName("foo");
    reader.setUnmarshaller(new Unmarshaller() {
            @Override
      public Object unmarshal(Source source) throws XmlMappingException, IOException {
        Attribute attr = null ;
View Full Code Here

    @Override
  protected void pointToEmptyInput(ItemReader<Foo> tested) throws Exception {
    StaxEventItemReader<Foo> reader = (StaxEventItemReader<Foo>) tested;
    reader.close();
   
    reader.setResource(new ByteArrayResource("<foos />".getBytes()));
    reader.afterPropertiesSet();
   
    reader.open(new ExecutionContext());
  }
View Full Code Here

  private ResourcesItemReader reader = new ResourcesItemReader();

  @Before
  public void init() {
    reader.setResources(new Resource[] { new ByteArrayResource("foo".getBytes()),
        new ByteArrayResource("bar".getBytes()) });
  }
View Full Code Here

   * Resources are ordered according to injected comparator.
   */
  @Test
  public void testResourceOrderingWithCustomComparator() {

    Resource r1 = new ByteArrayResource("".getBytes(), "b");
    Resource r2 = new ByteArrayResource("".getBytes(), "a");
    Resource r3 = new ByteArrayResource("".getBytes(), "c");

    Resource[] resources = new Resource[] { r1, r2, r3 };

    Comparator<Resource> comp = new Comparator<Resource>() {

View Full Code Here

        HTable htable = new HTable(conf, systemTable);
        Result r = htable.get(new Get(HBL_MODEL_KEY).addColumn(HBL_SYSTEM_FAMILY, Bytes.toBytes(modelName)));
        byte[] rbytes;
        if (r == null || (rbytes = r.getValue(HBL_SYSTEM_FAMILY, Bytes.toBytes(modelName))) == null)
            throw new IOException(String.format("Model '%s' was not found in the system table.", modelName));
        return new ByteArrayResource(rbytes);
    }
View Full Code Here

    });
    fileReader.setSaveState(true);

    multiReader.setDelegate(fileReader);

    Resource r1 = new ByteArrayResource("1\n2\n".getBytes());
    Resource r2 = new ByteArrayResource("".getBytes());
    Resource r3 = new ByteArrayResource("3\n".getBytes());
    Resource r4 = new ByteArrayResource("4\n5\n".getBytes());

    multiReader.setResources(new Resource[] { r1, r2, r3, r4 });
    multiReader.setSaveState(true);
    multiReader.setComparator(new Comparator<Resource>() {
            @Override
View Full Code Here

    @Override
  protected void pointToEmptyInput(ItemReader<Foo> tested) throws Exception {
    MultiResourceItemReader<Foo> multiReader = (MultiResourceItemReader<Foo>) tested;
    multiReader.close();
    multiReader.setResources(new Resource[] { new ByteArrayResource(""
        .getBytes()) });
    multiReader.open(new ExecutionContext());
  }
View Full Code Here

    assertEquals("testLine5testLine6", item3.getValue());
    assertEquals(3, item3.getItemCount());
  }

  private Resource getInputResource(String input) {
    return new ByteArrayResource(input.getBytes());
  }
View Full Code Here

  private static final String FOOS = "1 \n 2 \n 3 \n 4 \n 5 \n";
 
  @Override
  protected ItemReader<Foo> getItemReader() throws Exception {
    FlatFileItemReader<Foo> tested = new FlatFileItemReader<Foo>();
    Resource resource = new ByteArrayResource(FOOS.getBytes());
    tested.setResource(resource);
    tested.setLineMapper(new LineMapper<Foo>() {
            @Override
      public Foo mapLine(String line, int lineNumber) {
        Foo foo = new Foo();
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.