Skip to content

Commit

Permalink
Merge pull request #274 from apache/coheigea/junit5
Browse files Browse the repository at this point in the history
DIRKRB-769 - Junit5 migration
  • Loading branch information
coheigea authored Oct 26, 2023
2 parents e7de18a + e3673b6 commit bb0f47a
Show file tree
Hide file tree
Showing 147 changed files with 511 additions and 507 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.apache.kerby.config.Config;
import org.apache.kerby.kerberos.kdc.identitybackend.JsonIdentityBackend;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;

import java.io.File;

Expand All @@ -34,7 +34,7 @@
public class JsonBackendTest extends BackendTestBase {
private static File jsonBackendFile;

@BeforeClass
@BeforeAll
public static void setup() throws KrbException {
File testDir = new File(System.getProperty("test.dir", "target"));
jsonBackendFile = new File(testDir, "json-identity-backend-file");
Expand All @@ -47,7 +47,7 @@ public static void setup() throws KrbException {
backend.initialize();
}

@AfterClass
@AfterAll
public static void cleanJsonBackendFile() {
if (jsonBackendFile.exists()) {
jsonBackendFile.delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.apache.directory.server.ldap.LdapServer;
import org.apache.kerby.kerberos.kdc.identitybackend.LdapIdentityBackend;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.After;
import org.junit.jupiter.api.Test;

public abstract class AbstractLdapIdentityBackendTest extends BackendTest {
protected LdapIdentityBackend backend;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.kerby.config.Conf;
import org.apache.kerby.kerberos.kdc.identitybackend.LdapIdentityBackend;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Before;
import org.junit.jupiter.api.runner.RunWith;

@RunWith(FrameworkRunner.class)
@CreateDS(name = "KerberosKRBProtocolTest-class",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
import org.apache.kerby.kerberos.kerb.server.KdcConfigKey;
import org.apache.kerby.kerberos.kerb.type.ticket.SgtTicket;
import org.apache.kerby.kerberos.kerb.type.ticket.TgtTicket;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.After;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Before;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.runner.RunWith;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -115,7 +115,7 @@ public void testKdc() throws Exception {
tkt = getKrbClient().requestSgt(tgt, getServerPrincipal());
assertThat(tkt).isNotNull();
} catch (Exception e) {
Assert.fail("Exception occurred with good password. "
Assertions.fail("Exception occurred with good password. "
+ e.toString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.kerby.config.Conf;
import org.apache.kerby.kerberos.kdc.identitybackend.LdapIdentityBackend;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Before;
import org.junit.jupiter.api.runner.RunWith;

@RunWith(FrameworkRunner.class)
@CreateDS(name = "KerberosKRBProtocolTest-class",
Expand Down
7 changes: 7 additions & 0 deletions kerby-backend/mavibot-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,12 @@
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
import org.apache.kerby.kerberos.kerb.type.KerberosTime;
import org.apache.kerby.kerberos.kerb.type.base.EncryptionKey;
import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

/**
* Tests for KrbIdentity serializer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,34 @@
import org.apache.kerby.kerberos.kerb.identity.backend.BackendTestUtil;
import org.apache.kerby.kerberos.kerb.identity.backend.IdentityBackend;
import org.apache.kerby.kerberos.kerb.request.KrbIdentity;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.io.TempDir;

import java.io.File;
import java.nio.file.Path;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Tests for MavibotBackend.
*
* @author <a href="mailto:kerby@directory.apache.org">Apache Kerby Project</a>
*/
public class MavibotBackendTest extends BackendTestBase {
private static TemporaryFolder tmpFolder = new TemporaryFolder();

@BeforeClass
@TempDir
static Path tmpFolder;

@BeforeAll
public static void setup() throws Exception {
tmpFolder.create();

File dbFile = tmpFolder.newFile();
File dbFile = tmpFolder.toFile();
backend = new MavibotBackend(dbFile);
backend.initialize();
}

@AfterClass
public static void tearDown() throws KrbException {
tmpFolder.delete();
}

// overriding this cause MavibotBackend doesn't support range search
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import org.apache.kerby.kerberos.kerb.server.KdcTestBase;
import org.apache.kerby.kerberos.kerb.type.ticket.SgtTicket;
import org.apache.kerby.kerberos.kerb.type.ticket.TgtTicket;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.io.File;

Expand All @@ -37,7 +37,7 @@ public class MySQLBackendKdcTest extends KdcTestBase {
private static File testDir = new File(System.getProperty("test.dir", "target"));
private static File dbFile = new File(testDir, "mysqlbackend.mv.db");

@After
@AfterEach
public void tearDown() {
if (dbFile.exists() && !dbFile.delete()) {
System.err.println("Failed to delete the test database file.");
Expand Down Expand Up @@ -71,7 +71,7 @@ public void testKdc() {
tkt = getKrbClient().requestSgt(tgt, getServerPrincipal());
assertThat(tkt).isNotNull();
} catch (Exception e) {
Assert.fail("Exception occurred with good password. "
Assertions.fail("Exception occurred with good password. "
+ e.toString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.apache.kerby.kerberos.kdc.identitybackend.MySQLConfKey;
import org.apache.kerby.kerberos.kdc.identitybackend.MySQLIdentityBackend;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;

import java.io.File;
import java.io.IOException;
Expand All @@ -33,7 +33,7 @@ public class MySQLBackendTest extends BackendTestBase {
private static File testDir = new File(System.getProperty("test.dir", "target"));
private static File dbFile = new File(testDir, "mysqlbackend.mv.db");

@BeforeClass
@BeforeAll
public static void setup() throws KrbException, IOException {
Conf config = new Conf();
config.setString(MySQLConfKey.MYSQL_DRIVER, "org.h2.Driver");
Expand All @@ -45,7 +45,7 @@ public static void setup() throws KrbException, IOException {
backend.initialize();
}

@AfterClass
@AfterAll
public static void tearDown() throws KrbException {
if (backend != null) {
backend.stop();
Expand Down
2 changes: 1 addition & 1 deletion kerby-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</activation>
<modules>
<module>json-backend</module>
<module>ldap-backend</module>
<!--<module>ldap-backend</module>-->
<module>mavibot-backend</module>
<module>zookeeper-backend</module>
<module>mysql-backend</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.apache.kerby.kerberos.kerb.server.KdcTestBase;
import org.apache.kerby.kerberos.kerb.type.ticket.SgtTicket;
import org.apache.kerby.kerberos.kerb.type.ticket.TgtTicket;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.io.File;

Expand Down Expand Up @@ -63,7 +63,7 @@ public void testKdc() throws Exception {
tkt = getKrbClient().requestSgt(tgt, getServerPrincipal());
assertThat(tkt).isNotNull();
} catch (Exception e) {
Assert.fail("Exception occurred with good password. "
Assertions.fail("Exception occurred with good password. "
+ e.toString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.apache.kerby.kerberos.kdc.identitybackend.ZKConfKey;
import org.apache.kerby.kerberos.kdc.identitybackend.ZookeeperIdentityBackend;
import org.apache.kerby.kerberos.kerb.KrbException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;

import java.io.File;

Expand All @@ -35,7 +35,7 @@ public class ZookeeperBackendTest extends BackendTestBase {
private static File instanceDir;
private static File dataDir;

@BeforeClass
@BeforeAll
public static void setup() throws KrbException {
Conf config = new Conf();
File testdir = new File(System.getProperty("test.dir", "target"));
Expand All @@ -50,7 +50,7 @@ public static void setup() throws KrbException {
backend.start();
}

@AfterClass
@AfterAll
public static void tearDown() throws KrbException {
if (dataDir.exists()) {
dataDir.delete();
Expand Down
4 changes: 2 additions & 2 deletions kerby-common/kerby-asn1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.apache.kerby.asn1.type.Asn1Boolean;
import org.apache.kerby.asn1.util.HexUtil;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.kerby.asn1.type.Asn1IA5String;
import org.apache.kerby.asn1.type.Asn1Sequence;
import org.apache.kerby.asn1.type.Asn1String;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.apache.kerby.asn1;

import org.apache.kerby.asn1.type.Asn1OctetString;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/
package org.apache.kerby.asn1;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.io.IOException;

Expand All @@ -36,7 +36,7 @@ public void testDumpWithPersonnelRecord() throws IOException {
Asn1.parseAndDump(data);
Asn1.decodeAndDump(data);
} catch (Exception e) {
Assert.fail("Test dump with personnel record failed. "
Assertions.fail("Test dump with personnel record failed. "
+ e.toString());
}
}
Expand All @@ -48,7 +48,7 @@ public void testDumpWithCompressedData() throws IOException {
Asn1.parseAndDump(hexStr);
Asn1.decodeAndDump(hexStr);
} catch (Exception e) {
Assert.fail("Test dump with compressed data failed. "
Assertions.fail("Test dump with compressed data failed. "
+ e.toString());
}
}
Expand All @@ -60,7 +60,7 @@ public void testDumpWithSignedData() throws IOException {
Asn1.parseAndDump(hexStr);
Asn1.decodeAndDump(hexStr);
} catch (Exception e) {
Assert.fail("test dump with signed data from file: "
Assertions.fail("test dump with signed data from file: "
+ "signed-data.txt failed. " + e.toString());
}
}
Expand All @@ -72,7 +72,7 @@ public void testDumpWithDerData() throws IOException {
Asn1.parseAndDump(data);
Asn1.decodeAndDump(data);
} catch (Exception e) {
Assert.fail("test dump with derData from file: "
Assertions.fail("test dump with derData from file: "
+ "der-data.dat failed. " + e.toString());
}
}
Expand All @@ -84,7 +84,7 @@ public void testDumpWithEmptyContainer() throws IOException {
Asn1.parseAndDump(data);
Asn1.decodeAndDump(data);
} catch (Exception e) {
Assert.fail("test dump with empty container from file: "
Assertions.fail("test dump with empty container from file: "
+ "empty-container.txt failed. " + e.toString());
}
}
Expand Down
Loading

0 comments on commit bb0f47a

Please sign in to comment.