You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2018/12/18 12:57:26 UTC
[1/7] james-project git commit: JAMES-2611 Migrate james-server-util
to JUNIT5
Repository: james-project
Updated Branches:
refs/heads/master c9a2ebfb5 -> c0b581165
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/ValuePatchTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/ValuePatchTest.java b/server/container/util/src/test/java/org/apache/james/util/ValuePatchTest.java
index ef84393..07144f0 100644
--- a/server/container/util/src/test/java/org/apache/james/util/ValuePatchTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/ValuePatchTest.java
@@ -25,7 +25,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.NoSuchElementException;
import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ValuePatchTest {
@@ -35,157 +35,157 @@ public class ValuePatchTest {
public static final Optional<Integer> OPTIONAL_OF_VALUE = Optional.of(VALUE);
@Test
- public void keepShouldProduceKeptValues() {
+ void keepShouldProduceKeptValues() {
assertThat(ValuePatch.<Integer>keep().isKept()).isTrue();
}
@Test
- public void keepShouldThrowOnGet() {
+ void keepShouldThrowOnGet() {
assertThatThrownBy(() -> ValuePatch.<Integer>keep().get()).isInstanceOf(NoSuchElementException.class);
}
@Test
- public void keepShouldNotBeModified() {
+ void keepShouldNotBeModified() {
assertThat(ValuePatch.<Integer>keep().isModified()).isFalse();
}
@Test
- public void keepShouldNotBeRemoved() {
+ void keepShouldNotBeRemoved() {
assertThat(ValuePatch.<Integer>keep().isRemoved()).isFalse();
}
@Test
- public void removeShouldNotBeKept() {
+ void removeShouldNotBeKept() {
assertThat(ValuePatch.<Integer>remove().isKept()).isFalse();
}
@Test
- public void removeShouldBeRemoved() {
+ void removeShouldBeRemoved() {
assertThat(ValuePatch.<Integer>remove().isRemoved()).isTrue();
}
@Test
- public void removedShouldNotBeModified() {
+ void removedShouldNotBeModified() {
assertThat(ValuePatch.<Integer>remove().isModified()).isFalse();
}
@Test
- public void removeShouldThrowOnGet() {
+ void removeShouldThrowOnGet() {
assertThatThrownBy(() -> ValuePatch.<Integer>remove().get()).isInstanceOf(NoSuchElementException.class);
}
@Test
- public void ofNullableShouldBeEquivalentToRemoveWhenNullParameter() {
+ void ofNullableShouldBeEquivalentToRemoveWhenNullParameter() {
assertThat(ValuePatch.<Integer>ofNullable(null)).isEqualTo(ValuePatch.<Integer>remove());
}
@Test
- public void ofNullableShouldBeEquivalentToModifyWhenNonNullParameter() {
+ void ofNullableShouldBeEquivalentToModifyWhenNonNullParameter() {
assertThat(ValuePatch.ofNullable(VALUE)).isEqualTo(ValuePatch.modifyTo(VALUE));
}
@Test
- public void modifyToShouldNotBeKept() {
+ void modifyToShouldNotBeKept() {
assertThat(ValuePatch.modifyTo(VALUE).isKept()).isFalse();
}
@Test
- public void modifyToShouldNotBeRemoved() {
+ void modifyToShouldNotBeRemoved() {
assertThat(ValuePatch.modifyTo(VALUE).isRemoved()).isFalse();
}
@Test
- public void modifyToShouldBeModified() {
+ void modifyToShouldBeModified() {
assertThat(ValuePatch.modifyTo(VALUE).isModified()).isTrue();
}
@Test
- public void modifyToShouldThrowOnNullValue() {
+ void modifyToShouldThrowOnNullValue() {
assertThatThrownBy(() -> ValuePatch.modifyTo(null)).isInstanceOf(NullPointerException.class);
}
@Test
- public void modifyToShouldBeRetrievedByGet() {
+ void modifyToShouldBeRetrievedByGet() {
assertThat(ValuePatch.modifyTo(VALUE).get()).isEqualTo(VALUE);
}
@Test
- public void ofOptionalShouldThrowOnNullValue() {
+ void ofOptionalShouldThrowOnNullValue() {
assertThatThrownBy(() -> ValuePatch.ofOptional(null)).isInstanceOf(NullPointerException.class);
}
@Test
- public void ofOptionalShouldBeEquivalentToModifyToWhenPresent() {
+ void ofOptionalShouldBeEquivalentToModifyToWhenPresent() {
assertThat(ValuePatch.ofOptional(OPTIONAL_OF_VALUE)).isEqualTo(ValuePatch.modifyTo(VALUE));
}
@Test
- public void ofOptionalShouldBeEquivalentToRemoveWhenEmpty() {
+ void ofOptionalShouldBeEquivalentToRemoveWhenEmpty() {
assertThat(ValuePatch.ofOptional(Optional.empty())).isEqualTo(ValuePatch.remove());
}
@Test
- public void notKeptOrElseShouldReturnElseWhenKept() {
+ void notKeptOrElseShouldReturnElseWhenKept() {
assertThat(ValuePatch.<Integer>keep().notKeptOrElse(REPLACEMENT)).isEqualTo(REPLACEMENT);
}
@Test
- public void notKeptOrElseShouldReturnEmptyWhenRemoved() {
+ void notKeptOrElseShouldReturnEmptyWhenRemoved() {
assertThat(ValuePatch.<Integer>remove().notKeptOrElse(REPLACEMENT)).isEqualTo(Optional.empty());
}
@Test
- public void notKeptOrElseShouldReturnOptionalWhenModified() {
+ void notKeptOrElseShouldReturnOptionalWhenModified() {
assertThat(ValuePatch.modifyTo(VALUE).notKeptOrElse(REPLACEMENT)).isEqualTo(OPTIONAL_OF_VALUE);
}
@Test
- public void toOptionalShouldReturnElseWhenKept() {
+ void toOptionalShouldReturnElseWhenKept() {
assertThat(ValuePatch.<Integer>keep().toOptional()).isEqualTo(Optional.empty());
}
@Test
- public void toOptionalShouldReturnEmptyWhenRemoved() {
+ void toOptionalShouldReturnEmptyWhenRemoved() {
assertThat(ValuePatch.<Integer>remove().toOptional()).isEqualTo(Optional.empty());
}
@Test
- public void toOptionalShouldReturnOptionalWhenModified() {
+ void toOptionalShouldReturnOptionalWhenModified() {
assertThat(ValuePatch.modifyTo(VALUE).toOptional()).isEqualTo(OPTIONAL_OF_VALUE);
}
@Test
- public void getOrElseShouldReturnReplacementWhenKept() {
+ void getOrElseShouldReturnReplacementWhenKept() {
assertThat(ValuePatch.<Integer>keep().getOrElse(REPLACEMENT_VALUE)).isEqualTo(REPLACEMENT_VALUE);
}
@Test
- public void getOrElseShouldReturnReplacementWhenRemoved() {
+ void getOrElseShouldReturnReplacementWhenRemoved() {
assertThat(ValuePatch.<Integer>remove().getOrElse(REPLACEMENT_VALUE)).isEqualTo(REPLACEMENT_VALUE);
}
@Test
- public void getOrElseShouldReturnValueWhenPresent() {
+ void getOrElseShouldReturnValueWhenPresent() {
assertThat(ValuePatch.modifyTo(VALUE).getOrElse(REPLACEMENT_VALUE)).isEqualTo(VALUE);
}
@Test
- public void getOrElseShouldReturnNullWhenKeptAndNullSpecified() {
+ void getOrElseShouldReturnNullWhenKeptAndNullSpecified() {
assertThat(ValuePatch.<Integer>keep().getOrElse(null)).isNull();
}
@Test
- public void getOrElseShouldReturnNullWhenRemovedAndNullSpecified() {
+ void getOrElseShouldReturnNullWhenRemovedAndNullSpecified() {
assertThat(ValuePatch.<Integer>remove().getOrElse(null)).isNull();
}
@Test
- public void getOrElseShouldReturnValueWhenPresentAndNullSpecified() {
+ void getOrElseShouldReturnValueWhenPresentAndNullSpecified() {
assertThat(ValuePatch.modifyTo(VALUE).getOrElse(null)).isEqualTo(VALUE);
}
@Test
- public void mapNotKeptToValueShouldPreserveKept() {
+ void mapNotKeptToValueShouldPreserveKept() {
assertThat(
ValuePatch.<Integer>keep()
.mapNotKeptToOptional(optional -> optional.map(i -> i + 1).orElse(REPLACEMENT_VALUE)))
@@ -193,7 +193,7 @@ public class ValuePatchTest {
}
@Test
- public void mapNotKeptToValueShouldTransformOf() {
+ void mapNotKeptToValueShouldTransformOf() {
assertThat(
ValuePatch.modifyTo(VALUE)
.mapNotKeptToOptional(optional -> optional.map(i -> i + 1).orElse(REPLACEMENT_VALUE)))
@@ -201,7 +201,7 @@ public class ValuePatchTest {
}
@Test
- public void mapNotKeptToValueShouldTransformRemoved() {
+ void mapNotKeptToValueShouldTransformRemoved() {
assertThat(
ValuePatch.<Integer>remove()
.mapNotKeptToOptional(optional -> optional.map(i -> i + 1).orElse(REPLACEMENT_VALUE)))
@@ -209,7 +209,7 @@ public class ValuePatchTest {
}
@Test
- public void mapNotKeptToValueShouldThrowWhenNull() {
+ void mapNotKeptToValueShouldThrowWhenNull() {
assertThatThrownBy(
() -> ValuePatch.modifyTo(12)
.mapNotKeptToOptional(any -> null)
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java b/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
index 4997bbe..2a2f81e 100644
--- a/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/concurrency/ConcurrentTestRunnerTest.java
@@ -27,14 +27,14 @@ import java.time.Duration;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutionException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ConcurrentTestRunnerTest {
public static final ConcurrentTestRunner.ConcurrentOperation NOOP = (threadNumber, step) -> { };
public static final Duration DEFAULT_AWAIT_TIME = Duration.ofMillis(100);
@Test
- public void constructorShouldThrowOnNegativeThreadCount() {
+ void constructorShouldThrowOnNegativeThreadCount() {
assertThatThrownBy(() ->
ConcurrentTestRunner.builder()
.operation(NOOP)
@@ -44,7 +44,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void constructorShouldThrowOnNegativeOperationCount() {
+ void constructorShouldThrowOnNegativeOperationCount() {
assertThatThrownBy(() ->
ConcurrentTestRunner.builder()
.operation(NOOP)
@@ -54,7 +54,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void constructorShouldThrowOnZeroThreadCount() {
+ void constructorShouldThrowOnZeroThreadCount() {
assertThatThrownBy(() ->
ConcurrentTestRunner.builder()
.operation(NOOP)
@@ -64,7 +64,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void constructorShouldThrowOnZeroOperationCount() {
+ void constructorShouldThrowOnZeroOperationCount() {
assertThatThrownBy(() ->
ConcurrentTestRunner.builder()
.operation(NOOP)
@@ -74,7 +74,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void constructorShouldThrowOnNullBiConsumer() {
+ void constructorShouldThrowOnNullBiConsumer() {
assertThatThrownBy(() ->
ConcurrentTestRunner.builder()
.operation(null)
@@ -84,7 +84,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void awaitTerminationShouldNotThrowWhenFinished() {
+ void awaitTerminationShouldNotThrowWhenFinished() {
assertThatCode(() -> ConcurrentTestRunner.builder()
.operation(NOOP)
.threadCount(1)
@@ -93,7 +93,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void awaitTerminationShouldThrowWhenNotFinished() {
+ void awaitTerminationShouldThrowWhenNotFinished() {
assertThatThrownBy(() -> ConcurrentTestRunner.builder()
.operation((threadNumber, step) -> Thread.sleep(50))
.threadCount(1)
@@ -102,7 +102,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void runShouldPerformAllOperations() {
+ void runShouldPerformAllOperations() {
ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
assertThatCode(() -> ConcurrentTestRunner.builder()
@@ -116,7 +116,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void operationCountShouldDefaultToOne() {
+ void operationCountShouldDefaultToOne() {
ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
assertThatCode(() -> ConcurrentTestRunner.builder()
@@ -127,7 +127,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void runShouldNotThrowOnExceptions() {
+ void runShouldNotThrowOnExceptions() {
assertThatCode(() -> ConcurrentTestRunner.builder()
.operation((threadNumber, step) -> {
throw new RuntimeException();
@@ -139,7 +139,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void noExceptionsShouldNotThrowWhenNoExceptionGenerated() throws Exception {
+ void noExceptionsShouldNotThrowWhenNoExceptionGenerated() throws Exception {
ConcurrentTestRunner.builder()
.operation(NOOP)
.threadCount(2)
@@ -149,7 +149,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void assertNoExceptionShouldThrowOnExceptions() throws Exception {
+ void assertNoExceptionShouldThrowOnExceptions() throws Exception {
assertThatThrownBy(() ->
ConcurrentTestRunner.builder()
.operation((threadNumber, step) -> {
@@ -163,7 +163,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void runShouldPerformAllOperationsEvenOnExceptions() throws Exception {
+ void runShouldPerformAllOperationsEvenOnExceptions() throws Exception {
ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
ConcurrentTestRunner.builder()
@@ -179,7 +179,7 @@ public class ConcurrentTestRunnerTest {
}
@Test
- public void runShouldPerformAllOperationsEvenOnOccasionalExceptions() throws Exception {
+ void runShouldPerformAllOperationsEvenOnOccasionalExceptions() throws Exception {
ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
ConcurrentTestRunner.builder()
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/date/ImapDateTimeFormatterTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/date/ImapDateTimeFormatterTest.java b/server/container/util/src/test/java/org/apache/james/util/date/ImapDateTimeFormatterTest.java
index ec970fb..41c1046 100644
--- a/server/container/util/src/test/java/org/apache/james/util/date/ImapDateTimeFormatterTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/date/ImapDateTimeFormatterTest.java
@@ -19,6 +19,7 @@
package org.apache.james.util.date;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.time.DayOfWeek;
import java.time.Month;
@@ -26,227 +27,223 @@ import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeParseException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
public class ImapDateTimeFormatterTest {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
- public void dayOfWeekShouldBeParsed() {
+ void dayOfWeekShouldBeParsed() {
ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getDayOfWeek()).isEqualTo(DayOfWeek.WEDNESDAY);
}
@Test
- public void parseShouldNotThrowWhenDayOfWeekIsAbsent() {
+ void parseShouldNotThrowWhenDayOfWeekIsAbsent() {
ZonedDateTime.parse("28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
}
@Test
- public void parseShouldThrowWhenDayOfWeekIsWrong() {
- expectedException.expect(DateTimeParseException.class);
+ void parseShouldThrowWhenDayOfWeekIsWrong() {
// must be wednesday
- ZonedDateTime.parse("Mon, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThatThrownBy(() ->
+ ZonedDateTime.parse("Mon, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenDayOfWeekIsUnknow() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("Abc, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenDayOfWeekIsUnknow() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("Abc, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void dayOfWeekShouldBeParsedWhenOneDigit() {
+ void dayOfWeekShouldBeParsedWhenOneDigit() {
ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getDayOfMonth()).isEqualTo(3);
}
@Test
- public void dayOfWeekShouldBeParsedWhenTwoDigits() {
+ void dayOfWeekShouldBeParsedWhenTwoDigits() {
ZonedDateTime dateTime = ZonedDateTime.parse("13 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getDayOfMonth()).isEqualTo(13);
}
@Test
- public void parseShouldThrowWhenDayOfMonthIsAbsent() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenDayOfMonthIsAbsent() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenDayOfMonthIsNegative() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("-2 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenDayOfMonthIsNegative() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("-2 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenDayOfMonthIsUnknow() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("64 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenDayOfMonthIsUnknow() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("64 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void monthOfYearShouldBeParsed() {
+ void monthOfYearShouldBeParsed() {
ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getMonth()).isEqualTo(Month.JUNE);
}
@Test
- public void parseShouldThrowWhenMonthOfYearIsAbsent() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("Wed, 28 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenMonthOfYearIsAbsent() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("Wed, 28 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenMonthOfYearIsUnknow() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("Wed, 28 Abc 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenMonthOfYearIsUnknow() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("Wed, 28 Abc 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void yearShouldBeParsedWhenFourDigits() {
+ void yearShouldBeParsedWhenFourDigits() {
ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getYear()).isEqualTo(2017);
}
@Test
- public void yearShouldBeParsedWhenTwoDigitsGreaterThanInitialYear() {
+ void yearShouldBeParsedWhenTwoDigitsGreaterThanInitialYear() {
ZonedDateTime dateTime = ZonedDateTime.parse("28 Jun 77 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getYear()).isEqualTo(1977);
}
@Test
- public void yearShouldBeParsedWhenTwoDigitsLesserThanInitialYear() {
+ void yearShouldBeParsedWhenTwoDigitsLesserThanInitialYear() {
ZonedDateTime dateTime = ZonedDateTime.parse("28 Jun 64 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getYear()).isEqualTo(2064);
}
@Test
- public void parseShouldThrowWhenYearIsAbsent() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("Wed, 28 Jun 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenYearIsAbsent() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("Wed, 28 Jun 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenYearIsLesserThanTwoDigits() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("Wed, 28 Jun 1 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenYearIsLesserThanTwoDigits() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("Wed, 28 Jun 1 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenYearIsGreaterThanFourDigits() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("Wed, 28 Jun 12345 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenYearIsGreaterThanFourDigits() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("Wed, 28 Jun 12345 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void hourOfDayShouldBeParsed() {
+ void hourOfDayShouldBeParsed() {
ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getHour()).isEqualTo(4);
}
@Test
- public void parseShouldNotThrowWhenHourOfDayIsLesserThanTwoDigits() {
+ void parseShouldNotThrowWhenHourOfDayIsLesserThanTwoDigits() {
ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 4:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getHour()).isEqualTo(4);
}
@Test
- public void parseShouldThrowWhenHourOfDayIsAbsent() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("3 Jun 2017 :35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenHourOfDayIsAbsent() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("3 Jun 2017 :35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenHourOfDayIsGreaterThanTwoDigits() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("3 Jun 2017 123:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenHourOfDayIsGreaterThanTwoDigits() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("3 Jun 2017 123:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenHourOfDayIsUnknow() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("3 Jun 2017 48:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenHourOfDayIsUnknow() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("3 Jun 2017 48:35:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void minuteOfHourShouldBeParsed() {
+ void minuteOfHourShouldBeParsed() {
ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getMinute()).isEqualTo(35);
}
@Test
- public void parseShouldNotThrowWhenMinuteOfHourIsLesserThanTwoDigits() {
+ void parseShouldNotThrowWhenMinuteOfHourIsLesserThanTwoDigits() {
ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:5:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getMinute()).isEqualTo(5);
}
@Test
- public void parseShouldThrowWhenMinuteOfHourIsAbsent() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("3 Jun 2017 04::11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenMinuteOfHourIsAbsent() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("3 Jun 2017 04::11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenMinuteOfHourIsGreaterThanTwoDigits() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("3 Jun 2017 04:123:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenMinuteOfHourIsGreaterThanTwoDigits() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("3 Jun 2017 04:123:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenMinuteOfHourDayIsUnknow() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("3 Jun 2017 04:72:11 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenMinuteOfHourDayIsUnknow() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("3 Jun 2017 04:72:11 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void secondOfMinuteShouldBeParsed() {
+ void secondOfMinuteShouldBeParsed() {
ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getSecond()).isEqualTo(11);
}
@Test
- public void parseShouldNotThrowWhenSecondOfMinuteIsLesserThanTwoDigits() {
+ void parseShouldNotThrowWhenSecondOfMinuteIsLesserThanTwoDigits() {
ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:1 -0700", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getSecond()).isEqualTo(1);
}
@Test
- public void parseShouldNotThrowWhenSecondOfMinuteIsAbsent() {
+ void parseShouldNotThrowWhenSecondOfMinuteIsAbsent() {
ZonedDateTime.parse("28 Jun 2017 04:35 -0700", ImapDateTimeFormatter.rfc5322());
}
@Test
- public void parseShouldThrowWhenSecondOfMinuteIsGreaterThanTwoDigits() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("3 Jun 2017 04:35:123 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenSecondOfMinuteIsGreaterThanTwoDigits() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("3 Jun 2017 04:35:123 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenSecondOfMinuteDayIsUnknow() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("3 Jun 2017 04:35:78 -0700", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenSecondOfMinuteDayIsUnknow() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("3 Jun 2017 04:35:78 -0700", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void offsetShouldBeParsed() {
+ void offsetShouldBeParsed() {
ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0712", ImapDateTimeFormatter.rfc5322());
assertThat(dateTime.getOffset()).isEqualTo(ZoneOffset.ofHoursMinutes(-7, -12));
}
@Test
- public void parseShouldThrowWhenOffsetIsAbsent() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("3 Jun 2017 04:35:11", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenOffsetIsAbsent() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("3 Jun 2017 04:35:11", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
@Test
- public void parseShouldThrowWhenOffsetIsUnknow() {
- expectedException.expect(DateTimeParseException.class);
- ZonedDateTime.parse("3 Jun 2017 04:35:11 +7894", ImapDateTimeFormatter.rfc5322());
+ void parseShouldThrowWhenOffsetIsUnknow() {
+ assertThatThrownBy(() -> ZonedDateTime.parse("3 Jun 2017 04:35:11 +7894", ImapDateTimeFormatter.rfc5322()))
+ .isInstanceOf(DateTimeParseException.class);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/mime/MessageContentExtractorTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/mime/MessageContentExtractorTest.java b/server/container/util/src/test/java/org/apache/james/util/mime/MessageContentExtractorTest.java
index deae849..ecf0e5a 100644
--- a/server/container/util/src/test/java/org/apache/james/util/mime/MessageContentExtractorTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/mime/MessageContentExtractorTest.java
@@ -38,8 +38,8 @@ import org.apache.james.mime4j.message.MultipartBuilder;
import org.apache.james.mime4j.stream.Field;
import org.apache.james.mime4j.util.ByteSequence;
import org.apache.james.util.mime.MessageContentExtractor.MessageContent;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class MessageContentExtractorTest {
private static final String BINARY_CONTENT = "binary";
@@ -74,8 +74,8 @@ public class MessageContentExtractorTest {
private BodyPartBuilder inlineText;
private BodyPartBuilder inlineImage;
- @Before
- public void setup() throws IOException {
+ @BeforeEach
+ void setup() throws IOException {
testee = new MessageContentExtractor();
textPart = BodyPartBuilder.create().setBody(TEXT_CONTENT, "plain", StandardCharsets.UTF_8);
htmlPart = BodyPartBuilder.create().setBody(HTML_CONTENT, "html", StandardCharsets.UTF_8);
@@ -91,7 +91,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnEmptyWhenBinaryContentOnly() throws IOException {
+ void extractShouldReturnEmptyWhenBinaryContentOnly() throws IOException {
Message message = Message.Builder.of()
.setBody(BasicBodyFactory.INSTANCE.binaryBody(BINARY_CONTENT, StandardCharsets.UTF_8))
.build();
@@ -101,7 +101,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnTextOnlyWhenTextOnlyBody() throws IOException {
+ void extractShouldReturnTextOnlyWhenTextOnlyBody() throws IOException {
Message message = Message.Builder.of()
.setBody(TEXT_CONTENT, StandardCharsets.UTF_8)
.build();
@@ -111,7 +111,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnHtmlOnlyWhenHtmlOnlyBody() throws IOException {
+ void extractShouldReturnHtmlOnlyWhenHtmlOnlyBody() throws IOException {
Message message = Message.Builder.of()
.setBody(HTML_CONTENT, "html", StandardCharsets.UTF_8)
.build();
@@ -121,7 +121,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnHtmlAndTextWhenMultipartAlternative() throws IOException {
+ void extractShouldReturnHtmlAndTextWhenMultipartAlternative() throws IOException {
Multipart multipart = MultipartBuilder.create("alternative")
.addBodyPart(textPart)
.addBodyPart(htmlPart)
@@ -135,7 +135,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnHtmlWhenMultipartAlternativeWithoutPlainPart() throws IOException {
+ void extractShouldReturnHtmlWhenMultipartAlternativeWithoutPlainPart() throws IOException {
Multipart multipart = MultipartBuilder.create("alternative")
.addBodyPart(htmlPart)
.build();
@@ -148,7 +148,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnTextWhenMultipartAlternativeWithoutHtmlPart() throws IOException {
+ void extractShouldReturnTextWhenMultipartAlternativeWithoutHtmlPart() throws IOException {
Multipart multipart = MultipartBuilder.create("alternative")
.addBodyPart(textPart)
.build();
@@ -161,7 +161,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnFirstNonAttachmentPartWhenMultipartMixed() throws IOException {
+ void extractShouldReturnFirstNonAttachmentPartWhenMultipartMixed() throws IOException {
Multipart multipart = MultipartBuilder.create("mixed")
.addBodyPart(textAttachment)
.addBodyPart(htmlPart)
@@ -176,7 +176,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnInlinedTextBodyWithoutCIDWhenNoOtherValidParts() throws IOException {
+ void extractShouldReturnInlinedTextBodyWithoutCIDWhenNoOtherValidParts() throws IOException {
String textBody = "body 1";
Multipart multipart = MultipartBuilder.create("report")
.addBodyPart(BodyPartBuilder.create()
@@ -196,7 +196,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnEmptyWhenMultipartMixedAndFirstPartIsATextAttachment() throws IOException {
+ void extractShouldReturnEmptyWhenMultipartMixedAndFirstPartIsATextAttachment() throws IOException {
Multipart multipart = MultipartBuilder.create("mixed")
.addBodyPart(textAttachment)
.build();
@@ -209,7 +209,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnFirstPartOnlyWhenMultipartMixedAndFirstPartIsHtml() throws IOException {
+ void extractShouldReturnFirstPartOnlyWhenMultipartMixedAndFirstPartIsHtml() throws IOException {
Multipart multipart = MultipartBuilder.create("mixed")
.addBodyPart(htmlPart)
.addBodyPart(textPart)
@@ -223,7 +223,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnHtmlAndTextWhenMultipartMixedAndFirstPartIsMultipartAlternative() throws IOException {
+ void extractShouldReturnHtmlAndTextWhenMultipartMixedAndFirstPartIsMultipartAlternative() throws IOException {
BodyPart multipartAlternative = BodyPartBuilder.create()
.setBody(MultipartBuilder.create("alternative")
.addBodyPart(htmlPart)
@@ -242,7 +242,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnHtmlWhenMultipartRelated() throws IOException {
+ void extractShouldReturnHtmlWhenMultipartRelated() throws IOException {
Multipart multipart = MultipartBuilder.create("related")
.addBodyPart(htmlPart)
.build();
@@ -255,7 +255,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldReturnHtmlAndTextWhenMultipartAlternativeAndFirstPartIsMultipartRelated() throws IOException {
+ void extractShouldReturnHtmlAndTextWhenMultipartAlternativeAndFirstPartIsMultipartRelated() throws IOException {
BodyPart multipartRelated = BodyPartBuilder.create()
.setBody(MultipartBuilder.create("related")
.addBodyPart(htmlPart)
@@ -272,7 +272,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldRetrieveHtmlBodyWithOneInlinedHTMLAttachmentWithoutCid() throws IOException {
+ void extractShouldRetrieveHtmlBodyWithOneInlinedHTMLAttachmentWithoutCid() throws IOException {
//Given
BodyPart inlinedHTMLPart = BodyPartBuilder.create()
.setBody(HTML_CONTENT, "html", StandardCharsets.UTF_8)
@@ -296,7 +296,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldNotRetrieveHtmlBodyWithOneInlinedHTMLAttachmentWithCid() throws IOException {
+ void extractShouldNotRetrieveHtmlBodyWithOneInlinedHTMLAttachmentWithCid() throws IOException {
//Given
BodyPart inlinedHTMLPart = BodyPartBuilder.create()
.setBody(HTML_CONTENT, "html", StandardCharsets.UTF_8)
@@ -322,7 +322,7 @@ public class MessageContentExtractorTest {
@Test
- public void extractShouldRetrieveTextBodyWithOneInlinedTextAttachmentWithoutCid() throws IOException {
+ void extractShouldRetrieveTextBodyWithOneInlinedTextAttachmentWithoutCid() throws IOException {
//Given
BodyPart inlinedTextPart = BodyPartBuilder.create()
.setBody(TEXT_CONTENT, "text", StandardCharsets.UTF_8)
@@ -346,7 +346,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldNotRetrieveTextBodyWithOneInlinedTextAttachmentWithCid() throws IOException {
+ void extractShouldNotRetrieveTextBodyWithOneInlinedTextAttachmentWithCid() throws IOException {
//Given
BodyPart inlinedTextPart = BodyPartBuilder.create()
.setBody(TEXT_CONTENT, "text", StandardCharsets.UTF_8)
@@ -371,7 +371,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldRetrieveTextAndHtmlBodyWhenOneInlinedTextAttachmentAndMainContentInMultipart() throws IOException {
+ void extractShouldRetrieveTextAndHtmlBodyWhenOneInlinedTextAttachmentAndMainContentInMultipart() throws IOException {
BodyPart multipartAlternative = BodyPartBuilder.create()
.setBody(MultipartBuilder.create("alternative")
.addBodyPart(textPart)
@@ -394,7 +394,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldRetrieveTextBodyAndHtmlBodyWhenTextBodyInMainMultipartAndHtmlBodyInInnerMultipart() throws IOException {
+ void extractShouldRetrieveTextBodyAndHtmlBodyWhenTextBodyInMainMultipartAndHtmlBodyInInnerMultipart() throws IOException {
BodyPart multipartRelated = BodyPartBuilder.create()
.setBody(MultipartBuilder.create("related")
.addBodyPart(htmlPart)
@@ -417,7 +417,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void mergeMessageContentShouldReturnEmptyWhenAllEmpty() {
+ void mergeMessageContentShouldReturnEmptyWhenAllEmpty() {
MessageContent messageContent1 = MessageContent.empty();
MessageContent messageContent2 = MessageContent.empty();
MessageContent expected = MessageContent.empty();
@@ -428,7 +428,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void mergeMessageContentShouldReturnFirstWhenSecondEmpty() {
+ void mergeMessageContentShouldReturnFirstWhenSecondEmpty() {
MessageContent messageContent1 = new MessageContent(Optional.of(TEXT_CONTENT), Optional.of(HTML_CONTENT));
MessageContent messageContent2 = MessageContent.empty();
MessageContent expected = messageContent1;
@@ -439,7 +439,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void mergeMessageContentShouldReturnSecondWhenFirstEmpty() {
+ void mergeMessageContentShouldReturnSecondWhenFirstEmpty() {
MessageContent messageContent1 = MessageContent.empty();
MessageContent messageContent2 = new MessageContent(Optional.of(TEXT_CONTENT), Optional.of(HTML_CONTENT));
MessageContent expected = messageContent2;
@@ -450,7 +450,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void mergeMessageContentShouldReturnMixWhenFirstTextOnlyAndSecondHtmlOnly() {
+ void mergeMessageContentShouldReturnMixWhenFirstTextOnlyAndSecondHtmlOnly() {
MessageContent messageContent1 = MessageContent.ofTextOnly(Optional.of(TEXT_CONTENT));
MessageContent messageContent2 = MessageContent.ofHtmlOnly(Optional.of(HTML_CONTENT));
MessageContent expected = new MessageContent(Optional.of(TEXT_CONTENT), Optional.of(HTML_CONTENT));
@@ -461,7 +461,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void mergeMessageContentShouldReturnMixWhenFirstHtmlOnlyAndSecondTextOnly() {
+ void mergeMessageContentShouldReturnMixWhenFirstHtmlOnlyAndSecondTextOnly() {
MessageContent messageContent1 = MessageContent.ofHtmlOnly(Optional.of(HTML_CONTENT));
MessageContent messageContent2 = MessageContent.ofTextOnly(Optional.of(TEXT_CONTENT));
MessageContent expected = new MessageContent(Optional.of(TEXT_CONTENT), Optional.of(HTML_CONTENT));
@@ -472,7 +472,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void mergeMessageContentShouldReturnFirstWhenTwiceAreComplete() {
+ void mergeMessageContentShouldReturnFirstWhenTwiceAreComplete() {
MessageContent messageContent1 = new MessageContent(Optional.of(TEXT_CONTENT), Optional.of(HTML_CONTENT));
MessageContent messageContent2 = new MessageContent(Optional.of(TEXT_CONTENT2), Optional.of(HTML_CONTENT2));
MessageContent expected = messageContent1;
@@ -483,7 +483,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldRespectCharsetWhenOtherThanUTF8() throws IOException {
+ void extractShouldRespectCharsetWhenOtherThanUTF8() throws IOException {
String text = "éééé\r\nèèèè\r\nàààà";
Message message = Message.Builder.of()
.setBody(text, Charset.forName("windows-1252"))
@@ -493,7 +493,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldRespectCharsetWhenUTF8() throws IOException {
+ void extractShouldRespectCharsetWhenUTF8() throws IOException {
String text = "éééé\r\nèèèè\r\nàààà";
Message message = Message.Builder.of()
.setBody(text, StandardCharsets.UTF_8)
@@ -503,7 +503,7 @@ public class MessageContentExtractorTest {
}
@Test
- public void extractShouldUseUSASCIIWhenNoCharset() throws IOException {
+ void extractShouldUseUSASCIIWhenNoCharset() throws IOException {
String text = "éééé\r\nèèèè\r\nàààà";
Message message = Message.Builder.of()
.setBody(text, null)
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/retry/DoublingRetryScheduleTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/retry/DoublingRetryScheduleTest.java b/server/container/util/src/test/java/org/apache/james/util/retry/DoublingRetryScheduleTest.java
index 05f3e18..ba0faf9 100644
--- a/server/container/util/src/test/java/org/apache/james/util/retry/DoublingRetryScheduleTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/retry/DoublingRetryScheduleTest.java
@@ -22,62 +22,50 @@ package org.apache.james.util.retry;
import static org.assertj.core.api.Assertions.assertThat;
import org.apache.james.util.retry.api.RetrySchedule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-/**
- * <code>DoublingRetryScheduleTest</code>
- */
public class DoublingRetryScheduleTest {
- /**
- * Test method for .
- */
@Test
- public final void testDoublingRetrySchedule() {
- assertThat(RetrySchedule.class.isAssignableFrom(DoublingRetrySchedule.class)).isTrue();
- assertThat(new DoublingRetrySchedule(0, 0).getInterval(0)).isEqualTo(0);
- assertThat(new DoublingRetrySchedule(-1, -1).getInterval(0)).isEqualTo(0);
- assertThat(new DoublingRetrySchedule(-1, 0).getInterval(0)).isEqualTo(0);
- assertThat(new DoublingRetrySchedule(0, -1).getInterval(0)).isEqualTo(0);
+ void testDoublingRetrySchedule() {
+ assertThat(RetrySchedule.class.isAssignableFrom(DoublingRetrySchedule.class)).isTrue();
+ assertThat(new DoublingRetrySchedule(0, 0).getInterval(0)).isEqualTo(0);
+ assertThat(new DoublingRetrySchedule(-1, -1).getInterval(0)).isEqualTo(0);
+ assertThat(new DoublingRetrySchedule(-1, 0).getInterval(0)).isEqualTo(0);
+ assertThat(new DoublingRetrySchedule(0, -1).getInterval(0)).isEqualTo(0);
}
- /**
- * Test method for .
- */
@Test
- public final void testGetInterval() {
- assertThat(new DoublingRetrySchedule(0, 8).getInterval(0)).isEqualTo(0);
- assertThat(new DoublingRetrySchedule(0, 8).getInterval(1)).isEqualTo(1);
- assertThat(new DoublingRetrySchedule(0, 8).getInterval(2)).isEqualTo(2);
- assertThat(new DoublingRetrySchedule(0, 8).getInterval(3)).isEqualTo(4);
- assertThat(new DoublingRetrySchedule(0, 8).getInterval(4)).isEqualTo(8);
- assertThat(new DoublingRetrySchedule(0, 8).getInterval(5)).isEqualTo(8);
+ void testGetInterval() {
+ assertThat(new DoublingRetrySchedule(0, 8).getInterval(0)).isEqualTo(0);
+ assertThat(new DoublingRetrySchedule(0, 8).getInterval(1)).isEqualTo(1);
+ assertThat(new DoublingRetrySchedule(0, 8).getInterval(2)).isEqualTo(2);
+ assertThat(new DoublingRetrySchedule(0, 8).getInterval(3)).isEqualTo(4);
+ assertThat(new DoublingRetrySchedule(0, 8).getInterval(4)).isEqualTo(8);
+ assertThat(new DoublingRetrySchedule(0, 8).getInterval(5)).isEqualTo(8);
- assertThat(new DoublingRetrySchedule(1, 8).getInterval(0)).isEqualTo(1);
- assertThat(new DoublingRetrySchedule(1, 8).getInterval(1)).isEqualTo(2);
- assertThat(new DoublingRetrySchedule(1, 8).getInterval(2)).isEqualTo(4);
- assertThat(new DoublingRetrySchedule(1, 8).getInterval(3)).isEqualTo(8);
- assertThat(new DoublingRetrySchedule(1, 8).getInterval(4)).isEqualTo(8);
+ assertThat(new DoublingRetrySchedule(1, 8).getInterval(0)).isEqualTo(1);
+ assertThat(new DoublingRetrySchedule(1, 8).getInterval(1)).isEqualTo(2);
+ assertThat(new DoublingRetrySchedule(1, 8).getInterval(2)).isEqualTo(4);
+ assertThat(new DoublingRetrySchedule(1, 8).getInterval(3)).isEqualTo(8);
+ assertThat(new DoublingRetrySchedule(1, 8).getInterval(4)).isEqualTo(8);
- assertThat(new DoublingRetrySchedule(3, 12).getInterval(0)).isEqualTo(3);
- assertThat(new DoublingRetrySchedule(3, 12).getInterval(1)).isEqualTo(6);
- assertThat(new DoublingRetrySchedule(3, 12).getInterval(2)).isEqualTo(12);
- assertThat(new DoublingRetrySchedule(3, 12).getInterval(3)).isEqualTo(12);
+ assertThat(new DoublingRetrySchedule(3, 12).getInterval(0)).isEqualTo(3);
+ assertThat(new DoublingRetrySchedule(3, 12).getInterval(1)).isEqualTo(6);
+ assertThat(new DoublingRetrySchedule(3, 12).getInterval(2)).isEqualTo(12);
+ assertThat(new DoublingRetrySchedule(3, 12).getInterval(3)).isEqualTo(12);
- assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(0)).isEqualTo(0);
- assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(1)).isEqualTo(1000);
- assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(2)).isEqualTo(2000);
- assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(3)).isEqualTo(4000);
- assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(4)).isEqualTo(8000);
- assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(5)).isEqualTo(8000);
+ assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(0)).isEqualTo(0);
+ assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(1)).isEqualTo(1000);
+ assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(2)).isEqualTo(2000);
+ assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(3)).isEqualTo(4000);
+ assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(4)).isEqualTo(8000);
+ assertThat(new DoublingRetrySchedule(0, 8, 1000).getInterval(5)).isEqualTo(8000);
}
- /**
- * Test method for .
- */
@Test
- public final void testToString() {
- assertThat(new DoublingRetrySchedule(0,
- 1).toString()).isEqualTo("DoublingRetrySchedule [startInterval=0, maxInterval=1, multiplier=1]");
+ void testToString() {
+ assertThat(new DoublingRetrySchedule(0, 1).toString())
+ .isEqualTo("DoublingRetrySchedule [startInterval=0, maxInterval=1, multiplier=1]");
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java b/server/container/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java
index 800ca50..a61f05f 100644
--- a/server/container/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/retry/ExceptionRetryHandlerTest.java
@@ -29,8 +29,8 @@ import javax.naming.Context;
import org.apache.james.util.retry.api.ExceptionRetryingProxy;
import org.apache.james.util.retry.api.RetryHandler;
import org.apache.james.util.retry.api.RetrySchedule;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class ExceptionRetryHandlerTest {
private static class TestRetryingProxy implements ExceptionRetryingProxy {
@@ -54,15 +54,15 @@ public class ExceptionRetryHandlerTest {
private ExceptionRetryingProxy proxy = null;
private RetrySchedule schedule = null;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
exceptionClasses = new Class<?>[]{Exception.class};
proxy = new TestRetryingProxy();
schedule = i -> i;
}
@Test
- public final void testExceptionRetryHandler() {
+ void testExceptionRetryHandler() {
assertThat(RetryHandler.class.isAssignableFrom(new ExceptionRetryHandler(
exceptionClasses, proxy, schedule, 0) {
@@ -74,7 +74,7 @@ public class ExceptionRetryHandlerTest {
}
@Test
- public final void testPerform() throws Exception {
+ void testPerform() throws Exception {
Object result = new ExceptionRetryHandler(
exceptionClasses, proxy, schedule, 0) {
@@ -101,7 +101,7 @@ public class ExceptionRetryHandlerTest {
}
@Test
- public final void testPostFailure() {
+ void testPostFailure() {
final List<Exception> results = new ArrayList<>();
RetryHandler handler = new ExceptionRetryHandler(
exceptionClasses, proxy, schedule, 7) {
@@ -126,7 +126,7 @@ public class ExceptionRetryHandlerTest {
}
@Test
- public final void testOperation() throws Exception {
+ void testOperation() throws Exception {
RetryHandler handler = new ExceptionRetryHandler(
exceptionClasses, proxy, schedule, 0) {
@@ -139,7 +139,7 @@ public class ExceptionRetryHandlerTest {
}
@Test
- public final void testGetRetryInterval() {
+ void testGetRetryInterval() {
ExceptionRetryHandler handler = new ExceptionRetryHandler(
exceptionClasses, proxy, schedule, 0) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/retry/RetryExecutorUtilTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/retry/RetryExecutorUtilTest.java b/server/container/util/src/test/java/org/apache/james/util/retry/RetryExecutorUtilTest.java
index 28307fb..3af80ca 100644
--- a/server/container/util/src/test/java/org/apache/james/util/retry/RetryExecutorUtilTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/retry/RetryExecutorUtilTest.java
@@ -30,9 +30,9 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import org.apache.james.util.concurrent.NamedThreadFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -48,20 +48,20 @@ public class RetryExecutorUtilTest {
private RetryExecutor retryExecutor;
private ScheduledExecutorService scheduledExecutor;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
ThreadFactory threadFactory = NamedThreadFactory.withClassName(getClass());
scheduledExecutor = Executors.newSingleThreadScheduledExecutor(threadFactory);
}
- @After
- public void tearDown() throws Exception {
+ @AfterEach
+ void tearDown() throws Exception {
scheduledExecutor.shutdownNow();
}
@Test
- public void retryOnExceptionsAndExecuteShouldRethrowWhenScheduledServiceAlwaysThrowException() throws Exception {
+ void retryOnExceptionsAndExecuteShouldRethrowWhenScheduledServiceAlwaysThrowException() throws Exception {
given(serviceMock.faultyService())
.willThrow(IllegalArgumentException.class)
.willThrow(IllegalArgumentException.class)
@@ -76,7 +76,7 @@ public class RetryExecutorUtilTest {
}
@Test
- public void retryOnExceptionsAndExecuteShouldRetryWhenMatchExceptionAndSuccess() throws Exception {
+ void retryOnExceptionsAndExecuteShouldRetryWhenMatchExceptionAndSuccess() throws Exception {
given(serviceMock.faultyService())
.willThrow(IllegalArgumentException.class)
.willReturn("Foo");
@@ -88,7 +88,7 @@ public class RetryExecutorUtilTest {
}
@Test
- public void retryOnExceptionsAndExecuteShouldNotRetryWhenDoesNotMatchException() throws Exception {
+ void retryOnExceptionsAndExecuteShouldNotRetryWhenDoesNotMatchException() throws Exception {
given(serviceMock.faultyService())
.willThrow(IllegalStateException.class)
.willReturn("Foo");
@@ -102,7 +102,7 @@ public class RetryExecutorUtilTest {
@Test
@SuppressWarnings("unchecked")
- public void retryOnExceptionsAndExecuteShouldRetryWithMaxTimesAndReturnValue() throws Exception {
+ void retryOnExceptionsAndExecuteShouldRetryWithMaxTimesAndReturnValue() throws Exception {
given(serviceMock.faultyService())
.willThrow(IllegalStateException.class, IllegalStateException.class, IllegalStateException.class)
.willReturn("Foo");
@@ -116,7 +116,7 @@ public class RetryExecutorUtilTest {
@Test
@SuppressWarnings("unchecked")
- public void retryOnExceptionsAndExecuteShouldFailIfFailMoreThanMaxRetry() throws Exception {
+ void retryOnExceptionsAndExecuteShouldFailIfFailMoreThanMaxRetry() throws Exception {
given(serviceMock.faultyService())
.willThrow(IllegalStateException.class, IllegalStateException.class, IllegalStateException.class, IllegalStateException.class)
.willReturn("Foo");
@@ -127,4 +127,4 @@ public class RetryExecutorUtilTest {
.isInstanceOf(ExecutionException.class)
.hasCauseInstanceOf(IllegalStateException.class);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/retry/naming/NamingExceptionRetryHandlerTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/retry/naming/NamingExceptionRetryHandlerTest.java b/server/container/util/src/test/java/org/apache/james/util/retry/naming/NamingExceptionRetryHandlerTest.java
index 6b5cf36..2bb357a 100644
--- a/server/container/util/src/test/java/org/apache/james/util/retry/naming/NamingExceptionRetryHandlerTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/retry/naming/NamingExceptionRetryHandlerTest.java
@@ -27,8 +27,7 @@ import javax.naming.NamingException;
import org.apache.james.util.retry.api.ExceptionRetryingProxy;
import org.apache.james.util.retry.api.RetryHandler;
import org.apache.james.util.retry.api.RetrySchedule;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class NamingExceptionRetryHandlerTest {
@@ -48,19 +47,12 @@ public class NamingExceptionRetryHandlerTest {
}
}
- private Class<?>[] exceptionClasses;
- private ExceptionRetryingProxy proxy;
- private RetrySchedule schedule;
-
- @Before
- public void setUp() throws Exception {
- exceptionClasses = new Class<?>[]{NamingException.class};
- proxy = new TestRetryingProxy();
- schedule = i -> i;
- }
+ private static final Class<?>[] exceptionClasses = new Class<?>[]{NamingException.class};
+ private static final ExceptionRetryingProxy proxy = new TestRetryingProxy();
+ private static final RetrySchedule schedule = i -> i;
@Test
- public void testExceptionRetryHandler() {
+ void testExceptionRetryHandler() {
assertThat(RetryHandler.class.isAssignableFrom(new NamingExceptionRetryHandler(
exceptionClasses, proxy, schedule, 0) {
@@ -72,7 +64,7 @@ public class NamingExceptionRetryHandlerTest {
}
@Test
- public void testPerform() throws NamingException {
+ void testPerform() throws NamingException {
Object result = new NamingExceptionRetryHandler(
exceptionClasses, proxy, schedule, 0) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/streams/ImmutableCollectorsTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/streams/ImmutableCollectorsTest.java b/server/container/util/src/test/java/org/apache/james/util/streams/ImmutableCollectorsTest.java
index 8c9c98b..d6f1bf2 100644
--- a/server/container/util/src/test/java/org/apache/james/util/streams/ImmutableCollectorsTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/streams/ImmutableCollectorsTest.java
@@ -28,7 +28,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.github.steveash.guavate.Guavate;
import com.google.common.collect.ImmutableList;
@@ -38,25 +38,25 @@ import com.google.common.collect.ImmutableSet;
public class ImmutableCollectorsTest {
@Test
- public void immutableListCollectorShouldReturnEmptyImmutableListWhenEmptyStream() {
+ void immutableListCollectorShouldReturnEmptyImmutableListWhenEmptyStream() {
String[] data = {};
List<String> actual = Arrays.stream(data)
.collect(Guavate.toImmutableList());
assertThat(actual).isInstanceOf(ImmutableList.class);
assertThat(actual).isEmpty();
}
-
+
@Test
- public void immutableListCollectorShouldReturnImmutableListWhenOneElementStream() {
+ void immutableListCollectorShouldReturnImmutableListWhenOneElementStream() {
String[] data = {"a"};
List<String> actual = Arrays.stream(data)
.collect(Guavate.toImmutableList());
assertThat(actual).isInstanceOf(ImmutableList.class);
assertThat(actual).containsExactly("a");
}
-
+
@Test
- public void immutableListCollectorShouldReturnImmutableListWhen3ElementsStream() {
+ void immutableListCollectorShouldReturnImmutableListWhen3ElementsStream() {
String[] data = {"a", "b", "c"};
List<String> actual = Arrays.stream(data)
.collect(Guavate.toImmutableList());
@@ -65,7 +65,7 @@ public class ImmutableCollectorsTest {
}
@Test
- public void immutableSetCollectorShouldReturnEmptyImmutableSetWhenEmptyStream() {
+ void immutableSetCollectorShouldReturnEmptyImmutableSetWhenEmptyStream() {
String[] data = {};
Set<String> actual = Arrays.stream(data)
.collect(Guavate.toImmutableSet());
@@ -74,7 +74,7 @@ public class ImmutableCollectorsTest {
}
@Test
- public void immutableSetCollectorShouldReturnImmutableSetWhenOneElementStream() {
+ void immutableSetCollectorShouldReturnImmutableSetWhenOneElementStream() {
String[] data = {"a"};
Set<String> actual = Arrays.stream(data)
.collect(Guavate.toImmutableSet());
@@ -83,7 +83,7 @@ public class ImmutableCollectorsTest {
}
@Test
- public void immutableSetCollectorShouldReturnImmutableSetWhen3ElementsStream() {
+ void immutableSetCollectorShouldReturnImmutableSetWhen3ElementsStream() {
String[] data = {"a", "b", "c"};
Set<String> actual = Arrays.stream(data)
.collect(Guavate.toImmutableSet());
@@ -93,31 +93,31 @@ public class ImmutableCollectorsTest {
@Test
- public void immutableMapCollectorShouldReturnEmptyImmutableMapWhenEmptyStream() {
+ void immutableMapCollectorShouldReturnEmptyImmutableMapWhenEmptyStream() {
String[] data = {};
Map<String, Integer> actual = Arrays.stream(data)
.collect(Guavate.toImmutableMap(x -> x.toUpperCase(Locale.US), String::length));
assertThat(actual).isInstanceOf(ImmutableMap.class);
assertThat(actual).isEmpty();
}
-
+
@Test
- public void immutableMapCollectorShouldReturnAppliedImmutableMapWhenOneElementStream() {
+ void immutableMapCollectorShouldReturnAppliedImmutableMapWhenOneElementStream() {
String[] data = {"a"};
Map<String, Integer> actual = Arrays.stream(data)
.collect(Guavate.toImmutableMap(x -> x.toUpperCase(Locale.US), String::length));
assertThat(actual).isInstanceOf(ImmutableMap.class);
assertThat(actual).containsExactly(entry("A", 1));
}
-
+
@Test
- public void immutableMapCollectorShouldReturnAppliedImmutableMapWhen3ElementsStream() {
+ void immutableMapCollectorShouldReturnAppliedImmutableMapWhen3ElementsStream() {
String[] data = {"a", "bb", "ccc"};
Map<String, Integer> actual = Arrays.stream(data)
.collect(Guavate.toImmutableMap(x -> x.toUpperCase(Locale.US), String::length));
assertThat(actual).isInstanceOf(ImmutableMap.class);
assertThat(actual).containsExactly(entry("A", 1), entry("BB", 2), entry("CCC", 3));
}
-
+
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/streams/IteratorsTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/streams/IteratorsTest.java b/server/container/util/src/test/java/org/apache/james/util/streams/IteratorsTest.java
index 4c63f1a..e596ef1 100644
--- a/server/container/util/src/test/java/org/apache/james/util/streams/IteratorsTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/streams/IteratorsTest.java
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.stream.Stream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.UnmodifiableIterator;
@@ -32,7 +32,7 @@ import com.google.common.collect.UnmodifiableIterator;
public class IteratorsTest {
@Test
- public void toStreamShouldReturnEmptyStreamWhenEmptyIterator() {
+ void toStreamShouldReturnEmptyStreamWhenEmptyIterator() {
//Given
UnmodifiableIterator<String> emptyIterator = ImmutableList.<String>of().iterator();
@@ -44,7 +44,7 @@ public class IteratorsTest {
}
@Test
- public void toStreamShouldReturnSameContent() {
+ void toStreamShouldReturnSameContent() {
//Given
UnmodifiableIterator<String> iterator = ImmutableList.of("a", "b", "c").iterator();
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/streams/JamesCollectorsTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/streams/JamesCollectorsTest.java b/server/container/util/src/test/java/org/apache/james/util/streams/JamesCollectorsTest.java
index 52f1c3a..8cca6bf 100644
--- a/server/container/util/src/test/java/org/apache/james/util/streams/JamesCollectorsTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/streams/JamesCollectorsTest.java
@@ -20,24 +20,20 @@
package org.apache.james.util.streams;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import java.util.List;
import java.util.stream.Stream;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import com.github.steveash.guavate.Guavate;
import com.google.common.collect.ImmutableList;
public class JamesCollectorsTest {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
- public void chunkerShouldAcceptEmptyStrem() {
+ void chunkerShouldAcceptEmptyStrem() {
Stream<Integer> emptyStream = Stream.of();
assertThat(emptyStream.collect(JamesCollectors.chunker(10))
@@ -46,21 +42,19 @@ public class JamesCollectorsTest {
}
@Test
- public void chunkerShouldThrowOnZeroChunkSize() {
- expectedException.expect(IllegalArgumentException.class);
-
- JamesCollectors.chunker(0);
+ void chunkerShouldThrowOnZeroChunkSize() {
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> JamesCollectors.chunker(0));
}
@Test
- public void chunkerShouldThrowOnNegativeChunkSize() {
- expectedException.expect(IllegalArgumentException.class);
-
- JamesCollectors.chunker(-1);
+ void chunkerShouldThrowOnNegativeChunkSize() {
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> JamesCollectors.chunker(-1));
}
@Test
- public void chunkerShouldChunkMonoValueStreams() {
+ void chunkerShouldChunkMonoValueStreams() {
Stream<Integer> monoValueStream = Stream.of(1);
List<List<Integer>> values = monoValueStream.collect(JamesCollectors.chunker(10))
@@ -71,7 +65,7 @@ public class JamesCollectorsTest {
}
@Test
- public void chunkerShouldChunkStreamsSmallerThanChunkSize() {
+ void chunkerShouldChunkStreamsSmallerThanChunkSize() {
Stream<Integer> stream = Stream.of(1, 2);
List<List<Integer>> values = stream.collect(JamesCollectors.chunker(3))
@@ -82,7 +76,7 @@ public class JamesCollectorsTest {
}
@Test
- public void chunkerShouldChunkStreamsAsBigAsChunkSize() {
+ void chunkerShouldChunkStreamsAsBigAsChunkSize() {
Stream<Integer> stream = Stream.of(1, 2, 3);
List<List<Integer>> values = stream.collect(JamesCollectors.chunker(3))
@@ -93,7 +87,7 @@ public class JamesCollectorsTest {
}
@Test
- public void chunkerShouldChunkStreamsBiggerThanChunkSize() {
+ void chunkerShouldChunkStreamsBiggerThanChunkSize() {
Stream<Integer> stream = Stream.of(1, 2, 3, 4);
List<List<Integer>> values = stream.collect(JamesCollectors.chunker(3))
@@ -106,7 +100,7 @@ public class JamesCollectorsTest {
}
@Test
- public void chunkerShouldChunkInSeveralBuckets() {
+ void chunkerShouldChunkInSeveralBuckets() {
Stream<Integer> stream = Stream.of(1, 2, 3, 4, 5, 6, 7);
List<List<Integer>> values = stream.collect(JamesCollectors.chunker(3))
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/streams/LimitTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/streams/LimitTest.java b/server/container/util/src/test/java/org/apache/james/util/streams/LimitTest.java
index fcd92d8..2a1d35b 100644
--- a/server/container/util/src/test/java/org/apache/james/util/streams/LimitTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/streams/LimitTest.java
@@ -20,13 +20,12 @@
package org.apache.james.util.streams;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import java.util.List;
import java.util.Optional;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import com.github.steveash.guavate.Guavate;
import com.google.common.collect.ImmutableList;
@@ -37,23 +36,20 @@ public class LimitTest {
private final List<Integer> aList = ImmutableList.of(1, 2, 3, 4, 5, 6);
- @Rule
- public final ExpectedException expectedException = ExpectedException.none();
-
@Test
- public void unlimitedShouldCreateLimitWithNoLimit() {
+ void unlimitedShouldCreateLimitWithNoLimit() {
Limit testee = Limit.unlimited();
assertThat(testee.getLimit()).isEqualTo(Optional.empty());
}
@Test
- public void beanShouldRespectBeanContract() {
+ void beanShouldRespectBeanContract() {
EqualsVerifier.forClass(Limit.class)
.verify();
}
@Test
- public void unlimitedShouldCreateLimitThatDoesNotAffectStream() {
+ void unlimitedShouldCreateLimitThatDoesNotAffectStream() {
Limit testee = Limit.unlimited();
assertThat(
@@ -64,7 +60,7 @@ public class LimitTest {
}
@Test
- public void limitShouldCreateLimitWithNoLimit() {
+ void limitShouldCreateLimitWithNoLimit() {
int expected = 3;
Limit testee = Limit.limit(expected);
@@ -73,7 +69,7 @@ public class LimitTest {
}
@Test
- public void limitShouldCreateLimitThatCorrectlyTruncateStream() {
+ void limitShouldCreateLimitThatCorrectlyTruncateStream() {
Limit testee = Limit.limit(3);
assertThat(testee
@@ -83,33 +79,33 @@ public class LimitTest {
}
@Test
- public void limitShouldThrowAnErrorWhenCalledWithZero() {
- expectedException.expect(IllegalArgumentException.class);
- Limit.limit(0);
+ void limitShouldThrowAnErrorWhenCalledWithZero() {
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> Limit.limit(0));
}
@Test
- public void limitShouldThrowAnErrorWhenCalledWithNegativeValue() {
- expectedException.expect(IllegalArgumentException.class);
- Limit.limit(-1);
+ void limitShouldThrowAnErrorWhenCalledWithNegativeValue() {
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> Limit.limit(-1));
}
@Test
- public void ofShouldTakePositiveValueAsLimit() {
+ void ofShouldTakePositiveValueAsLimit() {
assertThat(Limit.from(3))
.isEqualTo(Limit.limit(3));
}
@Test
- public void ofShouldTakeNegativeValueAsUnlimited() {
+ void ofShouldTakeNegativeValueAsUnlimited() {
assertThat(Limit.from(-1))
.isEqualTo(Limit.unlimited());
}
@Test
- public void ofShouldTakeZeroValueAsUnlimited() {
+ void ofShouldTakeZeroValueAsUnlimited() {
assertThat(Limit.from(0))
.isEqualTo(Limit.unlimited());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/streams/OffsetTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/streams/OffsetTest.java b/server/container/util/src/test/java/org/apache/james/util/streams/OffsetTest.java
index 45d8e6d..f62762e 100644
--- a/server/container/util/src/test/java/org/apache/james/util/streams/OffsetTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/streams/OffsetTest.java
@@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
@@ -32,27 +32,27 @@ public class OffsetTest {
public static final int VALUE = 18;
@Test
- public void shouldMatchBeanContract() {
+ void shouldMatchBeanContract() {
EqualsVerifier.forClass(Offset.class)
.verify();
}
@Test
- public void fromZeroShouldBeEquivalentToNone() {
+ void fromZeroShouldBeEquivalentToNone() {
assertThat(Offset.from(0))
.isEqualTo(Offset.none());
}
@Test
- public void getOffsetShouldReturnContainedValue() {
+ void getOffsetShouldReturnContainedValue() {
assertThat(Offset.from(VALUE).getOffset())
.isEqualTo(VALUE);
}
@Test
- public void fromOptionalShouldBeEquivalentToFromValueWhenPresent() {
+ void fromOptionalShouldBeEquivalentToFromValueWhenPresent() {
assertThat(Offset.from(Optional.of(VALUE)))
.isEqualTo(Offset.from(VALUE));
}
-}
\ No newline at end of file
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[6/7] james-project git commit: JAMES-2611 Fix typo
Posted by ro...@apache.org.
JAMES-2611 Fix typo
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e11a3a76
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e11a3a76
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e11a3a76
Branch: refs/heads/master
Commit: e11a3a76b94e29d4ed9237fa99a249c935095833
Parents: 5fb1525
Author: Gautier DI FOLCO <gd...@linagora.com>
Authored: Tue Nov 27 17:22:49 2018 +0100
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Tue Dec 18 13:56:45 2018 +0100
----------------------------------------------------------------------
.../server/core/configuration/FileConfigurationProvider.java | 4 ++--
.../org/apache/james/utils/FileConfigurationProviderTest.java | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/e11a3a76/server/container/core/src/main/java/org/apache/james/server/core/configuration/FileConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/configuration/FileConfigurationProvider.java b/server/container/core/src/main/java/org/apache/james/server/core/configuration/FileConfigurationProvider.java
index 1fcfe6b..b36db81 100644
--- a/server/container/core/src/main/java/org/apache/james/server/core/configuration/FileConfigurationProvider.java
+++ b/server/container/core/src/main/java/org/apache/james/server/core/configuration/FileConfigurationProvider.java
@@ -44,7 +44,7 @@ public class FileConfigurationProvider implements ConfigurationProvider {
private static final String CONFIGURATION_FILE_SUFFIX = ".xml";
private static final char SEMICOLON = ';';
- public static final HierarchicalConfiguration EMTY_CONFIGURATION = new HierarchicalConfiguration();
+ public static final HierarchicalConfiguration EMPTY_CONFIGURATION = new HierarchicalConfiguration();
public static XMLConfiguration getConfig(InputStream configStream) throws ConfigurationException {
PropertiesConfiguration.setDefaultListDelimiter(SEMICOLON);
@@ -74,7 +74,7 @@ public class FileConfigurationProvider implements ConfigurationProvider {
return selectConfigurationPart(configPathParts,
getConfig(inputStream.get()));
}
- return EMTY_CONFIGURATION;
+ return EMPTY_CONFIGURATION;
}
private HierarchicalConfiguration selectConfigurationPart(List<String> configPathParts, HierarchicalConfiguration config) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/e11a3a76/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
index 8fc061a..dc4217b 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/FileConfigurationProviderTest.java
@@ -125,7 +125,7 @@ public class FileConfigurationProviderTest {
@Test
public void getConfigurationShouldReturnDefaultOnNonExistingXMLFile() throws Exception {
- assertThat(configurationProvider.getConfiguration(FAKE_CONFIG_KEY)).isEqualTo(FileConfigurationProvider.EMTY_CONFIGURATION);
+ assertThat(configurationProvider.getConfiguration(FAKE_CONFIG_KEY)).isEqualTo(FileConfigurationProvider.EMPTY_CONFIGURATION);
}
@Test(expected = IllegalArgumentException.class)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[2/7] james-project git commit: JAMES-2611 Migrate james-server-util
to JUNIT5
Posted by ro...@apache.org.
JAMES-2611 Migrate james-server-util to JUNIT5
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/c0b58116
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/c0b58116
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/c0b58116
Branch: refs/heads/master
Commit: c0b5811650f7cd92857fdd960227992370d78071
Parents: e11a3a7
Author: Gautier DI FOLCO <gd...@linagora.com>
Authored: Wed Nov 28 11:31:08 2018 +0100
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Tue Dec 18 13:56:45 2018 +0100
----------------------------------------------------------------------
.../james/util/BodyOffsetInputStreamTest.java | 22 ++-
.../james/util/CommutativityCheckerTest.java | 20 +--
.../james/util/CompletableFutureUtilTest.java | 64 +++----
.../james/util/FluentFutureStreamTest.java | 46 ++---
.../org/apache/james/util/GuavaUtilsTest.java | 12 +-
.../java/org/apache/james/util/HostTest.java | 119 +++++--------
.../apache/james/util/IteratorWrapperTest.java | 23 +--
.../org/apache/james/util/MDCBuilderTest.java | 40 ++---
.../apache/james/util/OptionalUtilsTest.java | 69 ++++----
.../java/org/apache/james/util/PortTest.java | 26 +--
.../org/apache/james/util/SizeFormatTest.java | 24 +--
.../java/org/apache/james/util/SizeTest.java | 31 ++--
.../org/apache/james/util/StreamUtilsTest.java | 24 +--
.../apache/james/util/TimeConverterTest.java | 172 ++++++++++---------
.../org/apache/james/util/ValuePatchTest.java | 70 ++++----
.../concurrency/ConcurrentTestRunnerTest.java | 30 ++--
.../util/date/ImapDateTimeFormatterTest.java | 161 +++++++++--------
.../util/mime/MessageContentExtractorTest.java | 64 +++----
.../util/retry/DoublingRetryScheduleTest.java | 76 ++++----
.../util/retry/ExceptionRetryHandlerTest.java | 18 +-
.../james/util/retry/RetryExecutorUtilTest.java | 26 +--
.../naming/NamingExceptionRetryHandlerTest.java | 20 +--
.../util/streams/ImmutableCollectorsTest.java | 30 ++--
.../james/util/streams/IteratorsTest.java | 6 +-
.../james/util/streams/JamesCollectorsTest.java | 34 ++--
.../apache/james/util/streams/LimitTest.java | 38 ++--
.../apache/james/util/streams/OffsetTest.java | 12 +-
27 files changed, 600 insertions(+), 677 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/BodyOffsetInputStreamTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/BodyOffsetInputStreamTest.java b/server/container/util/src/test/java/org/apache/james/util/BodyOffsetInputStreamTest.java
index 5826c7f..cf3a09e 100644
--- a/server/container/util/src/test/java/org/apache/james/util/BodyOffsetInputStreamTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/BodyOffsetInputStreamTest.java
@@ -23,17 +23,17 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class BodyOffsetInputStreamTest {
private String mail = "Subject: test\r\n\r\nbody";
private long expectedOffset = 17;
private long bytes = mail.length();
-
+
@Test
- public void testRead() throws IOException {
+ void testRead() throws IOException {
BodyOffsetInputStream in = new BodyOffsetInputStream(new ByteArrayInputStream(mail.getBytes()));
-
+
while (in.read() != -1) {
// consume stream
}
@@ -41,12 +41,11 @@ public class BodyOffsetInputStreamTest {
assertThat(in.getReadBytes()).isEqualTo(bytes);
in.close();
}
-
-
+
@Test
- public void testReadWithArray() throws IOException {
+ void testReadWithArray() throws IOException {
BodyOffsetInputStream in = new BodyOffsetInputStream(new ByteArrayInputStream(mail.getBytes()));
-
+
byte[] b = new byte[8];
while (in.read(b) != -1) {
// consume stream
@@ -55,12 +54,11 @@ public class BodyOffsetInputStreamTest {
assertThat(in.getReadBytes()).isEqualTo(bytes);
in.close();
}
-
-
+
@Test
- public void testReadWithArrayBiggerThenStream() throws IOException {
+ void testReadWithArrayBiggerThenStream() throws IOException {
BodyOffsetInputStream in = new BodyOffsetInputStream(new ByteArrayInputStream(mail.getBytes()));
-
+
byte[] b = new byte[4096];
while (in.read(b) != -1) {
// consume stream
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/CommutativityCheckerTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/CommutativityCheckerTest.java b/server/container/util/src/test/java/org/apache/james/util/CommutativityCheckerTest.java
index ec0802a..d0b9dac 100644
--- a/server/container/util/src/test/java/org/apache/james/util/CommutativityCheckerTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/CommutativityCheckerTest.java
@@ -26,13 +26,13 @@ import java.util.Set;
import java.util.function.BinaryOperator;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.google.common.collect.ImmutableSet;
public class CommutativityCheckerTest {
@Test
- public void constructorShouldThrowWhenNullValuesToTest() throws Exception {
+ void constructorShouldThrowWhenNullValuesToTest() throws Exception {
BinaryOperator<Integer> binaryOperator = (a, b) -> a * a + b;
assertThatThrownBy(() -> new CommutativityChecker<>(null, binaryOperator))
@@ -40,7 +40,7 @@ public class CommutativityCheckerTest {
}
@Test
- public void constructorShouldThrowWhenEmptyValuesToTest() throws Exception {
+ void constructorShouldThrowWhenEmptyValuesToTest() throws Exception {
BinaryOperator<Integer> binaryOperator = (a, b) -> a * a + b;
assertThatThrownBy(() -> new CommutativityChecker<>(ImmutableSet.of(), binaryOperator))
@@ -48,7 +48,7 @@ public class CommutativityCheckerTest {
}
@Test
- public void constructorShouldThrowWhenSingleValueToTest() throws Exception {
+ void constructorShouldThrowWhenSingleValueToTest() throws Exception {
BinaryOperator<Integer> binaryOperator = (a, b) -> a * a + b;
assertThatThrownBy(() -> new CommutativityChecker<>(ImmutableSet.of(0), binaryOperator))
@@ -56,13 +56,13 @@ public class CommutativityCheckerTest {
}
@Test
- public void constructorShouldThrowWhenNullOperation() throws Exception {
+ void constructorShouldThrowWhenNullOperation() throws Exception {
assertThatThrownBy(() -> new CommutativityChecker<>(ImmutableSet.of(0, 1), null))
.isInstanceOf(NullPointerException.class);
}
@Test
- public void findNonCommutativeInputShouldReturnEmptyWhenCommutativeOperation() throws Exception {
+ void findNonCommutativeInputShouldReturnEmptyWhenCommutativeOperation() throws Exception {
Set<Integer> integers = ImmutableSet.of(5, 4, 3, 2, 1);
BinaryOperator<Integer> commutativeOperator = (a, b) -> a + b;
CommutativityChecker<Integer> commutativityChecker = new CommutativityChecker<>(integers, commutativeOperator);
@@ -71,7 +71,7 @@ public class CommutativityCheckerTest {
}
@Test
- public void findNonCommutativeInputShouldReturnDataWhenNonCommutativeOperation() throws Exception {
+ void findNonCommutativeInputShouldReturnDataWhenNonCommutativeOperation() throws Exception {
Set<Integer> integers = ImmutableSet.of(2, 1);
BinaryOperator<Integer> nonCommutativeOperator = (a, b) -> 2 * a + b;
CommutativityChecker<Integer> commutativityChecker = new CommutativityChecker<>(integers, nonCommutativeOperator);
@@ -81,7 +81,7 @@ public class CommutativityCheckerTest {
}
@Test
- public void findNonCommutativeInputShouldNotReturnStableValues() throws Exception {
+ void findNonCommutativeInputShouldNotReturnStableValues() throws Exception {
Set<Integer> integers = ImmutableSet.of(0, 1, 2);
BinaryOperator<Integer> nonCommutativeOperatorWithStableValues = (a, b) -> a * a + b;
CommutativityChecker<Integer> commutativityChecker = new CommutativityChecker<>(integers, nonCommutativeOperatorWithStableValues);
@@ -92,11 +92,11 @@ public class CommutativityCheckerTest {
}
@Test
- public void findNonCommutativeInputShouldReturnEmptyWhenNonCommutativeOperationButOnlyStableValues() throws Exception {
+ void findNonCommutativeInputShouldReturnEmptyWhenNonCommutativeOperationButOnlyStableValues() throws Exception {
Set<Integer> stableValues = ImmutableSet.of(0, 1);
BinaryOperator<Integer> nonCommutativeOperatorWithStableValues = (a, b) -> a * a + b;
CommutativityChecker<Integer> commutativityChecker = new CommutativityChecker<>(stableValues, nonCommutativeOperatorWithStableValues);
assertThat(commutativityChecker.findNonCommutativeInput()).isEmpty();
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/CompletableFutureUtilTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/CompletableFutureUtilTest.java b/server/container/util/src/test/java/org/apache/james/util/CompletableFutureUtilTest.java
index cdfce5e..3b544e9 100644
--- a/server/container/util/src/test/java/org/apache/james/util/CompletableFutureUtilTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/CompletableFutureUtilTest.java
@@ -34,29 +34,29 @@ import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.apache.james.util.concurrent.NamedThreadFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import com.github.steveash.guavate.Guavate;
import com.google.common.collect.ImmutableList;
public class CompletableFutureUtilTest {
- private ExecutorService executorService;
+ private static ExecutorService executorService;
- @Before
- public void setUp() {
- ThreadFactory threadFactory = NamedThreadFactory.withClassName(getClass());
+ @BeforeAll
+ static void setUp() {
+ ThreadFactory threadFactory = NamedThreadFactory.withClassName(CompletableFutureUtilTest.class);
executorService = Executors.newFixedThreadPool(4, threadFactory);
}
- @After
- public void tearDown() {
+ @AfterAll
+ static void tearDown() {
executorService.shutdownNow();
}
@Test
- public void allOfShouldUnboxEmptyStream() {
+ void allOfShouldUnboxEmptyStream() {
assertThat(
CompletableFutureUtil.allOf(Stream.empty())
.join()
@@ -65,7 +65,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void chainAllShouldPreserveExecutionOrder() {
+ void chainAllShouldPreserveExecutionOrder() {
int itemCount = 10;
ImmutableList<Integer> ints = IntStream.range(0, itemCount)
.boxed()
@@ -90,7 +90,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void chainAllShouldNotThrowOnEmptyStream() {
+ void chainAllShouldNotThrowOnEmptyStream() {
Stream<Integer> result = CompletableFutureUtil.chainAll(Stream.<Integer>of(),
i -> CompletableFuture.supplyAsync(() -> i, executorService))
.join();
@@ -100,7 +100,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void chainAllShouldPreserveOrder() {
+ void chainAllShouldPreserveOrder() {
int itemCount = 10;
ImmutableList<Integer> ints = IntStream.range(0, itemCount)
.boxed()
@@ -115,7 +115,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void allOfShouldUnboxStream() {
+ void allOfShouldUnboxStream() {
long value1 = 18L;
long value2 = 19L;
long value3 = 20L;
@@ -131,7 +131,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void allOfShouldSupportNullValue() {
+ void allOfShouldSupportNullValue() {
assertThatCode(() ->
CompletableFutureUtil.allOf(
Stream.of(
@@ -144,7 +144,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void allOfShouldPreserveOrder() {
+ void allOfShouldPreserveOrder() {
long value1 = 18L;
long value2 = 19L;
long value3 = 20L;
@@ -174,7 +174,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void allOfShouldWorkOnVeryLargeStream() {
+ void allOfShouldWorkOnVeryLargeStream() {
CompletableFutureUtil.allOf(
IntStream.range(0, 100000)
.boxed()
@@ -183,7 +183,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void mapShouldMapOnStreamInsideACompletableFuturOfStream() {
+ void mapShouldMapOnStreamInsideACompletableFuturOfStream() {
CompletableFuture<Stream<Integer>> futurOfInteger = CompletableFuture.completedFuture(Stream.of(1, 2, 3));
assertThat(
@@ -195,7 +195,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void mapShouldReturnEmptyStreamWhenGivenAnEmptyStream() {
+ void mapShouldReturnEmptyStreamWhenGivenAnEmptyStream() {
CompletableFuture<Stream<Integer>> futurOfInteger = CompletableFuture.completedFuture(Stream.of());
assertThat(
@@ -207,7 +207,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void composeIfTrueShouldReturnTrueWhenTrue() {
+ void composeIfTrueShouldReturnTrueWhenTrue() {
assertThat(
CompletableFutureUtil.composeIfTrue(() -> CompletableFuture.completedFuture(null))
.apply(true)
@@ -216,7 +216,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void composeIfTrueShouldReturnFalseWhenFalse() {
+ void composeIfTrueShouldReturnFalseWhenFalse() {
assertThat(
CompletableFutureUtil.composeIfTrue(() -> CompletableFuture.completedFuture(null))
.apply(false)
@@ -225,7 +225,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void composeIfTrueShouldComposeWhenTrue() {
+ void composeIfTrueShouldComposeWhenTrue() {
AtomicInteger atomicInteger = new AtomicInteger(0);
CompletableFutureUtil.composeIfTrue(() -> {
atomicInteger.incrementAndGet();
@@ -238,7 +238,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void composeIfTrueShouldNotComposeWhenFalse() {
+ void composeIfTrueShouldNotComposeWhenFalse() {
AtomicInteger atomicInteger = new AtomicInteger(0);
CompletableFutureUtil.composeIfTrue(() -> {
atomicInteger.incrementAndGet();
@@ -251,7 +251,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void reduceShouldReturnEmptyWhenNoValue() {
+ void reduceShouldReturnEmptyWhenNoValue() {
assertThat(
CompletableFutureUtil.reduce(
(i, j) -> i + j,
@@ -261,7 +261,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void reduceShouldWork() {
+ void reduceShouldWork() {
assertThat(
CompletableFutureUtil.reduce(
(i, j) -> i + j,
@@ -272,7 +272,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void reduceShouldReturnIdentityAccumulatorWhenNoValue() {
+ void reduceShouldReturnIdentityAccumulatorWhenNoValue() {
long identityAccumulator = 0L;
assertThat(
CompletableFutureUtil.reduce(
@@ -284,7 +284,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void reduceShouldWorkWithIdentityAccumulator() {
+ void reduceShouldWorkWithIdentityAccumulator() {
assertThat(
CompletableFutureUtil.reduce(
(i, j) -> i + j,
@@ -295,7 +295,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void unwrapShouldUnwrapWhenValue() {
+ void unwrapShouldUnwrapWhenValue() {
assertThat(
CompletableFutureUtil.unwrap(
CompletableFuture.completedFuture(Optional.of(CompletableFuture.completedFuture(1L))))
@@ -304,7 +304,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void unwrapShouldUnwrapWhenEmpty() {
+ void unwrapShouldUnwrapWhenEmpty() {
assertThat(
CompletableFutureUtil.unwrap(
CompletableFuture.completedFuture(Optional.empty()))
@@ -313,14 +313,14 @@ public class CompletableFutureUtilTest {
}
@Test
- public void sortShouldReturnEmptyWhenEmptyStream() {
+ void sortShouldReturnEmptyWhenEmptyStream() {
FluentFutureStream<Long> futureStream = FluentFutureStream.ofFutures();
assertThat(futureStream.sorted(Long::compareTo).join())
.isEmpty();
}
@Test
- public void sortShouldReturnTheSortedStream() {
+ void sortShouldReturnTheSortedStream() {
FluentFutureStream<Long> futureStream = FluentFutureStream.ofFutures(
CompletableFuture.completedFuture(4L),
CompletableFuture.completedFuture(3L),
@@ -332,7 +332,7 @@ public class CompletableFutureUtilTest {
}
@Test
- public void exceptionallyFutureShouldReturnACompletedExceptionallyFuture() {
+ void exceptionallyFutureShouldReturnACompletedExceptionallyFuture() {
CompletableFuture<Object> failedFuture = CompletableFutureUtil.exceptionallyFuture(new Exception("failure"));
assertThat(failedFuture)
.isCompletedExceptionally();
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/FluentFutureStreamTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/FluentFutureStreamTest.java b/server/container/util/src/test/java/org/apache/james/util/FluentFutureStreamTest.java
index 56017d6..2745280 100644
--- a/server/container/util/src/test/java/org/apache/james/util/FluentFutureStreamTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/FluentFutureStreamTest.java
@@ -26,14 +26,14 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.stream.Stream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.github.steveash.guavate.Guavate;
public class FluentFutureStreamTest {
@Test
- public void ofFutureShouldConstructAFluentFutureStream() {
+ void ofFutureShouldConstructAFluentFutureStream() {
assertThat(
FluentFutureStream.ofFutures(
CompletableFuture.completedFuture(1),
@@ -45,7 +45,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void ofShouldConstructAFluentFutureStreamWhenProvidedAFutureOfStream() {
+ void ofShouldConstructAFluentFutureStreamWhenProvidedAFutureOfStream() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -56,7 +56,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void ofShouldConstructAFluentFutureStreamWhenProvidedAStreamOfFuture() {
+ void ofShouldConstructAFluentFutureStreamWhenProvidedAStreamOfFuture() {
assertThat(
FluentFutureStream.of(
Stream.of(
@@ -69,7 +69,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void ofNestedStreamsShouldConstructAFluentFutureStreamWhenProvidedAStreamOfFutureOfStream() {
+ void ofNestedStreamsShouldConstructAFluentFutureStreamWhenProvidedAStreamOfFutureOfStream() {
assertThat(
FluentFutureStream.<Stream<Integer>, Integer>of(
Stream.of(
@@ -84,7 +84,7 @@ public class FluentFutureStreamTest {
@Test
- public void ofOptionalsShouldConstructAFluentFutureStreamWhenProvidedAStreamOfFutureOfOptionals() {
+ void ofOptionalsShouldConstructAFluentFutureStreamWhenProvidedAStreamOfFutureOfOptionals() {
assertThat(
FluentFutureStream.<Optional<Integer>, Integer>of(
Stream.of(
@@ -99,7 +99,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void completableFutureShouldReturnAFutureOfTheUnderLayingStream() {
+ void completableFutureShouldReturnAFutureOfTheUnderLayingStream() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -111,7 +111,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void mapShouldTransformUnderlyingValues() {
+ void mapShouldTransformUnderlyingValues() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -123,7 +123,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void flatMapShouldTransformUnderlyingValuesAndFlatMapResult() {
+ void flatMapShouldTransformUnderlyingValuesAndFlatMapResult() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -135,7 +135,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void flatMapOptionalShouldTransformUnderlyingValuesAndUnboxResult() {
+ void flatMapOptionalShouldTransformUnderlyingValuesAndUnboxResult() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -149,7 +149,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void reduceShouldGatherAllValuesOfTheUnderlyingStream() {
+ void reduceShouldGatherAllValuesOfTheUnderlyingStream() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -160,7 +160,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void reduceShouldGatherAllValuesOfTheUnderlyingStreamWithAnEmptyValue() {
+ void reduceShouldGatherAllValuesOfTheUnderlyingStreamWithAnEmptyValue() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -171,7 +171,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void filterShouldBeAppliedOnTheUnderlyingStream() {
+ void filterShouldBeAppliedOnTheUnderlyingStream() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -183,7 +183,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void thenFilterShouldBeAppliedOnTheUnderlyingStream() {
+ void thenFilterShouldBeAppliedOnTheUnderlyingStream() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -195,7 +195,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void thenComposeOnAllShouldTransformUnderlyingValuesAndComposeFutures() {
+ void thenComposeOnAllShouldTransformUnderlyingValuesAndComposeFutures() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -207,7 +207,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void thenFlatComposeShouldTransformUnderlyingValuesAndComposeFuturesWithStreamUnboxing() {
+ void thenFlatComposeShouldTransformUnderlyingValuesAndComposeFuturesWithStreamUnboxing() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -219,7 +219,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void thenFlatComposeOnOptionalShouldTransformUnderlyingValuesAndComposeFuturesWithOptionalUnboxing() {
+ void thenFlatComposeOnOptionalShouldTransformUnderlyingValuesAndComposeFuturesWithOptionalUnboxing() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(
@@ -233,7 +233,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void thenPerformOnAllShouldGenerateASynchronousSideEffectForAllElementsOfTheUnderlyingStream() {
+ void thenPerformOnAllShouldGenerateASynchronousSideEffectForAllElementsOfTheUnderlyingStream() {
ConcurrentLinkedDeque<Integer> sideEffects = new ConcurrentLinkedDeque<>();
FluentFutureStream.of(
@@ -250,7 +250,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void collectShouldReturnTheCollectionOfData() {
+ void collectShouldReturnTheCollectionOfData() {
assertThat(
FluentFutureStream.of(
Stream.of(
@@ -263,7 +263,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void collectShouldReturnEmptyWhenStreamIsEmpty() {
+ void collectShouldReturnEmptyWhenStreamIsEmpty() {
assertThat(
FluentFutureStream.ofFutures()
.collect(Guavate.toImmutableList())
@@ -272,7 +272,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void sortedShouldReturnInOrderElements() {
+ void sortedShouldReturnInOrderElements() {
assertThat(
FluentFutureStream.of(
CompletableFuture.completedFuture(Stream.of(4L, 3L, 2L, 1L)))
@@ -282,7 +282,7 @@ public class FluentFutureStreamTest {
}
@Test
- public void sortedShouldReturnEmptyWhenEmpty() {
+ void sortedShouldReturnEmptyWhenEmpty() {
CompletableFuture<Stream<Long>> completableFutureStream = CompletableFuture.completedFuture(Stream.of());
assertThat(
FluentFutureStream.of(completableFutureStream)
@@ -290,4 +290,4 @@ public class FluentFutureStreamTest {
.join())
.isEmpty();
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/GuavaUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/GuavaUtilsTest.java b/server/container/util/src/test/java/org/apache/james/util/GuavaUtilsTest.java
index 2d5a224..5b2ec4d 100644
--- a/server/container/util/src/test/java/org/apache/james/util/GuavaUtilsTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/GuavaUtilsTest.java
@@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
@@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableMap;
public class GuavaUtilsTest {
@Test
- public void toMultimapShouldAcceptEmptyMaps() {
+ void toMultimapShouldAcceptEmptyMaps() {
assertThat(GuavaUtils.toMultimap(ImmutableMap
.<String, List<String>>builder()
.build())
@@ -41,7 +41,7 @@ public class GuavaUtilsTest {
}
@Test
- public void toMultimapShouldAcceptSingleValuesMaps() {
+ void toMultimapShouldAcceptSingleValuesMaps() {
assertThat(GuavaUtils.toMultimap(ImmutableMap
.<String, List<String>>builder()
.put("k1", ImmutableList.of("v1"))
@@ -55,7 +55,7 @@ public class GuavaUtilsTest {
}
@Test
- public void toMultimapShouldAcceptMultiplesValuesMaps() {
+ void toMultimapShouldAcceptMultiplesValuesMaps() {
assertThat(GuavaUtils.toMultimap(ImmutableMap
.<String, List<String>>builder()
.put("k1", ImmutableList.of("v1"))
@@ -70,7 +70,7 @@ public class GuavaUtilsTest {
}
@Test
- public void shouldStripEntriesWithEmptyList() {
+ void shouldStripEntriesWithEmptyList() {
assertThat(GuavaUtils.toMultimap(ImmutableMap
.<String, List<String>>builder()
.put("k1", ImmutableList.of())
@@ -78,4 +78,4 @@ public class GuavaUtilsTest {
.asMap())
.isEqualTo(ImmutableListMultimap.of().asMap());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/HostTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/HostTest.java b/server/container/util/src/test/java/org/apache/james/util/HostTest.java
index 3ebeaee..2052b5e 100644
--- a/server/container/util/src/test/java/org/apache/james/util/HostTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/HostTest.java
@@ -20,10 +20,11 @@
package org.apache.james.util;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.assertj.core.api.Assertions.assertThatNullPointerException;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
@@ -31,25 +32,19 @@ public class HostTest {
private static final int DEFAULT_PORT = 154;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
- public void parseConfStringShouldParseConfWithIpAndPort() {
- //Given
+ void parseConfStringShouldParseConfWithIpAndPort() {
int expectedPort = 44;
String expectedIp = "142.145.254.111";
String ipAndPort = expectedIp + ":" + 44;
- //When
Host actual = Host.parseConfString(ipAndPort);
- //Then
assertThat(actual).isEqualTo(new Host(expectedIp, expectedPort));
}
@Test
- public void parseConfStringShouldParseConfWithHostanmeAndPort() {
+ void parseConfStringShouldParseConfWithHostanmeAndPort() {
int expectedPort = 44;
String host = "host";
@@ -59,98 +54,72 @@ public class HostTest {
}
@Test
- public void parseConfStringShouldParseConfWithHostOnlyWhenDefaultPortIsProvided() {
- //Given
+ void parseConfStringShouldParseConfWithHostOnlyWhenDefaultPortIsProvided() {
String ipAndPort = "142.145.254.111";
String expectedIp = "142.145.254.111";
- //When
Host actual = Host.parseConfString(ipAndPort, DEFAULT_PORT);
- //Then
assertThat(actual).isEqualTo(new Host(expectedIp, DEFAULT_PORT));
}
@Test
- public void parseConfStringShouldFailWhenConfigIsAnEmptyString() {
- expectedException.expect(IllegalArgumentException.class);
-
- //Given
- String ipAndPort = "";
-
- //When
- Host.parseConfString(ipAndPort);
+ void parseConfStringShouldFailWhenConfigIsAnEmptyString() {
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> Host.parseConfString(""));
}
@Test
- public void parseConfStringShouldFailWhenOnlyHostnameAndNoDefaultPort() {
- expectedException.expect(IllegalArgumentException.class);
-
- //Given
- String hostname = "hostnameOnly";
-
- //When
- Host.parseConfString(hostname);
+ void parseConfStringShouldFailWhenOnlyHostnameAndNoDefaultPort() {
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> Host.parseConfString("hostnameOnly"));
}
@Test
- public void parseConfStringShouldFailWhenNegativePort() {
- expectedException.expect(IllegalArgumentException.class);
-
- Host.parseConfString("host:-1");
+ void parseConfStringShouldFailWhenNegativePort() {
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> Host.parseConfString("host:-1"));
}
@Test
- public void parseConfStringShouldFailWhenZeroPort() {
- expectedException.expect(IllegalArgumentException.class);
-
- Host.parseConfString("host:0");
+ void parseConfStringShouldFailWhenZeroPort() {
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> Host.parseConfString("host:0"));
}
@Test
- public void parseConfStringShouldFailWhenTooHighPort() {
- expectedException.expect(IllegalArgumentException.class);
-
- Host.parseConfString("host:65536");
+ void parseConfStringShouldFailWhenTooHighPort() {
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> Host.parseConfString("host:65536"));
}
@Test
- public void parseConfStringShouldFailWhenConfigIsANullString() {
- expectedException.expect(NullPointerException.class);
-
- //Given
- String ipAndPort = null;
-
- //When
- Host.parseConfString(ipAndPort);
+ void parseConfStringShouldFailWhenConfigIsANullString() {
+ assertThatNullPointerException()
+ .isThrownBy(() -> Host.parseConfString(null));
}
@Test
- public void parseConfStringShouldFailWhenConfigIsInvalid() {
- expectedException.expect(IllegalArgumentException.class);
-
- //Given
- String ipAndPort = "10.10.10.10:42:43";
-
- //When
- Host.parseConfString(ipAndPort);
+ void parseConfStringShouldFailWhenConfigIsInvalid() {
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> Host.parseConfString("10.10.10.10:42:43"));
}
@Test
- public void parseHostsShouldParseEmptyString() {
+ void parseHostsShouldParseEmptyString() {
assertThat(Host.parseHosts(""))
.isEmpty();
}
@Test
- public void parseHostsShouldParseMonoHost() {
+ void parseHostsShouldParseMonoHost() {
assertThat(Host.parseHosts("localhost:9200"))
.containsOnly(new Host("localhost", 9200));
}
@Test
- public void parseHostsShouldParseMultiHosts() {
+ void parseHostsShouldParseMultiHosts() {
assertThat(Host.parseHosts("localhost:9200,server:9155"))
.containsOnly(
new Host("localhost", 9200),
@@ -158,7 +127,7 @@ public class HostTest {
}
@Test
- public void parseHostsShouldNotFailOnMultiComma() {
+ void parseHostsShouldNotFailOnMultiComma() {
assertThat(Host.parseHosts("localhost:9200,,server:9155"))
.containsOnly(
new Host("localhost", 9200),
@@ -166,21 +135,20 @@ public class HostTest {
}
@Test
- public void parseHostsShouldFailOnInvalidHost() {
- expectedException.expect(NumberFormatException.class);
-
- Host.parseHosts("localhost:invalid,,server:9155");
+ void parseHostsShouldFailOnInvalidHost() {
+ assertThatThrownBy(() -> Host.parseHosts("localhost:invalid,,server:9155"))
+ .isInstanceOf(NumberFormatException.class);
}
@Test
- public void parseHostsShouldSwallowDuplicates() {
+ void parseHostsShouldSwallowDuplicates() {
assertThat(Host.parseHosts("localhost:9200,localhost:9200"))
.containsOnly(
new Host("localhost", 9200));
}
@Test
- public void parseHostsShouldNotSwallowSameAddressDifferentPort() {
+ void parseHostsShouldNotSwallowSameAddressDifferentPort() {
assertThat(Host.parseHosts("localhost:9200,localhost:9155"))
.containsOnly(
new Host("localhost", 9200),
@@ -188,7 +156,7 @@ public class HostTest {
}
@Test
- public void parseHostsShouldNotSwallowSamePortDifferentAddress() {
+ void parseHostsShouldNotSwallowSamePortDifferentAddress() {
assertThat(Host.parseHosts("localhost:9200,abcd:9200"))
.containsOnly(
new Host("localhost", 9200),
@@ -196,7 +164,7 @@ public class HostTest {
}
@Test
- public void parseHostsShouldHandleDefaultPort() {
+ void parseHostsShouldHandleDefaultPort() {
int defaultPort = 155;
assertThat(Host.parseHosts("localhost:9200,abcd", defaultPort))
@@ -206,14 +174,13 @@ public class HostTest {
}
@Test
- public void parseHostsShouldThrowOnAbsentPortWhenNoDefaultPort() {
- expectedException.expect(IllegalArgumentException.class);
-
- Host.parseHosts("localhost:9200,abcd");
+ void parseHostsShouldThrowOnAbsentPortWhenNoDefaultPort() {
+ assertThatIllegalArgumentException()
+ .isThrownBy(() -> Host.parseHosts("localhost:9200,abcd"));
}
@Test
- public void hostShouldRespectBeanContract() {
+ void hostShouldRespectBeanContract() {
EqualsVerifier.forClass(Host.class).verify();
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/IteratorWrapperTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/IteratorWrapperTest.java b/server/container/util/src/test/java/org/apache/james/util/IteratorWrapperTest.java
index aa29e92..687f7b7 100644
--- a/server/container/util/src/test/java/org/apache/james/util/IteratorWrapperTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/IteratorWrapperTest.java
@@ -20,20 +20,16 @@
package org.apache.james.util;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatNullPointerException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import com.google.common.collect.ImmutableList;
public class IteratorWrapperTest {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
- public void getEntriesSeenShouldReturnEmptyWhenNotConsumed() {
+ void getEntriesSeenShouldReturnEmptyWhenNotConsumed() {
ImmutableList<Integer> originalData = ImmutableList.of(1, 2, 3);
IteratorWrapper<Integer> integerIteratorWrapper = new IteratorWrapper<>(originalData.iterator());
@@ -41,7 +37,7 @@ public class IteratorWrapperTest {
}
@Test
- public void getEntriesSeenShouldReturnViewOfConsumedData() {
+ void getEntriesSeenShouldReturnViewOfConsumedData() {
ImmutableList<Integer> originalData = ImmutableList.of(1, 2, 3);
IteratorWrapper<Integer> integerIteratorWrapper = new IteratorWrapper<>(originalData.iterator());
@@ -52,7 +48,7 @@ public class IteratorWrapperTest {
}
@Test
- public void getEntriesSeenShouldReturnViewOfConsumedDataWhenPartiallyConsumed() {
+ void getEntriesSeenShouldReturnViewOfConsumedDataWhenPartiallyConsumed() {
ImmutableList<Integer> originalData = ImmutableList.of(1, 2, 3);
IteratorWrapper<Integer> integerIteratorWrapper = new IteratorWrapper<>(originalData.iterator());
@@ -64,7 +60,7 @@ public class IteratorWrapperTest {
}
@Test
- public void getEntriesSeenShouldReturnEmptyWhenSuppliedEmpty() {
+ void getEntriesSeenShouldReturnEmptyWhenSuppliedEmpty() {
ImmutableList<Integer> originalData = ImmutableList.of();
IteratorWrapper<Integer> integerIteratorWrapper = new IteratorWrapper<>(originalData.iterator());
@@ -75,10 +71,9 @@ public class IteratorWrapperTest {
}
@Test
- public void constructorShouldThrowOnNull() {
- expectedException.expect(NullPointerException.class);
-
- new IteratorWrapper<Integer>(null);
+ void constructorShouldThrowOnNull() {
+ assertThatNullPointerException()
+ .isThrownBy(() -> new IteratorWrapper<Integer>(null));
}
private void consume(IteratorWrapper<Integer> integerIteratorWrapper) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/MDCBuilderTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/MDCBuilderTest.java b/server/container/util/src/test/java/org/apache/james/util/MDCBuilderTest.java
index bf09d1d..02494a8 100644
--- a/server/container/util/src/test/java/org/apache/james/util/MDCBuilderTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/MDCBuilderTest.java
@@ -20,13 +20,12 @@
package org.apache.james.util;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatNullPointerException;
import java.io.Closeable;
import java.io.IOException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import com.google.common.collect.ImmutableList;
@@ -37,25 +36,22 @@ public class MDCBuilderTest {
private static final String VALUE_1 = "value1";
private static final String VALUE_2 = "value2";
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
- public void addContextShouldThrowOnNullKey() {
- expectedException.expect(NullPointerException.class);
-
- MDCBuilder.create()
- .addContext(null, "any");
+ void addContextShouldThrowOnNullKey() {
+ assertThatNullPointerException()
+ .isThrownBy(() ->
+ MDCBuilder.create()
+ .addContext(null, "any"));
}
@Test
- public void buildContextMapShouldReturnEmptyWhenNoContext() {
+ void buildContextMapShouldReturnEmptyWhenNoContext() {
assertThat(MDCBuilder.create().buildContextMap())
.isEmpty();
}
@Test
- public void buildContextMapShouldReturnContext() {
+ void buildContextMapShouldReturnContext() {
assertThat(
MDCBuilder.create()
.addContext(KEY_1, VALUE_1)
@@ -67,7 +63,7 @@ public class MDCBuilderTest {
}
@Test
- public void addContextShouldFilterOutNullValues() {
+ void addContextShouldFilterOutNullValues() {
assertThat(
MDCBuilder.create()
.addContext(KEY_1, null)
@@ -76,7 +72,7 @@ public class MDCBuilderTest {
}
@Test
- public void addContextShouldAllowRecursiveBuild() {
+ void addContextShouldAllowRecursiveBuild() {
assertThat(
MDCBuilder.create()
.addContext(KEY_1, VALUE_1)
@@ -88,22 +84,20 @@ public class MDCBuilderTest {
.containsEntry(KEY_2, VALUE_2);
}
- @SuppressWarnings("resource")
@Test
- public void closeablesConstructorShouldThrowOnNullList() {
- expectedException.expect(NullPointerException.class);
-
- new MDCBuilder.Closeables(null);
+ void closeablesConstructorShouldThrowOnNullList() {
+ assertThatNullPointerException()
+ .isThrownBy(() -> new MDCBuilder.Closeables(null));
}
@Test
- public void closeablesCloseShouldNotThrowWhenEmpty() throws IOException {
+ void closeablesCloseShouldNotThrowWhenEmpty() throws IOException {
new MDCBuilder.Closeables(ImmutableList.of())
.close();
}
@Test
- public void closeablesCloseShouldCallAllUnderlyingCloseables() throws IOException {
+ void closeablesCloseShouldCallAllUnderlyingCloseables() throws IOException {
ImmutableList.Builder<String> builder = ImmutableList.builder();
Closeable closeable1 = () -> builder.add(VALUE_1);
@@ -119,7 +113,7 @@ public class MDCBuilderTest {
@Test
- public void closeablesCloseShouldCallAllUnderlyingCloseablesWhenError() throws IOException {
+ void closeablesCloseShouldCallAllUnderlyingCloseablesWhenError() throws IOException {
ImmutableList.Builder<String> builder = ImmutableList.builder();
Closeable closeable1 = () -> builder.add(VALUE_1);
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/OptionalUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/OptionalUtilsTest.java b/server/container/util/src/test/java/org/apache/james/util/OptionalUtilsTest.java
index 733e3e1..98812ab 100644
--- a/server/container/util/src/test/java/org/apache/james/util/OptionalUtilsTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/OptionalUtilsTest.java
@@ -23,24 +23,19 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
public class OptionalUtilsTest {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
@Test
- public void ifEmptyShouldPreserveValueOfEmptyOptionals() {
+ void ifEmptyShouldPreserveValueOfEmptyOptionals() {
Optional<Object> expected = OptionalUtils.executeIfEmpty(Optional.empty(), () -> { });
assertThat(expected).isEmpty();
}
@Test
- public void ifEmptyShouldPreserveValueOfPresentOptionals() {
+ void ifEmptyShouldPreserveValueOfPresentOptionals() {
String value = "value";
Optional<String> expected = OptionalUtils.executeIfEmpty(Optional.of(value), () -> { });
@@ -48,7 +43,7 @@ public class OptionalUtilsTest {
}
@Test
- public void ifEmptyShouldPerformOperationIfEmpty() {
+ void ifEmptyShouldPerformOperationIfEmpty() {
AtomicInteger operationCounter = new AtomicInteger(0);
OptionalUtils.executeIfEmpty(Optional.empty(), operationCounter::incrementAndGet);
@@ -57,7 +52,7 @@ public class OptionalUtilsTest {
}
@Test
- public void ifEmptyShouldNotPerformOperationIfPresent() {
+ void ifEmptyShouldNotPerformOperationIfPresent() {
AtomicInteger operationCounter = new AtomicInteger(0);
OptionalUtils.executeIfEmpty(Optional.of("value"), operationCounter::incrementAndGet);
@@ -66,26 +61,26 @@ public class OptionalUtilsTest {
}
@Test
- public void toStreamShouldConvertEmptyOptionalToEmptyStream() {
+ void toStreamShouldConvertEmptyOptionalToEmptyStream() {
assertThat(OptionalUtils.toStream(Optional.empty()))
.isEmpty();
}
@Test
- public void toStreamShouldConvertFullOptionalToStream() {
+ void toStreamShouldConvertFullOptionalToStream() {
long value = 18L;
assertThat(OptionalUtils.toStream(Optional.of(value)))
.containsExactly(value);
}
@Test
- public void orShouldReturnEmptyWhenNoParameter() {
+ void orShouldReturnEmptyWhenNoParameter() {
assertThat(OptionalUtils.or())
.isEmpty();
}
@Test
- public void orShouldReturnEmptyWhenEmpty() {
+ void orShouldReturnEmptyWhenEmpty() {
assertThat(
OptionalUtils.or(
Optional.empty()))
@@ -93,7 +88,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orShouldReturnValueWhenValue() {
+ void orShouldReturnValueWhenValue() {
assertThat(
OptionalUtils.or(
Optional.of(1)))
@@ -101,7 +96,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orShouldReturnEmptyWhenBothEmpty() {
+ void orShouldReturnEmptyWhenBothEmpty() {
assertThat(
OptionalUtils.or(
Optional.empty(),
@@ -110,7 +105,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orShouldReturnFirstValueWhenOnlyFirstValue() {
+ void orShouldReturnFirstValueWhenOnlyFirstValue() {
assertThat(
OptionalUtils.or(
Optional.of(18),
@@ -119,7 +114,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orShouldReturnSecondValueWhenOnlySecondValue() {
+ void orShouldReturnSecondValueWhenOnlySecondValue() {
assertThat(
OptionalUtils.or(
Optional.empty(),
@@ -128,7 +123,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orShouldReturnFirstValueWhenBothValues() {
+ void orShouldReturnFirstValueWhenBothValues() {
assertThat(
OptionalUtils.or(
Optional.of(1),
@@ -137,7 +132,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orShouldReturnThirdValueWhenOnlyThirdValue() {
+ void orShouldReturnThirdValueWhenOnlyThirdValue() {
assertThat(
OptionalUtils.or(
Optional.empty(),
@@ -147,13 +142,13 @@ public class OptionalUtilsTest {
}
@Test
- public void orSuppliersShouldReturnEmptyWhenNoParameter() {
+ void orSuppliersShouldReturnEmptyWhenNoParameter() {
assertThat(OptionalUtils.or())
.isEmpty();
}
@Test
- public void orSuppliersShouldReturnEmptyWhenEmpty() {
+ void orSuppliersShouldReturnEmptyWhenEmpty() {
assertThat(
OptionalUtils.orSuppliers(
Optional::empty))
@@ -161,7 +156,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orSuppliersShouldReturnValueWhenValue() {
+ void orSuppliersShouldReturnValueWhenValue() {
assertThat(
OptionalUtils.orSuppliers(
() -> Optional.of(1)))
@@ -169,7 +164,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orSuppliersShouldReturnEmptyWhenBothEmpty() {
+ void orSuppliersShouldReturnEmptyWhenBothEmpty() {
assertThat(
OptionalUtils.orSuppliers(
() -> Optional.empty(),
@@ -178,7 +173,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orSuppliersShouldReturnFirstValueWhenOnlyFirstValue() {
+ void orSuppliersShouldReturnFirstValueWhenOnlyFirstValue() {
assertThat(
OptionalUtils.orSuppliers(
() -> Optional.of(18),
@@ -187,7 +182,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orSuppliersShouldReturnSecondValueWhenOnlySecondValue() {
+ void orSuppliersShouldReturnSecondValueWhenOnlySecondValue() {
assertThat(
OptionalUtils.orSuppliers(
Optional::empty,
@@ -196,7 +191,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orSuppliersShouldReturnFirstValueWhenBothValues() {
+ void orSuppliersShouldReturnFirstValueWhenBothValues() {
assertThat(
OptionalUtils.orSuppliers(
() -> Optional.of(1),
@@ -205,7 +200,7 @@ public class OptionalUtilsTest {
}
@Test
- public void orSuppliersShouldReturnThirdValueWhenOnlyThirdValue() {
+ void orSuppliersShouldReturnThirdValueWhenOnlyThirdValue() {
assertThat(
OptionalUtils.orSuppliers(
Optional::empty,
@@ -215,27 +210,27 @@ public class OptionalUtilsTest {
}
@Test
- public void containsDifferentShouldReturnTrueWhenNullStoreValue() throws Exception {
+ void containsDifferentShouldReturnTrueWhenNullStoreValue() throws Exception {
assertThat(OptionalUtils.containsDifferent(Optional.of("any"), null)).isTrue();
}
@Test
- public void containsDifferentShouldReturnFalseWhenEmpty() throws Exception {
+ void containsDifferentShouldReturnFalseWhenEmpty() throws Exception {
assertThat(OptionalUtils.containsDifferent(Optional.empty(), "any")).isFalse();
}
@Test
- public void containsDifferentShouldReturnFalseWhenSameValue() throws Exception {
+ void containsDifferentShouldReturnFalseWhenSameValue() throws Exception {
assertThat(OptionalUtils.containsDifferent(Optional.of("any"), "any")).isFalse();
}
@Test
- public void containsDifferentShouldReturnTrueWhenDifferentValue() throws Exception {
+ void containsDifferentShouldReturnTrueWhenDifferentValue() throws Exception {
assertThat(OptionalUtils.containsDifferent(Optional.of("any"), "other")).isTrue();
}
@Test
- public void matchesShouldReturnFalseWhenFirstOptionalIsEmpty() {
+ void matchesShouldReturnFalseWhenFirstOptionalIsEmpty() {
assertThat(
OptionalUtils.matches(
Optional.empty(),
@@ -245,7 +240,7 @@ public class OptionalUtilsTest {
}
@Test
- public void matchesShouldReturnFalseWhenSecondOptionalIsEmpty() {
+ void matchesShouldReturnFalseWhenSecondOptionalIsEmpty() {
assertThat(
OptionalUtils.matches(
Optional.of(42),
@@ -255,7 +250,7 @@ public class OptionalUtilsTest {
}
@Test
- public void matchesShouldReturnFalseWhenBothOptionalsAreEmpty() {
+ void matchesShouldReturnFalseWhenBothOptionalsAreEmpty() {
assertThat(
OptionalUtils.matches(
Optional.empty(),
@@ -265,7 +260,7 @@ public class OptionalUtilsTest {
}
@Test
- public void matchesShouldReturnFalseWhenConditionIsNotMatching() {
+ void matchesShouldReturnFalseWhenConditionIsNotMatching() {
assertThat(
OptionalUtils.matches(
Optional.of(42),
@@ -275,7 +270,7 @@ public class OptionalUtilsTest {
}
@Test
- public void matchesShouldReturnTrueWhenConditionIsMatching() {
+ void matchesShouldReturnTrueWhenConditionIsMatching() {
assertThat(
OptionalUtils.matches(
Optional.of(42),
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/PortTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/PortTest.java b/server/container/util/src/test/java/org/apache/james/util/PortTest.java
index 9d04204..7e2c129 100644
--- a/server/container/util/src/test/java/org/apache/james/util/PortTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/PortTest.java
@@ -22,71 +22,71 @@ package org.apache.james.util;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class PortTest {
@Test
- public void assertValidShouldThrowOnNegativePort() {
+ void assertValidShouldThrowOnNegativePort() {
assertThatThrownBy(() -> Port.assertValid(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void assertValidShouldThrowOnZeroPort() {
+ void assertValidShouldThrowOnZeroPort() {
assertThatThrownBy(() -> Port.assertValid(0))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void assertValidShouldAcceptOne() {
+ void assertValidShouldAcceptOne() {
Port.assertValid(1);
}
@Test
- public void assertValidShouldAcceptMaxValue() {
+ void assertValidShouldAcceptMaxValue() {
Port.assertValid(Port.MAX_PORT_VALUE);
}
@Test
- public void assertValidShouldThrowOnTooBigValue() {
+ void assertValidShouldThrowOnTooBigValue() {
assertThatThrownBy(() -> Port.assertValid(Port.MAX_PORT_VALUE + 1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void isValidShouldReturnFalseWhenNegative() {
+ void isValidShouldReturnFalseWhenNegative() {
assertThat(Port.isValid(-1))
.isFalse();
}
@Test
- public void isValidShouldReturnFalseWhenZero() {
+ void isValidShouldReturnFalseWhenZero() {
assertThat(Port.isValid(0))
.isFalse();
}
@Test
- public void isValidShouldReturnTrueWhenOne() {
+ void isValidShouldReturnTrueWhenOne() {
assertThat(Port.isValid(1))
.isTrue();
}
@Test
- public void isValidShouldReturnTrueWhenMaxValue() {
+ void isValidShouldReturnTrueWhenMaxValue() {
assertThat(Port.isValid(Port.MAX_PORT_VALUE))
.isTrue();
}
@Test
- public void isValidShouldReturnFalseWhenAboveMaxValue() {
+ void isValidShouldReturnFalseWhenAboveMaxValue() {
assertThat(Port.isValid(Port.MAX_PORT_VALUE + 1))
.isFalse();
}
@Test
- public void generateValidUnprivilegedPortShouldReturnAValidPort() {
+ void generateValidUnprivilegedPortShouldReturnAValidPort() {
assertThat(Port.generateValidUnprivilegedPort())
.isBetween(Port.PRIVILEGED_PORT_BOUND, Port.MAX_PORT_VALUE);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/SizeFormatTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/SizeFormatTest.java b/server/container/util/src/test/java/org/apache/james/util/SizeFormatTest.java
index f506cc5..ef492a4 100644
--- a/server/container/util/src/test/java/org/apache/james/util/SizeFormatTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/SizeFormatTest.java
@@ -22,68 +22,68 @@ package org.apache.james.util;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SizeFormatTest {
@Test
- public void formatShouldThrowWhenNegative() {
+ void formatShouldThrowWhenNegative() {
assertThatThrownBy(() -> SizeFormat.format(-1))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- public void formatShouldAcceptZero() {
+ void formatShouldAcceptZero() {
assertThat(SizeFormat.format(0))
.isEqualTo("0 bytes");
}
@Test
- public void formatShouldUseByteWhenAlmostKiB() {
+ void formatShouldUseByteWhenAlmostKiB() {
assertThat(SizeFormat.format(1023))
.isEqualTo("1023 bytes");
}
@Test
- public void formatShouldUseKiBWhenExactlyOneKiB() {
+ void formatShouldUseKiBWhenExactlyOneKiB() {
assertThat(SizeFormat.format(1024))
.isEqualTo("1 KiB");
}
@Test
- public void formatShouldHaveTwoDigitPrecision() {
+ void formatShouldHaveTwoDigitPrecision() {
assertThat(SizeFormat.format(1024 + 100))
.isEqualTo("1.09 KiB");
}
@Test
- public void formatShouldBeExpressedInKiBWhenAlmostMiB() {
+ void formatShouldBeExpressedInKiBWhenAlmostMiB() {
assertThat(SizeFormat.format(1024 * 1024 - 1))
.isEqualTo("1023.99 KiB");
}
@Test
- public void formatShouldKeepTwoDigitPrecisionWhenRoundingDown() {
+ void formatShouldKeepTwoDigitPrecisionWhenRoundingDown() {
assertThat(SizeFormat.format(2 * 1024 * 1024 - 1))
.isEqualTo("1.99 MiB");
}
@Test
- public void formatShouldUseMiBWhenExactlyOneMiB() {
+ void formatShouldUseMiBWhenExactlyOneMiB() {
assertThat(SizeFormat.format(1024 * 1024))
.isEqualTo("1 MiB");
}
@Test
- public void formatShouldUseGiBWhenExactlyOneGiB() {
+ void formatShouldUseGiBWhenExactlyOneGiB() {
assertThat(SizeFormat.format(1024 * 1024 * 1024))
.isEqualTo("1 GiB");
}
@Test
- public void formatShouldUseTiBWhenExactlyOneTiB() {
+ void formatShouldUseTiBWhenExactlyOneTiB() {
assertThat(SizeFormat.format(1024L * 1024L * 1024L * 1024L))
.isEqualTo("1 TiB");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/SizeTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/SizeTest.java b/server/container/util/src/test/java/org/apache/james/util/SizeTest.java
index 0aaeae2..bc73a77 100644
--- a/server/container/util/src/test/java/org/apache/james/util/SizeTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/SizeTest.java
@@ -20,54 +20,57 @@
package org.apache.james.util;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SizeTest {
@Test
- public void testNoUnit() throws Exception {
+ void testNoUnit() throws Exception {
assertThat(Size.parse("1024").asBytes()).isEqualTo(1024);
}
@Test
- public void testUnitB() throws Exception {
+ void testUnitB() throws Exception {
assertThat(Size.parse("1024B").asBytes()).isEqualTo(1024);
}
@Test
- public void testUnitK() throws Exception {
+ void testUnitK() throws Exception {
assertThat(Size.parse("5K").asBytes()).isEqualTo(5 * 1024);
}
@Test
- public void testUnitM() throws Exception {
+ void testUnitM() throws Exception {
assertThat(Size.parse("5M").asBytes()).isEqualTo(5 * 1024 * 1024);
}
@Test
- public void testUnitG() throws Exception {
+ void testUnitG() throws Exception {
assertThat(Size.parse("1G").asBytes()).isEqualTo(1024 * 1024 * 1024);
}
@Test
- public void testUnknown() throws Exception {
+ void testUnknown() throws Exception {
assertThat(Size.parse("unknown").asBytes()).isEqualTo(Size.UNKNOWN_VALUE);
}
@Test
- public void testUnlimited() throws Exception {
+ void testUnlimited() throws Exception {
assertThat(Size.parse("unlimited").asBytes()).isEqualTo(Size.UNLIMITED_VALUE);
}
- @Test(expected = Exception.class)
- public void testBadUnit() throws Exception {
- Size.parse("42T");
+ @Test
+ void testBadUnit() {
+ assertThatThrownBy(() -> Size.parse("42T"))
+ .isInstanceOf(Exception.class);
}
- @Test(expected = NumberFormatException.class)
- public void testWrongNumber() throws Exception {
- Size.parse("42RG");
+ @Test
+ void testWrongNumber() throws Exception {
+ assertThatThrownBy(() -> Size.parse("42RG"))
+ .isInstanceOf(NumberFormatException.class);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/StreamUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/StreamUtilsTest.java b/server/container/util/src/test/java/org/apache/james/util/StreamUtilsTest.java
index 691c671..75f2526 100644
--- a/server/container/util/src/test/java/org/apache/james/util/StreamUtilsTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/StreamUtilsTest.java
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.stream.Stream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.github.steveash.guavate.Guavate;
import com.google.common.collect.ImmutableList;
@@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableList;
public class StreamUtilsTest {
@Test
- public void flattenShouldReturnEmptyWhenEmptyStreams() {
+ void flattenShouldReturnEmptyWhenEmptyStreams() {
assertThat(
StreamUtils.<Integer>flatten(ImmutableList.of())
.collect(Guavate.toImmutableList()))
@@ -40,7 +40,7 @@ public class StreamUtilsTest {
}
@Test
- public void flattenShouldPreserveSingleStreams() {
+ void flattenShouldPreserveSingleStreams() {
assertThat(
StreamUtils.flatten(ImmutableList.of(
Stream.of(1, 2, 3)))
@@ -49,7 +49,7 @@ public class StreamUtilsTest {
}
@Test
- public void flattenShouldMergeSeveralStreamsTogether() {
+ void flattenShouldMergeSeveralStreamsTogether() {
assertThat(
StreamUtils.flatten(ImmutableList.of(
Stream.of(1, 2, 3),
@@ -59,7 +59,7 @@ public class StreamUtilsTest {
}
@Test
- public void flattenShouldAcceptEmptyStreams() {
+ void flattenShouldAcceptEmptyStreams() {
assertThat(
StreamUtils.flatten(ImmutableList.of(
Stream.of()))
@@ -68,7 +68,7 @@ public class StreamUtilsTest {
}
@Test
- public void flattenShouldMergeEmptyStreamsWithOtherData() {
+ void flattenShouldMergeEmptyStreamsWithOtherData() {
assertThat(
StreamUtils.flatten(ImmutableList.of(
Stream.of(1, 2),
@@ -79,7 +79,7 @@ public class StreamUtilsTest {
}
@Test
- public void flattenShouldAcceptEmptyVarArg() {
+ void flattenShouldAcceptEmptyVarArg() {
assertThat(
StreamUtils.flatten()
.collect(Guavate.toImmutableList()))
@@ -87,29 +87,29 @@ public class StreamUtilsTest {
}
@Test
- public void flattenShouldThrowOnNullVarArg() {
+ void flattenShouldThrowOnNullVarArg() {
Stream<String>[] streams = null;
assertThatThrownBy(() -> StreamUtils.flatten(streams).collect(Guavate.toImmutableList()))
.isInstanceOf(NullPointerException.class);
}
@Test
- public void flattenShouldFlattenNonEmptyVarArg() {
+ void flattenShouldFlattenNonEmptyVarArg() {
assertThat(StreamUtils.flatten(Stream.of(1), Stream.of(2)).collect(Guavate.toImmutableList()))
.containsExactly(1, 2);
}
@Test
- public void ofNullableShouldReturnEmptyStreamWhenNull() {
+ void ofNullableShouldReturnEmptyStreamWhenNull() {
assertThat(StreamUtils.ofNullable(null)
.collect(Guavate.toImmutableList()))
.isEmpty();
}
@Test
- public void ofNullableShouldReturnAStreamWithElementsOfTheArray() {
+ void ofNullableShouldReturnAStreamWithElementsOfTheArray() {
assertThat(StreamUtils.ofNullable(ImmutableList.of(1, 2).toArray())
.collect(Guavate.toImmutableList()))
.containsExactly(1, 2);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0b58116/server/container/util/src/test/java/org/apache/james/util/TimeConverterTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/TimeConverterTest.java b/server/container/util/src/test/java/org/apache/james/util/TimeConverterTest.java
index 2a826c1..2d64018 100644
--- a/server/container/util/src/test/java/org/apache/james/util/TimeConverterTest.java
+++ b/server/container/util/src/test/java/org/apache/james/util/TimeConverterTest.java
@@ -19,15 +19,16 @@
package org.apache.james.util;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.concurrent.TimeUnit;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TimeConverterTest {
-
+
@Test
- public void getMilliSecondsShouldConvertValueWhenNoUnitAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenNoUnitAmountAsString() {
//Given
long expected = 2;
//When
@@ -37,7 +38,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldUseProvidedUnitWhenNoUnitAmountAsString() {
+ void getMilliSecondsShouldUseProvidedUnitWhenNoUnitAmountAsString() {
//Given
long expected = 2000;
//When
@@ -47,7 +48,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldNotUseProvidedUnitWhenNoUnitAmountAsString() {
+ void getMilliSecondsShouldNotUseProvidedUnitWhenNoUnitAmountAsString() {
//Given
long expected = 120000;
//When
@@ -56,8 +57,8 @@ public class TimeConverterTest {
assertThat(actual).isEqualTo(expected);
}
- @Test
- public void getMilliSecondsShouldConvertValueWhenMsecUnit() {
+ @Test
+ void getMilliSecondsShouldConvertValueWhenMsecUnit() {
//Given
long expected = 2;
//When
@@ -67,7 +68,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenMsecAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenMsecAmountAsString() {
//Given
long expected = 2;
//When
@@ -77,7 +78,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenMsUnit() {
+ void getMilliSecondsShouldConvertValueWhenMsUnit() {
//Given
long expected = 2;
//When
@@ -87,7 +88,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenMsAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenMsAmountAsString() {
//Given
long expected = 2;
//When
@@ -97,7 +98,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenMsUnitCapital() {
+ void getMilliSecondsShouldConvertValueWhenMsUnitCapital() {
//Given
long expected = 2;
//When
@@ -107,7 +108,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenMsCapitalAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenMsCapitalAmountAsString() {
//Given
long expected = 2;
//When
@@ -115,9 +116,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
+
@Test
- public void getMilliSecondsShouldConvertValueWhenMsecsUnit() {
+ void getMilliSecondsShouldConvertValueWhenMsecsUnit() {
//Given
long expected = 2;
//When
@@ -125,9 +126,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
+
@Test
- public void getMilliSecondsShouldConvertValueWhenMsecsAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenMsecsAmountAsString() {
//Given
long expected = 2;
//When
@@ -137,7 +138,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenSUnit() {
+ void getMilliSecondsShouldConvertValueWhenSUnit() {
//Given
long expected = TimeUnit.SECONDS.toMillis(2);
//When
@@ -147,7 +148,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenSAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenSAmountAsString() {
//Given
long expected = TimeUnit.SECONDS.toMillis(2);
//When
@@ -155,9 +156,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
- @Test
- public void getMilliSecondsShouldConvertValueWhenSecUnit() {
+
+ @Test
+ void getMilliSecondsShouldConvertValueWhenSecUnit() {
//Given
long expected = TimeUnit.SECONDS.toMillis(2);
//When
@@ -165,9 +166,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
- @Test
- public void getMilliSecondsShouldConvertValueWhenSecAmountAsString() {
+
+ @Test
+ void getMilliSecondsShouldConvertValueWhenSecAmountAsString() {
//Given
long expected = TimeUnit.SECONDS.toMillis(2);
//When
@@ -177,7 +178,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenSecCapitalUnit() {
+ void getMilliSecondsShouldConvertValueWhenSecCapitalUnit() {
//Given
long expected = TimeUnit.SECONDS.toMillis(2);
//When
@@ -187,7 +188,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenSecCapitalAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenSecCapitalAmountAsString() {
//Given
long expected = TimeUnit.SECONDS.toMillis(2);
//When
@@ -195,18 +196,18 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
- @Test
- public void getMilliSecondsShouldConvertValueWhenSecsUnit() {
+
+ @Test
+ void getMilliSecondsShouldConvertValueWhenSecsUnit() {
long expected = TimeUnit.SECONDS.toMillis(2);
//When
long actual = TimeConverter.getMilliSeconds(2, "secs");
//Then
assertThat(actual).isEqualTo(expected);
}
-
- @Test
- public void getMilliSecondsShouldConvertValueWhenSecsAmountAsString() {
+
+ @Test
+ void getMilliSecondsShouldConvertValueWhenSecsAmountAsString() {
//Given
long expected = TimeUnit.SECONDS.toMillis(2);
//When
@@ -216,7 +217,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenMUnit() {
+ void getMilliSecondsShouldConvertValueWhenMUnit() {
//Given
long expected = TimeUnit.MINUTES.toMillis(2);
//When
@@ -226,7 +227,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenMAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenMAmountAsString() {
//Given
long expected = TimeUnit.MINUTES.toMillis(2);
//When
@@ -235,8 +236,8 @@ public class TimeConverterTest {
assertThat(actual).isEqualTo(expected);
}
- @Test
- public void getMilliSecondsShouldConvertValueWhenMinuteUnit() {
+ @Test
+ void getMilliSecondsShouldConvertValueWhenMinuteUnit() {
//Given
long expected = TimeUnit.MINUTES.toMillis(2);
//When
@@ -244,9 +245,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
- @Test
- public void getMilliSecondsShouldConvertValueWhenMinuteAmountAsString() {
+
+ @Test
+ void getMilliSecondsShouldConvertValueWhenMinuteAmountAsString() {
//Given
long expected = TimeUnit.MINUTES.toMillis(2);
//When
@@ -256,7 +257,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenMinuteCapitalUnit() {
+ void getMilliSecondsShouldConvertValueWhenMinuteCapitalUnit() {
//Given
long expected = TimeUnit.MINUTES.toMillis(2);
//When
@@ -266,7 +267,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenMinuteCapitalAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenMinuteCapitalAmountAsString() {
//Given
long expected = TimeUnit.MINUTES.toMillis(2);
//When
@@ -276,7 +277,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenMinutesUnit() {
+ void getMilliSecondsShouldConvertValueWhenMinutesUnit() {
//Given
long expected = TimeUnit.MINUTES.toMillis(2);
//When
@@ -284,9 +285,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
- @Test
- public void getMilliSecondsShouldConvertValueWhenMinutesAmountAsString() {
+
+ @Test
+ void getMilliSecondsShouldConvertValueWhenMinutesAmountAsString() {
//Given
long expected = TimeUnit.MINUTES.toMillis(2);
//When
@@ -296,7 +297,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenHUnit() {
+ void getMilliSecondsShouldConvertValueWhenHUnit() {
//Given
long expected = TimeUnit.HOURS.toMillis(2);
//When
@@ -306,7 +307,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenHAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenHAmountAsString() {
//Given
long expected = TimeUnit.HOURS.toMillis(2);
//When
@@ -316,7 +317,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenHourUnit() {
+ void getMilliSecondsShouldConvertValueWhenHourUnit() {
//Given
long expected = TimeUnit.HOURS.toMillis(2);
//When
@@ -324,9 +325,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
+
@Test
- public void getMilliSecondsShouldConvertValueWhenHourAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenHourAmountAsString() {
//Given
long expected = TimeUnit.HOURS.toMillis(2);
//When
@@ -336,7 +337,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenHourCapitalUnit() {
+ void getMilliSecondsShouldConvertValueWhenHourCapitalUnit() {
//Given
long expected = TimeUnit.HOURS.toMillis(2);
//When
@@ -346,7 +347,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenHourCapitalAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenHourCapitalAmountAsString() {
//Given
long expected = TimeUnit.HOURS.toMillis(2);
//When
@@ -354,9 +355,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
+
@Test
- public void getMilliSecondsShouldConvertValueWhenHoursUnit() {
+ void getMilliSecondsShouldConvertValueWhenHoursUnit() {
//Given
long expected = TimeUnit.HOURS.toMillis(2);
//When
@@ -364,9 +365,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
- @Test
- public void getMilliSecondsShouldConvertValueWhenHoursAmountAsString() {
+
+ @Test
+ void getMilliSecondsShouldConvertValueWhenHoursAmountAsString() {
//Given
long expected = TimeUnit.HOURS.toMillis(2);
//When
@@ -376,7 +377,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenDUnit() {
+ void getMilliSecondsShouldConvertValueWhenDUnit() {
//Given
long expected = TimeUnit.DAYS.toMillis(2);
//When
@@ -386,7 +387,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenDAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenDAmountAsString() {
//Given
long expected = TimeUnit.DAYS.toMillis(2);
//When
@@ -394,9 +395,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
+
@Test
- public void getMilliSecondsShouldConvertValueWhenDayUnit() {
+ void getMilliSecondsShouldConvertValueWhenDayUnit() {
//Given
long expected = TimeUnit.DAYS.toMillis(2);
//When
@@ -404,9 +405,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
+
@Test
- public void getMilliSecondsShouldConvertValueWhenDayAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenDayAmountAsString() {
//Given
long expected = TimeUnit.DAYS.toMillis(2);
//When
@@ -416,7 +417,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenDayCapitalUnit() {
+ void getMilliSecondsShouldConvertValueWhenDayCapitalUnit() {
//Given
long expected = TimeUnit.DAYS.toMillis(2);
//When
@@ -426,7 +427,7 @@ public class TimeConverterTest {
}
@Test
- public void getMilliSecondsShouldConvertValueWhenDayCapitalAmountAsString() {
+ void getMilliSecondsShouldConvertValueWhenDayCapitalAmountAsString() {
//Given
long expected = TimeUnit.DAYS.toMillis(2);
//When
@@ -434,9 +435,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
+
@Test
- public void getMilliSecondsShouldConvertValueWhenDaysUnit() {
+ void getMilliSecondsShouldConvertValueWhenDaysUnit() {
//Given
long expected = TimeUnit.DAYS.toMillis(2);
//When
@@ -444,9 +445,9 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
- @Test
- public void getMilliSecondsShouldConvertValueWhenDaysAmountAsString() {
+
+ @Test
+ void getMilliSecondsShouldConvertValueWhenDaysAmountAsString() {
//Given
long expected = TimeUnit.DAYS.toMillis(2);
//When
@@ -454,19 +455,22 @@ public class TimeConverterTest {
//Then
assertThat(actual).isEqualTo(expected);
}
-
- @Test(expected = NumberFormatException.class)
- public void getMilliSecondsShouldThrowWhenIllegalUnitInUnit() {
- TimeConverter.getMilliSeconds(2, "week");
- }
-
- @Test(expected = NumberFormatException.class)
- public void getMilliSecondsShouldThrowWhenIllegalUnitInRawString() {
- TimeConverter.getMilliSeconds("2 week");
- }
- @Test (expected = NumberFormatException.class)
- public void getMilliSecondsShouldThrowWhenIllegalPattern() {
- TimeConverter.getMilliSeconds("illegal pattern");
+ @Test
+ void getMilliSecondsShouldThrowWhenIllegalUnitInUnit() {
+ assertThatThrownBy(() -> TimeConverter.getMilliSeconds(2, "week"))
+ .isInstanceOf(NumberFormatException.class);
+ }
+
+ @Test
+ void getMilliSecondsShouldThrowWhenIllegalUnitInRawString() {
+ assertThatThrownBy(() -> TimeConverter.getMilliSeconds("2 week"))
+ .isInstanceOf(NumberFormatException.class);
+ }
+
+ @Test
+ void getMilliSecondsShouldThrowWhenIllegalPattern() {
+ assertThatThrownBy(() -> TimeConverter.getMilliSeconds("illegal pattern"))
+ .isInstanceOf(NumberFormatException.class);
}
-}
\ No newline at end of file
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[7/7] james-project git commit: JAMES-2611 Use info level for logging
when managesieve.xml is missing
Posted by ro...@apache.org.
JAMES-2611 Use info level for logging when managesieve.xml is missing
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ab977196
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ab977196
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ab977196
Branch: refs/heads/master
Commit: ab977196f2a42eb6816d3f4507cc52000e2cb111
Parents: e57655f
Author: Gautier DI FOLCO <gd...@linagora.com>
Authored: Tue Nov 27 12:16:28 2018 +0100
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Tue Dec 18 13:56:45 2018 +0100
----------------------------------------------------------------------
.../apache/james/modules/protocols/ManageSieveServerModule.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/ab977196/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java b/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
index 2f87370..051d5b5 100644
--- a/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
+++ b/server/container/guice/protocols/managedsieve/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
@@ -25,6 +25,7 @@ import org.apache.james.managesieve.api.commands.CoreCommands;
import org.apache.james.managesieve.core.CoreProcessor;
import org.apache.james.managesieveserver.netty.ManageSieveServerFactory;
import org.apache.james.server.core.configuration.ConfigurationProvider;
+import org.apache.james.util.LoggingLevel;
import org.apache.james.utils.ConfigurationPerformer;
import org.apache.james.utils.GuiceProbe;
@@ -58,7 +59,7 @@ public class ManageSieveServerModule extends AbstractModule {
@Override
public void initModule() {
try {
- manageSieveServerFactory.configure(configurationProvider.getConfiguration("managesieveserver"));
+ manageSieveServerFactory.configure(configurationProvider.getConfiguration("managesieveserver", LoggingLevel.INFO));
manageSieveServerFactory.init();
} catch (Exception e) {
throw new RuntimeException(e);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[3/7] james-project git commit: JAMES-2611 Use info level for logging
when lmtpserver.xml is missing
Posted by ro...@apache.org.
JAMES-2611 Use info level for logging when lmtpserver.xml is missing
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5fb15251
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5fb15251
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5fb15251
Branch: refs/heads/master
Commit: 5fb152514c287cdf57c111efd6130ac062e81b07
Parents: ab97719
Author: Gautier DI FOLCO <gd...@linagora.com>
Authored: Tue Nov 27 14:45:45 2018 +0100
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Tue Dec 18 13:56:45 2018 +0100
----------------------------------------------------------------------
.../java/org/apache/james/modules/protocols/LMTPServerModule.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/5fb15251/server/container/guice/protocols/lmtp/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/lmtp/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java b/server/container/guice/protocols/lmtp/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
index dd67a1b..a6a0da2 100644
--- a/server/container/guice/protocols/lmtp/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
+++ b/server/container/guice/protocols/lmtp/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
@@ -25,6 +25,7 @@ import org.apache.james.lifecycle.api.Configurable;
import org.apache.james.lmtpserver.netty.LMTPServerFactory;
import org.apache.james.lmtpserver.netty.OioLMTPServerFactory;
import org.apache.james.server.core.configuration.ConfigurationProvider;
+import org.apache.james.util.LoggingLevel;
import org.apache.james.utils.ConfigurationPerformer;
import org.apache.james.utils.GuiceProbe;
@@ -61,7 +62,7 @@ public class LMTPServerModule extends AbstractModule {
@Override
public void initModule() {
try {
- lmtpServerFactory.configure(configurationProvider.getConfiguration("lmtpserver"));
+ lmtpServerFactory.configure(configurationProvider.getConfiguration("lmtpserver", LoggingLevel.INFO));
lmtpServerFactory.init();
} catch (Exception e) {
throw new RuntimeException(e);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[4/7] james-project git commit: JAMES-2611 Add Logger facilities
Posted by ro...@apache.org.
JAMES-2611 Add Logger facilities
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/18666e30
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/18666e30
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/18666e30
Branch: refs/heads/master
Commit: 18666e301362ba9d3b640ee570318a10fbba46c2
Parents: c9a2ebf
Author: Gautier DI FOLCO <gd...@linagora.com>
Authored: Tue Nov 27 12:11:27 2018 +0100
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Tue Dec 18 13:56:45 2018 +0100
----------------------------------------------------------------------
.../org/apache/james/util/LoggingLevel.java | 43 +++++++++++++
.../org/apache/james/util/LoggingLevelTest.java | 63 ++++++++++++++++++++
2 files changed, 106 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/18666e30/server/container/util/src/main/java/org/apache/james/util/LoggingLevel.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/main/java/org/apache/james/util/LoggingLevel.java b/server/container/util/src/main/java/org/apache/james/util/LoggingLevel.java
new file mode 100644
index 0000000..fa84e9e
--- /dev/null
+++ b/server/container/util/src/main/java/org/apache/james/util/LoggingLevel.java
@@ -0,0 +1,43 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.util;
+
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+
+import org.slf4j.Logger;
+
+public enum LoggingLevel {
+ DEBUG(logger -> logger::debug),
+ ERROR(logger -> logger::error),
+ INFO(logger -> logger::info),
+ TRACE(logger -> logger::trace),
+ WARNING(logger -> logger::warn);
+
+ private final Function<Logger, BiConsumer<String, Object[]>> formatter;
+
+ private LoggingLevel(Function<Logger, BiConsumer<String, Object[]>> formatter) {
+ this.formatter = formatter;
+ }
+
+ public void format(Logger logger, String format, Object... arguments) {
+ formatter.apply(logger).accept(format, arguments);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/18666e30/server/container/util/src/test/java/org/apache/james/util/LoggingLevelTest.java
----------------------------------------------------------------------
diff --git a/server/container/util/src/test/java/org/apache/james/util/LoggingLevelTest.java b/server/container/util/src/test/java/org/apache/james/util/LoggingLevelTest.java
new file mode 100644
index 0000000..dfb5fc0
--- /dev/null
+++ b/server/container/util/src/test/java/org/apache/james/util/LoggingLevelTest.java
@@ -0,0 +1,63 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.util;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+
+public class LoggingLevelTest {
+ @Test
+ public void formatShouldCallDebugWhenDebugLevelIsGiven() {
+ Logger logger = mock(Logger.class);
+ LoggingLevel.DEBUG.format(logger, "easy as {} {} {}", 1, 2.0, "3");
+ verify(logger).debug("easy as {} {} {}", 1, 2.0, "3");
+ }
+
+ @Test
+ public void formatShouldCallErrorWhenErrorLevelIsGiven() {
+ Logger logger = mock(Logger.class);
+ LoggingLevel.ERROR.format(logger, "easy as {} {} {}", 1, 2.0, "3");
+ verify(logger).error("easy as {} {} {}", 1, 2.0, "3");
+ }
+
+ @Test
+ public void formatShouldCallInfoWhenInfoLevelIsGiven() {
+ Logger logger = mock(Logger.class);
+ LoggingLevel.INFO.format(logger, "easy as {} {} {}", 1, 2.0, "3");
+ verify(logger).info("easy as {} {} {}", 1, 2.0, "3");
+ }
+
+ @Test
+ public void formatShouldCallTraceWhenTraceLevelIsGiven() {
+ Logger logger = mock(Logger.class);
+ LoggingLevel.TRACE.format(logger, "easy as {} {} {}", 1, 2.0, "3");
+ verify(logger).trace("easy as {} {} {}", 1, 2.0, "3");
+ }
+
+ @Test
+ public void formatShouldCallWarningWhenWarningLevelIsGiven() {
+ Logger logger = mock(Logger.class);
+ LoggingLevel.WARNING.format(logger, "easy as {} {} {}", 1, 2.0, "3");
+ verify(logger).warn("easy as {} {} {}", 1, 2.0, "3");
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[5/7] james-project git commit: JAMES-2611 Add Logging level
parameterization for ConfigurationProvider
Posted by ro...@apache.org.
JAMES-2611 Add Logging level parameterization for ConfigurationProvider
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e57655f9
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e57655f9
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e57655f9
Branch: refs/heads/master
Commit: e57655f961e6b58e49835f289ca09e2dea5a58d2
Parents: 18666e3
Author: Gautier DI FOLCO <gd...@linagora.com>
Authored: Wed Nov 28 11:37:00 2018 +0100
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Tue Dec 18 13:56:45 2018 +0100
----------------------------------------------------------------------
.../server/core/configuration/ConfigurationProvider.java | 8 +++++++-
.../core/configuration/FileConfigurationProvider.java | 9 +++++----
.../org/apache/james/DefaultCassandraJamesServerTest.java | 2 +-
.../java/org/apache/james/DefaultMemoryJamesServerTest.java | 2 +-
4 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/e57655f9/server/container/core/src/main/java/org/apache/james/server/core/configuration/ConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/configuration/ConfigurationProvider.java b/server/container/core/src/main/java/org/apache/james/server/core/configuration/ConfigurationProvider.java
index c1f5539..1e23289 100644
--- a/server/container/core/src/main/java/org/apache/james/server/core/configuration/ConfigurationProvider.java
+++ b/server/container/core/src/main/java/org/apache/james/server/core/configuration/ConfigurationProvider.java
@@ -21,10 +21,16 @@ package org.apache.james.server.core.configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.util.LoggingLevel;
public interface ConfigurationProvider {
- HierarchicalConfiguration getConfiguration(String component)
+ default HierarchicalConfiguration getConfiguration(String component)
+ throws ConfigurationException {
+ return getConfiguration(component, LoggingLevel.WARNING);
+ }
+
+ HierarchicalConfiguration getConfiguration(String component, LoggingLevel loggingLevelOnError)
throws ConfigurationException;
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/e57655f9/server/container/core/src/main/java/org/apache/james/server/core/configuration/FileConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/server/container/core/src/main/java/org/apache/james/server/core/configuration/FileConfigurationProvider.java b/server/container/core/src/main/java/org/apache/james/server/core/configuration/FileConfigurationProvider.java
index 911907e..1fcfe6b 100644
--- a/server/container/core/src/main/java/org/apache/james/server/core/configuration/FileConfigurationProvider.java
+++ b/server/container/core/src/main/java/org/apache/james/server/core/configuration/FileConfigurationProvider.java
@@ -29,6 +29,7 @@ import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.util.LoggingLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,12 +64,12 @@ public class FileConfigurationProvider implements ConfigurationProvider {
}
@Override
- public HierarchicalConfiguration getConfiguration(String component) throws ConfigurationException {
+ public HierarchicalConfiguration getConfiguration(String component, LoggingLevel loggingLevelOnError) throws ConfigurationException {
Preconditions.checkNotNull(component);
List<String> configPathParts = Splitter.on(".").splitToList(component);
Preconditions.checkArgument(!configPathParts.isEmpty());
- Optional<InputStream> inputStream = retrieveConfigInputStream(configPathParts.get(0));
+ Optional<InputStream> inputStream = retrieveConfigInputStream(configPathParts.get(0), loggingLevelOnError);
if (inputStream.isPresent()) {
return selectConfigurationPart(configPathParts,
getConfig(inputStream.get()));
@@ -80,13 +81,13 @@ public class FileConfigurationProvider implements ConfigurationProvider {
return selectHierarchicalConfigPart(config, Iterables.skip(configPathParts, 1));
}
- private Optional<InputStream> retrieveConfigInputStream(String configurationFileWithoutExtension) throws ConfigurationException {
+ private Optional<InputStream> retrieveConfigInputStream(String configurationFileWithoutExtension, LoggingLevel loggingLevelOnError) throws ConfigurationException {
Preconditions.checkArgument(!Strings.isNullOrEmpty(configurationFileWithoutExtension), "The configuration file name should not be empty or null");
try {
return Optional.of(
fileSystem.getResource(configurationPrefix + configurationFileWithoutExtension + CONFIGURATION_FILE_SUFFIX));
} catch (IOException e) {
- LOGGER.warn("Unable to locate configuration file {}" + CONFIGURATION_FILE_SUFFIX + ", assuming empty configuration", configurationFileWithoutExtension);
+ loggingLevelOnError.format(LOGGER, "Unable to locate configuration file {}" + CONFIGURATION_FILE_SUFFIX + ", assuming empty configuration", configurationFileWithoutExtension);
return Optional.empty();
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/e57655f9/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DefaultCassandraJamesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DefaultCassandraJamesServerTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DefaultCassandraJamesServerTest.java
index 7e6b6a9..65495b5 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DefaultCassandraJamesServerTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DefaultCassandraJamesServerTest.java
@@ -44,7 +44,7 @@ class DefaultCassandraJamesServerTest {
.overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
.overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))
.overrideWith(binder -> binder.bind(PropertiesProvider.class).to(FailingPropertiesProvider.class))
- .overrideWith(binder -> binder.bind(ConfigurationProvider.class).toInstance(s -> new HierarchicalConfiguration())))
+ .overrideWith(binder -> binder.bind(ConfigurationProvider.class).toInstance((s, l) -> new HierarchicalConfiguration())))
.build();
@Test
http://git-wip-us.apache.org/repos/asf/james-project/blob/e57655f9/server/container/guice/memory-guice/src/test/java/org/apache/james/DefaultMemoryJamesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/DefaultMemoryJamesServerTest.java b/server/container/guice/memory-guice/src/test/java/org/apache/james/DefaultMemoryJamesServerTest.java
index fdd2196..47a8d19 100644
--- a/server/container/guice/memory-guice/src/test/java/org/apache/james/DefaultMemoryJamesServerTest.java
+++ b/server/container/guice/memory-guice/src/test/java/org/apache/james/DefaultMemoryJamesServerTest.java
@@ -41,7 +41,7 @@ class DefaultMemoryJamesServerTest {
.overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))
.overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
.overrideWith(binder -> binder.bind(PropertiesProvider.class).to(FailingPropertiesProvider.class))
- .overrideWith(binder -> binder.bind(ConfigurationProvider.class).toInstance(s -> new HierarchicalConfiguration())))
+ .overrideWith(binder -> binder.bind(ConfigurationProvider.class).toInstance((s, l) -> new HierarchicalConfiguration())))
.build();
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org