[java-opensaml] branch master updated: IDP-1508 - TestNG @BeforeTest and @AfterTest are being misused
Scott Cantor
cantor.2 at osu.edu
Tue Apr 7 15:17:14 EDT 2020
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=bdb80102055c2e8880871262c30497486e416e64
The following commit(s) were added to refs/heads/master by this push:
new bdb8010 IDP-1508 - TestNG @BeforeTest and @AfterTest are being misused
bdb8010 is described below
commit bdb80102055c2e8880871262c30497486e416e64
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Apr 7 15:17:11 2020 -0400
IDP-1508 - TestNG @BeforeTest and @AfterTest are being misused
https://issues.shibboleth.net/jira/browse/IDP-1508
Sanitize OpenSAML.
---
.../impl/TrustEngineX509TrustManagerTest.java | 8 +++---
.../storage/impl/LDAPStorageServiceTest.java | 32 ++++++----------------
2 files changed, 12 insertions(+), 28 deletions(-)
diff --git a/opensaml-security-impl/src/test/java/org/opensaml/security/trust/impl/TrustEngineX509TrustManagerTest.java b/opensaml-security-impl/src/test/java/org/opensaml/security/trust/impl/TrustEngineX509TrustManagerTest.java
index 3f77bb0..6f2cfd1 100644
--- a/opensaml-security-impl/src/test/java/org/opensaml/security/trust/impl/TrustEngineX509TrustManagerTest.java
+++ b/opensaml-security-impl/src/test/java/org/opensaml/security/trust/impl/TrustEngineX509TrustManagerTest.java
@@ -38,8 +38,8 @@ import org.ldaptive.ssl.SslConfig;
import org.opensaml.security.credential.BasicCredential;
import org.opensaml.security.credential.impl.StaticCredentialResolver;
import org.testng.Assert;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.unboundid.ldap.sdk.LDAPException;
@@ -62,7 +62,7 @@ public class TrustEngineX509TrustManagerTest {
* @throws LDAPException if the in-memory directory server cannot be created
* @throws IOException ...
*/
- @BeforeTest public void setupDirectoryServer() throws IOException, LDAPException {
+ @BeforeClass public void setupDirectoryServer() throws IOException, LDAPException {
directoryServer = new InMemoryDirectory(new File(DATA_PATH + "test-ldap.ldif"), new File(DATA_PATH + "test-ldap.keystore"));
directoryServer.start();
}
@@ -70,7 +70,7 @@ public class TrustEngineX509TrustManagerTest {
/**
* Shutdown the in-memory directory server.
*/
- @AfterTest public void teardownDirectoryServer() {
+ @AfterClass public void teardownDirectoryServer() {
directoryServer.stop();
}
diff --git a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/LDAPStorageServiceTest.java b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/LDAPStorageServiceTest.java
index 98de98d..309e6a9 100644
--- a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/LDAPStorageServiceTest.java
+++ b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/LDAPStorageServiceTest.java
@@ -31,9 +31,7 @@ import org.ldaptive.pool.PooledConnectionFactory;
import org.opensaml.storage.StorageRecord;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.unboundid.ldap.listener.InMemoryDirectoryServer;
@@ -56,23 +54,7 @@ public class LDAPStorageServiceTest {
private final String context = "cn=Principal,ou=people,dc=shibboleth,dc=net";
@BeforeClass
- protected void setUp() throws ComponentInitializationException {
- storageService = getStorageService();
- storageService.initialize();
- }
-
- @AfterClass
- protected void tearDown() {
- storageService.destroy();
- }
-
- /**
- * Creates an UnboundID in-memory directory server. Leverages LDIF found in test resources.
- *
- * @throws LDAPException if the in-memory directory server cannot be created
- */
- @BeforeTest public void setupDirectoryServer() throws LDAPException {
-
+ protected void setUp() throws ComponentInitializationException, LDAPException {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=shibboleth,dc=net");
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", 10389));
config.addAdditionalBindCredentials("cn=Directory Manager", "password");
@@ -80,12 +62,14 @@ public class LDAPStorageServiceTest {
directoryServer.importFromLDIF(true,
"src/test/resources/org/opensaml/storage/impl/LDAPStorageServiceTest.ldif");
directoryServer.startListening();
- }
- /**
- * Shutdown the in-memory directory server.
- */
- @AfterTest public void teardownDirectoryServer() {
+ storageService = getStorageService();
+ storageService.initialize();
+ }
+
+ @AfterClass
+ protected void tearDown() {
+ storageService.destroy();
directoryServer.shutDown(true);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list