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
DRFATestCase.java
/*
* Copyright 1999,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.log4j;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import java.util.Calendar;
import java.util.TimeZone;
import org.apache.log4j.rolling.helper.RollingCalendar;
/**
Exhaustive test of the DailyRollingFileAppender compute algorithm.
@author Ceki Gülcü
*/
public class DRFATestCase extends TestCase {
public DRFATestCase(String name) {
super(name);
}
public void testComputeCheckPeriod() {
RollingCalendar rc = new RollingCalendar();
//DailyRollingFileAppender drfa = new DailyRollingFileAppender();
//drfa.setName("testComputeCheckPeriod");
//rc.setsetDatePattern("yyyy-MM-dd.'log'");
//drfa.activateOptions();
//int x = rc.computeTriggeringPeriod("yyyy-MM-dd.'log'");
//int y = RollingCalendar.TOP_OF_DAY;
assertEquals(
rc.computeTriggeringPeriod("yyyy-MM-dd.'log'"), RollingCalendar.TOP_OF_DAY);
assertEquals(rc.computeTriggeringPeriod("yyyy-MM-dd mm.'log'"), RollingCalendar.TOP_OF_MINUTE);
assertEquals(rc.computeTriggeringPeriod("yyyy-MM-dd a.'log'"), RollingCalendar.HALF_DAY);
assertEquals(
rc.computeTriggeringPeriod("yyyy-MM-dd HH.'log'"), RollingCalendar.TOP_OF_HOUR);
assertEquals(
rc.computeTriggeringPeriod("yyyy-MM.'log'"), RollingCalendar.TOP_OF_MONTH);
assertEquals(
rc.computeTriggeringPeriod("'log'HH'log'"), RollingCalendar.TOP_OF_HOUR);
}
public void testRC1() {
RollingCalendar rc = new RollingCalendar();
rc.setType(RollingCalendar.TOP_OF_DAY);
Calendar c = Calendar.getInstance();
// jan, mar, may, july, aug, oct, dec have 31 days
int[] M31 = { 0, 2, 4, 6, 7, 9, 11 };
for (int i = 0; i < M31.length; i++) {
for (int d = 1; d <= 31; d++) {
for (int h = 0; h < 23; h++) {
c.clear();
c.set(Calendar.YEAR, 20);
c.set(Calendar.MONTH, Calendar.JANUARY + M31[i]);
c.set(Calendar.DAY_OF_MONTH, d);
c.set(Calendar.HOUR_OF_DAY, h);
c.set(Calendar.MINUTE, 10);
c.set(Calendar.SECOND, 10);
c.set(Calendar.MILLISECOND, 88);
c.setTime(rc.getNextCheckDate(c.getTime()));
if (d == 31) {
assertEquals(
c.get(Calendar.MONTH), (Calendar.JANUARY + M31[i] + 1) % 12);
assertEquals(c.get(Calendar.DAY_OF_MONTH), 1);
} else {
assertEquals(c.get(Calendar.MONTH), Calendar.JANUARY + M31[i]);
assertEquals(c.get(Calendar.DAY_OF_MONTH), d + 1);
}
assertEquals(c.get(Calendar.HOUR_OF_DAY), 0);
assertEquals(c.get(Calendar.MINUTE), 0);
assertEquals(c.get(Calendar.SECOND), 0);
assertEquals(c.get(Calendar.MILLISECOND), 0);
}
}
}
}
public void testRC2() {
RollingCalendar rc = new RollingCalendar();
rc.setType(RollingCalendar.TOP_OF_HOUR);
Calendar c = Calendar.getInstance();
TimeZone tz = c.getTimeZone();
// jan, mar, may, july, aug, oct, dec have 31 days
int[] M31 = { 0, 2, 4, 6, 7, 9, 11 };
for (int i = 0; i < M31.length; i++) {
System.out.println("Month = " + (M31[i] + 1));
for (int d = 1; d <= 31; d++) {
for (int h = 0; h < 23; h++) {
for (int m = 0; m <= 59; m++) {
c.clear();
c.set(Calendar.YEAR, 20);
c.set(Calendar.MONTH, Calendar.JANUARY + M31[i]);
c.set(Calendar.DAY_OF_MONTH, d);
c.set(Calendar.HOUR_OF_DAY, h);
c.set(Calendar.MINUTE, m);
c.set(Calendar.SECOND, 12);
c.set(Calendar.MILLISECOND, 88);
boolean dltState0 = c.getTimeZone().inDaylightTime(c.getTime());
c.setTime(rc.getNextCheckDate(c.getTime()));
boolean dltState1 = c.getTimeZone().inDaylightTime(c.getTime());
assertEquals(c.get(Calendar.MILLISECOND), 0);
assertEquals(c.get(Calendar.SECOND), 0);
assertEquals(c.get(Calendar.MINUTE), 0);
if (dltState0 == dltState1) {
assertEquals(c.get(Calendar.HOUR_OF_DAY), (h + 1) % 24);
} else {
// returning to standard time
if (dltState0) {
assertEquals(c.get(Calendar.HOUR_OF_DAY), h);
} else { // switching to day light saving time
}
}
if (h == 23) {
assertEquals(c.get(Calendar.DAY_OF_MONTH), (d + 1) % 32);
if (d == 31) {
assertEquals(
c.get(Calendar.MONTH), (Calendar.JANUARY + M31[i] + 1) % 12);
} else {
assertEquals(c.get(Calendar.MONTH), Calendar.JANUARY + M31[i]);
}
} else {
assertEquals(c.get(Calendar.DAY_OF_MONTH), d);
assertEquals(c.get(Calendar.MONTH), Calendar.JANUARY + M31[i]);
}
}
}
}
}
}
public void testRC3() {
RollingCalendar rc = new RollingCalendar();
rc.setType(RollingCalendar.TOP_OF_MINUTE);
int[] S = { 0, 1, 5, 10, 21, 30, 59 };
int[] M = { 0, 1, 5, 10, 21, 30, 59 };
Calendar c = Calendar.getInstance();
// jan, mar, may, july, aug, oct, dec have 31 days
int[] M31 = { 2, 9, 0, 4, 6, 7, 11 };
for (int i = 0; i < M31.length; i++) {
System.out.println("Month = " + (M31[i] + 1));
for (int d = 1; d <= 31; d++) {
for (int h = 0; h < 23; h++) {
for (int m = 0; m < M.length; m++) {
for (int s = 0; s < S.length; s++) {
c.clear();
c.set(Calendar.YEAR, 20);
c.set(Calendar.MONTH, Calendar.JANUARY + M31[i]);
c.set(Calendar.DAY_OF_MONTH, d);
c.set(Calendar.HOUR_OF_DAY, h);
c.set(Calendar.MINUTE, M[m]);
c.set(Calendar.SECOND, S[s]);
c.set(Calendar.MILLISECOND, 88);
c.add(Calendar.MILLISECOND, 1);
boolean dltState0 = c.getTimeZone().inDaylightTime(c.getTime());
c.setTime(rc.getNextCheckDate(c.getTime()));
c.add(Calendar.MILLISECOND, 0);
boolean dltState1 = c.getTimeZone().inDaylightTime(c.getTime());
assertEquals(c.get(Calendar.MILLISECOND), 0);
assertEquals(c.get(Calendar.SECOND), 0);
assertEquals(c.get(Calendar.MINUTE), (M[m] + 1) % 60);
if (M[m] == 59) {
if (dltState0 == dltState1) {
assertEquals(c.get(Calendar.HOUR_OF_DAY), (h + 1) % 24);
}
if (h == 23) {
assertEquals(c.get(Calendar.DAY_OF_MONTH), (d + 1) % 32);
if (d == 31) {
assertEquals(
c.get(Calendar.MONTH),
(Calendar.JANUARY + M31[i] + 1) % 12);
} else {
assertEquals(
c.get(Calendar.MONTH), Calendar.JANUARY + M31[i]);
}
} else {
assertEquals(c.get(Calendar.DAY_OF_MONTH), d);
}
} else {
// allow discrepancies only if we are switching from std to dls time
if (c.get(Calendar.HOUR_OF_DAY) != h) {
c.add(Calendar.HOUR_OF_DAY, +1);
boolean dltState2 =
c.getTimeZone().inDaylightTime(c.getTime());
if (dltState1 == dltState2) {
fail("No switch");
}
}
assertEquals(c.get(Calendar.DAY_OF_MONTH), d);
assertEquals(c.get(Calendar.MONTH), Calendar.JANUARY + M31[i]);
}
}
}
}
}
}
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(new DRFATestCase("testComputeCheckPeriod"));
suite.addTest(new DRFATestCase("testRC1"));
suite.addTest(new DRFATestCase("testRC2"));
suite.addTest(new DRFATestCase("testRC3"));
return suite;
}
}