Beispiel #1
0
 @Configuration
 public Option[] config() {
   return options(
       junitBundles(),
       systemProperty("org.ops4j.pax.url.mvn.localRepository")
           .value(System.getProperty("maven.repo.local")),
       mavenBundle("org.jruby", "jruby-complete", System.getProperty("jruby.version")),
       mavenBundle("org.jruby.osgi", "gems-bundle", "1.0"),
       mavenBundle("org.jruby.osgi", "scripts-bundle", "1.0"));
 }
 @Test
 public void basicSanityFromResourceReader() throws Exception {
   InputStream is = UnicodeBomInputStreamTest.class.getResourceAsStream("bom.js");
   UnicodeBomInputStream is2 = new UnicodeBomInputStream(is);
   is2.skipBOM();
   InputStreamReader isr = new InputStreamReader(is2, Charset.forName("UTF-8"));
   String s = Util.readerToString(isr);
   String nl = System.getProperty("line.separator");
   assertThat(s, is("// This file starts with a UTF-8 BOM." + nl + "alert(\"Hello BOM\");" + nl));
 }
  @Test
  public void testZipFileWrite() throws Exception {

    String outputFileName = null;

    try {
      // Get somewhere temporary to write out to
      outputFileName = File.createTempFile("ItemWriterTest-", ".csv.zip").getAbsolutePath();

      // Configure the ItemWriter
      C24ItemWriter itemWriter = new C24ItemWriter();
      itemWriter.setSink(new TextualSink());
      itemWriter.setWriterSource(new ZipFileWriterSource());
      itemWriter.setup(getStepExecution(outputFileName));
      // Write the employees out
      itemWriter.write(employees);
      // Close the file
      itemWriter.cleanup();

      // Check that we wrote out what was expected
      ZipFile zipFile = new ZipFile(outputFileName);
      Enumeration<? extends ZipEntry> entries = zipFile.entries();
      assertNotNull(entries);
      // Make sure there's at least one entry
      assertTrue(entries.hasMoreElements());
      ZipEntry entry = entries.nextElement();
      // Make sure that the trailing .zip has been removed and the leading path has been removed
      assertFalse(entry.getName().contains(System.getProperty("file.separator")));
      assertFalse(entry.getName().endsWith(".zip"));
      // Make sure that there aren't any other entries
      assertFalse(entries.hasMoreElements());

      try {
        compareCsv(zipFile.getInputStream(entry), employees);
      } finally {
        if (zipFile != null) {
          zipFile.close();
        }
      }

    } finally {
      if (outputFileName != null) {
        // Clear up our temporary file
        File file = new File(outputFileName);
        file.delete();
      }
    }
  }
 public static Matcher<String> text(String text) {
   return new MultiLineStringMatcher(text, System.getProperty("line.separator"));
 }
 @Test
 public void joinで文字列が連結される() throws Exception {
   String ls = System.getProperty("line.separator");
   String expected = "Hello" + ls + "World" + ls;
   assertThat(MultiLineString.join("Hello", "World"), is(text(expected)));
 }