Package org.springframework.core.io

Examples of org.springframework.core.io.InputStreamResource


    }
    assertEquals(1, count);
  }

  public void testWhitespace() throws Exception {
    Resource resource = new InputStreamResource(new ByteArrayInputStream(" foo ,bar,spam".getBytes()));
    ResourceFieldSetReader reader = new ResourceFieldSetReader(resource);
    FieldSet fieldSet = reader.read();
    assertNotNull(fieldSet);
    assertEquals("foo", fieldSet.readString(0));
  }
View Full Code Here


    assertNotNull(fieldSet);
    assertEquals("foo", fieldSet.readString(0));
  }

  public void testQuotes() throws Exception {
    Resource resource = new InputStreamResource(new ByteArrayInputStream("\" foo \",bar,\"spam\"".getBytes()));
    ResourceFieldSetReader reader = new ResourceFieldSetReader(resource);
    FieldSet fieldSet = reader.read();
    assertNotNull(fieldSet);
    // TODO: maybe this should be with the whitespace still?
    assertEquals("foo", fieldSet.readString(0));
View Full Code Here

    assertEquals("foo", fieldSet.readString(0));
    assertEquals("spam", fieldSet.readString(2));
  }

  public void testMultiLineField() throws Exception {
    Resource resource = new InputStreamResource(new ByteArrayInputStream("foo,bar,\"s\npam\"".getBytes()));
    ResourceFieldSetReader reader = new ResourceFieldSetReader(resource);
    FieldSet fieldSet = reader.read();
    assertNotNull(fieldSet);
    assertEquals("foo", fieldSet.readString(0));
    System.err.println(fieldSet);
View Full Code Here

/**
*/
public class ResourceLineReaderTests extends TestCase {

  public void testBadResource() throws Exception {
    ResourceLineReader reader = new ResourceLineReader(new InputStreamResource(new InputStream() {
      public int read() throws IOException {
        throw new IOException("Foo");
      }
    }));
    try {
View Full Code Here

      assertTrue(e.getMessage().startsWith("Unable to read"));
    }
  }

  public void testRead() throws Exception {
    Resource resource = new InputStreamResource(new ByteArrayInputStream("a,b,c\n1,2,3".getBytes()));
    ResourceLineReader reader = new ResourceLineReader(resource);
    int count = 0;
    String line;
    while ((line = (String) reader.read()) != null) {
      count++;
View Full Code Here

          }
        }));
  }

  public void testNoRecords() throws Exception {
    int count = batch.processResource(new InputStreamResource(new ByteArrayInputStream("".getBytes())));
    assertEquals(0, count);
    assertEquals(confirmations, 0);
  }
View Full Code Here

    assertEquals(0, count);
    assertEquals(confirmations, 0);
  }

  public void testSunnyDay() throws Exception {
    int count = batch.processResource(new InputStreamResource(new ByteArrayInputStream(
        ("100,1234123412341234,1234567890,2007/02/12\n" + "200,1234123412341234,1234567890,2007/02/26\n")
            .getBytes())));
    assertEquals(2, count);
    assertEquals(confirmations, 2);
  }
View Full Code Here

TOP

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

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.