Skip to content

Commit

Permalink
HDFS-17719. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-hdfs-httpfs P…
Browse files Browse the repository at this point in the history
…art1. (#7371)

Co-authored-by: Chris Nauroth <cnauroth@apache.org>
Co-authored-by: Tsz-wo Sze <szetszwo@apache.org>
Reviewed-by: Chris Nauroth <cnauroth@apache.org>
Reviewed-by: Tsz-wo Sze <szetszwo@apache.org>
Signed-off-by: Shilun Fan <slfan1989@apache.org>
  • Loading branch information
3 people authored Feb 12, 2025
1 parent 8424c15 commit b24996c
Show file tree
Hide file tree
Showing 39 changed files with 828 additions and 751 deletions.
20 changes: 20 additions & 0 deletions hadoop-hdfs-project/hadoop-hdfs-httpfs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,26 @@
<artifactId>kotlin-stdlib-jdk8</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</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>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.TestJettyHelper;
import org.junit.AfterClass;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.AfterAll;

import java.io.File;
import java.net.URI;
import java.net.URL;
import java.util.UUID;

@RunWith(value = Parameterized.class)
public class TestHttpFSFWithSWebhdfsFileSystem
extends TestHttpFSWithHttpFSFileSystem {
private static String classpathDir;
Expand Down Expand Up @@ -69,15 +66,14 @@ public class TestHttpFSFWithSWebhdfsFileSystem
"serverP");
}

@AfterClass
@AfterAll
public static void cleanUp() throws Exception {
new File(classpathDir, "ssl-client.xml").delete();
new File(classpathDir, "ssl-server.xml").delete();
KeyStoreTestUtil.cleanupSSLConfig(keyStoreDir, classpathDir);
}

public TestHttpFSFWithSWebhdfsFileSystem(Operation operation) {
super(operation);
public TestHttpFSFWithSWebhdfsFileSystem() {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@
package org.apache.hadoop.fs.http.client;

import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

@RunWith(value = Parameterized.class)
public class TestHttpFSFWithWebhdfsFileSystem
extends TestHttpFSWithHttpFSFileSystem {

public TestHttpFSFWithWebhdfsFileSystem(Operation operation) {
super(operation);
public TestHttpFSFWithWebhdfsFileSystem() {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.TestDirHelper;
import org.junit.Assert;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.io.File;

@RunWith(value = Parameterized.class)
import static org.junit.jupiter.api.Assertions.assertEquals;

public class TestHttpFSFileSystemLocalFileSystem extends BaseTestHttpFSWith {

private static String PATH_PREFIX;
Expand All @@ -45,8 +43,7 @@ public class TestHttpFSFileSystemLocalFileSystem extends BaseTestHttpFSWith {
PATH_PREFIX = file.getAbsolutePath();
}

public TestHttpFSFileSystemLocalFileSystem(Operation operation) {
super(operation);
public TestHttpFSFileSystemLocalFileSystem() {
}

@Override
Expand Down Expand Up @@ -86,7 +83,7 @@ protected void testSetPermission() throws Exception {
FileStatus status1 = fs.getFileStatus(path);
fs.close();
FsPermission permission2 = status1.getPermission();
Assert.assertEquals(permission2, permission1);
assertEquals(permission2, permission1);

// sticky bit not supported on Windows with local file system, so the
// subclass skips that part of the test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.test.TestHdfsHelper;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

@RunWith(value = Parameterized.class)
public class TestHttpFSWithHttpFSFileSystem extends BaseTestHttpFSWith {

public TestHttpFSWithHttpFSFileSystem(Operation operation) {
super(operation);
public TestHttpFSWithHttpFSFileSystem() {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import javax.servlet.http.HttpServletResponse;

import org.apache.hadoop.fs.http.client.HttpFSFileSystem;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

public class TestCheckUploadContentTypeFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
import org.apache.hadoop.test.TestDirHelper;
import org.apache.hadoop.test.TestJetty;
import org.apache.hadoop.test.TestJettyHelper;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

Expand All @@ -44,6 +43,9 @@
import java.net.URL;
import java.text.MessageFormat;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* This test class ensures that everything works as expected when
* support with the access controlled HTTPFS file system.
Expand Down Expand Up @@ -93,9 +95,9 @@ private void startMiniDFS() throws Exception {
*/
private void createHttpFSServer() throws Exception {
File homeDir = TestDirHelper.getTestDir();
Assert.assertTrue(new File(homeDir, "conf").mkdir());
Assert.assertTrue(new File(homeDir, "log").mkdir());
Assert.assertTrue(new File(homeDir, "temp").mkdir());
assertTrue(new File(homeDir, "conf").mkdir());
assertTrue(new File(homeDir, "log").mkdir());
assertTrue(new File(homeDir, "temp").mkdir());
HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());

File secretFile = new File(new File(homeDir, "conf"), "secret");
Expand Down Expand Up @@ -175,9 +177,9 @@ private void getCmd(String filename, String message, String command, boolean exp
conn.connect();
int resp = conn.getResponseCode();
if ( expectOK ) {
Assert.assertEquals( outMsg, HttpURLConnection.HTTP_OK, resp);
assertEquals(HttpURLConnection.HTTP_OK, resp, outMsg);
} else {
Assert.assertEquals(outMsg, HttpURLConnection.HTTP_FORBIDDEN, resp);
assertEquals(HttpURLConnection.HTTP_FORBIDDEN, resp, outMsg);
}
}

Expand Down Expand Up @@ -207,9 +209,9 @@ private void putCmd(String filename, String message, String command,
conn.connect();
int resp = conn.getResponseCode();
if ( expectOK ) {
Assert.assertEquals(outMsg, HttpURLConnection.HTTP_OK, resp);
assertEquals(HttpURLConnection.HTTP_OK, resp, outMsg);
} else {
Assert.assertEquals(outMsg, HttpURLConnection.HTTP_FORBIDDEN, resp);
assertEquals(HttpURLConnection.HTTP_FORBIDDEN, resp, outMsg);
}
}

Expand Down Expand Up @@ -239,9 +241,9 @@ private void deleteCmd(String filename, String message, String command,
conn.connect();
int resp = conn.getResponseCode();
if ( expectOK ) {
Assert.assertEquals(outMsg, HttpURLConnection.HTTP_OK, resp);
assertEquals(HttpURLConnection.HTTP_OK, resp, outMsg);
} else {
Assert.assertEquals(outMsg, HttpURLConnection.HTTP_FORBIDDEN, resp);
assertEquals(HttpURLConnection.HTTP_FORBIDDEN, resp, outMsg);
}
}

Expand Down Expand Up @@ -271,9 +273,9 @@ private void postCmd(String filename, String message, String command,
conn.connect();
int resp = conn.getResponseCode();
if ( expectOK ) {
Assert.assertEquals(outMsg, HttpURLConnection.HTTP_OK, resp);
assertEquals(HttpURLConnection.HTTP_OK, resp, outMsg);
} else {
Assert.assertEquals(outMsg, HttpURLConnection.HTTP_FORBIDDEN, resp);
assertEquals(HttpURLConnection.HTTP_FORBIDDEN, resp, outMsg);
}
}

Expand Down
Loading

0 comments on commit b24996c

Please sign in to comment.