Skip to content

Commit

Permalink
Migrate old TCK to maven / junit
Browse files Browse the repository at this point in the history
Signed-off-by: Arjan Tijms <arjan.tijms@omnifish.ee>
  • Loading branch information
arjantijms committed Apr 27, 2024
1 parent 9ad338d commit 11949a5
Show file tree
Hide file tree
Showing 108 changed files with 20,971 additions and 2,000 deletions.
34 changes: 29 additions & 5 deletions tck/common/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022, 2022 Contributors to Eclipse Foundation. All rights reserved.
Copyright (c) 2022, 2024 Contributors to Eclipse Foundation. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -30,8 +30,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -59,13 +58,38 @@
<dependency>
<groupId>org.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>3.11.0</version>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.2</version>
<version>1.17.2</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.8.6</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Expand Up @@ -28,6 +28,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Base64;
import java.util.Map;
import java.util.logging.Logger;
import org.htmlunit.DefaultCredentialsProvider;
Expand Down Expand Up @@ -163,6 +164,10 @@ protected String readFromServerWithCredentials(String path, String username, Str
credentialsProvider.addCredentials(username, password.toCharArray());

getWebClient().setCredentialsProvider(credentialsProvider);
getWebClient().addRequestHeader(
"Authorization",
"Basic " + Base64.getEncoder()
.encodeToString((username + ":" + password).getBytes()));

return readFromServer(path);
}
Expand Down
Expand Up @@ -23,7 +23,6 @@
import java.net.URL;
import java.util.Collection;
import java.util.Iterator;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
Expand Down Expand Up @@ -56,13 +55,19 @@
*/
public class LogFileProcessor {

//private Properties props = null;
private String logFileLocation = null;
private Collection recordCollection = null;
private Collection appIdRecordCollection = null;
private Collection appSpecificRecordCollection = null;
private String logFileLocation;
private Collection recordCollection;
private Collection appIdRecordCollection;
private Collection appSpecificRecordCollection;

private boolean client;

public LogFileProcessor() {
this(false);
}

public LogFileProcessor(boolean client) {
this.client = client;
boolean pass = true;
try {
logFileLocation = System.getProperty("log.file.location");
Expand All @@ -73,15 +78,13 @@ public LogFileProcessor() {

if (!pass) {
TestUtil.logErr("Setup Failed ");
TestUtil.logErr("Please verify the following in ts.jte");
TestUtil.logErr("log.file.location");
TestUtil.logErr("Please verify \"log.file.location\"");
}
TestUtil.logMsg("Setup ok");

} catch (Exception e) {
TestUtil.logErr("Setup Failed ");
TestUtil.logErr("Please verify the following in ts.jte");
TestUtil.logErr("log.file.location");
TestUtil.logErr("Please verify \"log.file.location\"");
}
}

Expand All @@ -94,12 +97,17 @@ public void fetchLogs() {
URL url = null;

try {
String fileName = "authentication-trace-log.xml";
if (client) {
fileName = "client-authentication-trace-log.xml";
}

DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();

String strFilePathAndName = "";
if (logFileLocation.indexOf("authentication-trace-log.xml") <= 0) {
strFilePathAndName = logFileLocation + "/authentication-trace-log.xml";
if (logFileLocation.indexOf(fileName) <= 0) {
strFilePathAndName = logFileLocation + "/" + fileName;
}
System.out.println("Log File = " + strFilePathAndName);

Expand Down
Expand Up @@ -84,22 +84,27 @@ public static void initializeTSLogger() {
logger = TSLogger.getTSLogger("jacc");
boolean appendMode = true;

String fileName = "/authentication-trace-log.xml";

// Clean the content of authentication-trace-log.xml if it exists
File file = new File(logFileLocation + "/authentication-trace-log.xml");
if (file.exists()) {
System.out.println("XXXX: in initializeTSLogger() - authentication-trace-log.xml exists");
// Delete the file, if it exists
file.delete();
// file.delete();
fileName = "/client-authentication-trace-log.xml";
}

File fileLock = new File(logFileLocation + "/authentication-trace-log.xml.lck");
if (fileLock.exists()) {
System.out.println("XXXX: in initializeTSLogger() - authentication-trace-log.xml.lck exists");
// Delete the file, if it exists
fileLock.delete();
// fileLock.delete();
}

// Create a new file
System.out.println("XXXX: in initializeTSLogger() - about to create authentication-trace-log.xml");
fileHandler = new FileHandler(logFileLocation + "/authentication-trace-log.xml", appendMode);
fileHandler = new FileHandler(logFileLocation + fileName, appendMode);
fileHandler.setFormatter(new TSXMLFormatter());
logger.addHandler(fileHandler);
setTSLogger(logger);
Expand All @@ -119,7 +124,7 @@ public static void setTSLogger(TSLogger lgr) {
}

public static void close() {
fileHandler.close();
// fileHandler.close();
}


Expand Down
2 changes: 1 addition & 1 deletion tck/old-tck/source/pom.xml
Expand Up @@ -171,7 +171,7 @@
<artifactItem>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<version>3.3.0</version>
</artifactItem>
<artifactItem>
<groupId>commons-httpclient</groupId>
Expand Down

0 comments on commit 11949a5

Please sign in to comment.