Examples of DummyPOILogger


Examples of org.apache.poi.util.DummyPOILogger

     *  as people seem to have "valid" truncated files
     */
    public void testShortConstructor() throws Exception
    {
        // Get the logger to be used
        DummyPOILogger logger = new DummyPOILogger();
        Field fld = RawDataBlock.class.getDeclaredField("log");
        fld.setAccessible(true);
        fld.set(null, logger);
        assertEquals(0, logger.logged.size());
       
        // Test for various data sizes
        for (int k = 1; k <= 512; k++)
        {
            byte[] data = new byte[ k ];

            for (int j = 0; j < k; j++)
            {
                data[ j ] = ( byte ) j;
            }
            RawDataBlock block = null;
           
            logger.reset();
            assertEquals(0, logger.logged.size());
           
            // Have it created
            block = new RawDataBlock(new ByteArrayInputStream(data));
            assertNotNull(block);
View Full Code Here

Examples of org.apache.poi.util.DummyPOILogger

     *  won't return a full block at a time, we don't
     *  incorrectly think that there's not enough data
     */
    public void testSlowInputStream() throws Exception {
        // Get the logger to be used
        DummyPOILogger logger = new DummyPOILogger();
        Field fld = RawDataBlock.class.getDeclaredField("log");
        fld.setAccessible(true);
        fld.set(null, logger);
        assertEquals(0, logger.logged.size());
       
        // Test for various ok data sizes
        for (int k = 1; k < 512; k++) {
            byte[] data = new byte[ 512 ];
            for (int j = 0; j < data.length; j++) {
                data[j] = (byte) j;
            }
           
            // Shouldn't complain, as there is enough data,
            //  even if it dribbles through
            RawDataBlock block =
              new RawDataBlock(new SlowInputStream(data, k));
            assertFalse(block.eof());
        }
       
        // But if there wasn't enough data available, will
        //  complain
        for (int k = 1; k < 512; k++) {
            byte[] data = new byte[ 511 ];
            for (int j = 0; j < data.length; j++) {
                data[j] = (byte) j;
            }
           
            logger.reset();
            assertEquals(0, logger.logged.size());
           
            // Should complain, as there isn't enough data
            RawDataBlock block =
              new RawDataBlock(new SlowInputStream(data, k));
View Full Code Here

Examples of org.apache.poi.util.DummyPOILogger

     */

    public void testShortConstructor() throws Exception
    {
        // Get the logger to be used
        DummyPOILogger logger = new DummyPOILogger();
        Field fld = RawDataBlock.class.getDeclaredField("log");
        fld.setAccessible(true);
        fld.set(null, logger);
        assertEquals(0, logger.logged.size());
       
        // Test for various short sizes
        for (int k = 2049; k < 2560; k++)
        {
            byte[] data = new byte[ k ];

            for (int j = 0; j < k; j++)
            {
                data[ j ] = ( byte ) j;
            }

            // Check we logged the error
            logger.reset();
            new RawDataBlockList(new ByteArrayInputStream(data), POIFSConstants.BIG_BLOCK_SIZE);
            assertEquals(1, logger.logged.size());
        }
    }
View Full Code Here

Examples of org.apache.poi.util.DummyPOILogger

     */

    public void testShortConstructor() throws Exception
    {
        // Get the logger to be used
        DummyPOILogger logger = (DummyPOILogger)POILogFactory.getLogger(
            RawDataBlock.class
        );
        assertEquals(0, logger.logged.size());
       
        // Test for various short sizes
        for (int k = 2049; k < 2560; k++)
        {
            byte[] data = new byte[ k ];

            for (int j = 0; j < k; j++)
            {
                data[ j ] = ( byte ) j;
            }

            // Check we logged the error
            logger.reset();
            new RawDataBlockList(new ByteArrayInputStream(data), POIFSConstants.BIG_BLOCK_SIZE);
            assertEquals(1, logger.logged.size());
        }
    }
View Full Code Here

Examples of org.apache.poi.util.DummyPOILogger

     *  as people seem to have "valid" truncated files
     */
    public void testShortConstructor() throws Exception
    {
        // Get the logger to be used
        DummyPOILogger logger = (DummyPOILogger)POILogFactory.getLogger(
            RawDataBlock.class
        );
        assertEquals(0, logger.logged.size());
       
        // Test for various data sizes
        for (int k = 1; k <= 512; k++)
        {
            byte[] data = new byte[ k ];

            for (int j = 0; j < k; j++)
            {
                data[ j ] = ( byte ) j;
            }
            RawDataBlock block = null;
           
            logger.reset();
            assertEquals(0, logger.logged.size());
           
            // Have it created
            block = new RawDataBlock(new ByteArrayInputStream(data));
            assertNotNull(block);
View Full Code Here

Examples of org.apache.poi.util.DummyPOILogger

     *  won't return a full block at a time, we don't
     *  incorrectly think that there's not enough data
     */
    public void testSlowInputStream() throws Exception {
        // Get the logger to be used
        DummyPOILogger logger = (DummyPOILogger)POILogFactory.getLogger(
            RawDataBlock.class
        );
        assertEquals(0, logger.logged.size());
       
        // Test for various ok data sizes
        for (int k = 1; k < 512; k++) {
            byte[] data = new byte[ 512 ];
            for (int j = 0; j < data.length; j++) {
                data[j] = (byte) j;
            }
           
            // Shouldn't complain, as there is enough data,
            //  even if it dribbles through
            RawDataBlock block =
              new RawDataBlock(new SlowInputStream(data, k));
            assertFalse(block.eof());
        }
       
        // But if there wasn't enough data available, will
        //  complain
        for (int k = 1; k < 512; k++) {
            byte[] data = new byte[ 511 ];
            for (int j = 0; j < data.length; j++) {
                data[j] = (byte) j;
            }
           
            logger.reset();
            assertEquals(0, logger.logged.size());
           
            // Should complain, as there isn't enough data
            RawDataBlock block =
              new RawDataBlock(new SlowInputStream(data, k));
View Full Code Here

Examples of org.apache.poi.util.DummyPOILogger

    /**
     * Test creating a short RawDataBlockList
     */
    public void testShortConstructor() throws Exception {
        // Get the logger to be used
        DummyPOILogger logger = new DummyPOILogger();
        Field fld = RawDataBlock.class.getDeclaredField("log");
        fld.setAccessible(true);
        fld.set(null, logger);
        assertEquals(0, logger.logged.size());

        // Test for various short sizes
        for (int k = 2049; k < 2560; k++)
        {
            byte[] data = new byte[ k ];

            for (int j = 0; j < k; j++)
            {
                data[ j ] = ( byte ) j;
            }

            // Check we logged the error
            logger.reset();
            new RawDataBlockList(new ByteArrayInputStream(data), POIFSConstants.BIG_BLOCK_SIZE);
            assertEquals(1, logger.logged.size());
        }
    }
View Full Code Here

Examples of org.apache.poi.util.DummyPOILogger

    /**
     * Test creating a short RawDataBlockList
     */
    public void testShortConstructor() throws Exception {
        // Get the logger to be used
        DummyPOILogger logger = new DummyPOILogger();
        Field fld = RawDataBlock.class.getDeclaredField("log");
        fld.setAccessible(true);
        fld.set(null, logger);
        assertEquals(0, logger.logged.size());

        // Test for various short sizes
        for (int k = 2049; k < 2560; k++)
        {
            byte[] data = new byte[ k ];

            for (int j = 0; j < k; j++)
            {
                data[ j ] = ( byte ) j;
            }

            // Check we logged the error
            logger.reset();
            new RawDataBlockList(new ByteArrayInputStream(data), POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS);
            assertEquals(1, logger.logged.size());
        }
    }
View Full Code Here

Examples of org.apache.poi.util.DummyPOILogger

   * Will trigger a warning, but no longer an IOException,
   *  as people seem to have "valid" truncated files
   */
  public void testShortConstructor() throws Exception {
    // Get the logger to be used
    DummyPOILogger logger = new DummyPOILogger();
    Field fld = RawDataBlock.class.getDeclaredField("log");
    fld.setAccessible(true);
    fld.set(null, logger);
    assertEquals(0, logger.logged.size());

    // Test for various data sizes
    for (int k = 1; k <= 512; k++)
    {
      byte[] data = new byte[ k ];

      for (int j = 0; j < k; j++)
      {
        data[ j ] = ( byte ) j;
      }
      RawDataBlock block = null;

      logger.reset();
      assertEquals(0, logger.logged.size());

      // Have it created
      block = new RawDataBlock(new ByteArrayInputStream(data));
      assertNotNull(block);
View Full Code Here

Examples of org.apache.poi.util.DummyPOILogger

   *  won't return a full block at a time, we don't
   *  incorrectly think that there's not enough data
   */
  public void testSlowInputStream() throws Exception {
    // Get the logger to be used
    DummyPOILogger logger = new DummyPOILogger();
    Field fld = RawDataBlock.class.getDeclaredField("log");
    fld.setAccessible(true);
    fld.set(null, logger);
    assertEquals(0, logger.logged.size());

    // Test for various ok data sizes
    for (int k = 1; k < 512; k++) {
      byte[] data = new byte[ 512 ];
      for (int j = 0; j < data.length; j++) {
        data[j] = (byte) j;
      }

      // Shouldn't complain, as there is enough data,
      //  even if it dribbles through
      RawDataBlock block =
        new RawDataBlock(new SlowInputStream(data, k));
      assertFalse(block.eof());
    }

    // But if there wasn't enough data available, will
    //  complain
    for (int k = 1; k < 512; k++) {
      byte[] data = new byte[ 511 ];
      for (int j = 0; j < data.length; j++) {
        data[j] = (byte) j;
      }

      logger.reset();
      assertEquals(0, logger.logged.size());

      // Should complain, as there isn't enough data
      RawDataBlock block =
        new RawDataBlock(new SlowInputStream(data, k));
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.