Package freenet.support.api

Examples of freenet.support.api.Bucket


    filterImage(input, DataFilterException.class);
  }

  /** Invalid compression type */
  public void testInvalidCompressionType() throws IOException {
    Bucket input = resourceToBucket("./bmp/seven.bmp");
    filterImage(input, DataFilterException.class);
  }
View Full Code Here


    filterImage(input, DataFilterException.class);
  }

  /** Invalid image data size (i.e. not satisfying fileSize = headerSize + imagedatasize) */
  public void testInvalidImageDataSize() throws IOException {
    Bucket input = resourceToBucket("./bmp/eight.bmp");
    filterImage(input, DataFilterException.class);
  }
View Full Code Here

    filterImage(input, DataFilterException.class);
  }

  /** Invalid image resolution */
  public void testInvalidImageResolution() throws IOException {
    Bucket input = resourceToBucket("./bmp/nine.bmp");
    filterImage(input, DataFilterException.class);
  }
View Full Code Here

    filterImage(input, DataFilterException.class);
  }

  /** File is shorter than expected */
  public void testNotEnoughImageData() throws IOException {
    Bucket input = resourceToBucket("./bmp/ten.bmp");
    filterImage(input, DataFilterException.class);
  }
View Full Code Here

    filterImage(input, DataFilterException.class);
  }

  /** Tests valid image */
  public void testValidImage() throws IOException {
    Bucket input = resourceToBucket("./bmp/ok.bmp");
    Bucket output = filterImage(input, null);

    //Filter should return the original
    assertEquals("Input and output should be the same length", input.size(), output.size());
    assertTrue("Input and output are not identical", Arrays.equals(BucketTools.toByteArray(input), BucketTools.toByteArray(output)));
  }
View Full Code Here

    assertTrue("Input and output are not identical", Arrays.equals(BucketTools.toByteArray(input), BucketTools.toByteArray(output)));
  }

  /** Checks that the image size calculation works for images with padding */
  public void testImageSizeCalculationWithPadding() throws IOException {
    Bucket input = resourceToBucket("./bmp/sizeCalculationWithPadding.bmp");
    Bucket output = filterImage(input, null);

    //Filter should return the original
    assertEquals("Input and output should be the same length", input.size(), output.size());
    assertTrue("Input and output are not identical", Arrays.equals(BucketTools.toByteArray(input), BucketTools.toByteArray(output)));
  }
View Full Code Here

    assertTrue("Input and output are not identical", Arrays.equals(BucketTools.toByteArray(input), BucketTools.toByteArray(output)));
  }

  /** Checks that the image size calculation works for images without padding */
  public void testImageSizeCalculationWithoutPadding() throws IOException {
    Bucket input = resourceToBucket("./bmp/sizeCalculationWithoutPadding.bmp");
    Bucket output = filterImage(input, null);

    //Filter should return the original
    assertEquals("Input and output should be the same length", input.size(), output.size());
    assertTrue("Input and output are not identical", Arrays.equals(BucketTools.toByteArray(input), BucketTools.toByteArray(output)));
  }
View Full Code Here

    assertTrue("Input and output are not identical", Arrays.equals(BucketTools.toByteArray(input), BucketTools.toByteArray(output)));
  }

  private Bucket filterImage(Bucket input, Class<? extends Exception> expected) {
    BMPFilter objBMPFilter = new BMPFilter();
    Bucket output = new ArrayBucket();

    InputStream inStream;
    OutputStream outStream;
    try {
      inStream = input.getInputStream();
      outStream = output.getOutputStream();
    } catch (IOException e) {
      e.printStackTrace();
      fail("Caugth unexpected IOException: " + e);
      return null; //Convince the compiler that we won't continue
    }
View Full Code Here

  }

  private Bucket resourceToBucket(String filename) throws IOException {
    InputStream is = getClass().getResourceAsStream(filename);
    if (is == null) throw new FileNotFoundException();
    Bucket ab = new ArrayBucket();
    BucketTools.copyFrom(ab, is, Long.MAX_VALUE);
    return ab;
  }
View Full Code Here

    PNGFilter filter = new PNGFilter(false, false, true);

    for (Object[] test : testImages) {
      String filename = (String) test[0];
      boolean valid = (Boolean) test[1];
      Bucket ib;
      try {
        ib = resourceToBucket(filename);
      } catch (IOException e) {
        System.out.println(filename + " not found, test skipped");
        continue;
      }

      try {
        filter.readFilter(ib.getInputStream(), new NullBucket().getOutputStream(), "", null, null);

        assertTrue(filename + " should " + (valid ? "" : "not ") + "be valid", valid);
      } catch (DataFilterException dfe) {
        assertFalse(filename + " should " + (valid ? "" : "not ") + "be valid", valid);
      }
View Full Code Here

TOP

Related Classes of freenet.support.api.Bucket

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.