Examples of ConditionalOutputStream


Examples of org.apache.clerezza.tools.offline.utils.ConditionalOutputStream

  private static final byte[] input = "<img href=\"/thumbnail-service?uri=http://localhost:8080/html_export/digital-assets/2010/08/30/770a7f14-74a7-4036-8341-f9e50e944e06&amp;width=700&height=300&exact=true\" />".getBytes();
 
  @Test
  public void thumbnailConditionTest() throws IOException {
    ByteArrayOutputStream bous = new ByteArrayOutputStream();
    OutputStream out = new ConditionalOutputStream(bous,
        new ThumbnailCondition(new ThumbnailService() {

      @Override
      public UriRef getThumbnailUri(UriRef infoBitUri, Integer width, Integer height, boolean exact) {
        Assert.assertEquals(uri, infoBitUri);
        Assert.assertEquals(Integer.valueOf(700), width);
        Assert.assertEquals(Integer.valueOf(300), height);
        Assert.assertEquals(true, exact);
        return new UriRef("http://example.com/test");
      }       
    }));
   
    out.write(input);
    Assert.assertEquals("<img href=\"http://example.com/test\" />", bous.toString());
  }
View Full Code Here

Examples of org.apache.clerezza.tools.offline.utils.ConditionalOutputStream

  }

  private byte[] applyThumbnailService(byte[] variant) {
    try {     
      final ByteArrayOutputStream resultWriter = new ByteArrayOutputStream(variant.length);
      OutputStream thumbnailCorrectingStream = new ConditionalOutputStream(resultWriter,
          new ThumbnailCondition(thumbnailService));
      thumbnailCorrectingStream.write(variant);
      thumbnailCorrectingStream.close();
      return resultWriter.toByteArray();
    } catch (IOException ex) {
      throw new RuntimeException(ex);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.