This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch postgresql
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/postgresql by this push:
new 159806c86a JAMES-2586 Fix PostgresAuthenticationTest
159806c86a is described below
commit 159806c86a4b2438a574b7b1dbccb8125aca3b50
Author: hung phan <[email protected]>
AuthorDate: Fri Mar 1 14:09:46 2024 +0700
JAMES-2586 Fix PostgresAuthenticationTest
---
.../org/apache/james/JamesServerExtension.java | 52 +++++++++++++++-------
.../postgres/PostgresAuthenticationTest.java | 3 --
2 files changed, 37 insertions(+), 18 deletions(-)
diff --git
a/server/container/guice/common/src/test/java/org/apache/james/JamesServerExtension.java
b/server/container/guice/common/src/test/java/org/apache/james/JamesServerExtension.java
index e473bf9f47..b96ff32bd8 100644
---
a/server/container/guice/common/src/test/java/org/apache/james/JamesServerExtension.java
+++
b/server/container/guice/common/src/test/java/org/apache/james/JamesServerExtension.java
@@ -56,11 +56,22 @@ public class JamesServerExtension implements
BeforeAllCallback, BeforeEachCallba
public enum Lifecycle {
// Restarts the server for each class, including nested classes
- PER_CLASS(JamesServerExtension::start, (extension, context) -> { },
(extension, context) -> { }, JamesServerExtension::stop),
+ PER_CLASS(
+ (extension, context) -> {
+ extension.setup(context);
+ extension.start(context);
+ },
+ (extension, context) -> { },
+ (extension, context) -> { },
+ (extension, context) -> {
+ extension.stop(context);
+ extension.tearDown(context);
+ }),
// Restarts the server for the enclosing class, it will ignore nested
classes
PER_ENCLOSING_CLASS(
(extension, context) -> {
if (!isNested(context)) {
+ extension.setup(context);
extension.start(context);
}
},
@@ -69,10 +80,15 @@ public class JamesServerExtension implements
BeforeAllCallback, BeforeEachCallba
(extension, context) -> {
if (!isNested(context)) {
extension.stop(context);
+ extension.tearDown(context);
}
}),
// Restarts the server for each test (default)
- PER_TEST((extension, context) -> { }, JamesServerExtension::start,
JamesServerExtension::stop, (extension, context) -> { });
+ PER_TEST(
+ JamesServerExtension::setup,
+ JamesServerExtension::start,
+ JamesServerExtension::stop,
+ JamesServerExtension::tearDown);
private static boolean isNested(ExtensionContext context) {
return context.getTestClass()
@@ -121,7 +137,6 @@ public class JamesServerExtension implements
BeforeAllCallback, BeforeEachCallba
@Override
public void beforeAll(ExtensionContext extensionContext) throws Exception {
- registrableExtension.beforeAll(extensionContext);
lifecycle.beforeAll.accept(this, extensionContext);
}
@@ -130,6 +145,24 @@ public class JamesServerExtension implements
BeforeAllCallback, BeforeEachCallba
lifecycle.beforeEach.accept(this, extensionContext);
}
+ @Override
+ public void afterEach(ExtensionContext extensionContext) throws Exception {
+ lifecycle.afterEach.accept(this, extensionContext);
+ }
+
+ @Override
+ public void afterAll(ExtensionContext extensionContext) throws Exception {
+ lifecycle.afterAll.accept(this, extensionContext);
+ }
+
+ private void setup(ExtensionContext extensionContext) throws Exception {
+ registrableExtension.beforeAll(extensionContext);
+ }
+
+ private void tearDown(ExtensionContext extensionContext) throws Exception {
+ registrableExtension.afterAll(extensionContext);
+ }
+
private void start(ExtensionContext extensionContext) throws Exception {
folderRegistrableExtension.beforeEach(extensionContext);
registrableExtension.beforeEach(extensionContext);
@@ -150,23 +183,12 @@ public class JamesServerExtension implements
BeforeAllCallback, BeforeEachCallba
}
}
- @Override
- public void afterEach(ExtensionContext extensionContext) throws Exception {
- lifecycle.afterEach.accept(this, extensionContext);
- }
-
private void stop(ExtensionContext extensionContext) throws Exception {
guiceJamesServer.stop();
registrableExtension.afterEach(extensionContext);
folderRegistrableExtension.afterEach(extensionContext);
}
- @Override
- public void afterAll(ExtensionContext extensionContext) throws Exception {
- lifecycle.afterAll.accept(this, extensionContext);
- registrableExtension.afterAll(extensionContext);
- }
-
@Override
public boolean supportsParameter(ParameterContext parameterContext,
ExtensionContext extensionContext) throws ParameterResolutionException {
return (parameterContext.getParameter().getType() ==
GuiceJamesServer.class)
@@ -192,4 +214,4 @@ public class JamesServerExtension implements
BeforeAllCallback, BeforeEachCallba
public void await() {
awaitCondition.await();
}
-}
+}
\ No newline at end of file
diff --git
a/server/protocols/jmap-rfc-8621-integration-tests/postgres-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/postgres/PostgresAuthenticationTest.java
b/server/protocols/jmap-rfc-8621-integration-tests/postgres-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/postgres/PostgresAuthenticationTest.java
index 8d1922e72a..57e4f56dca 100644
---
a/server/protocols/jmap-rfc-8621-integration-tests/postgres-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/postgres/PostgresAuthenticationTest.java
+++
b/server/protocols/jmap-rfc-8621-integration-tests/postgres-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/postgres/PostgresAuthenticationTest.java
@@ -31,11 +31,8 @@ import
org.apache.james.jmap.rfc8621.contract.AuthenticationContract;
import org.apache.james.modules.RabbitMQExtension;
import org.apache.james.modules.TestJMAPServerModule;
import org.apache.james.modules.blobstore.BlobStoreConfiguration;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.extension.RegisterExtension;
-@Disabled
-// TODO Need to fix
public class PostgresAuthenticationTest implements AuthenticationContract {
@RegisterExtension
static JamesServerExtension testExtension = new
JamesServerBuilder<PostgresJamesConfiguration>(tmpDir ->
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]