From 89f0f8720319a522f04faf2b6ffdbdd273c59be5 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 20:43:07 +0100 Subject: [PATCH 01/16] Upgrade kemitix-parent to 1.2.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a0f0bde..9dd2a54 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ net.kemitix kemitix-parent - 1.1.0 + 1.2.0 From 1bc8bac22979e774096f051ff8d387cfb913dd19 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 20:44:51 +0100 Subject: [PATCH 02/16] Update checkstyle ruleset from kemitix-parent-1.2.0 template --- checkstyle.xml | 355 ++++++++++++++++++++++++++----------------------- 1 file changed, 185 insertions(+), 170 deletions(-) diff --git a/checkstyle.xml b/checkstyle.xml index ba1e682..3eea98b 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -1,192 +1,207 @@ + "-//Puppy Crawl//DTD Check Configuration 1.3//EN" + "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> - + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - From 79032c0dd83aeb16f76d96e8af8305742ff3354f Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 20:46:39 +0100 Subject: [PATCH 03/16] WiserAssertions: apply checkstyle rule DeclarationOrder --- .../wiser/assertions/WiserAssertions.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java index 920adc5..6bce8a6 100644 --- a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java +++ b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java @@ -3,16 +3,15 @@ package net.kemitix.wiser.assertions; import org.subethamail.wiser.Wiser; import org.subethamail.wiser.WiserMessage; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; import java.io.IOException; import java.text.MessageFormat; import java.util.List; import java.util.function.Predicate; import java.util.function.Supplier; -import javax.mail.MessagingException; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMultipart; - /** * Provides a set of assertions for checking the status of any messages received * by subethamail's Wiser. @@ -46,6 +45,15 @@ public final class WiserAssertions { */ private final List messages; + /** + * Private constructor. + * + * @param wiserMessages the messages to be tested by the assertions + */ + private WiserAssertions(final List wiserMessages) { + this.messages = wiserMessages; + } + /** * Creates an instance of {@code} WiserAssertions} ready to make assertions * on any messages received by the {@link Wiser} server. @@ -58,15 +66,6 @@ public final class WiserAssertions { return new WiserAssertions(wiser.getMessages()); } - /** - * Private constructor. - * - * @param wiserMessages the messages to be tested by the assertions - */ - private WiserAssertions(final List wiserMessages) { - this.messages = wiserMessages; - } - /** * Checks that there was at least one email received that was sent from the * {@code sender}. From 97d67cb5574eca946a452135d8957e9196cb2fcd Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 20:51:48 +0100 Subject: [PATCH 04/16] WiserAssertions: apply checkstyle rule MultipleStringLiterals --- .../kemitix/wiser/assertions/WiserAssertions.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java index 6bce8a6..e583c72 100644 --- a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java +++ b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java @@ -40,6 +40,9 @@ import java.util.function.Supplier; */ public final class WiserAssertions { + private static final String ERROR_MESSAGE_SUBJECT + = "No message with subject [{0}] found!"; + /** * The messages received by Wiser. */ @@ -105,9 +108,8 @@ public final class WiserAssertions { public WiserAssertions withSubject(final String subject) { Predicate predicate = m -> subject.equals(unchecked(getMimeMessage(m)::getSubject)); - findFirstOrElseThrow(predicate, - assertionError("No message with subject [{0}] found!", - subject)); + findFirstOrElseThrow(predicate, assertionError(ERROR_MESSAGE_SUBJECT, + subject)); return this; } @@ -123,9 +125,8 @@ public final class WiserAssertions { Predicate predicate = m -> unchecked(getMimeMessage(m)::getSubject) .contains(subject); - findFirstOrElseThrow(predicate, - assertionError("No message with subject [{0}] found!", - subject)); + findFirstOrElseThrow(predicate, assertionError(ERROR_MESSAGE_SUBJECT, + subject)); return this; } From cef89074ef1a110aba0f4f11bab2376139a584a0 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 20:52:41 +0100 Subject: [PATCH 05/16] WiserAssertions: apply rule ReturnCount --- .../kemitix/wiser/assertions/WiserAssertions.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java index e583c72..9ec032e 100644 --- a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java +++ b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java @@ -181,16 +181,20 @@ public final class WiserAssertions { private String getMimeMessageBody(final WiserMessage message) throws IOException, MessagingException { Object content = getMimeMessage(message).getContent(); + String result = null; if (content instanceof String) { - return (String) content; + result = (String) content; } if (content instanceof MimeMessage) { - return content.toString(); + result = content.toString(); } if (content instanceof MimeMultipart) { - return getMimeMultipartAsString((MimeMultipart) content); + result = getMimeMultipartAsString((MimeMultipart) content); } - throw new RuntimeException("Unexpected MimeMessage content"); + if (result == null) { + throw new RuntimeException("Unexpected MimeMessage content"); + } + return result; } /** From af4b48e2121960c68e10e0176bdbc1ba9af59cc3 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 20:55:35 +0100 Subject: [PATCH 06/16] WiserAssertions: suppress checkstyle rule IllegalCatch --- src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java index 9ec032e..006a7c3 100644 --- a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java +++ b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java @@ -253,6 +253,7 @@ public final class WiserAssertions { * * @return the product of the supplier */ + @SuppressWarnings("illegalCatch") public static T unchecked(final ThrowingSupplier supplier) { try { return supplier.get(); From d20322cc65ecf8655bc5db4e351ecc4318db071c Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 20:56:22 +0100 Subject: [PATCH 07/16] WiserAssertions: suppress checkstyle rule IllegalThrows --- src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java index 006a7c3..34c2f2e 100644 --- a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java +++ b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java @@ -302,6 +302,7 @@ public final class WiserAssertions { * * @throws Throwable on error */ + @SuppressWarnings("illegalthrows") T get() throws Throwable; } } From 235ea4795746f317a92ac68d4428e6dd98ca1965 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 21:13:39 +0100 Subject: [PATCH 08/16] Update code style and reorganise methods --- .../wiser/assertions/WiserAssertions.java | 203 +++++++++--------- 1 file changed, 105 insertions(+), 98 deletions(-) diff --git a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java index 34c2f2e..76da070 100644 --- a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java +++ b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java @@ -3,39 +3,48 @@ package net.kemitix.wiser.assertions; import org.subethamail.wiser.Wiser; import org.subethamail.wiser.WiserMessage; -import javax.mail.MessagingException; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMultipart; import java.io.IOException; import java.text.MessageFormat; import java.util.List; import java.util.function.Predicate; import java.util.function.Supplier; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; + /** * Provides a set of assertions for checking the status of any messages received * by subethamail's Wiser. - * *
- * {@code
+ * 
  * {@literal @}Before
- * public void setUp() throws IOException {
- *     wiser = new Wiser(PORT);
- *     wiser.start();
- * }
+ *  public void setUp() throws IOException {
+ *      wiser = new Wiser(PORT);
+ *      wiser.start();
+ *  }
  *
- * {@literal @}After public void tearDown() { wiser.stop(); }
+ * {@literal @}After
+ *  public void tearDown() {
+ *      wiser.stop();
+ *  }
  *
- * {@literal @}Test public void testMail() { //given ...
- *
- * //when ...
- *
- * //then WiserAssertions.assertReceivedMessage(wiser) .from(sender)
- * .to(recipient_alpha) .to(recipient_beta) .withSubjectContains(subject_prefix)
- * .withSubjectContains(subject_suffix) .withContentContains(message_element_1)
- * .withContentContains(message_element_2)
- * .withContentContains(message_element_3); }
- * }
+ * {@literal @}Test
+ *  public void testMail() {
+ *      //given ...
+ *      //when ...
+ *      //then
+ *      WiserAssertions.assertReceivedMessage(wiser)
+ *                     .from(sender)
+ *                     .to(recipient_alpha)
+ *                     .to(recipient_beta)
+ *                     .withSubjectContains(subject_prefix)
+ *                     .withSubjectContains(subject_suffix)
+ *                     .withContentContains(message_element_1)
+ *                     .withContentContains(message_element_2)
+ *                     .withContentContains(message_element_3);
+ *  }
+ * 
  * 
