Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions log4j-1.2-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,85 +51,91 @@
</properties>

<dependencies>

<!-- Used for JMS appenders (needs an implementation of course) -->
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<!-- Log4j Runtime -->

<dependency>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<!-- JUnit -->

<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<!-- 1.2 tests -->
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<profiles>
Expand Down
60 changes: 0 additions & 60 deletions log4j-1.2-api/src/test/java/org/apache/log4j/VelocityTest.java

This file was deleted.

This file was deleted.

This file was deleted.

106 changes: 1 addition & 105 deletions log4j-1.2-api/src/test/java/org/apache/log4j/util/Compare.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,66 +17,12 @@
package org.apache.log4j.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Compare {

static final int B1_NULL = -1;
static final int B2_NULL = -2;

public static boolean compare(final Class testClass, final String file1, final String file2) throws IOException {
try (final BufferedReader in1 = new BufferedReader(new FileReader(file1));
final BufferedReader in2 = new BufferedReader(new InputStreamReader(open(testClass, file2)))) {
return compare(testClass, file1, file2, in1, in2);
}
}

public static boolean compare(
final Class testClass,
final String file1,
final String file2,
final BufferedReader in1,
final BufferedReader in2)
throws IOException {

String s1;
int lineCounter = 0;

while ((s1 = in1.readLine()) != null) {
lineCounter++;

final String s2 = in2.readLine();

if (!s1.equals(s2)) {
System.out.println("Files [" + file1 + "] and [" + file2 + "] differ on line " + lineCounter);
System.out.println("One reads: [" + s1 + "].");
System.out.println("Other reads:[" + s2 + "].");
outputFile(testClass, file1);
outputFile(testClass, file2);

return false;
}
}

// the second file is longer
if (in2.read() != -1) {
System.out.println("File [" + file2 + "] longer than file [" + file1 + "].");
outputFile(testClass, file1);
outputFile(testClass, file2);

return false;
}

return true;
}

public static boolean compare(final String file1, final String file2) throws FileNotFoundException, IOException {
public static boolean compare(final String file1, final String file2) throws IOException {
try (final BufferedReader in1 = new BufferedReader(new FileReader(file1));
final BufferedReader in2 = new BufferedReader(new FileReader(file2))) {

Expand All @@ -102,54 +48,4 @@ public static boolean compare(final String file1, final String file2) throws Fil
return true;
}
}

private static final InputStream open(final Class testClass, final String fileName) throws IOException {
String resourceName = fileName;
if (fileName.startsWith("witness/")) {
resourceName = fileName.substring(fileName.lastIndexOf('/') + 1);
}
InputStream is = testClass.getResourceAsStream(resourceName);
if (is == null) {
final File file = new File(fileName);
if (file.exists()) {
is = new FileInputStream(file);
} else {
throw new FileNotFoundException("Resource " + resourceName + " not found");
}
}
return is;
}

/**
*
* Prints file on the console.
*
*/
private static void outputFile(final Class testClass, final String file) throws IOException {
try (final InputStream is = open(testClass, file);
final BufferedReader in1 = new BufferedReader(new InputStreamReader(is))) {

String s1;
int lineCounter = 0;
System.out.println("--------------------------------");
System.out.println("Contents of " + file + ":");

while ((s1 = in1.readLine()) != null) {
lineCounter++;
System.out.print(lineCounter);

if (lineCounter < 10) {
System.out.print(" : ");
} else if (lineCounter < 100) {
System.out.print(" : ");
} else if (lineCounter < 1000) {
System.out.print(" : ");
} else {
System.out.print(": ");
}

System.out.println(s1);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
package org.apache.log4j.util;

import java.util.Arrays;
import org.apache.oro.text.perl.Perl5Util;

public class ControlFilter implements Filter {

Perl5Util util = new Perl5Util();

String[] allowedPatterns;

public ControlFilter(final String[] allowedPatterns) {
Expand All @@ -31,11 +28,8 @@ public ControlFilter(final String[] allowedPatterns) {

@Override
public String filter(final String in) throws UnexpectedFormatException {
final int len = allowedPatterns.length;
for (int i = 0; i < len; i++) {
// System.out.println("["+allowedPatterns[i]+"]");
if (util.match("/" + allowedPatterns[i] + "/", in)) {
// System.out.println("["+in+"] matched ["+allowedPatterns[i]);
for (String allowedPattern : allowedPatterns) {
if (in.matches(allowedPattern)) {
return in;
}
}
Expand Down
Loading