@Test
  public void testStreamBasedImportResource() throws IOException {
    final String data = "INSERT Language;isocode;active\n;test;true";

    final ImpExResource res =
        new StreamBasedImpExResource(
            new ByteArrayInputStream(data.getBytes()), CSVConstants.HYBRIS_ENCODING);
    final ImpExMediaModel media = res.getMedia();
    assertNotNull(media);
    assertArrayEquals(data.getBytes(), mediaService.getDataFromMedia(media));
  }
  @Test
  public void testFileBasedImportResource() throws IOException {
    final String data = "INSERT Language;isocode;active\n;test;true";
    final File testFile = File.createTempFile("test", "test");
    final PrintWriter writer = new PrintWriter(testFile);
    writer.write(data);
    writer.close();

    final ImpExResource res = new FileBasedImpExResource(testFile, "windows-1252");
    final ImpExMediaModel media = res.getMedia();
    assertNotNull(media);
    assertArrayEquals(data.getBytes(), mediaService.getDataFromMedia(media));
    assertEquals("windows-1252", media.getEncoding().getCode().toLowerCase());
  }
  @Test
  public void testMediaBasedImportResource() throws IOException {
    final String data = "INSERT Language;isocode;active\n;test;true";
    final ImpExMediaModel newMedia = modelService.create(ImpExMediaModel._TYPECODE);
    try {
      modelService.initDefaults(newMedia);
    } catch (final ModelInitializationException e) {
      throw new SystemException(e);
    }
    modelService.save(newMedia);
    mediaService.setDataForMedia(newMedia, data.getBytes());

    final ImpExResource res = new MediaBasedImpExResource(newMedia);
    final ImpExMediaModel media = res.getMedia();
    assertNotNull(media);
    assertArrayEquals(data.getBytes(), mediaService.getDataFromMedia(media));
  }