The version of Apache log4j used by SoundHelix.
Clone
HTTPS:
git clone https://vervis.peers.community/repos/aEp6o
SSH:
git clone USERNAME@vervis.peers.community:aEp6o
Branches
Tags
- 1.3alpha-7
- CHAINSAW_2_SANDBOX_MERGE
- CORE_VERSION
- LEVEL_REPLACES_PRIORITY
- PREALPHA_1_3_AS_OF_2004_05_12
- PRE_CHAINSAW_MODEL_CONVERSION
- PRE_UGLI_MOVE
- TAG_CHAINSAW2_MOVE
- log4j-1.2.17
- log4j-1.2.17-rc1
- v1.3alpha8
- v1.3alpha8-temp
- v1_2_1
- v1_2_10-recalled
- v1_2_11
- v1_2_11_rc1
- v1_2_11rc3
- v1_2_12
- v1_2_12_rc1
- v1_2_12_rc2
- v1_2_12_rc3
- v1_2_12_rc4
- v1_2_12_rc5
- v1_2_12_rc6
- v1_2_13
- v1_2_13_rc1
- v1_2_13_rc2
- v1_2_13_site_update
- v1_2_14
- v1_2_14_maven
- v1_2_14_rc1
- v1_2_14_site_update
- v1_2_15
- v1_2_15_rc1
- v1_2_15_rc2
- v1_2_15_rc3
- v1_2_15_rc4
- v1_2_15_rc5
- v1_2_15_rc6
- v1_2_16
- v1_2_16_rc1
- v1_2_16_rc2
- v1_2_17
- v1_2_17-rc1
- v1_2_17_rc1
- v1_2_17_rc2
- v1_2_17_rc3
- v1_2_2
- v1_2_3
- v1_2_4
- v1_2_6
- v1_2_7
- v1_2_9
- v1_2_alpha0
- v1_2_alpha7
- v1_2beta1
- v1_2final
- v1_3alpha_1
- v1_3alpha_6
- v_1_0
- v_1_0_1
- v_1_0_4
- v_1_1
- v_1_1_1
- v_1_1_2
- v_1_1_3
- v_1_1_b1
- v_1_1b2
- v_1_1b3
- v_1_1b5
- v_1_1b6
- v_1_1b7
- v_1_2beta3
UnitTestBoundedFIFO.java
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software
* License version 1.1, a copy of which has been included with this
* distribution in the LICENSE.APL file. */
//
// Log4j uses the JUnit framework for internal unit testing. JUnit
// available from
//
// http://www.junit.org
package org.apache.log4j.test;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.Category;
import org.apache.log4j.Priority;
import org.apache.log4j.helpers.BoundedFIFO;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.framework.TestFailure;
import junit.framework.Test;
/**
Unit test the {@link BoundedFIFO}.
@author Ceki Gülcü
@since 0.9.1 */
public class UnitTestBoundedFIFO extends TestCase {
static Category cat = Category.getInstance("x");
static int MAX = 1000;
static LoggingEvent[] e = new LoggingEvent[MAX];
{
for (int i = 0; i < MAX; i++) {
e[i] = new LoggingEvent("", cat, Priority.DEBUG, "e"+i, null);
}
}
public UnitTestBoundedFIFO(String name) {
super(name);
}
public
void setUp() {
}
/**
Pattern: +++++..-----..
*/
public
void test1() {
for(int size = 1; size <= 128; size *=2) {
BoundedFIFO bf = new BoundedFIFO(size);
assertEquals(bf.getMaxSize(), size);
assertNull(bf.get());
int i;
int j;
int k;
for(i = 1; i < 2*size; i++) {
for(j = 0; j < i; j++) {
//System.out.println("Putting "+e[j]);
bf.put(e[j]); assertEquals(bf.length(), j < size ? j+1 : size);
}
int max = size < j ? size : j;
j--;
for(k = 0; k <= j; k++) {
//System.out.println("max="+max+", j="+j+", k="+k);
assertEquals(bf.length(), max - k > 0 ? max - k : 0);
Object r = bf.get();
//System.out.println("Got "+r);
if(k >= size)
assertNull(r);
else
assertEquals(r, e[k]);
}
}
//System.out.println("Passed size="+size);
}
}
/**
Pattern: ++++--++--++
*/
public
void test2() {
int size = 3;
BoundedFIFO bf = new BoundedFIFO(size);
bf.put(e[0]);
assertEquals(bf.get(), e[0]);
assertNull(bf.get());
bf.put(e[1]); assertEquals(bf.length(), 1);
bf.put(e[2]); assertEquals(bf.length(), 2);
bf.put(e[3]); assertEquals(bf.length(), 3);
assertEquals(bf.get(), e[1]); assertEquals(bf.length(), 2);
assertEquals(bf.get(), e[2]); assertEquals(bf.length(), 1);
assertEquals(bf.get(), e[3]); assertEquals(bf.length(), 0);
assertNull(bf.get()); assertEquals(bf.length(), 0);
}
int min(int a, int b) {
return a < b ? a : b;
}
/**
Pattern ++++++++++++++++++++ (insert only);
*/
public
void testResize1() {
int size = 10;
for(int n = 1; n < size*2; n++) {
for(int i = 0; i < size*2; i++) {
BoundedFIFO bf = new BoundedFIFO(size);
for(int f = 0; f < i; f++) {
bf.put(e[f]);
}
bf.resize(n);
int expectedSize = min(n, min(i, size));
assertEquals(bf.length(), expectedSize);
for(int c = 0; c < expectedSize; c++) {
assertEquals(bf.get(), e[c]);
}
}
}
}
/**
Pattern ++...+ --...-
*/
public
void testResize2() {
int size = 10;
for(int n = 1; n < size*2; n++) {
for(int i = 0; i < size*2; i++) {
for(int d = 0; d < min(i,size); d++) {
BoundedFIFO bf = new BoundedFIFO(size);
for(int p = 0; p < i; p++) {
bf.put(e[p]);
}
for(int g = 0; g < d; g++) {
bf.get();
}
// x = the number of elems in
int x = bf.length();
bf.resize(n);
int expectedSize = min(n, x);
assertEquals(bf.length(), expectedSize);
for(int c = 0; c < expectedSize; c++) {
assertEquals(bf.get(), e[c+d]);
}
assertNull(bf.get());
}
}
}
}
/**
Pattern: i inserts, d deletes, r inserts
*/
public
void testResize3() {
int size = 10;
for(int n = 1; n < size*2; n++) {
for(int i = 0; i < size; i++) {
for(int d = 0; d < i; d++) {
for(int r = 0; r < d; r++) {
BoundedFIFO bf = new BoundedFIFO(size);
for(int p0 = 0; p0 < i; p0++)
bf.put(e[p0]);
for(int g = 0; g < d; g++)
bf.get();
for(int p1 = 0; p1 < r; p1++)
bf.put(e[i+p1]);
int x = bf.length();
bf.resize(n);
int expectedSize = min(n, x);
assertEquals(bf.length(), expectedSize);
for(int c = 0; c < expectedSize; c++) {
assertEquals(bf.get(), e[c+d]);
}
//assertNull(bf.get());
}
}
}
}
}
public
static
Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(new UnitTestBoundedFIFO("test1"));
suite.addTest(new UnitTestBoundedFIFO("test2"));
suite.addTest(new UnitTestBoundedFIFO("testResize1"));
suite.addTest(new UnitTestBoundedFIFO("testResize2"));
suite.addTest(new UnitTestBoundedFIFO("testResize3"));
return suite;
}
}