Package org.apache.log4j.helpers

Examples of org.apache.log4j.helpers.CyclicBuffer


 
  public
  void test0() {
    int size = 2;

    CyclicBuffer cb = new CyclicBuffer(size);   
    assertEquals(cb.getMaxSize(), size);   

    cb.add(e[0]);
    assertEquals(cb.length(), 1);   
    assertEquals(cb.get(), e[0]); assertEquals(cb.length(), 0);
    assertNull(cb.get()); assertEquals(cb.length(), 0);


    cb = new CyclicBuffer(size);   
    cb.add(e[0]);
    cb.add(e[1]);
    assertEquals(cb.length(), 2);   
    assertEquals(cb.get(), e[0]); assertEquals(cb.length(), 1);
    assertEquals(cb.get(), e[1]); assertEquals(cb.length(), 0);
    assertNull(cb.get()); assertEquals(cb.length(), 0);

   
  }
View Full Code Here


      doTest1(bufSize);
  }

  void doTest1(int size) {
    //System.out.println("Doing test with size = "+size);
    CyclicBuffer cb = new CyclicBuffer(size);

    assertEquals(cb.getMaxSize(), size);

    for(int i = -(size+10); i < (size+10); i++) {
      assertNull(cb.get(i));
    }
   
    for(int i = 0; i < MAX; i++) {
      cb.add(e[i]);
      int limit = i < size-1 ? i : size-1;

      //System.out.println("\nLimit is " + limit + ", i="+i);

      for(int j = limit; j >= 0; j--) {
  //System.out.println("i= "+i+", j="+j);
  assertEquals(cb.get(j), e[i-(limit-j)]);
      }
      assertNull(cb.get(-1));
      assertNull(cb.get(limit+1));
    }
  }
View Full Code Here

  }
 
  void doTestResize(int initialSize, int numberOfAdds, int newSize) {
    //System.out.println("initialSize = "+initialSize+", numberOfAdds="
    //         +numberOfAdds+", newSize="+newSize);
    CyclicBuffer cb = new CyclicBuffer(initialSize);
    for(int i = 0; i < numberOfAdds; i++) {
      cb.add(e[i]);
    }   
    cb.resize(newSize);

    int offset = numberOfAdds - initialSize;
    if(offset< 0)
      offset = 0;

    int len = newSize < numberOfAdds ? newSize : numberOfAdds;
    len = len < initialSize ? len : initialSize;
    //System.out.println("Len = "+len+", offset="+offset);
    for(int j = 0; j < len; j++) {
      assertEquals(cb.get(j), e[offset+j]);
    }

  }
View Full Code Here

   * The <b>BufferSize</b> option takes a positive integer representing the number of events this appender will buffer and send to newly connected
   * clients.
   */
  public
  void setBufferSize(int _bufferSize) {
    buffer = new CyclicBuffer(_bufferSize);
  }
View Full Code Here

  /**
     The <b>BufferSize</b> option takes a positive integer representing
     the number of events this appender will buffer and send to newly connected clients.*/
  public void setBufferSize(int _bufferSize) {
    buffer = new CyclicBuffer(_bufferSize);
  }
View Full Code Here

 
  public
  void test0() {
    int size = 2;

    CyclicBuffer cb = new CyclicBuffer(size);   
    assertEquals(cb.getMaxSize(), size);   

    cb.add(e[0]);
    assertEquals(cb.length(), 1);   
    assertEquals(cb.get(), e[0]); assertEquals(cb.length(), 0);
    assertNull(cb.get()); assertEquals(cb.length(), 0);


    cb = new CyclicBuffer(size);   
    cb.add(e[0]);
    cb.add(e[1]);
    assertEquals(cb.length(), 2);   
    assertEquals(cb.get(), e[0]); assertEquals(cb.length(), 1);
    assertEquals(cb.get(), e[1]); assertEquals(cb.length(), 0);
    assertNull(cb.get()); assertEquals(cb.length(), 0);

   
  }
View Full Code Here

      doTest1(bufSize);
  }

  void doTest1(int size) {
    //System.out.println("Doing test with size = "+size);
    CyclicBuffer cb = new CyclicBuffer(size);

    assertEquals(cb.getMaxSize(), size);

    for(int i = -(size+10); i < (size+10); i++) {
      assertNull(cb.get(i));
    }
   
    for(int i = 0; i < MAX; i++) {
      cb.add(e[i]);
      int limit = i < size-1 ? i : size-1;

      //System.out.println("\nLimit is " + limit + ", i="+i);

      for(int j = limit; j >= 0; j--) {
  //System.out.println("i= "+i+", j="+j);
  assertEquals(cb.get(j), e[i-(limit-j)]);
      }
      assertNull(cb.get(-1));
      assertNull(cb.get(limit+1));
    }
  }
View Full Code Here

  }
 
  void doTestResize(int initialSize, int numberOfAdds, int newSize) {
    //System.out.println("initialSize = "+initialSize+", numberOfAdds="
    //         +numberOfAdds+", newSize="+newSize);
    CyclicBuffer cb = new CyclicBuffer(initialSize);
    for(int i = 0; i < numberOfAdds; i++) {
      cb.add(e[i]);
    }   
    cb.resize(newSize);

    int offset = numberOfAdds - initialSize;
    if(offset< 0)
      offset = 0;

    int len = newSize < numberOfAdds ? newSize : numberOfAdds;
    len = len < initialSize ? len : initialSize;
    //System.out.println("Len = "+len+", offset="+offset);
    for(int j = 0; j < len; j++) {
      assertEquals(cb.get(j), e[offset+j]);
    }

  }
View Full Code Here

class JListViewModel extends AbstractListModel {

  CyclicBuffer cb;
 
  JListViewModel(int size) {
    cb = new CyclicBuffer(size);
  }
View Full Code Here

class JTableAppenderModel extends AbstractTableModel {

  CyclicBuffer cb;
 
  JTableAppenderModel(int size) {
    cb = new CyclicBuffer(size);
  }
View Full Code Here

TOP

Related Classes of org.apache.log4j.helpers.CyclicBuffer

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.