*/ public final class WiserAssertions { @@ -83,6 +92,39 @@ public final class WiserAssertions { return this; } + /** + * Checks that at least on message matches the predicate or the supplied + * exception will be thrown. + * + * @param predicate the condition a message must match + * @param exceptionSupplier the supplier of the exception + */ + private void findFirstOrElseThrow( + final Predicate predicate, + final Supplier exceptionSupplier) { + messages.stream() + .filter(predicate) + .findFirst() + .orElseThrow(exceptionSupplier); + } + + /** + * Returns a {@link Supplier} for an {@link AssertionError}. + * + * @param errorMessage the message for the exception + * @param args the parameters to insert into the message using + * {@link MessageFormat} + * + * @return a supplier of an {@link AssertionError} + */ + @SuppressWarnings( + {"ThrowableInstanceNotThrown", "ThrowableInstanceNeverThrown"}) + private static Supplier assertionError( + final String errorMessage, final Object... args) { + return () -> new AssertionError( + MessageFormat.format(errorMessage, args)); + } + /** * Checks that there was at least one email received that was sent to the * {@code recipient}. @@ -106,13 +148,44 @@ public final class WiserAssertions { * @return the {@code WiserAssertions} instance */ public WiserAssertions withSubject(final String subject) { - Predicate predicate - = m -> subject.equals(unchecked(getMimeMessage(m)::getSubject)); - findFirstOrElseThrow(predicate, assertionError(ERROR_MESSAGE_SUBJECT, - subject)); + Predicate predicate = m -> subject.equals( + unchecked(getMimeMessage(m)::getSubject)); + findFirstOrElseThrow(predicate, + assertionError(ERROR_MESSAGE_SUBJECT, subject)); return this; } + /** + * Convert any checked Exceptions into unchecked Exceptions. + * + * @param the item type to be returned after suppressing any + * checked exceptions + * @param supplier the source of the return value that could cause a checked + * exception + * + * @return the product of the supplier + */ + @SuppressWarnings("illegalCatch") + public static T unchecked(final ThrowingSupplier supplier) { + try { + return supplier.get(); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /** + * Returns the mime message within the {@link WiserMessage} converting any + * {@link MessagingException}s into {@link RuntimeException}s. + * + * @param wiserMessage the message + * + * @return the mime message + */ + private MimeMessage getMimeMessage(final WiserMessage wiserMessage) { + return unchecked(wiserMessage::getMimeMessage); + } + /** * Checks that there was at least one email received that has a subject that * contains the search text. @@ -122,11 +195,10 @@ public final class WiserAssertions { * @return the {@code WiserAssertions} instance */ public WiserAssertions withSubjectContains(final String subject) { - Predicate predicate - = m -> unchecked(getMimeMessage(m)::getSubject) - .contains(subject); - findFirstOrElseThrow(predicate, assertionError(ERROR_MESSAGE_SUBJECT, - subject)); + Predicate predicate = m -> unchecked( + getMimeMessage(m)::getSubject).contains(subject); + findFirstOrElseThrow(predicate, + assertionError(ERROR_MESSAGE_SUBJECT, subject)); return this; } @@ -140,8 +212,8 @@ public final class WiserAssertions { */ public WiserAssertions withContent(final String content) { findFirstOrElseThrow(m -> { - ThrowingSupplier contentAsString - = () -> getMimeMessageBody(m).trim(); + ThrowingSupplier contentAsString = () -> getMimeMessageBody( + m).trim(); return content.equals(unchecked(contentAsString)); }, assertionError("No message with content [{0}] found!", content)); return this; @@ -158,8 +230,8 @@ public final class WiserAssertions { public WiserAssertions withContentContains(final String content) { StringBuilder messageContent = new StringBuilder(); findFirstOrElseThrow((WiserMessage m) -> { - ThrowingSupplier contentAsString - = () -> getMimeMessageBody(m).trim(); + ThrowingSupplier contentAsString = () -> getMimeMessageBody( + m).trim(); messageContent.append(unchecked(contentAsString)); return unchecked(contentAsString).contains(content); }, assertionError( @@ -197,71 +269,6 @@ public final class WiserAssertions { return result; } - /** - * Checks that at least on message matches the predicate or the supplied - * exception will be thrown. - * - * @param predicate the condition a message must match - * @param exceptionSupplier the supplier of the exception - */ - private void findFirstOrElseThrow( - final Predicate predicate, - final Supplier exceptionSupplier - ) { - messages.stream().filter(predicate) - .findFirst().orElseThrow(exceptionSupplier); - } - - /** - * Returns the mime message within the {@link WiserMessage} converting any - * {@link MessagingException}s into {@link RuntimeException}s. - * - * @param wiserMessage the message - * - * @return the mime message - */ - private MimeMessage getMimeMessage(final WiserMessage wiserMessage) { - return unchecked(wiserMessage::getMimeMessage); - } - - /** - * Returns a {@link Supplier} for an {@link AssertionError}. - * - * @param errorMessage the message for the exception - * @param args the parameters to insert into the message using - * {@link MessageFormat} - * - * @return a supplier of an {@link AssertionError} - */ - @SuppressWarnings( - {"ThrowableInstanceNotThrown", "ThrowableInstanceNeverThrown"}) - private static Supplier assertionError( - final String errorMessage, - final Object... args - ) { - return () - -> new AssertionError(MessageFormat.format(errorMessage, args)); - } - - /** - * Convert any checked Exceptions into unchecked Exceptions. - * - * @param the item type to be returned after suppressing any - * checked exceptions - * @param supplier the source of the return value that could cause a checked - * exception - * - * @return the product of the supplier - */ - @SuppressWarnings("illegalCatch") - public static T unchecked(final ThrowingSupplier supplier) { - try { - return supplier.get(); - } catch (Throwable e) { - throw new RuntimeException(e); - } - } - /** * Converts a {@link MimeMultipart} into a {@link String} stripping out the * mime part boundary and headers.. From 2543593f2133ae530159b11a977bd456f5ace2a6 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 21:22:31 +0100 Subject: [PATCH 09/16] Upgrade simple-java-mail to 3.1.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a0f0bde..41731aa 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ 3.1.7 4.12 1.10.19 - 3.0.1 + 3.1.1 4.2.6.RELEASE
From 80fbbb1c60af741d822810b7ff3924f1e3a92bca Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 21:32:45 +0100 Subject: [PATCH 10/16] Report coverage reports to coveralls --- .travis.yml | 2 ++ pom.xml | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9bcf999..3e912ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ language: java jdk: - oraclejdk8 +after_success: + - mvn clean cobertura:cobertura coveralls:report diff --git a/pom.xml b/pom.xml index a0f0bde..062697b 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,7 @@ 1.10.19 3.0.1 4.2.6.RELEASE + 4.2.0 @@ -77,4 +78,13 @@ + + + + org.eluder.coveralls + coveralls-maven-plugin + ${coveralls-maven-plugin.version} + + + From 67fb0d090121bd50d62ccb27c4207a83e6d6daf7 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 21:43:41 +0100 Subject: [PATCH 11/16] Add Build and Coverage Status badges to README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index caf9cc3..0ce663c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Build Status](https://travis-ci.org/kemitix/wiser-assertions.svg?branch=develop)](https://travis-ci.org/kemitix/wiser-assertions) +[![Coverage Status](https://coveralls.io/repos/github/kemitix/wiser-assertions/badge.svg?branch=develop)](https://coveralls.io/github/kemitix/wiser-assertions?branch=develop) + # wiser-assertions Assertions for Wiser SMTP test server from subethamail @@ -38,4 +41,4 @@ Taken from Rafal Browiec [WiserAssertions] class. .withContentContains(message_element_3); } -[WiserAssertions]:http://blog.codeleak.pl/2014/09/testing-mail-code-in-spring-boot.html \ No newline at end of file +[WiserAssertions]:http://blog.codeleak.pl/2014/09/testing-mail-code-in-spring-boot.html From 03063ef9b7f665b5b02a090c046d7d7db4ca3cda Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 2 Jun 2016 23:03:24 +0100 Subject: [PATCH 12/16] Use correct coverage test command Cut-and-pasted the wrong example command for travis-CI. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3e912ec..7a1d0fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,4 @@ language: java jdk: - oraclejdk8 after_success: - - mvn clean cobertura:cobertura coveralls:report + - mvn clean test jacoco:report coveralls:report From 8e950db6f4c30b08b1eb6ddb17050782d19ec3c0 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 10 Jun 2016 10:36:43 +0100 Subject: [PATCH 13/16] Update .gitignore to use template --- .gitignore | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index e43e9a3..4ea327c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ -*.class - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - # Package Files # *.jar *.war @@ -10,4 +5,44 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* -/target + +# maven build outputs +target/ + +# netbeans legacy +nbproject/ +nbactions.xml + +# eclipse legacy +.project + +# intellij +.idea/libraries/ +.idea/workspace.xml +.idea/uiDesigner.xml +.idea/compiler.xml +.idea/misc.xml +.idea/checkstyle.xml +.idea/artifacts/ +.idea/dataSources* +.idea/tasks.xml +.idea/dictionaries/ +.idea/shelf/ +.idea/dynamic.xml +.idea/sqlDataSources.xml +.idea/gradle.xml +.idea/mongoSettings.xml + +# Spring +spring.log +logs/ +/application.properties +/bootstrap.properties + +# Composer-style +vendor + +# Git and temp files +*.orig +*.patch +*~ From 3984f801468a890ad0da6e8b40ed81140bccae15 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 10 Jun 2016 10:36:59 +0100 Subject: [PATCH 14/16] Add files not longer ignored --- .idea/.name | 1 + .idea/checkstyle-idea.xml | 10 ++ .idea/codeStyleSettings.xml | 105 ++++++++++++++++++ .idea/encodings.xml | 6 + .idea/inspectionProfiles/Project_Default.xml | 60 ++++++++++ .../inspectionProfiles/profiles_settings.xml | 7 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 + wiser-assertions.iml | 33 ++++++ 9 files changed, 236 insertions(+) create mode 100644 .idea/.name create mode 100644 .idea/checkstyle-idea.xml create mode 100644 .idea/codeStyleSettings.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 wiser-assertions.iml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..aa042d1 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +wiser-assertions \ No newline at end of file diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml new file mode 100644 index 0000000..9d5b48d --- /dev/null +++ b/.idea/checkstyle-idea.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 0000000..fb808ee --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,105 @@ + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..b26911b --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..b42a9f8 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,60 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..3b31283 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0cf1fee --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/wiser-assertions.iml b/wiser-assertions.iml new file mode 100644 index 0000000..2bfebb1 --- /dev/null +++ b/wiser-assertions.iml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 88b821c9b7455b76d94ee94fa5d41a6c71210b9f Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 23 Aug 2018 20:00:12 +0100 Subject: [PATCH 15/16] jenkins: switch to Jenkins and trunk based development --- .travis.yml | 9 ++-- Jenkinsfile.groovy | 104 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 Jenkinsfile.groovy diff --git a/.travis.yml b/.travis.yml index 7a1d0fd..65b9122 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ language: java jdk: - - oraclejdk8 -after_success: - - mvn clean test jacoco:report coveralls:report +- oraclejdk8 +cache: + directories: + - "$HOME/.m2" +install: true +script: "mvn -B -U clean install" diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy new file mode 100644 index 0000000..f9bfea5 --- /dev/null +++ b/Jenkinsfile.groovy @@ -0,0 +1,104 @@ +final String publicRepo = 'https://github.com/kemitix/' +final String mvn = "mvn --batch-mode --update-snapshots --errors" +final dependenciesSupportJDK = 10 + +pipeline { + agent any + stages { + stage('Build & Test') { + steps { + withMaven(maven: 'maven', jdk: 'JDK 1.8') { + sh "${mvn} clean compile checkstyle:checkstyle pmd:pmd test" + // PMD to Jenkins + pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' + } + } + } + stage('Report Coverage') { + steps { + withMaven(maven: 'maven', jdk: 'JDK 1.8') { + // Code Coverage to Jenkins + jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' + } + } + } + stage('Report Checkstyle') { + steps { + withMaven(maven: 'maven', jdk: 'JDK 1.8') { + // Checkstyle to Jenkins + step([$class: 'hudson.plugins.checkstyle.CheckStylePublisher', + pattern: '**/target/checkstyle-result.xml', + healthy:'20', + unHealthy:'100']) + } + } + } + stage('Verify & Install') { + steps { + withMaven(maven: 'maven', jdk: 'JDK 1.8') { + sh "${mvn} -DskipTests install" + } + } + } + stage('SonarQube (published)') { + when { expression { isPublished(publicRepo) } } + steps { + withSonarQubeEnv('sonarqube') { + withMaven(maven: 'maven', jdk: 'JDK 1.8') { + sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" + } + } + } + } + stage('Deploy (published release branch)') { + when { + expression { + (isReleaseBranch() && + isPublished(publicRepo) && + notSnapshot()) + } + } + steps { + withMaven(maven: 'maven', jdk: 'JDK 1.8') { + sh "${mvn} --activate-profiles release deploy" + } + } + } + stage('Build Java 9') { + when { expression { dependenciesSupportJDK >= 9 } } + steps { + withMaven(maven: 'maven', jdk: 'JDK 9') { + sh "${mvn} clean verify -Djava.version=9" + } + } + } + stage('Build Java 10') { + when { expression { dependenciesSupportJDK >= 10 } } + steps { + withMaven(maven: 'maven', jdk: 'JDK 10') { + sh "${mvn} clean verify -Djava.version=10" + } + } + } + } +} + +private boolean isReleaseBranch() { + return branchStartsWith('release/') +} + +private boolean branchStartsWith(final String branchName) { + startsWith(env.GIT_BRANCH, branchName) +} + +private boolean isPublished(final String repo) { + startsWith(env.GIT_URL, repo) +} + +private static boolean startsWith(final String value, final String match) { + value != null && value.startsWith(match) +} + +private boolean notSnapshot() { + return !(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") +} From 76022b8877fba3d7af7ed8c083bc7d19a2871282 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 23 Aug 2018 22:03:57 +0100 Subject: [PATCH 16/16] Upgrade kemitix-parent to 5.1.1 to bring Java 9+ compatibility --- LICENSE | 22 ---------- LICENSE.txt | 20 +++++++++ pom.xml | 39 +++++++++++++--- .../wiser/assertions/WiserAssertions.java | 23 ++++++++++ .../wiser/assertions/package-info.java | 44 +++++++++---------- 5 files changed, 96 insertions(+), 52 deletions(-) delete mode 100644 LICENSE create mode 100644 LICENSE.txt diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 6d6f5e9..0000000 --- a/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Paul Campbell - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..7607e05 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,20 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2018 Paul Campbell + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE + * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ diff --git a/pom.xml b/pom.xml index 6daedb3..f9c265e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,8 +1,18 @@ + + + net.kemitix + kemitix-parent + 5.1.1 + + + 4.0.0 + net.kemitix wiser-assertions + 0.4.0 jar @@ -24,14 +34,12 @@ git@github.com:kemitix/wiser-assertions.git - - net.kemitix - kemitix-parent - 1.2.0 - - - UTF-8 + 2.11 + 0.9.0 + 4.1.1 + net.kemitix.wiser.assertions + 1.4.7 3.1.7 4.12 @@ -39,6 +47,10 @@ 3.1.1 4.2.6.RELEASE 4.2.0 + + 0 + 0 + 1 @@ -85,6 +97,19 @@ coveralls-maven-plugin ${coveralls-maven-plugin.version} + + + io.repaint.maven + tiles-maven-plugin + ${tiles-maven-plugin.version} + true + + + net.kemitix.tiles:all:${kemitix-tiles.version} + net.kemitix.checkstyle:tile:${kemitix-checkstyle.version} + + + diff --git a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java index 76da070..1d3b26a 100644 --- a/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java +++ b/src/main/java/net/kemitix/wiser/assertions/WiserAssertions.java @@ -1,3 +1,24 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2018 Paul Campbell + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE + * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package net.kemitix.wiser.assertions; import org.subethamail.wiser.Wiser; @@ -47,6 +68,7 @@ import javax.mail.internet.MimeMultipart; * * */ +@SuppressWarnings("methodcount") public final class WiserAssertions { private static final String ERROR_MESSAGE_SUBJECT @@ -250,6 +272,7 @@ public final class WiserAssertions { * @throws IOException if error extracting the mime message * @throws MessagingException if the message type is not known */ + @SuppressWarnings("npathcomplexity") private String getMimeMessageBody(final WiserMessage message) throws IOException, MessagingException { Object content = getMimeMessage(message).getContent(); diff --git a/src/main/java/net/kemitix/wiser/assertions/package-info.java b/src/main/java/net/kemitix/wiser/assertions/package-info.java index f459df7..930e3bc 100644 --- a/src/main/java/net/kemitix/wiser/assertions/package-info.java +++ b/src/main/java/net/kemitix/wiser/assertions/package-info.java @@ -1,28 +1,26 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2018 Paul Campbell + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE + * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + /** * Provides {@link WiserAssertions} to check for messages received by the Wiser * SMTP test server from subethamail. - * - *

- * The MIT License. - *

- * Copyright 2015 pcampbell. - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. */ package net.kemitix.wiser.assertions;