From b03e0b8c35abb3d4bc964f1bb7f352068df157f3 Mon Sep 17 00:00:00 2001 From: Anirudh Date: Tue, 1 Oct 2019 20:34:19 +0200 Subject: [PATCH 01/30] Fix for BallThreadTest#testResume (#935) * Fix for flaky test * Remove other file changes * Remove other file changes * Remove other file changes not related to bug --- twin/src/test/java/com/iluwatar/twin/BallThreadTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twin/src/test/java/com/iluwatar/twin/BallThreadTest.java b/twin/src/test/java/com/iluwatar/twin/BallThreadTest.java index 6e46cd4f1af5..5b5f8f6a2aea 100644 --- a/twin/src/test/java/com/iluwatar/twin/BallThreadTest.java +++ b/twin/src/test/java/com/iluwatar/twin/BallThreadTest.java @@ -84,7 +84,7 @@ public void testResume() { verifyZeroInteractions(ballItem); ballThread.resumeMe(); - sleep(200); + sleep(300); verify(ballItem, atLeastOnce()).draw(); verify(ballItem, atLeastOnce()).move(); From 823c58bef2197c30d7f8a40c2701973ee9a04ea2 Mon Sep 17 00:00:00 2001 From: Denise Date: Wed, 2 Oct 2019 08:53:57 +0100 Subject: [PATCH 02/30] added new information (#937) --- abstract-factory/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/abstract-factory/README.md b/abstract-factory/README.md index 0bf86dfa6a91..0084030b645e 100644 --- a/abstract-factory/README.md +++ b/abstract-factory/README.md @@ -169,15 +169,20 @@ Use the Abstract Factory pattern when * you need a run-time value to construct a particular dependency * you want to decide which product to call from a family at runtime. * you need to supply one or more parameters only known at run-time before you can resolve a dependency. +* when you need consistency among products +* you don’t want to change existing code when adding new products or families of products to the program. ## Use Cases: * Selecting to call the appropriate implementation of FileSystemAcmeService or DatabaseAcmeService or NetworkAcmeService at runtime. * Unit test case writing becomes much easier +* UI tools for different OS ## Consequences: * Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time. +* While the pattern is great when creating predefined objects, adding the new ones might be challenging. +* The code may become more complicated than it should be, since a lot of new interfaces and classes are introduced along with the pattern. ## Tutorial From 05d0f0babfcb37fc46bc92c384db6e096d78ddca Mon Sep 17 00:00:00 2001 From: Per Wramdemark Date: Thu, 3 Oct 2019 20:50:50 +0200 Subject: [PATCH 03/30] #834 Fix dependency management issue for POM files (#940) --- aggregator-microservices/aggregator-service/pom.xml | 11 ----------- .../information-microservice/pom.xml | 9 --------- .../inventory-microservice/pom.xml | 12 +----------- api-gateway/api-gateway-service/pom.xml | 10 ---------- api-gateway/image-microservice/pom.xml | 11 ----------- api-gateway/price-microservice/pom.xml | 9 --------- pom.xml | 5 ----- 7 files changed, 1 insertion(+), 66 deletions(-) diff --git a/aggregator-microservices/aggregator-service/pom.xml b/aggregator-microservices/aggregator-service/pom.xml index dbe303809f9b..6ad8c3c8c5a4 100644 --- a/aggregator-microservices/aggregator-service/pom.xml +++ b/aggregator-microservices/aggregator-service/pom.xml @@ -32,18 +32,8 @@ 1.22.0-SNAPSHOT 4.0.0 - aggregator-service jar - - - - - org.springframework.boot - spring-boot-dependencies - - - org.springframework @@ -74,7 +64,6 @@ org.springframework.boot spring-boot-maven-plugin - ${spring-boot.version} diff --git a/aggregator-microservices/information-microservice/pom.xml b/aggregator-microservices/information-microservice/pom.xml index b15af35e4b82..54113d3ad2eb 100644 --- a/aggregator-microservices/information-microservice/pom.xml +++ b/aggregator-microservices/information-microservice/pom.xml @@ -36,14 +36,6 @@ information-microservice jar - - - - org.springframework.boot - spring-boot-dependencies - - - org.springframework @@ -65,7 +57,6 @@ org.springframework.boot spring-boot-maven-plugin - ${spring-boot.version} diff --git a/aggregator-microservices/inventory-microservice/pom.xml b/aggregator-microservices/inventory-microservice/pom.xml index 1791ee72c9e8..3a24e9540edf 100644 --- a/aggregator-microservices/inventory-microservice/pom.xml +++ b/aggregator-microservices/inventory-microservice/pom.xml @@ -32,18 +32,9 @@ 1.22.0-SNAPSHOT 4.0.0 - inventory-microservice - jar - - - - org.springframework.boot - spring-boot-dependencies - - - + jar org.springframework @@ -65,7 +56,6 @@ org.springframework.boot spring-boot-maven-plugin - ${spring-boot.version} diff --git a/api-gateway/api-gateway-service/pom.xml b/api-gateway/api-gateway-service/pom.xml index 82aa6aedef80..44a8bde37923 100644 --- a/api-gateway/api-gateway-service/pom.xml +++ b/api-gateway/api-gateway-service/pom.xml @@ -34,15 +34,6 @@ 4.0.0 api-gateway-service jar - - - - - org.springframework.boot - spring-boot-dependencies - - - org.springframework @@ -73,7 +64,6 @@ org.springframework.boot spring-boot-maven-plugin - ${spring-boot.version} diff --git a/api-gateway/image-microservice/pom.xml b/api-gateway/image-microservice/pom.xml index c4367cdd8f45..4c897325d931 100644 --- a/api-gateway/image-microservice/pom.xml +++ b/api-gateway/image-microservice/pom.xml @@ -31,19 +31,9 @@ com.iluwatar 1.22.0-SNAPSHOT - 4.0.0 image-microservice jar - - - - - org.springframework.boot - spring-boot-dependencies - - - org.springframework @@ -65,7 +55,6 @@ org.springframework.boot spring-boot-maven-plugin - ${spring-boot.version} diff --git a/api-gateway/price-microservice/pom.xml b/api-gateway/price-microservice/pom.xml index 89aaba7ae7d4..21a68dc6efd3 100644 --- a/api-gateway/price-microservice/pom.xml +++ b/api-gateway/price-microservice/pom.xml @@ -36,14 +36,6 @@ price-microservice jar - - - - org.springframework.boot - spring-boot-dependencies - - - org.springframework @@ -65,7 +57,6 @@ org.springframework.boot spring-boot-maven-plugin - ${spring-boot.version} diff --git a/pom.xml b/pom.xml index ce773f61a243..5dfb1fff4376 100644 --- a/pom.xml +++ b/pom.xml @@ -211,11 +211,6 @@ spring-webmvc ${spring.version} - - org.springframework.boot - spring-boot-starter-web - ${spring-boot.version} - org.apache.httpcomponents httpclient From 218ba44dbfcaaacc12f11ec4830cf6cd13451388 Mon Sep 17 00:00:00 2001 From: Per Wramdemark Date: Sat, 5 Oct 2019 13:23:20 +0200 Subject: [PATCH 04/30] Upgrade of maven plugins (#951) * Upgrade maven plugins * Upgrade maven plugins Some general code cleanup was necessary due to upgrade of PMD and checkstyle. Also needed to add Junit 4 as a dependency due to Mockito.timout issue found here: https://github.com/mockito/mockito/issues/152 --- async-method-invocation/pom.xml | 5 ++ .../com/iluwatar/bytecode/Instruction.java | 4 +- caching/pom.xml | 1 - .../com/iluwatar/caching/CachingPolicy.java | 2 +- .../com/iluwatar/commander/Commander.java | 17 +++--- .../com/iluwatar/commander/queue/Queue.java | 4 +- .../iluwatar/doublechecked/locking/App.java | 4 +- .../iluwatar/event/asynchronous/Event.java | 2 +- exclude-pmd.properties | 1 + .../com/iluwatar/flux/action/Content.java | 2 +- half-sync-half-async/pom.xml | 5 ++ .../hexagonal/service/ConsoleLottery.java | 2 +- naked-objects/pom.xml | 22 -------- .../com/iluwatar/poison/pill/Message.java | 2 +- pom.xml | 56 ++++++++----------- .../java/com/iluwatar/retry/RetryTest.java | 9 ++- .../java/com/iluwatar/semaphore/Fruit.java | 2 +- .../servicelayer/common/BaseEntity.java | 6 +- trampoline/pom.xml | 1 - 19 files changed, 63 insertions(+), 84 deletions(-) diff --git a/async-method-invocation/pom.xml b/async-method-invocation/pom.xml index c6764f61cad0..49e39009ebdd 100644 --- a/async-method-invocation/pom.xml +++ b/async-method-invocation/pom.xml @@ -43,5 +43,10 @@ mockito-core test + + junit + junit + test + diff --git a/bytecode/src/main/java/com/iluwatar/bytecode/Instruction.java b/bytecode/src/main/java/com/iluwatar/bytecode/Instruction.java index 2ceb66e3bdc2..1d921da51037 100644 --- a/bytecode/src/main/java/com/iluwatar/bytecode/Instruction.java +++ b/bytecode/src/main/java/com/iluwatar/bytecode/Instruction.java @@ -29,7 +29,7 @@ public enum Instruction { LITERAL(1), SET_HEALTH(2), - SET_WISDOM (3), + SET_WISDOM(3), SET_AGILITY(4), PLAY_SOUND(5), SPAWN_PARTICLES(6), @@ -37,7 +37,7 @@ public enum Instruction { GET_AGILITY(8), GET_WISDOM(9), ADD(10), - DIVIDE (11); + DIVIDE(11); private int value; diff --git a/caching/pom.xml b/caching/pom.xml index 76578b8830cc..c20e29e922d2 100644 --- a/caching/pom.xml +++ b/caching/pom.xml @@ -65,7 +65,6 @@ org.apache.maven.plugins maven-surefire-plugin - 2.19 false diff --git a/caching/src/main/java/com/iluwatar/caching/CachingPolicy.java b/caching/src/main/java/com/iluwatar/caching/CachingPolicy.java index 9f7c92b2eef5..6b7fc35c3ace 100644 --- a/caching/src/main/java/com/iluwatar/caching/CachingPolicy.java +++ b/caching/src/main/java/com/iluwatar/caching/CachingPolicy.java @@ -32,7 +32,7 @@ public enum CachingPolicy { private String policy; - private CachingPolicy(String policy) { + CachingPolicy(String policy) { this.policy = policy; } diff --git a/commander/src/main/java/com/iluwatar/commander/Commander.java b/commander/src/main/java/com/iluwatar/commander/Commander.java index 87d4604d4ac3..8f19d1df8794 100644 --- a/commander/src/main/java/com/iluwatar/commander/Commander.java +++ b/commander/src/main/java/com/iluwatar/commander/Commander.java @@ -239,12 +239,12 @@ private void updateQueue(QueueTask qt) throws InterruptedException { //since payment time is lesser than queuetime it would have already failed..additional check not needed LOG.trace("Order " + qt.order.id + ": Queue time for order over, failed.."); return; - } else if ((qt.taskType.equals(TaskType.Payment) && !qt.order.paid.equals(PaymentStatus.Trying)) - || (qt.taskType.equals(TaskType.Messaging) && ((qt.messageType == 1 - && !qt.order.messageSent.equals(MessageSent.NoneSent)) + } else if (qt.taskType.equals(TaskType.Payment) && !qt.order.paid.equals(PaymentStatus.Trying) + || qt.taskType.equals(TaskType.Messaging) && (qt.messageType == 1 + && !qt.order.messageSent.equals(MessageSent.NoneSent) || qt.order.messageSent.equals(MessageSent.PaymentFail) - || qt.order.messageSent.equals(MessageSent.PaymentSuccessful))) - || (qt.taskType.equals(TaskType.EmployeeDb) && qt.order.addedToEmployeeHandle)) { + || qt.order.messageSent.equals(MessageSent.PaymentSuccessful)) + || qt.taskType.equals(TaskType.EmployeeDb) && qt.order.addedToEmployeeHandle) { LOG.trace("Order " + qt.order.id + ": Not queueing task since task already done.."); return; } @@ -576,8 +576,8 @@ private void doTasksInQueue() throws Exception { || qt.order.messageSent.equals(MessageSent.PaymentSuccessful)) { tryDequeue(); LOG.trace("Order " + qt.order.id + ": This messaging task already done, dequeue.."); - } else if ((qt.messageType == 1 && (!qt.order.messageSent.equals(MessageSent.NoneSent) - || !qt.order.paid.equals(PaymentStatus.Trying)))) { + } else if (qt.messageType == 1 && (!qt.order.messageSent.equals(MessageSent.NoneSent) + || !qt.order.paid.equals(PaymentStatus.Trying))) { tryDequeue(); LOG.trace("Order " + qt.order.id + ": This messaging task does not need to be done, dequeue.."); } else if (qt.messageType == 0) { @@ -606,8 +606,7 @@ private void doTasksInQueue() throws Exception { } else { Thread.sleep(queueTaskTime / 3); tryDoingTasksInQueue(); - } - return; + } } } diff --git a/commander/src/main/java/com/iluwatar/commander/queue/Queue.java b/commander/src/main/java/com/iluwatar/commander/queue/Queue.java index f1b0ef533117..440f65c90938 100644 --- a/commander/src/main/java/com/iluwatar/commander/queue/Queue.java +++ b/commander/src/main/java/com/iluwatar/commander/queue/Queue.java @@ -83,7 +83,7 @@ T dequeue() throws IsEmptyException { Node temp = front; front = front.next; size = size - 1; - return ((T) temp.value); + return (T) temp.value; } } @@ -91,7 +91,7 @@ T peek() throws IsEmptyException { if (isEmpty()) { throw new IsEmptyException(); } else { - return ((T)front.value); + return (T)front.value; } } } diff --git a/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/App.java b/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/App.java index c814f98bc586..3a9faf4dca16 100644 --- a/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/App.java +++ b/double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking/App.java @@ -55,7 +55,9 @@ public static void main(String[] args) { ExecutorService executorService = Executors.newFixedThreadPool(3); for (int i = 0; i < 3; i++) { executorService.execute(() -> { - while (inventory.addItem(new Item())) {}; + while (inventory.addItem(new Item())) { + LOGGER.info("Adding another item"); + } }); } diff --git a/event-asynchronous/src/main/java/com/iluwatar/event/asynchronous/Event.java b/event-asynchronous/src/main/java/com/iluwatar/event/asynchronous/Event.java index 5dc069bc7032..c22f54ca0e29 100644 --- a/event-asynchronous/src/main/java/com/iluwatar/event/asynchronous/Event.java +++ b/event-asynchronous/src/main/java/com/iluwatar/event/asynchronous/Event.java @@ -97,7 +97,7 @@ public final void removeListener(final ThreadCompleteListener listener) { this.eventListener = null; } - private final void completed() { + private void completed() { if (eventListener != null) { eventListener.completedEventHandler(eventId); } diff --git a/exclude-pmd.properties b/exclude-pmd.properties index 288ee9b2d318..5a4bb138834e 100644 --- a/exclude-pmd.properties +++ b/exclude-pmd.properties @@ -24,3 +24,4 @@ com.iluwatar.servicelayer.common.BaseEntity=UnusedPrivateField com.iluwatar.doublechecked.locking.App=EmptyStatementNotInLoop,EmptyWhileStmt com.iluwatar.doublechecked.locking.InventoryTest=EmptyStatementNotInLoop,EmptyWhileStmt +domainapp.dom.modules.simple.QSimpleObject=UnusedFormalParameter \ No newline at end of file diff --git a/flux/src/main/java/com/iluwatar/flux/action/Content.java b/flux/src/main/java/com/iluwatar/flux/action/Content.java index 596b466db414..8854ebced07a 100644 --- a/flux/src/main/java/com/iluwatar/flux/action/Content.java +++ b/flux/src/main/java/com/iluwatar/flux/action/Content.java @@ -34,7 +34,7 @@ public enum Content { private String title; - private Content(String title) { + Content(String title) { this.title = title; } diff --git a/half-sync-half-async/pom.xml b/half-sync-half-async/pom.xml index d965298ca364..2ca43a964844 100644 --- a/half-sync-half-async/pom.xml +++ b/half-sync-half-async/pom.xml @@ -43,5 +43,10 @@ mockito-core test + + junit + junit + test + diff --git a/hexagonal/src/main/java/com/iluwatar/hexagonal/service/ConsoleLottery.java b/hexagonal/src/main/java/com/iluwatar/hexagonal/service/ConsoleLottery.java index 9956788ad100..2d2a53318620 100644 --- a/hexagonal/src/main/java/com/iluwatar/hexagonal/service/ConsoleLottery.java +++ b/hexagonal/src/main/java/com/iluwatar/hexagonal/service/ConsoleLottery.java @@ -48,7 +48,7 @@ public static void main(String[] args) { Injector injector = Guice.createInjector(new LotteryModule()); LotteryService service = injector.getInstance( LotteryService.class); WireTransfers bank = injector.getInstance(WireTransfers.class); - try (final Scanner scanner = new Scanner(System.in)) { + try (Scanner scanner = new Scanner(System.in)) { boolean exit = false; while (!exit) { printMainMenu(); diff --git a/naked-objects/pom.xml b/naked-objects/pom.xml index 8c21504bb6f5..d0fe727d3205 100644 --- a/naked-objects/pom.xml +++ b/naked-objects/pom.xml @@ -90,31 +90,9 @@ - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.8 - 1.8 - -parameters - - - - source - compile - - - test - test-compile - - - - org.apache.maven.plugins maven-surefire-plugin - 2.16 **/*Test.java diff --git a/poison-pill/src/main/java/com/iluwatar/poison/pill/Message.java b/poison-pill/src/main/java/com/iluwatar/poison/pill/Message.java index cd2d2da6ac90..e9937d30cac0 100644 --- a/poison-pill/src/main/java/com/iluwatar/poison/pill/Message.java +++ b/poison-pill/src/main/java/com/iluwatar/poison/pill/Message.java @@ -66,7 +66,7 @@ private RuntimeException poison() { /** * Enumeration of Type of Headers */ - public enum Headers { + enum Headers { DATE, SENDER } diff --git a/pom.xml b/pom.xml index 5dfb1fff4376..d985b6c62fe2 100644 --- a/pom.xml +++ b/pom.xml @@ -36,10 +36,9 @@ 4.12 5.0.2 ${junit.version}.2 - 1.0.2 1.0.2 - 3.0 - 0.7.2.201409121644 + 3.8.1 + 0.8.4 1.4 2.16.1 19.0 @@ -55,6 +54,7 @@ 1.0.0 2.0.1 2.8.5 + 3.12.0 abstract-factory @@ -353,20 +353,27 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${compiler.version} + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M3 + + -Xmx1024M ${argLine} + + - - - org.apache.maven.plugins - maven-compiler-plugin - ${compiler.version} - - 1.8 - 1.8 - - org.jacoco jacoco-maven-plugin @@ -387,7 +394,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 2.17 + 3.1.0 validate @@ -406,25 +413,10 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 2.19.1 - - - org.junit.platform - junit-platform-surefire-provider - ${junit-platform.version} - - - - -Xmx1024M ${argLine} - - org.apache.maven.plugins maven-pmd-plugin - 3.6 + ${pmd.version} true 5 @@ -445,7 +437,7 @@ com.mycila license-maven-plugin - 2.11 + 3.0
com/mycila/maven/plugin/license/templates/MIT.txt
@@ -471,7 +463,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.6 + ${pmd.version}
diff --git a/retry/src/test/java/com/iluwatar/retry/RetryTest.java b/retry/src/test/java/com/iluwatar/retry/RetryTest.java index a8307d1cd9f3..d435c7e84331 100644 --- a/retry/src/test/java/com/iluwatar/retry/RetryTest.java +++ b/retry/src/test/java/com/iluwatar/retry/RetryTest.java @@ -43,7 +43,8 @@ public class RetryTest { public void errors() { final BusinessException e = new BusinessException("unhandled"); final Retry retry = new Retry<>( - () -> { throw e; }, + () -> { + throw e; }, 2, 0 ); @@ -67,7 +68,8 @@ public void errors() { public void attempts() { final BusinessException e = new BusinessException("unhandled"); final Retry retry = new Retry<>( - () -> { throw e; }, + () -> { + throw e; }, 2, 0 ); @@ -91,7 +93,8 @@ public void attempts() { public void ignore() throws Exception { final BusinessException e = new CustomerNotFoundException("customer not found"); final Retry retry = new Retry<>( - () -> { throw e; }, + () -> { + throw e; }, 2, 0, ex -> CustomerNotFoundException.class.isAssignableFrom(ex.getClass()) diff --git a/semaphore/src/main/java/com/iluwatar/semaphore/Fruit.java b/semaphore/src/main/java/com/iluwatar/semaphore/Fruit.java index 88255997fa7e..9ab004c17531 100644 --- a/semaphore/src/main/java/com/iluwatar/semaphore/Fruit.java +++ b/semaphore/src/main/java/com/iluwatar/semaphore/Fruit.java @@ -30,7 +30,7 @@ public class Fruit { /** * Enumeration of Fruit Types */ - public static enum FruitType { + public enum FruitType { ORANGE, APPLE, LEMON } diff --git a/service-layer/src/main/java/com/iluwatar/servicelayer/common/BaseEntity.java b/service-layer/src/main/java/com/iluwatar/servicelayer/common/BaseEntity.java index 52c24292e2ec..bf3988d07484 100644 --- a/service-layer/src/main/java/com/iluwatar/servicelayer/common/BaseEntity.java +++ b/service-layer/src/main/java/com/iluwatar/servicelayer/common/BaseEntity.java @@ -25,10 +25,9 @@ import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.MappedSuperclass; -import javax.persistence.Version; /** - * + * * Base class for entities. * */ @@ -36,9 +35,6 @@ @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class BaseEntity { - @Version - private Long version; - /** * Indicates the unique id of this entity * diff --git a/trampoline/pom.xml b/trampoline/pom.xml index e6f2e620afac..1e019ef31297 100644 --- a/trampoline/pom.xml +++ b/trampoline/pom.xml @@ -62,7 +62,6 @@ org.apache.maven.plugins maven-surefire-plugin - 2.19 false From 364c43a73aab5b5d4cb76194a90f0122ab3a608d Mon Sep 17 00:00:00 2001 From: Per Wramdemark Date: Sat, 5 Oct 2019 16:13:08 +0200 Subject: [PATCH 05/30] Get rid of build warnings WARNING about problems found when building the effective model (#953) --- naked-objects/pom.xml | 9 --------- pom.xml | 5 +++++ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/naked-objects/pom.xml b/naked-objects/pom.xml index d0fe727d3205..271a07705589 100644 --- a/naked-objects/pom.xml +++ b/naked-objects/pom.xml @@ -17,23 +17,14 @@ com.iluwatar 1.22.0-SNAPSHOT - naked-objects - pom - - - 3.0.4 - - 1.9.0 - UTF-8 UTF-8 2.0.0 - apache.snapshots diff --git a/pom.xml b/pom.xml index d985b6c62fe2..7d5b038873de 100644 --- a/pom.xml +++ b/pom.xml @@ -370,6 +370,11 @@ -Xmx1024M ${argLine} + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + From 933de30d42271f422a487b0a74d6d7ccf6053709 Mon Sep 17 00:00:00 2001 From: Per Wramdemark Date: Sat, 5 Oct 2019 17:01:23 +0200 Subject: [PATCH 06/30] Add JXR plugin to get rid of WARNING Unable to locate Source XRef to link to (#952) --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 7d5b038873de..f1a586eb8b34 100644 --- a/pom.xml +++ b/pom.xml @@ -470,6 +470,11 @@ maven-pmd-plugin ${pmd.version}
+ + org.apache.maven.plugins + maven-jxr-plugin + 3.0.0 + From 60171e3c873257b86f66b0a67935321735d2c7d1 Mon Sep 17 00:00:00 2001 From: Arpit Jain Date: Sun, 6 Oct 2019 20:57:39 +0530 Subject: [PATCH 07/30] Fix for Issue #549 : Update Exception Handling Code in Aggregator Microservice (#958) * Fix for Issue##549 Catch ClientProtocolException and Update Error Logs * Fix indentation, checkstyle errors --- .../microservices/ProductInformationClientImpl.java | 7 +++++-- .../microservices/ProductInventoryClientImpl.java | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java index 16849d529386..131fbf8695cd 100644 --- a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java +++ b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java @@ -22,6 +22,7 @@ */ package com.iluwatar.aggregator.microservices; +import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; @@ -49,8 +50,10 @@ public String getProductTitle() { try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { response = EntityUtils.toString(httpResponse.getEntity()); } - } catch (IOException e) { - LOGGER.error("Exception caught.", e); + } catch (ClientProtocolException cpe) { + LOGGER.error("ClientProtocolException Occured", cpe); + } catch (IOException ioe) { + LOGGER.error("IOException Occurred", ioe); } return response; } diff --git a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java index 89f1a25e0580..780dccb78e20 100644 --- a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java +++ b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java @@ -22,6 +22,7 @@ */ package com.iluwatar.aggregator.microservices; +import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; @@ -49,8 +50,10 @@ public int getProductInventories() { try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { response = EntityUtils.toString(httpResponse.getEntity()); } - } catch (IOException e) { - LOGGER.error("Exception caught.", e); + } catch (ClientProtocolException cpe) { + LOGGER.error("ClientProtocolException Occured", cpe); + } catch (IOException ioe) { + LOGGER.error("IOException Occurred", ioe); } return Integer.parseInt(response); } From 94ca25462667b15d2d4f7d5120c94a0733f53bf7 Mon Sep 17 00:00:00 2001 From: Arpit Jain Date: Sun, 6 Oct 2019 21:36:39 +0530 Subject: [PATCH 08/30] Fix for issue #954 : Add external Dependencies to run with Java11 (#957) * Fix for issue #954 Add javax.annotation and java.xml.bind as external maven dependencies Verified with jdk-11 * Move dependency versions to main pom.xml's dependencyManagement section --- pom.xml | 12 ++++++++++++ repository/pom.xml | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/pom.xml b/pom.xml index f1a586eb8b34..acaaef6181c5 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,8 @@ 2.0.1 2.8.5 3.12.0 + 2.3.0 + 1.3.1 abstract-factory @@ -298,6 +300,16 @@ mongo-java-driver ${mongo-java-driver.version}
+ + javax.xml.bind + jaxb-api + ${jaxb-api.version} + + + javax.annotation + javax.annotation-api + ${annotation-api.version} +
diff --git a/repository/pom.xml b/repository/pom.xml index 48bca0cf2ba8..2ccdc9da7ba5 100644 --- a/repository/pom.xml +++ b/repository/pom.xml @@ -63,5 +63,13 @@ com.google.guava guava
+ + javax.xml.bind + jaxb-api + + + javax.annotation + javax.annotation-api +
From 2b1c09aa72149bed1b5391561bbb409cfa47fad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Mon, 7 Oct 2019 09:45:06 +0300 Subject: [PATCH 09/30] Fix link in Acyclic Visitor --- acyclic-visitor/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acyclic-visitor/README.md b/acyclic-visitor/README.md index 939fe38b97d1..83b618601fb2 100644 --- a/acyclic-visitor/README.md +++ b/acyclic-visitor/README.md @@ -33,7 +33,7 @@ The bad: * Parallel hierarchy of visitors has to be created for all members in visitable class hierarchy. ## Related patterns -* [Visitor Pattern](../visitor/README.md) +* [Visitor Pattern](../visitor/) ## Credits -* [Acyclic Visitor](http://condor.depaul.edu/dmumaugh/OOT/Design-Principles/acv.pdf) \ No newline at end of file +* [Acyclic Visitor](http://condor.depaul.edu/dmumaugh/OOT/Design-Principles/acv.pdf) From f5455f9887f2613ef2b8ca16eb594d6a962196d8 Mon Sep 17 00:00:00 2001 From: Kevin O'Neal Date: Mon, 7 Oct 2019 11:10:26 -0500 Subject: [PATCH 10/30] update buggy dependencies (#968) --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index acaaef6181c5..539da396b2d8 100644 --- a/pom.xml +++ b/pom.xml @@ -43,12 +43,12 @@ 2.16.1 19.0 1.10.19 - 4.5.2 + 4.5.10 2.22 4.0 3.3.0 - 1.7.21 - 1.1.7 + 1.7.28 + 1.2.3 1.1.0 1.11.289 1.0.0 From 84c4b034a9f282a0d8739ef7bd4cd83813a7c454 Mon Sep 17 00:00:00 2001 From: Gaurav Deshpande Date: Tue, 8 Oct 2019 10:12:54 +0530 Subject: [PATCH 11/30] Fix: Github reports security vulnerabilities #933 (#960) * Fix: Github reports security vulnerabilities #933 Upgrade camel and spring-data * -Fix github security vulnerabilities in spring-data and camel * -Code changes for review comments --- .../routes/AggregatorRouteTest.java | 4 +-- .../splitter/routes/SplitterRouteTest.java | 4 +-- .../eip/wiretap/routes/WireTapRouteTest.java | 4 +-- layers/pom.xml | 6 ++++- .../layers/CakeBakingServiceImpl.java | 27 +++++++++++-------- .../src/main/resources/applicationContext.xml | 2 +- pom.xml | 21 ++++++++------- repository/pom.xml | 6 ++++- .../java/com/iluwatar/repository/App.java | 9 ++++--- .../com/iluwatar/repository/AppConfig.java | 13 +++++---- .../src/main/resources/applicationContext.xml | 2 +- .../AnnotationBasedRepositoryTest.java | 12 ++++----- .../iluwatar/repository/AppConfigTest.java | 5 ++-- .../iluwatar/repository/RepositoryTest.java | 11 ++++---- 14 files changed, 72 insertions(+), 54 deletions(-) diff --git a/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/AggregatorRouteTest.java b/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/AggregatorRouteTest.java index 2c7d207d6f53..2b831e01958b 100644 --- a/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/AggregatorRouteTest.java +++ b/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/AggregatorRouteTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; @@ -44,7 +44,7 @@ *

*/ @ExtendWith(SpringExtension.class) -@SpringApplicationConfiguration(classes = AggregatorRouteTest.class) +@SpringBootTest(classes = AggregatorRouteTest.class) @ActiveProfiles("test") @EnableAutoConfiguration @ComponentScan diff --git a/eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java b/eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java index 9257a4410186..334b77da03c8 100644 --- a/eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java +++ b/eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; @@ -42,7 +42,7 @@ *

*/ @ExtendWith(SpringExtension.class) -@SpringApplicationConfiguration(classes = SplitterRouteTest.class) +@SpringBootTest(classes = SplitterRouteTest.class) @ActiveProfiles("test") @EnableAutoConfiguration @ComponentScan diff --git a/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java b/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java index 449f86208258..bb433f350238 100644 --- a/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java +++ b/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; @@ -45,7 +45,7 @@ *

*/ @ExtendWith(SpringExtension.class) -@SpringApplicationConfiguration(classes = WireTapRouteTest.class) +@SpringBootTest(classes = WireTapRouteTest.class) @ActiveProfiles("test") @EnableAutoConfiguration @ComponentScan diff --git a/layers/pom.xml b/layers/pom.xml index 8237c8f4f6e0..a6d3d17199f6 100644 --- a/layers/pom.xml +++ b/layers/pom.xml @@ -41,7 +41,11 @@
org.hibernate - hibernate-entitymanager + hibernate-core + + + javax.xml.bind + jaxb-api commons-dbcp diff --git a/layers/src/main/java/com/iluwatar/layers/CakeBakingServiceImpl.java b/layers/src/main/java/com/iluwatar/layers/CakeBakingServiceImpl.java index e8deee73a767..556a74c7afbf 100644 --- a/layers/src/main/java/com/iluwatar/layers/CakeBakingServiceImpl.java +++ b/layers/src/main/java/com/iluwatar/layers/CakeBakingServiceImpl.java @@ -72,18 +72,23 @@ public void bakeNewCake(CakeInfo cakeInfo) throws CakeBakingException { } } CakeToppingDao toppingBean = context.getBean(CakeToppingDao.class); - CakeTopping topping = toppingBean.findOne(matchingToppings.iterator().next().getId()); + Optional topping = toppingBean.findById(matchingToppings.iterator().next().getId()); CakeDao cakeBean = context.getBean(CakeDao.class); - Cake cake = new Cake(); - cake.setTopping(topping); - cake.setLayers(foundLayers); - cakeBean.save(cake); - topping.setCake(cake); - toppingBean.save(topping); - CakeLayerDao layerBean = context.getBean(CakeLayerDao.class); - for (CakeLayer layer : foundLayers) { - layer.setCake(cake); - layerBean.save(layer); + if (topping.isPresent()) { + Cake cake = new Cake(); + cake.setTopping(topping.get()); + cake.setLayers(foundLayers); + cakeBean.save(cake); + topping.get().setCake(cake); + toppingBean.save(topping.get()); + CakeLayerDao layerBean = context.getBean(CakeLayerDao.class); + for (CakeLayer layer : foundLayers) { + layer.setCake(cake); + layerBean.save(layer); + } + } else { + throw new CakeBakingException(String.format("Topping %s is not available", + cakeInfo.cakeToppingInfo.name)); } } diff --git a/layers/src/main/resources/applicationContext.xml b/layers/src/main/resources/applicationContext.xml index eca3670b0fbf..c149094c1fa3 100644 --- a/layers/src/main/resources/applicationContext.xml +++ b/layers/src/main/resources/applicationContext.xml @@ -50,7 +50,7 @@ - + diff --git a/pom.xml b/pom.xml index 539da396b2d8..33219175ec9d 100644 --- a/pom.xml +++ b/pom.xml @@ -28,10 +28,10 @@ 2014 UTF-8 - 5.0.1.Final - 4.2.4.RELEASE - 1.3.3.RELEASE - 1.9.2.RELEASE + 5.2.18.Final + 5.0.13.RELEASE + 2.0.9.RELEASE + 2.0.14.RELEASE 1.4.190 4.12 5.0.2 @@ -40,7 +40,7 @@ 3.8.1 0.8.4 1.4 - 2.16.1 + 2.24.0 19.0 1.10.19 4.5.10 @@ -55,6 +55,7 @@ 2.0.1 2.8.5 3.12.0 + 1.2.17 2.3.0 1.3.1 @@ -191,11 +192,6 @@ hibernate-core ${hibernate.version} - - org.hibernate - hibernate-entitymanager - ${hibernate.version} - org.springframework.boot spring-boot-dependencies @@ -300,6 +296,11 @@ mongo-java-driver ${mongo-java-driver.version} + + log4j + log4j + ${log4j.version} + javax.xml.bind jaxb-api diff --git a/repository/pom.xml b/repository/pom.xml index 2ccdc9da7ba5..f0340f1260ef 100644 --- a/repository/pom.xml +++ b/repository/pom.xml @@ -44,7 +44,7 @@ org.hibernate - hibernate-entitymanager + hibernate-core commons-dbcp @@ -71,5 +71,9 @@ javax.annotation javax.annotation-api + + org.springframework.boot + spring-boot-starter-test +
diff --git a/repository/src/main/java/com/iluwatar/repository/App.java b/repository/src/main/java/com/iluwatar/repository/App.java index d96b4351ea38..c4a885380064 100644 --- a/repository/src/main/java/com/iluwatar/repository/App.java +++ b/repository/src/main/java/com/iluwatar/repository/App.java @@ -23,6 +23,7 @@ package com.iluwatar.repository; import java.util.List; +import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -84,17 +85,17 @@ public static void main(String[] args) { nasta.setSurname("Spotakova"); repository.save(nasta); - LOGGER.info("Find by id 2: {}", repository.findOne(2L)); + LOGGER.info("Find by id 2: {}", repository.findById(2L).get()); // Remove record from Person - repository.delete(2L); + repository.deleteById(2L); // count records LOGGER.info("Count Person records: {}", repository.count()); // find by name - Person p = repository.findOne(new PersonSpecifications.NameEqualSpec("John")); - LOGGER.info("Find by John is {}", p); + Optional p = repository.findOne(new PersonSpecifications.NameEqualSpec("John")); + LOGGER.info("Find by John is {}", p.get()); // find by age persons = repository.findAll(new PersonSpecifications.AgeBetweenSpec(20, 40)); diff --git a/repository/src/main/java/com/iluwatar/repository/AppConfig.java b/repository/src/main/java/com/iluwatar/repository/AppConfig.java index c5ccb7d00002..584c09037be7 100644 --- a/repository/src/main/java/com/iluwatar/repository/AppConfig.java +++ b/repository/src/main/java/com/iluwatar/repository/AppConfig.java @@ -24,6 +24,7 @@ import java.sql.SQLException; import java.util.List; +import java.util.Optional; import java.util.Properties; import javax.sql.DataSource; @@ -32,6 +33,7 @@ import org.hibernate.jpa.HibernatePersistenceProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.boot.SpringBootConfiguration; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @@ -44,6 +46,7 @@ * */ @EnableJpaRepositories +@SpringBootConfiguration public class AppConfig { private static final Logger LOGGER = LoggerFactory.getLogger(AppConfig.class); @@ -60,7 +63,7 @@ public DataSource dataSource() { basicDataSource.setUrl("jdbc:h2:~/databases/person"); basicDataSource.setUsername("sa"); basicDataSource.setPassword("sa"); - return (DataSource) basicDataSource; + return basicDataSource; } /** @@ -134,17 +137,17 @@ public static void main(String[] args) { nasta.setSurname("Spotakova"); repository.save(nasta); - LOGGER.info("Find by id 2: {}", repository.findOne(2L)); + LOGGER.info("Find by id 2: {}", repository.findById(2L).get()); // Remove record from Person - repository.delete(2L); + repository.deleteById(2L); // count records LOGGER.info("Count Person records: {}", repository.count()); // find by name - Person p = repository.findOne(new PersonSpecifications.NameEqualSpec("John")); - LOGGER.info("Find by John is {}", p); + Optional p = repository.findOne(new PersonSpecifications.NameEqualSpec("John")); + LOGGER.info("Find by John is {}", p.get()); // find by age persons = repository.findAll(new PersonSpecifications.AgeBetweenSpec(20, 40)); diff --git a/repository/src/main/resources/applicationContext.xml b/repository/src/main/resources/applicationContext.xml index 26d6cb3f4dc3..b27bb4c85f73 100644 --- a/repository/src/main/resources/applicationContext.xml +++ b/repository/src/main/resources/applicationContext.xml @@ -49,7 +49,7 @@ - + diff --git a/repository/src/test/java/com/iluwatar/repository/AnnotationBasedRepositoryTest.java b/repository/src/test/java/com/iluwatar/repository/AnnotationBasedRepositoryTest.java index 4cfb6e022f51..8d7e1d94b797 100644 --- a/repository/src/test/java/com/iluwatar/repository/AnnotationBasedRepositoryTest.java +++ b/repository/src/test/java/com/iluwatar/repository/AnnotationBasedRepositoryTest.java @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.List; +import java.util.Optional; import javax.annotation.Resource; @@ -35,9 +36,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.test.context.ContextConfiguration; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.test.context.support.AnnotationConfigContextLoader; import com.google.common.collect.Lists; @@ -47,7 +47,7 @@ * */ @ExtendWith(SpringExtension.class) -@ContextConfiguration(classes = { AppConfig.class }, loader = AnnotationConfigContextLoader.class) +@SpringBootTest(classes = { AppConfig.class }) public class AnnotationBasedRepositoryTest { @Resource @@ -66,7 +66,7 @@ public class AnnotationBasedRepositoryTest { @BeforeEach public void setup() { - repository.save(persons); + repository.saveAll(persons); } @Test @@ -119,8 +119,8 @@ public void testFindAllByAgeBetweenSpec() { @Test public void testFindOneByNameEqualSpec() { - Person actual = repository.findOne(new PersonSpecifications.NameEqualSpec("Terry")); - assertEquals(terry, actual); + Optional actual = repository.findOne(new PersonSpecifications.NameEqualSpec("Terry")); + assertEquals(terry, actual.get()); } @AfterEach diff --git a/repository/src/test/java/com/iluwatar/repository/AppConfigTest.java b/repository/src/test/java/com/iluwatar/repository/AppConfigTest.java index 3fb1b427b232..1839a2523e6c 100644 --- a/repository/src/test/java/com/iluwatar/repository/AppConfigTest.java +++ b/repository/src/test/java/com/iluwatar/repository/AppConfigTest.java @@ -25,9 +25,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.test.context.support.AnnotationConfigContextLoader; import org.springframework.transaction.annotation.Transactional; import javax.sql.DataSource; @@ -42,7 +41,7 @@ * */ @ExtendWith(SpringExtension.class) -@ContextConfiguration(classes = { AppConfig.class }, loader = AnnotationConfigContextLoader.class) +@SpringBootTest(classes = { AppConfig.class }) public class AppConfigTest { @Autowired diff --git a/repository/src/test/java/com/iluwatar/repository/RepositoryTest.java b/repository/src/test/java/com/iluwatar/repository/RepositoryTest.java index 5b4b8e80c055..dc976cbe72d3 100644 --- a/repository/src/test/java/com/iluwatar/repository/RepositoryTest.java +++ b/repository/src/test/java/com/iluwatar/repository/RepositoryTest.java @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.List; +import java.util.Optional; import javax.annotation.Resource; @@ -35,7 +36,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.test.context.ContextConfiguration; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; import com.google.common.collect.Lists; @@ -45,7 +46,7 @@ * by {@link org.springframework.data.jpa.domain.Specification} are also test. */ @ExtendWith(SpringExtension.class) -@ContextConfiguration(locations = { "classpath:applicationContext.xml" }) +@SpringBootTest(properties = { "locations=classpath:applicationContext.xml" }) public class RepositoryTest { @Resource @@ -64,7 +65,7 @@ public class RepositoryTest { @BeforeEach public void setup() { - repository.save(persons); + repository.saveAll(persons); } @Test @@ -115,8 +116,8 @@ public void testFindAllByAgeBetweenSpec() { @Test public void testFindOneByNameEqualSpec() { - Person actual = repository.findOne(new PersonSpecifications.NameEqualSpec("Terry")); - assertEquals(terry, actual); + Optional actual = repository.findOne(new PersonSpecifications.NameEqualSpec("Terry")); + assertEquals(terry, actual.get()); } @AfterEach From f903d7e9a9379c79742ecc61a3901bdbe2a0a318 Mon Sep 17 00:00:00 2001 From: Joshua Jimenez Date: Tue, 8 Oct 2019 14:19:28 +0800 Subject: [PATCH 12/30] #496 Pipeline pattern (#967) * #496 Add pipeline module to parent pom :sparkles: * #496: Add main application class and test for pipeline * #496: Checkstyle format and add log messages on pipeline stages :art: * #496: Fill readme sections of pipeline :sparkles: * #496: Javadocs and checkstyle formatting :art: * #496: Follow PMD checks and add more explanation as block comment on App.java * #496: Apply requested PR changes by iluwatar :art: --- pipeline/README.md | 37 +++++++++++ pipeline/pom.xml | 47 +++++++++++++ .../main/java/com.iluwatar.pipeline/App.java | 66 +++++++++++++++++++ .../ConvertToCharArrayHandler.java | 45 +++++++++++++ .../java/com.iluwatar.pipeline/Handler.java | 32 +++++++++ .../java/com.iluwatar.pipeline/Pipeline.java | 46 +++++++++++++ .../RemoveAlphabetsHandler.java | 54 +++++++++++++++ .../RemoveDigitsHandler.java | 54 +++++++++++++++ .../java/com.iluwatar.pipeline/AppTest.java | 37 +++++++++++ .../com.iluwatar.pipeline/PipelineTest.java | 45 +++++++++++++ pom.xml | 1 + 11 files changed, 464 insertions(+) create mode 100644 pipeline/README.md create mode 100644 pipeline/pom.xml create mode 100644 pipeline/src/main/java/com.iluwatar.pipeline/App.java create mode 100644 pipeline/src/main/java/com.iluwatar.pipeline/ConvertToCharArrayHandler.java create mode 100644 pipeline/src/main/java/com.iluwatar.pipeline/Handler.java create mode 100644 pipeline/src/main/java/com.iluwatar.pipeline/Pipeline.java create mode 100644 pipeline/src/main/java/com.iluwatar.pipeline/RemoveAlphabetsHandler.java create mode 100644 pipeline/src/main/java/com.iluwatar.pipeline/RemoveDigitsHandler.java create mode 100644 pipeline/src/test/java/com.iluwatar.pipeline/AppTest.java create mode 100644 pipeline/src/test/java/com.iluwatar.pipeline/PipelineTest.java diff --git a/pipeline/README.md b/pipeline/README.md new file mode 100644 index 000000000000..e990affd62c7 --- /dev/null +++ b/pipeline/README.md @@ -0,0 +1,37 @@ +--- +layout: pattern +title: Pipeline +folder: pipeline +permalink: /patterns/pipeline/ +categories: Behavioral +tags: + - Java + - Functional + - Difficulty-Intermediate +--- + +## Intent +Allows processing of data in a series of stages by giving in an initial input and passing the processed output to be used by the next stages. + +## Applicability +Use the Pipeline pattern when you want to + +* execute individual stages that yields a final value +* add readability to complex sequence of operations by providing a fluent builder as an interface +* improve testability of code since stages will most likely be doing a single thing, complying to the [Single Responsibility Principle (SRP)](https://java-design-patterns.com/principles/#single-responsibility-principle) + +## Typical Use Case + +* implement stages and execute them in an ordered manner + +## Real world examples + +* [java.util.Stream](https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html) +* [Maven Build Lifecycle](http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html) +* [Functional Java](https://github.com/functionaljava/functionaljava) + +## Credits + +* [The Pipeline Pattern — for fun and profit](https://medium.com/@aaronweatherall/the-pipeline-pattern-for-fun-and-profit-9b5f43a98130) +* [The Pipeline design pattern (in Java)](https://medium.com/@deepakbapat/the-pipeline-design-pattern-in-java-831d9ce2fe21) +* [Pipelines | Microsoft Docs](https://docs.microsoft.com/en-us/previous-versions/msp-n-p/ff963548(v=pandp.10)) \ No newline at end of file diff --git a/pipeline/pom.xml b/pipeline/pom.xml new file mode 100644 index 000000000000..7ad60d5620e4 --- /dev/null +++ b/pipeline/pom.xml @@ -0,0 +1,47 @@ + + + + 4.0.0 + + com.iluwatar + java-design-patterns + 1.22.0-SNAPSHOT + + pipeline + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.mockito + mockito-core + test + + + diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/App.java b/pipeline/src/main/java/com.iluwatar.pipeline/App.java new file mode 100644 index 000000000000..7efa2ecca003 --- /dev/null +++ b/pipeline/src/main/java/com.iluwatar.pipeline/App.java @@ -0,0 +1,66 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.pipeline; + +/** + * The Pipeline pattern uses ordered stages to process a sequence of input values. + * Each implemented task is represented by a stage of the pipeline. You can think of + * pipelines as similar to assembly lines in a factory, where each item in the assembly + * line is constructed in stages. The partially assembled item is passed from one assembly + * stage to another. The outputs of the assembly line occur in the same order as that of the + * inputs. + * + * Classes used in this example are suffixed with "Handlers", and synonymously refers to the + * "stage". + */ +public class App { + /** + * Specify the initial input type for the first stage handler and the expected output type + * of the last stage handler as type parameters for Pipeline. Use the fluent builder by + * calling addHandler to add more stage handlers on the pipeline. + */ + public static void main(String[] args) { + /* + Suppose we wanted to pass through a String to a series of filtering stages and convert it + as a char array on the last stage. + + - Stage handler 1 (pipe): Removing the alphabets, accepts a String input and returns the + processed String output. This will be used by the next handler as its input. + + - Stage handler 2 (pipe): Removing the digits, accepts a String input and returns the + processed String output. This shall also be used by the last handler we have. + + - Stage handler 3 (pipe): Converting the String input to a char array handler. We would + be returning a different type in here since that is what's specified by the requirement. + This means that at any stages along the pipeline, the handler can return any type of data + as long as it fulfills the requirements for the next handler's input. + + Suppose we wanted to add another handler after ConvertToCharArrayHandler. That handler + then is expected to receive an input of char[] array since that is the type being returned + by the previous handler, ConvertToCharArrayHandler. + */ + new Pipeline<>(new RemoveAlphabetsHandler()) + .addHandler(new RemoveDigitsHandler()) + .addHandler(new ConvertToCharArrayHandler()); + } +} diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/ConvertToCharArrayHandler.java b/pipeline/src/main/java/com.iluwatar.pipeline/ConvertToCharArrayHandler.java new file mode 100644 index 000000000000..b69241914980 --- /dev/null +++ b/pipeline/src/main/java/com.iluwatar.pipeline/ConvertToCharArrayHandler.java @@ -0,0 +1,45 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.pipeline; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; + +/** + * Stage handler that converts an input String to its char[] array counterpart. + */ +class ConvertToCharArrayHandler implements Handler { + + private final Logger logger = LoggerFactory.getLogger(ConvertToCharArrayHandler.class); + + @Override + public char[] process(String input) { + char[] characters = input.toCharArray(); + logger.info(String.format("Current handler: %s, input is %s of type %s, output is %s, of type %s", + ConvertToCharArrayHandler.class, input, String.class, Arrays.toString(characters), Character[].class)); + + return characters; + } +} diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/Handler.java b/pipeline/src/main/java/com.iluwatar.pipeline/Handler.java new file mode 100644 index 000000000000..7d2bc0db7f59 --- /dev/null +++ b/pipeline/src/main/java/com.iluwatar.pipeline/Handler.java @@ -0,0 +1,32 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.pipeline; + +/** + * Forms a contract to all stage handlers to accept a certain type of input and return a processed output. + * @param the input type of the handler + * @param the processed output type of the handler + */ +interface Handler { + O process(I input); +} \ No newline at end of file diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/Pipeline.java b/pipeline/src/main/java/com.iluwatar.pipeline/Pipeline.java new file mode 100644 index 000000000000..8e231bbc4d09 --- /dev/null +++ b/pipeline/src/main/java/com.iluwatar.pipeline/Pipeline.java @@ -0,0 +1,46 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.pipeline; + +/** + * Main Pipeline class that initially sets the current handler. Processed output + * of the initial handler is then passed as the input to the next stage handlers. + * @param the type of the input for the first stage handler + * @param the final stage handler's output type + */ +class Pipeline { + + private final Handler currentHandler; + + Pipeline(Handler currentHandler) { + this.currentHandler = currentHandler; + } + + Pipeline addHandler(Handler newHandler) { + return new Pipeline<>(input -> newHandler.process(currentHandler.process(input))); + } + + O execute(I input) { + return currentHandler.process(input); + } +} \ No newline at end of file diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/RemoveAlphabetsHandler.java b/pipeline/src/main/java/com.iluwatar.pipeline/RemoveAlphabetsHandler.java new file mode 100644 index 000000000000..2085052742fa --- /dev/null +++ b/pipeline/src/main/java/com.iluwatar.pipeline/RemoveAlphabetsHandler.java @@ -0,0 +1,54 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.pipeline; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Stage handler that returns a new instance of String without the alphabet characters of the input string. + */ +class RemoveAlphabetsHandler implements Handler { + + private final Logger logger = LoggerFactory.getLogger(RemoveAlphabetsHandler.class); + + @Override + public String process(String input) { + StringBuilder inputWithoutAlphabets = new StringBuilder(); + + for (int index = 0; index < input.length(); index++) { + char currentCharacter = input.charAt(index); + if (Character.isAlphabetic(currentCharacter)) { + continue; + } + + inputWithoutAlphabets.append(currentCharacter); + } + + String inputWithoutAlphabetsStr = inputWithoutAlphabets.toString(); + logger.info(String.format("Current handler: %s, input is %s of type %s, output is %s, of type %s", + RemoveAlphabetsHandler.class, input, String.class, inputWithoutAlphabetsStr, String.class)); + + return inputWithoutAlphabetsStr; + } +} \ No newline at end of file diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/RemoveDigitsHandler.java b/pipeline/src/main/java/com.iluwatar.pipeline/RemoveDigitsHandler.java new file mode 100644 index 000000000000..e0c0aa6a87b2 --- /dev/null +++ b/pipeline/src/main/java/com.iluwatar.pipeline/RemoveDigitsHandler.java @@ -0,0 +1,54 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.pipeline; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Stage handler that returns a new instance of String without the digit characters of the input string. + */ +class RemoveDigitsHandler implements Handler { + + private final Logger logger = LoggerFactory.getLogger(RemoveDigitsHandler.class); + + @Override + public String process(String input) { + StringBuilder inputWithoutDigits = new StringBuilder(); + + for (int index = 0; index < input.length(); index++) { + char currentCharacter = input.charAt(index); + if (Character.isDigit(currentCharacter)) { + continue; + } + + inputWithoutDigits.append(currentCharacter); + } + + String inputWithoutDigitsStr = inputWithoutDigits.toString(); + logger.info(String.format("Current handler: %s, input is %s of type %s, output is %s, of type %s", + RemoveDigitsHandler.class, input, String.class, inputWithoutDigitsStr, String.class)); + + return inputWithoutDigitsStr; + } +} \ No newline at end of file diff --git a/pipeline/src/test/java/com.iluwatar.pipeline/AppTest.java b/pipeline/src/test/java/com.iluwatar.pipeline/AppTest.java new file mode 100644 index 000000000000..79524575c13c --- /dev/null +++ b/pipeline/src/test/java/com.iluwatar.pipeline/AppTest.java @@ -0,0 +1,37 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + *

+ * 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 com.iluwatar.pipeline; + +import org.junit.jupiter.api.Test; + +/** + * Application Test + */ +public class AppTest { + + @Test + public void test() { + String[] args = {}; + App.main(args); + } +} diff --git a/pipeline/src/test/java/com.iluwatar.pipeline/PipelineTest.java b/pipeline/src/test/java/com.iluwatar.pipeline/PipelineTest.java new file mode 100644 index 000000000000..1a2676e25d05 --- /dev/null +++ b/pipeline/src/test/java/com.iluwatar.pipeline/PipelineTest.java @@ -0,0 +1,45 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + *

+ * 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 com.iluwatar.pipeline; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + +/** + * Test for {@link Pipeline} + */ +public class PipelineTest { + + @Test + public void testAddHandlersToPipeline() { + Pipeline filters = new Pipeline<>(new RemoveAlphabetsHandler()) + .addHandler(new RemoveDigitsHandler()) + .addHandler(new ConvertToCharArrayHandler()); + + assertArrayEquals( + new char[] {'#', '!', '(', '&', '%', '#', '!'}, + filters.execute("#H!E(L&L0O%THE3R#34E!") + ); + } +} diff --git a/pom.xml b/pom.xml index 33219175ec9d..39cfee91c241 100644 --- a/pom.xml +++ b/pom.xml @@ -97,6 +97,7 @@ property intercepting-filter producer-consumer + pipeline poison-pill reader-writer-lock lazy-loading From 41b8d8047965f247c9a3dcf7aeb19046599c8583 Mon Sep 17 00:00:00 2001 From: erikgajdos1997 <56270468+erikgajdos1997@users.noreply.github.com> Date: Tue, 8 Oct 2019 17:08:56 +0200 Subject: [PATCH 13/30] Close #969 (#972) --- repository/src/main/resources/logback.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repository/src/main/resources/logback.xml b/repository/src/main/resources/logback.xml index 56b6a59bb6cf..81b998ad9021 100644 --- a/repository/src/main/resources/logback.xml +++ b/repository/src/main/resources/logback.xml @@ -42,11 +42,11 @@ - + - + From 90ea4506caa653711f69fabb99ee7ac26c4ecce7 Mon Sep 17 00:00:00 2001 From: Azureyjt Date: Tue, 8 Oct 2019 23:29:59 +0800 Subject: [PATCH 14/30] Leader Election Pattern (#923) * Fix issue #761: ThreadSafeDoubleCheckLocking.java: Instantiating by Reflection call will be successful if you do that firstly * Create leader election module * Create Interface of Instance and MessageManager * Create implementations with token ring algorithm * Change package structure. Create basic message system. * Implement heartbeat and heartbeat invoking message system * Implement election message handler * Add leader message handler * Add main entry point * Add comments * Update README.md * Fix checkstyle issue * Add Unit Tests * Add Unit Tests * Add bully leader selection * Change System.out to log print. Add MIT license in each file. * Add More java doc comments * Add unit test * Add unit tests --- leader-election/README.md | 31 ++++ leader-election/pom.xml | 43 +++++ .../leaderelection/AbstractInstance.java | 148 +++++++++++++++++ .../AbstractMessageManager.java | 73 +++++++++ .../com/iluwatar/leaderelection/Instance.java | 49 ++++++ .../com/iluwatar/leaderelection/Message.java | 76 +++++++++ .../leaderelection/MessageManager.java | 60 +++++++ .../iluwatar/leaderelection/MessageType.java | 62 +++++++ .../leaderelection/bully/BullyApp.java | 77 +++++++++ .../leaderelection/bully/BullyInstance.java | 121 ++++++++++++++ .../bully/BullyMessageManager.java | 117 ++++++++++++++ .../iluwatar/leaderelection/ring/RingApp.java | 77 +++++++++ .../leaderelection/ring/RingInstance.java | 133 +++++++++++++++ .../ring/RingMessageManager.java | 96 +++++++++++ .../iluwatar/leaderelection/MessageTest.java | 48 ++++++ .../leaderelection/bully/BullyAppTest.java | 39 +++++ .../bully/BullyMessageManagerTest.java | 151 ++++++++++++++++++ .../bully/BullyinstanceTest.java | 78 +++++++++ .../leaderelection/ring/RingAppTest.java | 39 +++++ .../leaderelection/ring/RingInstanceTest.java | 76 +++++++++ .../ring/RingMessageManagerTest.java | 123 ++++++++++++++ pom.xml | 2 + 22 files changed, 1719 insertions(+) create mode 100644 leader-election/README.md create mode 100644 leader-election/pom.xml create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/AbstractInstance.java create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/AbstractMessageManager.java create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/Instance.java create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/Message.java create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/MessageManager.java create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/MessageType.java create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyApp.java create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyInstance.java create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyMessageManager.java create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingApp.java create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingInstance.java create mode 100644 leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingMessageManager.java create mode 100644 leader-election/src/test/java/com/iluwatar/leaderelection/MessageTest.java create mode 100644 leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyAppTest.java create mode 100644 leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyMessageManagerTest.java create mode 100644 leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyinstanceTest.java create mode 100644 leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingAppTest.java create mode 100644 leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingInstanceTest.java create mode 100644 leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingMessageManagerTest.java diff --git a/leader-election/README.md b/leader-election/README.md new file mode 100644 index 000000000000..36c2670dffa0 --- /dev/null +++ b/leader-election/README.md @@ -0,0 +1,31 @@ +--- +layout: pattern +title: Leader Election +folder: leader-election +permalink: /patterns/leader-election/ +categories: Other +tags: + - Java + - Difficulty-Beginner +--- + +## Intent +Leader Election pattern is commonly used in cloud system design. It can help to ensure that task instances selec the leader instance correctly and do not conflict with each other, cause contention for shared resources, or inadvertently interfere with the work that other task instances are performing. + +## Applicability +Use this pattern when + +* the tasks in a distributed application, such as a cloud-hosted solution, require careful coordination and there is no natural leader. + +Do not use this pattern when + +* there is a natural leader or dedicated process that can always act as the leader. For example, it may be possible to implement a singleton process that coordinates the task instances. If this process fails or becomes unhealthy, the system can shut it down and restart it. +* the coordination between tasks can be easily achieved by using a more lightweight mechanism. For example, if several task instances simply require coordinated access to a shared resource, a preferable solution might be to use optimistic or pessimistic locking to control access to that resource. + +## Real world examples + +* [Raft Leader Election](https://github.com/ronenhamias/raft-leader-election) + +## Credits + +* [ Cloud Design Patterns: Prescriptive Architecture Guidance for Cloud Applications](https://docs.microsoft.com/en-us/previous-versions/msp-n-p/dn568104(v=pandp.10)) diff --git a/leader-election/pom.xml b/leader-election/pom.xml new file mode 100644 index 000000000000..7c1312d01a1d --- /dev/null +++ b/leader-election/pom.xml @@ -0,0 +1,43 @@ + + + + 4.0.0 + + java-design-patterns + com.iluwatar + 1.22.0-SNAPSHOT + + leader-election + + + org.junit.jupiter + junit-jupiter-engine + test + + + \ No newline at end of file diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractInstance.java b/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractInstance.java new file mode 100644 index 000000000000..5f153870a300 --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractInstance.java @@ -0,0 +1,148 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; + +/** + * Abstract class of all the instance implementation classes. + */ +public abstract class AbstractInstance implements Instance, Runnable { + + private static final Logger LOGGER = LoggerFactory.getLogger(AbstractInstance.class); + + protected static final int HEARTBEAT_INTERVAL = 5000; + + protected MessageManager messageManager; + protected Queue messageQueue; + protected final int localId; + protected int leaderId; + protected boolean alive; + + /** + * Constructor of BullyInstance. + */ + public AbstractInstance(MessageManager messageManager, int localId, int leaderId) { + this.messageManager = messageManager; + this.messageQueue = new ConcurrentLinkedQueue<>(); + this.localId = localId; + this.leaderId = leaderId; + this.alive = true; + } + + /** + * The instance will execute the message in its message queue periodically once it is alive. + */ + @Override + public void run() { + while (true) { + if (!this.messageQueue.isEmpty()) { + this.processMessage(this.messageQueue.remove()); + } + } + } + + /** + * Once messages are sent to the certain instance, it will firstly be added to the queue and wait to be executed. + * @param message Message sent by other instances + */ + @Override + public void onMessage(Message message) { + messageQueue.offer(message); + } + + /** + * Check if the instance is alive or not. + * @return {@code true} if the instance is alive. + */ + @Override + public boolean isAlive() { + return alive; + } + + /** + * Set the health status of the certain instance. + * @param alive {@code true} for alive. + */ + @Override + public void setAlive(boolean alive) { + this.alive = alive; + } + + /** + * Process the message according to its type. + * @param message Message polled from queue. + */ + private void processMessage(Message message) { + switch (message.getType()) { + case ELECTION: + LOGGER.info("Instance " + localId + " - Election Message handling..."); + handleElectionMessage(message); + break; + case LEADER: + LOGGER.info("Instance " + localId + " - Leader Message handling..."); + handleLeaderMessage(message); + break; + case HEARTBEAT: + LOGGER.info("Instance " + localId + " - Heartbeat Message handling..."); + handleHeartbeatMessage(message); + break; + case ELECTION_INVOKE: + LOGGER.info("Instance " + localId + " - Election Invoke Message handling..."); + handleElectionInvokeMessage(); + break; + case LEADER_INVOKE: + LOGGER.info("Instance " + localId + " - Leader Invoke Message handling..."); + handleLeaderInvokeMessage(); + break; + case HEARTBEAT_INVOKE: + LOGGER.info("Instance " + localId + " - Heartbeat Invoke Message handling..."); + handleHeartbeatInvokeMessage(); + break; + default: + break; + } + } + + /** + * Abstract methods to handle different types of message. These methods need to be implemented in concrete instance + * class to implement corresponding leader-selection pattern. + */ + protected abstract void handleElectionMessage(Message message); + + protected abstract void handleElectionInvokeMessage(); + + protected abstract void handleLeaderMessage(Message message); + + protected abstract void handleLeaderInvokeMessage(); + + protected abstract void handleHeartbeatMessage(Message message); + + protected abstract void handleHeartbeatInvokeMessage(); + +} diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractMessageManager.java b/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractMessageManager.java new file mode 100644 index 000000000000..4384da25f79d --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractMessageManager.java @@ -0,0 +1,73 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Abstract class of all the message manager classes. + */ +public abstract class AbstractMessageManager implements MessageManager { + + /** + * Contain all the instances in the system. Key is its ID, and value is the instance itself. + */ + protected Map instanceMap; + + /** + * Construtor of AbstractMessageManager + */ + public AbstractMessageManager(Map instanceMap) { + this.instanceMap = instanceMap; + } + + /** + * Find the next instance with smallest ID. + * @return The next instance. + */ + protected Instance findNextInstance(int currentId) { + Instance result = null; + List candidateList = instanceMap.keySet() + .stream() + .filter((i) -> i > currentId && instanceMap.get(i).isAlive()) + .sorted() + .collect(Collectors.toList()); + if (candidateList.isEmpty()) { + int index = instanceMap.keySet() + .stream() + .filter((i) -> instanceMap.get(i).isAlive()) + .sorted() + .collect(Collectors.toList()) + .get(0); + result = instanceMap.get(index); + } else { + int index = candidateList.get(0); + result = instanceMap.get(index); + } + return result; + } + +} diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/Instance.java b/leader-election/src/main/java/com/iluwatar/leaderelection/Instance.java new file mode 100644 index 000000000000..abaa62791185 --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/Instance.java @@ -0,0 +1,49 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.leaderelection; + +/** + * Instance interface + */ +public interface Instance { + + /** + * Check if the instance is alive or not. + * @return {@code true} if the instance is alive. + */ + boolean isAlive(); + + /** + * Set the health status of the certain instance. + * @param alive {@code true} for alive. + */ + void setAlive(boolean alive); + + /** + * Consume messages from other instances. + * @param message Message sent by other instances + */ + void onMessage(Message message); + +} diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/Message.java b/leader-election/src/main/java/com/iluwatar/leaderelection/Message.java new file mode 100644 index 000000000000..7ac79e4bcd46 --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/Message.java @@ -0,0 +1,76 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.leaderelection; + +import java.util.Objects; + +/** + * Message used to transport data between instances. + */ +public class Message { + + private MessageType type; + + private String content; + + public Message() {} + + public Message(MessageType type, String content) { + this.type = type; + this.content = content; + } + + public MessageType getType() { + return type; + } + + public void setType(MessageType type) { + this.type = type; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Message message = (Message) o; + return type == message.type && Objects.equals(content, message.content); + } + + @Override + public int hashCode() { + return Objects.hash(type, content); + } +} diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/MessageManager.java b/leader-election/src/main/java/com/iluwatar/leaderelection/MessageManager.java new file mode 100644 index 000000000000..56e78a00856a --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/MessageManager.java @@ -0,0 +1,60 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.leaderelection; + +/** + * MessageManager interface + */ +public interface MessageManager { + + /** + * Send heartbeat message to leader instance to check whether the leader instance is alive. + * @param leaderId Instance ID of leader instance. + * @return {@code true} if leader instance is alive, or {@code false} if not. + */ + boolean sendHeartbeatMessage(int leaderId); + + /** + * Send election message to other instances. + * @param currentId Instance ID of which sends this message. + * @param content Election message content. + * @return {@code true} if the message is accepted by the target instances. + */ + boolean sendElectionMessage(int currentId, String content); + + /** + * Send new leader notification message to other instances. + * @param currentId Instance ID of which sends this message. + * @param leaderId Leader message content. + * @return {@code true} if the message is accepted by the target instances. + */ + boolean sendLeaderMessage(int currentId, int leaderId); + + /** + * Send heartbeat invoke message. This will invoke heartbeat task in the target instance. + * @param currentId Instance ID of which sends this message. + */ + void sendHeartbeatInvokeMessage(int currentId); + +} diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/MessageType.java b/leader-election/src/main/java/com/iluwatar/leaderelection/MessageType.java new file mode 100644 index 000000000000..17f658ec4244 --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/MessageType.java @@ -0,0 +1,62 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.leaderelection; + +/** + * Message Type enum + */ +public enum MessageType { + + /** + * Start the election. The content of the message stores ID(s) of the candidate instance(s). + */ + ELECTION, + + /** + * Nodify the new leader. The content of the message should be the leader ID. + */ + LEADER, + + /** + * Check health of current leader instance. + */ + HEARTBEAT, + + /** + * Inform target instance to start election. + */ + ELECTION_INVOKE, + + /** + * Inform target instance to notify all the other instance that it is the new leader. + */ + LEADER_INVOKE, + + /** + * Inform target instance to start heartbeat. + */ + HEARTBEAT_INVOKE + +} + diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyApp.java b/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyApp.java new file mode 100644 index 000000000000..7355b34456a9 --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyApp.java @@ -0,0 +1,77 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection.bully; + +import com.iluwatar.leaderelection.Instance; +import com.iluwatar.leaderelection.Message; +import com.iluwatar.leaderelection.MessageManager; +import com.iluwatar.leaderelection.MessageType; + +import java.util.HashMap; +import java.util.Map; + +/** + * Example of how to use bully leader election. Initially 5 instances is created in the clould + * system, and the instance with ID 1 is set as leader. After the system is started stop the + * leader instance, and the new leader will be elected. + */ +public class BullyApp { + + /** + * Program entry point + */ + public static void main(String[] args) { + + Map instanceMap = new HashMap<>(); + MessageManager messageManager = new BullyMessageManager(instanceMap); + + BullyInstance instance1 = new BullyInstance(messageManager, 1, 1); + BullyInstance instance2 = new BullyInstance(messageManager, 2, 1); + BullyInstance instance3 = new BullyInstance(messageManager, 3, 1); + BullyInstance instance4 = new BullyInstance(messageManager, 4, 1); + BullyInstance instance5 = new BullyInstance(messageManager, 5, 1); + + instanceMap.put(1, instance1); + instanceMap.put(2, instance2); + instanceMap.put(3, instance3); + instanceMap.put(4, instance4); + instanceMap.put(5, instance5); + + instance4.onMessage(new Message(MessageType.HEARTBEAT_INVOKE, "")); + + Thread thread1 = new Thread(instance1); + Thread thread2 = new Thread(instance2); + Thread thread3 = new Thread(instance3); + Thread thread4 = new Thread(instance4); + Thread thread5 = new Thread(instance5); + + thread1.start(); + thread2.start(); + thread3.start(); + thread4.start(); + thread5.start(); + + instance1.setAlive(false); + } +} diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyInstance.java b/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyInstance.java new file mode 100644 index 000000000000..70a9c60f341a --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyInstance.java @@ -0,0 +1,121 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection.bully; + +import com.iluwatar.leaderelection.AbstractInstance; +import com.iluwatar.leaderelection.Message; +import com.iluwatar.leaderelection.MessageManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Impelemetation with bully algorithm. Each instance should have a sequential id and is able to + * communicate with other instances in the system. Initially the instance with smallest (or largest) + * ID is selected to be the leader. All the other instances send heartbeat message to leader periodically + * to check its health. If one certain instance finds the server done, it will send an election message + * to all the instances of which the ID is larger. If the target instance is alive, it will return an + * alive message (in this sample return true) and then send election message with its ID. If not, + * the original instance will send leader message to all the other instances. + */ +public class BullyInstance extends AbstractInstance { + + private static final Logger LOGGER = LoggerFactory.getLogger(BullyInstance.class); + + /** + * Constructor of BullyInstance. + */ + public BullyInstance(MessageManager messageManager, int localId, int leaderId) { + super(messageManager, localId, leaderId); + } + + /** + * Process the heartbeat invoke message. After receiving the message, the instance will send a heartbeat + * to leader to check its health. If alive, it will inform the next instance to do the heartbeat. If not, + * it will start the election process. + */ + @Override + protected void handleHeartbeatInvokeMessage() { + try { + boolean isLeaderAlive = messageManager.sendHeartbeatMessage(leaderId); + if (isLeaderAlive) { + LOGGER.info("Instance " + localId + "- Leader is alive."); + Thread.sleep(HEARTBEAT_INTERVAL); + messageManager.sendHeartbeatInvokeMessage(localId); + } else { + LOGGER.info("Instance " + localId + "- Leader is not alive. Start election."); + boolean electionResult = messageManager.sendElectionMessage(localId, String.valueOf(localId)); + if (electionResult) { + LOGGER.info("Instance " + localId + "- Succeed in election. Start leader notification."); + messageManager.sendLeaderMessage(localId, localId); + } + } + } catch (InterruptedException e) { + LOGGER.info("Instance " + localId + "- Interrupted."); + } + } + + /** + * Process election invoke message. Send election message to all the instances with smaller ID. If any + * one of them is alive, do nothing. If no instance alive, send leader message to all the alive instance + * and restart heartbeat. + */ + @Override + protected void handleElectionInvokeMessage() { + if (!isLeader()) { + LOGGER.info("Instance " + localId + "- Start election."); + boolean electionResult = messageManager.sendElectionMessage(localId, String.valueOf(localId)); + if (electionResult) { + LOGGER.info("Instance " + localId + "- Succeed in election. Start leader notification."); + leaderId = localId; + messageManager.sendLeaderMessage(localId, localId); + messageManager.sendHeartbeatInvokeMessage(localId); + } + } + } + + /** + * Process leader message. Update local leader information. + */ + @Override + protected void handleLeaderMessage(Message message) { + leaderId = Integer.valueOf(message.getContent()); + LOGGER.info("Instance " + localId + " - Leader update done."); + } + + private boolean isLeader() { + return localId == leaderId; + } + + /** + * Not used in Bully instance. + */ + @Override + protected void handleLeaderInvokeMessage() {} + + @Override + protected void handleHeartbeatMessage(Message message) {} + + @Override + protected void handleElectionMessage(Message message) {} +} diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyMessageManager.java b/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyMessageManager.java new file mode 100644 index 000000000000..3fcadefba2de --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyMessageManager.java @@ -0,0 +1,117 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection.bully; + +import com.iluwatar.leaderelection.AbstractMessageManager; +import com.iluwatar.leaderelection.Instance; +import com.iluwatar.leaderelection.Message; +import com.iluwatar.leaderelection.MessageType; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Implementation of BullyMessageManager + */ +public class BullyMessageManager extends AbstractMessageManager { + + /** + * Constructor of BullyMessageManager. + */ + public BullyMessageManager(Map instanceMap) { + super(instanceMap); + } + + /** + * Send heartbeat message to current leader instance to check the health. + * @param leaderId leaderID + * @return {@code true} if the leader is alive. + */ + @Override + public boolean sendHeartbeatMessage(int leaderId) { + Instance leaderInstance = instanceMap.get(leaderId); + boolean alive = leaderInstance.isAlive(); + return alive; + } + + /** + * Send election message to all the instances with smaller ID. + * @param currentId Instance ID of which sends this message. + * @param content Election message content. + * @return {@code true} if no alive instance has smaller ID, so that the election is accepted. + */ + @Override + public boolean sendElectionMessage(int currentId, String content) { + List candidateList = findElectionCandidateInstanceList(currentId); + if (candidateList.isEmpty()) { + return true; + } else { + Message electionMessage = new Message(MessageType.ELECTION_INVOKE, ""); + candidateList.stream() + .forEach((i) -> instanceMap.get(i).onMessage(electionMessage)); + return false; + } + } + + /** + * Send leader message to all the instances to notify the new leader. + * @param currentId Instance ID of which sends this message. + * @param leaderId Leader message content. + * @return {@code true} if the message is accepted. + */ + @Override + public boolean sendLeaderMessage(int currentId, int leaderId) { + Message leaderMessage = new Message(MessageType.LEADER, String.valueOf(leaderId)); + instanceMap.keySet() + .stream() + .filter((i) -> i != currentId) + .forEach((i) -> instanceMap.get(i).onMessage(leaderMessage)); + return false; + } + + /** + * Send heartbeat invoke message to the next instance. + * @param currentId Instance ID of which sends this message. + */ + @Override + public void sendHeartbeatInvokeMessage(int currentId) { + Instance nextInstance = this.findNextInstance(currentId); + Message heartbeatInvokeMessage = new Message(MessageType.HEARTBEAT_INVOKE, ""); + nextInstance.onMessage(heartbeatInvokeMessage); + } + + /** + * Find all the alive instances with smaller ID than current instance. + * @param currentId ID of current instance. + * @return ID list of all the candidate instance. + */ + private List findElectionCandidateInstanceList(int currentId) { + return instanceMap.keySet() + .stream() + .filter((i) -> i < currentId && instanceMap.get(i).isAlive()) + .collect(Collectors.toList()); + } + +} diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingApp.java b/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingApp.java new file mode 100644 index 000000000000..ade5bb70dc29 --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingApp.java @@ -0,0 +1,77 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.leaderelection.ring; + +import com.iluwatar.leaderelection.Instance; +import com.iluwatar.leaderelection.Message; +import com.iluwatar.leaderelection.MessageManager; +import com.iluwatar.leaderelection.MessageType; + +import java.util.HashMap; +import java.util.Map; + +/** + * Example of how to use ring leader election. Initially 5 instances is created in the clould + * system, and the instance with ID 1 is set as leader. After the system is started stop the + * leader instance, and the new leader will be elected. + */ +public class RingApp { + + /** + * Program entry point + */ + public static void main(String[] args) { + + Map instanceMap = new HashMap<>(); + MessageManager messageManager = new RingMessageManager(instanceMap); + + RingInstance instance1 = new RingInstance(messageManager, 1, 1); + RingInstance instance2 = new RingInstance(messageManager, 2, 1); + RingInstance instance3 = new RingInstance(messageManager, 3, 1); + RingInstance instance4 = new RingInstance(messageManager, 4, 1); + RingInstance instance5 = new RingInstance(messageManager, 5, 1); + + instanceMap.put(1, instance1); + instanceMap.put(2, instance2); + instanceMap.put(3, instance3); + instanceMap.put(4, instance4); + instanceMap.put(5, instance5); + + instance2.onMessage(new Message(MessageType.HEARTBEAT_INVOKE, "")); + + Thread thread1 = new Thread(instance1); + Thread thread2 = new Thread(instance2); + Thread thread3 = new Thread(instance3); + Thread thread4 = new Thread(instance4); + Thread thread5 = new Thread(instance5); + + thread1.start(); + thread2.start(); + thread3.start(); + thread4.start(); + thread5.start(); + + instance1.setAlive(false); + } +} diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingInstance.java b/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingInstance.java new file mode 100644 index 000000000000..e3472e4b4669 --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingInstance.java @@ -0,0 +1,133 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.leaderelection.ring; + +import com.iluwatar.leaderelection.AbstractInstance; +import com.iluwatar.leaderelection.Message; +import com.iluwatar.leaderelection.MessageManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Implementation with token ring algorithm. The instances in the system are organized as a ring. + * Each instance should have a sequential id and the instance with smallest (or largest) id should + * be the initial leader. All the other instances send heartbeat message to leader periodically + * to check its health. If one certain instance finds the server done, it will send an election + * message to the next alive instance in the ring, which contains its own ID. Then the next instance + * add its ID into the message and pass it to the next. After all the alive instances' ID are add + * to the message, the message is send back to the first instance and it will choose the instance + * with smallest ID to be the new leader, and then send a leader message to other instances to + * inform the result. + */ +public class RingInstance extends AbstractInstance { + + private static final Logger LOGGER = LoggerFactory.getLogger(RingInstance.class); + + /** + * Constructor of RingInstance. + */ + public RingInstance(MessageManager messageManager, int localId, int leaderId) { + super(messageManager, localId, leaderId); + } + + /** + * Process the heartbeat invoke message. After receiving the message, the instance will send a heartbeat + * to leader to check its health. If alive, it will inform the next instance to do the heartbeat. If not, + * it will start the election process. + */ + @Override + protected void handleHeartbeatInvokeMessage() { + try { + boolean isLeaderAlive = messageManager.sendHeartbeatMessage(this.leaderId); + if (isLeaderAlive) { + LOGGER.info("Instance " + localId + "- Leader is alive. Start next heartbeat in 5 second."); + Thread.sleep(HEARTBEAT_INTERVAL); + messageManager.sendHeartbeatInvokeMessage(this.localId); + } else { + LOGGER.info("Instance " + localId + "- Leader is not alive. Start election."); + messageManager.sendElectionMessage(this.localId, String.valueOf(this.localId)); + } + } catch (InterruptedException e) { + LOGGER.info("Instance " + localId + "- Interrupted."); + } + } + + /** + * Process election message. If the local ID is contained in the ID list, the instance will select the + * alive instance with smallest ID to be the new leader, and send the leader inform message. If not, + * it will add its local ID to the list and send the message to the next instance in the ring. + */ + @Override + protected void handleElectionMessage(Message message) { + String content = message.getContent(); + LOGGER.info("Instance " + localId + " - Election Message: " + content); + List candidateList = + Arrays.stream(content.trim().split(",")) + .map(Integer::valueOf) + .sorted() + .collect(Collectors.toList()); + if (candidateList.contains(localId)) { + int newLeaderId = candidateList.get(0); + LOGGER.info("Instance " + localId + " - New leader should be " + newLeaderId + "."); + messageManager.sendLeaderMessage(localId, newLeaderId); + } else { + content += "," + localId; + messageManager.sendElectionMessage(localId, content); + } + } + + /** + * Process leader Message. The instance will set the leader ID to be the new one and send the message to + * the next instance until all the alive instance in the ring is informed. + */ + @Override + protected void handleLeaderMessage(Message message) { + int newLeaderId = Integer.valueOf(message.getContent()); + if (this.leaderId != newLeaderId) { + LOGGER.info("Instance " + localId + " - Update leaderID"); + this.leaderId = newLeaderId; + messageManager.sendLeaderMessage(localId, newLeaderId); + } else { + LOGGER.info("Instance " + localId + " - Leader update done. Start heartbeat."); + messageManager.sendHeartbeatInvokeMessage(localId); + } + } + + /** + * Not used in Ring instance. + */ + @Override + protected void handleLeaderInvokeMessage() {} + + @Override + protected void handleHeartbeatMessage(Message message) {} + + @Override + protected void handleElectionInvokeMessage() {} + +} diff --git a/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingMessageManager.java b/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingMessageManager.java new file mode 100644 index 000000000000..257a9f764d97 --- /dev/null +++ b/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingMessageManager.java @@ -0,0 +1,96 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + * + * 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 com.iluwatar.leaderelection.ring; + +import com.iluwatar.leaderelection.AbstractMessageManager; +import com.iluwatar.leaderelection.Instance; +import com.iluwatar.leaderelection.Message; +import com.iluwatar.leaderelection.MessageType; + +import java.util.Map; + +/** + * Implementation of RingMessageManager + */ +public class RingMessageManager extends AbstractMessageManager { + + /** + * Constructor of RingMessageManager. + */ + public RingMessageManager(Map instanceMap) { + super(instanceMap); + } + + /** + * Send heartbeat message to current leader instance to check the health. + * @param leaderId leaderID + * @return {@code true} if the leader is alive. + */ + @Override + public boolean sendHeartbeatMessage(int leaderId) { + Instance leaderInstance = instanceMap.get(leaderId); + boolean alive = leaderInstance.isAlive(); + return alive; + } + + /** + * Send election message to the next instance. + * @param currentId currentID + * @param content list contains all the IDs of instances which have received this election message. + * @return {@code true} if the election message is accepted by the target instance. + */ + @Override + public boolean sendElectionMessage(int currentId, String content) { + Instance nextInstance = this.findNextInstance(currentId); + Message electionMessage = new Message(MessageType.ELECTION, content); + nextInstance.onMessage(electionMessage); + return true; + } + + /** + * Send leader message to the next instance. + * @param currentId Instance ID of which sends this message. + * @param leaderId Leader message content. + * @return {@code true} if the leader message is accepted by the target instance. + */ + @Override + public boolean sendLeaderMessage(int currentId, int leaderId) { + Instance nextInstance = this.findNextInstance(currentId); + Message leaderMessage = new Message(MessageType.LEADER, String.valueOf(leaderId)); + nextInstance.onMessage(leaderMessage); + return true; + } + + /** + * Send heartbeat invoke message to the next instance. + * @param currentId Instance ID of which sends this message. + */ + @Override + public void sendHeartbeatInvokeMessage(int currentId) { + Instance nextInstance = this.findNextInstance(currentId); + Message heartbeatInvokeMessage = new Message(MessageType.HEARTBEAT_INVOKE, ""); + nextInstance.onMessage(heartbeatInvokeMessage); + } + +} diff --git a/leader-election/src/test/java/com/iluwatar/leaderelection/MessageTest.java b/leader-election/src/test/java/com/iluwatar/leaderelection/MessageTest.java new file mode 100644 index 000000000000..3cd5b93d9fdd --- /dev/null +++ b/leader-election/src/test/java/com/iluwatar/leaderelection/MessageTest.java @@ -0,0 +1,48 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Message test case. + */ +public class MessageTest { + + @Test + public void testGetType() { + Message message = new Message(MessageType.HEARTBEAT, ""); + assertEquals(MessageType.HEARTBEAT, message.getType()); + } + + @Test + public void testGetContent() { + String content = "test"; + Message message = new Message(MessageType.HEARTBEAT, content); + assertEquals(content, message.getContent()); + } + +} diff --git a/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyAppTest.java b/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyAppTest.java new file mode 100644 index 000000000000..b4b527d5a813 --- /dev/null +++ b/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyAppTest.java @@ -0,0 +1,39 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection.bully; + +import org.junit.jupiter.api.Test; + +/** + * BullyApp unit test. + */ +public class BullyAppTest { + + @Test + public void test() { + String[] args = {}; + BullyApp.main(args); + } + +} diff --git a/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyMessageManagerTest.java b/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyMessageManagerTest.java new file mode 100644 index 000000000000..3a8e35b54abe --- /dev/null +++ b/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyMessageManagerTest.java @@ -0,0 +1,151 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection.bully; + +import com.iluwatar.leaderelection.*; +import com.iluwatar.leaderelection.ring.RingInstance; +import com.iluwatar.leaderelection.ring.RingMessageManager; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.Queue; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * BullyMessageManager unit test. + */ +public class BullyMessageManagerTest { + + @Test + public void testSendHeartbeatMessage() { + Instance instance1 = new BullyInstance(null, 1, 1); + Map instanceMap = new HashMap<>(); + instanceMap.put(1, instance1); + MessageManager messageManager = new BullyMessageManager(instanceMap); + assertTrue(messageManager.sendHeartbeatMessage(1)); + } + + @Test + public void testSendElectionMessageNotAccepted() { + try { + Instance instance1 = new BullyInstance(null, 1, 1); + Instance instance2 = new BullyInstance(null, 1, 2); + Instance instance3 = new BullyInstance(null, 1, 3); + Instance instance4 = new BullyInstance(null, 1, 4); + Map instanceMap = new HashMap<>(); + instanceMap.put(1, instance1); + instanceMap.put(2, instance2); + instanceMap.put(3, instance3); + instanceMap.put(4, instance4); + instance1.setAlive(false); + MessageManager messageManager = new BullyMessageManager(instanceMap); + boolean result = messageManager.sendElectionMessage(3, "3"); + Class instanceClass = AbstractInstance.class; + Field messageQueueField = instanceClass.getDeclaredField("messageQueue"); + messageQueueField.setAccessible(true); + Message message2 = ((Queue) messageQueueField.get(instance2)).poll(); + int instance4QueueSize = ((Queue) messageQueueField.get(instance4)).size(); + Message expectedMessage = new Message(MessageType.ELECTION_INVOKE, ""); + assertEquals(message2, expectedMessage); + assertEquals(instance4QueueSize, 0); + assertEquals(result, false); + } catch (IllegalAccessException | NoSuchFieldException e) { + fail("Error to access private field."); + } + } + + @Test + public void testElectionMessageAccepted() { + Instance instance1 = new BullyInstance(null, 1, 1); + Instance instance2 = new BullyInstance(null, 1, 2); + Instance instance3 = new BullyInstance(null, 1, 3); + Instance instance4 = new BullyInstance(null, 1, 4); + Map instanceMap = new HashMap<>(); + instanceMap.put(1, instance1); + instanceMap.put(2, instance2); + instanceMap.put(3, instance3); + instanceMap.put(4, instance4); + instance1.setAlive(false); + MessageManager messageManager = new BullyMessageManager(instanceMap); + boolean result = messageManager.sendElectionMessage(2, "2"); + assertEquals(result, true); + } + + @Test + public void testSendLeaderMessage() { + try { + Instance instance1 = new BullyInstance(null, 1, 1); + Instance instance2 = new BullyInstance(null, 1, 2); + Instance instance3 = new BullyInstance(null, 1, 3); + Instance instance4 = new BullyInstance(null, 1, 4); + Map instanceMap = new HashMap<>(); + instanceMap.put(1, instance1); + instanceMap.put(2, instance2); + instanceMap.put(3, instance3); + instanceMap.put(4, instance4); + instance1.setAlive(false); + MessageManager messageManager = new BullyMessageManager(instanceMap); + messageManager.sendLeaderMessage(2, 2); + Class instanceClass = AbstractInstance.class; + Field messageQueueField = instanceClass.getDeclaredField("messageQueue"); + messageQueueField.setAccessible(true); + Message message3 = ((Queue) messageQueueField.get(instance3)).poll(); + Message message4 = ((Queue) messageQueueField.get(instance4)).poll(); + Message expectedMessage = new Message(MessageType.LEADER, "2"); + assertEquals(message3, expectedMessage); + assertEquals(message4, expectedMessage); + } catch (IllegalAccessException | NoSuchFieldException e) { + fail("Error to access private field."); + } + } + + @Test + public void testSendHeartbeatInvokeMessage() { + try { + Instance instance1 = new BullyInstance(null, 1, 1); + Instance instance2 = new BullyInstance(null, 1, 2); + Instance instance3 = new BullyInstance(null, 1, 3); + Map instanceMap = new HashMap<>(); + instanceMap.put(1, instance1); + instanceMap.put(2, instance2); + instanceMap.put(3, instance3); + MessageManager messageManager = new BullyMessageManager(instanceMap); + messageManager.sendHeartbeatInvokeMessage(2); + Message message = new Message(MessageType.HEARTBEAT_INVOKE, ""); + Class instanceClass = AbstractInstance.class; + Field messageQueueField = instanceClass.getDeclaredField("messageQueue"); + messageQueueField.setAccessible(true); + Message messageSent = ((Queue) messageQueueField.get(instance3)).poll(); + assertEquals(messageSent.getType(), message.getType()); + assertEquals(messageSent.getContent(), message.getContent()); + } catch (NoSuchFieldException | IllegalAccessException e) { + fail("Error to access private field."); + } + } + + +} diff --git a/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyinstanceTest.java b/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyinstanceTest.java new file mode 100644 index 000000000000..7581a8af1247 --- /dev/null +++ b/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyinstanceTest.java @@ -0,0 +1,78 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection.bully; + +import com.iluwatar.leaderelection.AbstractInstance; +import com.iluwatar.leaderelection.Message; +import com.iluwatar.leaderelection.MessageType; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Field; +import java.util.Queue; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * BullyInstance unit test. + */ +public class BullyinstanceTest { + + @Test + public void testOnMessage() { + try { + final BullyInstance bullyInstance = new BullyInstance(null, 1, 1); + Message bullyMessage = new Message(MessageType.HEARTBEAT, ""); + bullyInstance.onMessage(bullyMessage); + Class instanceClass = AbstractInstance.class; + Field messageQueueField = instanceClass.getDeclaredField("messageQueue"); + messageQueueField.setAccessible(true); + assertEquals(bullyMessage, ((Queue) messageQueueField.get(bullyInstance)).poll()); + } catch (IllegalAccessException | NoSuchFieldException e) { + fail("fail to access messasge queue."); + } + + } + + @Test + public void testIsAlive() { + try { + final BullyInstance bullyInstance = new BullyInstance(null, 1, 1); + Class instanceClass = AbstractInstance.class; + Field aliveField = instanceClass.getDeclaredField("alive"); + aliveField.setAccessible(true); + aliveField.set(bullyInstance, false); + assertFalse(bullyInstance.isAlive()); + } catch (NoSuchFieldException | IllegalAccessException e) { + fail("Fail to access field alive."); + } + } + + @Test + public void testSetAlive() { + final BullyInstance bullyInstance = new BullyInstance(null, 1, 1); + bullyInstance.setAlive(false); + assertFalse(bullyInstance.isAlive()); + } + +} diff --git a/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingAppTest.java b/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingAppTest.java new file mode 100644 index 000000000000..c6f50bc799fd --- /dev/null +++ b/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingAppTest.java @@ -0,0 +1,39 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection.ring; + +import org.junit.jupiter.api.Test; + +/** + * RingApp unit test. + */ +public class RingAppTest { + + @Test + public void test() { + String[] args = {}; + RingApp.main(args); + } + +} diff --git a/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingInstanceTest.java b/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingInstanceTest.java new file mode 100644 index 000000000000..65c3916cc535 --- /dev/null +++ b/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingInstanceTest.java @@ -0,0 +1,76 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection.ring; + +import com.iluwatar.leaderelection.AbstractInstance; +import com.iluwatar.leaderelection.Message; +import com.iluwatar.leaderelection.MessageType; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Field; +import java.util.Queue; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * RingInstance unit test. + */ +public class RingInstanceTest { + + @Test + public void testOnMessage() { + try { + final RingInstance ringInstance = new RingInstance(null, 1, 1); + Message ringMessage = new Message(MessageType.HEARTBEAT, ""); + ringInstance.onMessage(ringMessage); + Class ringInstanceClass = AbstractInstance.class; + Field messageQueueField = ringInstanceClass.getDeclaredField("messageQueue"); + messageQueueField.setAccessible(true); + assertEquals(ringMessage, ((Queue) messageQueueField.get(ringInstance)).poll()); + } catch (IllegalAccessException | NoSuchFieldException e) { + fail("fail to access messasge queue."); + } + } + + @Test + public void testIsAlive() { + try { + final RingInstance ringInstance = new RingInstance(null, 1, 1); + Class ringInstanceClass = AbstractInstance.class; + Field aliveField = ringInstanceClass.getDeclaredField("alive"); + aliveField.setAccessible(true); + aliveField.set(ringInstance, false); + assertFalse(ringInstance.isAlive()); + } catch (NoSuchFieldException | IllegalAccessException e) { + fail("Fail to access field alive."); + } + } + + @Test + public void testSetAlive() { + final RingInstance ringInstance = new RingInstance(null, 1, 1); + ringInstance.setAlive(false); + assertFalse(ringInstance.isAlive()); + } +} diff --git a/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingMessageManagerTest.java b/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingMessageManagerTest.java new file mode 100644 index 000000000000..64d5af69f5bb --- /dev/null +++ b/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingMessageManagerTest.java @@ -0,0 +1,123 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.leaderelection.ring; + +import com.iluwatar.leaderelection.*; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.Queue; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * RingMessageManager unit test. + */ +public class RingMessageManagerTest { + + @Test + public void testSendHeartbeatMessage() { + Instance instance1 = new RingInstance(null, 1, 1); + Map instanceMap = new HashMap<>(); + instanceMap.put(1, instance1); + MessageManager messageManager = new RingMessageManager(instanceMap); + assertTrue(messageManager.sendHeartbeatMessage(1)); + } + + @Test + public void testSendElectionMessage() { + try { + Instance instance1 = new RingInstance(null, 1, 1); + Instance instance2 = new RingInstance(null, 1, 2); + Instance instance3 = new RingInstance(null, 1, 3); + Map instanceMap = new HashMap<>(); + instanceMap.put(1, instance1); + instanceMap.put(2, instance2); + instanceMap.put(3, instance3); + MessageManager messageManager = new RingMessageManager(instanceMap); + String messageContent = "2"; + messageManager.sendElectionMessage(2, messageContent); + Message ringMessage = new Message(MessageType.ELECTION, messageContent); + Class instanceClass = AbstractInstance.class; + Field messageQueueField = instanceClass.getDeclaredField("messageQueue"); + messageQueueField.setAccessible(true); + Message ringMessageSent = ((Queue) messageQueueField.get(instance3)).poll(); + assertEquals(ringMessageSent.getType(), ringMessage.getType()); + assertEquals(ringMessageSent.getContent(), ringMessage.getContent()); + } catch (NoSuchFieldException | IllegalAccessException e) { + fail("Error to access private field."); + } + } + + @Test + public void testSendLeaderMessage() { + try { + Instance instance1 = new RingInstance(null, 1, 1); + Instance instance2 = new RingInstance(null, 1, 2); + Instance instance3 = new RingInstance(null, 1, 3); + Map instanceMap = new HashMap<>(); + instanceMap.put(1, instance1); + instanceMap.put(2, instance2); + instanceMap.put(3, instance3); + MessageManager messageManager = new RingMessageManager(instanceMap); + String messageContent = "3"; + messageManager.sendLeaderMessage(2, 3); + Message ringMessage = new Message(MessageType.LEADER, messageContent); + Class instanceClass = AbstractInstance.class; + Field messageQueueField = instanceClass.getDeclaredField("messageQueue"); + messageQueueField.setAccessible(true); + Message ringMessageSent = ((Queue) messageQueueField.get(instance3)).poll(); + assertEquals(ringMessageSent, ringMessage); + } catch (NoSuchFieldException | IllegalAccessException e) { + fail("Error to access private field."); + } + } + + @Test + public void testSendHeartbeatInvokeMessage() { + try { + Instance instance1 = new RingInstance(null, 1, 1); + Instance instance2 = new RingInstance(null, 1, 2); + Instance instance3 = new RingInstance(null, 1, 3); + Map instanceMap = new HashMap<>(); + instanceMap.put(1, instance1); + instanceMap.put(2, instance2); + instanceMap.put(3, instance3); + MessageManager messageManager = new RingMessageManager(instanceMap); + messageManager.sendHeartbeatInvokeMessage(2); + Message ringMessage = new Message(MessageType.HEARTBEAT_INVOKE, ""); + Class instanceClass = AbstractInstance.class; + Field messageQueueField = instanceClass.getDeclaredField("messageQueue"); + messageQueueField.setAccessible(true); + Message ringMessageSent = ((Queue) messageQueueField.get(instance3)).poll(); + assertEquals(ringMessageSent.getType(), ringMessage.getType()); + assertEquals(ringMessageSent.getContent(), ringMessage.getContent()); + } catch (NoSuchFieldException | IllegalAccessException e) { + fail("Error to access private field."); + } + } + +} diff --git a/pom.xml b/pom.xml index 39cfee91c241..d812d27c4c54 100644 --- a/pom.xml +++ b/pom.xml @@ -176,7 +176,9 @@ commander typeobjectpattern bytecode + leader-election data-locality + From 795b6be17d270e93ccfc871fa4976f052c33a181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Fri, 11 Oct 2019 19:28:50 +0300 Subject: [PATCH 15/30] Configure Travis to build on JDK8 and JDK11 --- .travis.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 58edddeb416e..2a82f6051f2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ language: java -dist: trusty # Xenial build environment won't allow installation of Java 8 +dist: xenial jdk: -- oraclejdk8 +- openjdk8 +- openjdk11 env: global: @@ -21,12 +22,6 @@ after_success: - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN - bash update-ghpages.sh -# use latest java version available instead of travis default -addons: - apt: - packages: - - oracle-java8-installer - notifications: email: - iluwatar@gmail.com From 71f26c3e59f45d0e62b7137a75705a522d43cdec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Fri, 11 Oct 2019 19:37:28 +0300 Subject: [PATCH 16/30] Fix Travis xvfb --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2a82f6051f2c..84b031fadcc1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,9 @@ env: - GH_REF: github.com/iluwatar/java-design-patterns.git - secure: LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg= - secure: "eoWlW9GyTJY04P8K3pxayXwU9/hmptQg/LfirispQkV9YvmziCfSzXnatnBhNfud98sCzY8BScXnb+OWLTnjLKpId4rtEqb0aJ40Jc32cUKzgzFAUn7cNcDAbUIfyPAGVqyQqfj/11wYSADwWMMOPlW97ExUtoyiH2WenXuRHso=" - -before_install: -- export DISPLAY=:99.0 -- sh -e /etc/init.d/xvfb start + +services: +- xvfb # default install command is just "mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V" install: From e36bbbb22bad5e24c15ea2d185309033580f2ba8 Mon Sep 17 00:00:00 2001 From: lbroman Date: Fri, 11 Oct 2019 20:55:48 +0200 Subject: [PATCH 17/30] Maven profiles to support jdk 11 builds. #948 (#975) * Maven profiles to support jdk 11 builds. #948 Added maven profiles activated by jdk 11, wich will not break java 8 support. Bumped lombok and datanucleus enhancer as the old versions dont work with 11. * Fixed PMD issue when building naked-objects * Fixed the eip modules with xml dependencies. Previous dependency relaxing commit causes xml libs to go missing from some modules that actually needed them --- cqrs/pom.xml | 21 ++++++++++++++++ eip-aggregator/pom.xml | 20 +++++++++++++++ eip-splitter/pom.xml | 21 ++++++++++++++++ eip-wire-tap/pom.xml | 19 +++++++++++++++ naked-objects/dom/exclude-pmd.properties | 24 ++++++++++++++++++ naked-objects/dom/pom.xml | 2 +- naked-objects/integtests/pom.xml | 14 +++++++++++ pom.xml | 31 +++++++++++++++++++++++- service-layer/pom.xml | 18 ++++++++++++++ trampoline/pom.xml | 2 +- 10 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 naked-objects/dom/exclude-pmd.properties diff --git a/cqrs/pom.xml b/cqrs/pom.xml index beb195473ced..fc89a93b7c79 100644 --- a/cqrs/pom.xml +++ b/cqrs/pom.xml @@ -39,4 +39,25 @@ hibernate-core + + + jdk11-deps + + [11,) + + + + com.sun.xml.bind + jaxb-impl + test + 2.1.17 + + + javax.xml.bind + jaxb-api + test + + + + diff --git a/eip-aggregator/pom.xml b/eip-aggregator/pom.xml index f56ae78deb73..39270f02097e 100644 --- a/eip-aggregator/pom.xml +++ b/eip-aggregator/pom.xml @@ -70,4 +70,24 @@ + + + + jdk11-deps + + [11,) + + + + com.sun.xml.bind + jaxb-impl + + + javax.xml.bind + jaxb-api + + + + + diff --git a/eip-splitter/pom.xml b/eip-splitter/pom.xml index 2bc3eec8402b..7319f651939c 100644 --- a/eip-splitter/pom.xml +++ b/eip-splitter/pom.xml @@ -70,4 +70,25 @@ + + + + jdk11-deps + + [11,) + + + + com.sun.xml.bind + jaxb-impl + + + javax.xml.bind + jaxb-api + + + + + + diff --git a/eip-wire-tap/pom.xml b/eip-wire-tap/pom.xml index efca8d3c4cfb..a9d30924204a 100644 --- a/eip-wire-tap/pom.xml +++ b/eip-wire-tap/pom.xml @@ -70,4 +70,23 @@ + + + + jdk11-deps + + [11,) + + + + com.sun.xml.bind + jaxb-impl + + + javax.xml.bind + jaxb-api + + + + diff --git a/naked-objects/dom/exclude-pmd.properties b/naked-objects/dom/exclude-pmd.properties new file mode 100644 index 000000000000..bda3929accc6 --- /dev/null +++ b/naked-objects/dom/exclude-pmd.properties @@ -0,0 +1,24 @@ +# +# The MIT License +# Copyright (c) 2014-2016 Ilkka Seppälä +# +# 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. +# + +domainapp.dom.modules.simple.QSimpleObject=UnusedFormalParameter \ No newline at end of file diff --git a/naked-objects/dom/pom.xml b/naked-objects/dom/pom.xml index 69365bd4b00a..039afc373727 100644 --- a/naked-objects/dom/pom.xml +++ b/naked-objects/dom/pom.xml @@ -78,7 +78,7 @@ true - 4.0.1 + 5.2.1 diff --git a/naked-objects/integtests/pom.xml b/naked-objects/integtests/pom.xml index c4dd52dcf652..f12f4ae1e368 100644 --- a/naked-objects/integtests/pom.xml +++ b/naked-objects/integtests/pom.xml @@ -122,6 +122,20 @@ --> + + + jdk11-deps + + [11,) + + + + javax.annotation + javax.annotation-api + + + + diff --git a/pom.xml b/pom.xml index d812d27c4c54..efeee185c788 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,8 @@ 2.8.5 3.12.0 1.2.17 - 2.3.0 + 2.3.1 + 2.3.2 1.3.1 @@ -314,6 +315,11 @@ javax.annotation-api ${annotation-api.version} + + com.sun.xml.bind + jaxb-impl + ${jaxb-impl.version} + @@ -494,4 +500,27 @@ + + + jdk11-dep-management + + [11,) + + + + + org.javassist + javassist + 3.25.0-GA + + + javax.annotation + javax.annotation-api + 1.3.2 + + + + + + diff --git a/service-layer/pom.xml b/service-layer/pom.xml index 403a896a4613..4edd950740a8 100644 --- a/service-layer/pom.xml +++ b/service-layer/pom.xml @@ -52,4 +52,22 @@ test + + + jdk11-deps + + [11,) + + + + com.sun.xml.bind + jaxb-impl + + + javax.xml.bind + jaxb-api + + + + diff --git a/trampoline/pom.xml b/trampoline/pom.xml index 1e019ef31297..86726a1186bc 100644 --- a/trampoline/pom.xml +++ b/trampoline/pom.xml @@ -51,7 +51,7 @@ org.projectlombok lombok - 1.16.18 + 1.18.10 From 6faec9901a2380800aa50af538c8669539997176 Mon Sep 17 00:00:00 2001 From: lbroman Date: Sat, 12 Oct 2019 07:39:58 +0200 Subject: [PATCH 18/30] Bump java language to 11 (#980) * Moved java XML and annotations dependencies to project level instead of as profiles * Set compiler language level to 11 * Removed jdk8 from travis build * Kept java level 8 in naked-objects/dom for datanucleus enhancer, for now. --- .travis.yml | 1 - cqrs/pom.xml | 34 ++++++++++++-------------------- eip-aggregator/pom.xml | 28 +++++++++----------------- eip-splitter/pom.xml | 30 ++++++++++------------------ eip-wire-tap/pom.xml | 28 ++++++++++---------------- naked-objects/dom/pom.xml | 11 +++++++++++ naked-objects/integtests/pom.xml | 20 +++++-------------- pom.xml | 34 ++++++++------------------------ service-layer/pom.xml | 27 +++++++++---------------- 9 files changed, 75 insertions(+), 138 deletions(-) diff --git a/.travis.yml b/.travis.yml index 84b031fadcc1..45323dcfd457 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: java dist: xenial jdk: -- openjdk8 - openjdk11 env: diff --git a/cqrs/pom.xml b/cqrs/pom.xml index fc89a93b7c79..9c9458505aba 100644 --- a/cqrs/pom.xml +++ b/cqrs/pom.xml @@ -38,26 +38,18 @@ org.hibernate hibernate-core + + com.sun.xml.bind + jaxb-impl + test + 2.1.17 + + + javax.xml.bind + jaxb-api + test + + - - - jdk11-deps - - [11,) - - - - com.sun.xml.bind - jaxb-impl - test - 2.1.17 - - - javax.xml.bind - jaxb-api - test - - - - + diff --git a/eip-aggregator/pom.xml b/eip-aggregator/pom.xml index 39270f02097e..6a5e32845cfc 100644 --- a/eip-aggregator/pom.xml +++ b/eip-aggregator/pom.xml @@ -47,6 +47,15 @@ ${camel.version} + + com.sun.xml.bind + jaxb-impl + + + javax.xml.bind + jaxb-api + + com.github.sbrannen @@ -71,23 +80,4 @@ - - - jdk11-deps - - [11,) - - - - com.sun.xml.bind - jaxb-impl - - - javax.xml.bind - jaxb-api - - - - - diff --git a/eip-splitter/pom.xml b/eip-splitter/pom.xml index 7319f651939c..9769d08034a7 100644 --- a/eip-splitter/pom.xml +++ b/eip-splitter/pom.xml @@ -47,6 +47,16 @@ ${camel.version} + + com.sun.xml.bind + jaxb-impl + + + javax.xml.bind + jaxb-api + + + com.github.sbrannen @@ -71,24 +81,4 @@ - - - jdk11-deps - - [11,) - - - - com.sun.xml.bind - jaxb-impl - - - javax.xml.bind - jaxb-api - - - - - - diff --git a/eip-wire-tap/pom.xml b/eip-wire-tap/pom.xml index a9d30924204a..c96063418c46 100644 --- a/eip-wire-tap/pom.xml +++ b/eip-wire-tap/pom.xml @@ -47,6 +47,16 @@ ${camel.version} + + com.sun.xml.bind + jaxb-impl + + + javax.xml.bind + jaxb-api + + + com.github.sbrannen @@ -71,22 +81,4 @@ - - - jdk11-deps - - [11,) - - - - com.sun.xml.bind - jaxb-impl - - - javax.xml.bind - jaxb-api - - - - diff --git a/naked-objects/dom/pom.xml b/naked-objects/dom/pom.xml index 039afc373727..e816c76bbd78 100644 --- a/naked-objects/dom/pom.xml +++ b/naked-objects/dom/pom.xml @@ -36,6 +36,17 @@ + + + org.apache.maven.plugins + maven-compiler-plugin + ${compiler.version} + + 8 + 8 + + + diff --git a/naked-objects/integtests/pom.xml b/naked-objects/integtests/pom.xml index f12f4ae1e368..7365a71a9acb 100644 --- a/naked-objects/integtests/pom.xml +++ b/naked-objects/integtests/pom.xml @@ -90,6 +90,11 @@ hsqldb + + javax.annotation + javax.annotation-api + + - - - jdk11-deps - - [11,) - - - - javax.annotation - javax.annotation-api - - - - - diff --git a/pom.xml b/pom.xml index efeee185c788..b3756e1c06fb 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ 1.2.17 2.3.1 2.3.2 - 1.3.1 + 1.3.2 abstract-factory @@ -320,6 +320,11 @@ jaxb-impl ${jaxb-impl.version} + + org.javassist + javassist + 3.25.0-GA + @@ -380,8 +385,8 @@ maven-compiler-plugin ${compiler.version} - 1.8 - 1.8 + 11 + 11 @@ -500,27 +505,4 @@ - - - jdk11-dep-management - - [11,) - - - - - org.javassist - javassist - 3.25.0-GA - - - javax.annotation - javax.annotation-api - 1.3.2 - - - - - - diff --git a/service-layer/pom.xml b/service-layer/pom.xml index 4edd950740a8..057a701341a7 100644 --- a/service-layer/pom.xml +++ b/service-layer/pom.xml @@ -41,6 +41,14 @@ com.h2database h2 + + com.sun.xml.bind + jaxb-impl + + + javax.xml.bind + jaxb-api + org.junit.jupiter junit-jupiter-engine @@ -52,22 +60,5 @@ test - - - jdk11-deps - - [11,) - - - - com.sun.xml.bind - jaxb-impl - - - javax.xml.bind - jaxb-api - - - - + From fcc1c0a27cbf92f07d4a2d9164598c883da74416 Mon Sep 17 00:00:00 2001 From: shumyk Date: Sat, 12 Oct 2019 12:58:48 +0300 Subject: [PATCH 19/30] [mvn] - Remove maven-pmd-plugin from the project (#977) (#979) --- exclude-pmd.properties | 27 --------------------------- pom.xml | 26 -------------------------- 2 files changed, 53 deletions(-) delete mode 100644 exclude-pmd.properties diff --git a/exclude-pmd.properties b/exclude-pmd.properties deleted file mode 100644 index 5a4bb138834e..000000000000 --- a/exclude-pmd.properties +++ /dev/null @@ -1,27 +0,0 @@ -# -# The MIT License -# Copyright (c) 2014-2016 Ilkka Seppälä -# -# 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. -# - -com.iluwatar.servicelayer.common.BaseEntity=UnusedPrivateField -com.iluwatar.doublechecked.locking.App=EmptyStatementNotInLoop,EmptyWhileStmt -com.iluwatar.doublechecked.locking.InventoryTest=EmptyStatementNotInLoop,EmptyWhileStmt -domainapp.dom.modules.simple.QSimpleObject=UnusedFormalParameter \ No newline at end of file diff --git a/pom.xml b/pom.xml index b3756e1c06fb..9b4672fb3b6e 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,6 @@ 1.0.0 2.0.1 2.8.5 - 3.12.0 1.2.17 2.3.1 2.3.2 @@ -445,26 +444,6 @@ - - org.apache.maven.plugins - maven-pmd-plugin - ${pmd.version} - - true - 5 - true - - - - - check - - - exclude-pmd.properties - - - - com.mycila @@ -492,11 +471,6 @@ - - org.apache.maven.plugins - maven-pmd-plugin - ${pmd.version} - org.apache.maven.plugins maven-jxr-plugin From 9ebbc421dd96b84c50808ca8ac4a520042e73b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Sat, 12 Oct 2019 20:05:54 +0300 Subject: [PATCH 20/30] Update license headers --- .sonarcloud.properties | 2 +- abstract-document/pom.xml | 2 +- .../abstractdocument/AbstractDocument.java | 8 ++-- .../com/iluwatar/abstractdocument/App.java | 8 ++-- .../iluwatar/abstractdocument/Document.java | 8 ++-- .../iluwatar/abstractdocument/domain/Car.java | 8 ++-- .../abstractdocument/domain/HasModel.java | 8 ++-- .../abstractdocument/domain/HasParts.java | 8 ++-- .../abstractdocument/domain/HasPrice.java | 8 ++-- .../abstractdocument/domain/HasType.java | 8 ++-- .../abstractdocument/domain/Part.java | 8 ++-- .../domain/enums/Property.java | 2 +- .../AbstractDocumentTest.java | 8 ++-- .../iluwatar/abstractdocument/AppTest.java | 8 ++-- .../iluwatar/abstractdocument/DomainTest.java | 8 ++-- abstract-factory/etc/presentation.html | 2 +- abstract-factory/pom.xml | 2 +- .../com/iluwatar/abstractfactory/App.java | 2 +- .../com/iluwatar/abstractfactory/Army.java | 2 +- .../com/iluwatar/abstractfactory/Castle.java | 2 +- .../com/iluwatar/abstractfactory/ElfArmy.java | 2 +- .../iluwatar/abstractfactory/ElfCastle.java | 2 +- .../com/iluwatar/abstractfactory/ElfKing.java | 2 +- .../abstractfactory/ElfKingdomFactory.java | 2 +- .../com/iluwatar/abstractfactory/King.java | 2 +- .../abstractfactory/KingdomFactory.java | 2 +- .../com/iluwatar/abstractfactory/OrcArmy.java | 2 +- .../iluwatar/abstractfactory/OrcCastle.java | 2 +- .../com/iluwatar/abstractfactory/OrcKing.java | 2 +- .../abstractfactory/OrcKingdomFactory.java | 2 +- .../abstractfactory/AbstractFactoryTest.java | 2 +- .../com/iluwatar/abstractfactory/AppTest.java | 2 +- acyclic-visitor/pom.xml | 2 +- .../acyclicvisitor/AllModemVisitor.java | 2 +- .../java/com/iluwatar/acyclicvisitor/App.java | 2 +- .../ConfigureForDosVisitor.java | 2 +- .../ConfigureForUnixVisitor.java | 2 +- .../com/iluwatar/acyclicvisitor/Hayes.java | 2 +- .../iluwatar/acyclicvisitor/HayesVisitor.java | 2 +- .../com/iluwatar/acyclicvisitor/Modem.java | 2 +- .../iluwatar/acyclicvisitor/ModemVisitor.java | 2 +- .../com/iluwatar/acyclicvisitor/Zoom.java | 2 +- .../iluwatar/acyclicvisitor/ZoomVisitor.java | 2 +- .../com/iluwatar/acyclicvisitor/AppTest.java | 2 +- .../ConfigureForDosVisitorTest.java | 2 +- .../ConfigureForUnixVisitorTest.java | 2 +- .../iluwatar/acyclicvisitor/HayesTest.java | 2 +- .../com/iluwatar/acyclicvisitor/ZoomTest.java | 2 +- adapter/pom.xml | 2 +- .../main/java/com/iluwatar/adapter/App.java | 2 +- .../java/com/iluwatar/adapter/Captain.java | 2 +- .../com/iluwatar/adapter/FishingBoat.java | 2 +- .../iluwatar/adapter/FishingBoatAdapter.java | 2 +- .../java/com/iluwatar/adapter/RowingBoat.java | 2 +- .../iluwatar/adapter/AdapterPatternTest.java | 2 +- .../java/com/iluwatar/adapter/AppTest.java | 2 +- .../aggregator-service/pom.xml | 2 +- .../aggregator/microservices/Aggregator.java | 8 ++-- .../aggregator/microservices/App.java | 8 ++-- .../aggregator/microservices/Product.java | 8 ++-- .../ProductInformationClient.java | 8 ++-- .../ProductInformationClientImpl.java | 8 ++-- .../microservices/ProductInventoryClient.java | 8 ++-- .../ProductInventoryClientImpl.java | 8 ++-- .../src/main/resources/application.properties | 2 +- .../microservices/AggregatorTest.java | 8 ++-- .../information-microservice/pom.xml | 2 +- .../microservice/InformationApplication.java | 8 ++-- .../microservice/InformationController.java | 8 ++-- .../src/main/resources/application.properties | 2 +- .../InformationControllerTest.java | 8 ++-- .../inventory-microservice/pom.xml | 2 +- .../microservice/InventoryApplication.java | 8 ++-- .../microservice/InventoryController.java | 8 ++-- .../src/main/resources/application.properties | 2 +- .../microservice/InventoryControllerTest.java | 8 ++-- aggregator-microservices/pom.xml | 2 +- ambassador/pom.xml | 2 +- .../java/com/iluwatar/ambassador/App.java | 2 +- .../java/com/iluwatar/ambassador/Client.java | 2 +- .../iluwatar/ambassador/RemoteService.java | 2 +- .../ambassador/RemoteServiceInterface.java | 2 +- .../ambassador/ServiceAmbassador.java | 2 +- .../ambassador/util/RandomProvider.java | 2 +- .../java/com/iluwatar/ambassador/AppTest.java | 2 +- .../com/iluwatar/ambassador/ClientTest.java | 2 +- .../ambassador/RemoteServiceTest.java | 2 +- .../ambassador/ServiceAmbassadorTest.java | 2 +- api-gateway/api-gateway-service/pom.xml | 2 +- .../com/iluwatar/api/gateway/ApiGateway.java | 2 +- .../java/com/iluwatar/api/gateway/App.java | 2 +- .../iluwatar/api/gateway/DesktopProduct.java | 2 +- .../com/iluwatar/api/gateway/ImageClient.java | 2 +- .../iluwatar/api/gateway/ImageClientImpl.java | 2 +- .../iluwatar/api/gateway/MobileProduct.java | 2 +- .../com/iluwatar/api/gateway/PriceClient.java | 2 +- .../iluwatar/api/gateway/PriceClientImpl.java | 2 +- .../src/main/resources/application.properties | 2 +- .../iluwatar/api/gateway/ApiGatewayTest.java | 2 +- api-gateway/image-microservice/pom.xml | 2 +- .../image/microservice/ImageApplication.java | 2 +- .../image/microservice/ImageController.java | 2 +- .../src/main/resources/application.properties | 2 +- .../microservice/ImageControllerTest.java | 2 +- api-gateway/pom.xml | 2 +- api-gateway/price-microservice/pom.xml | 2 +- .../price/microservice/PriceApplication.java | 2 +- .../price/microservice/PriceController.java | 2 +- .../src/main/resources/application.properties | 2 +- .../microservice/PriceControllerTest.java | 2 +- async-method-invocation/pom.xml | 2 +- .../iluwatar/async/method/invocation/App.java | 2 +- .../method/invocation/AsyncCallback.java | 2 +- .../method/invocation/AsyncExecutor.java | 2 +- .../async/method/invocation/AsyncResult.java | 2 +- .../invocation/ThreadAsyncExecutor.java | 2 +- .../async/method/invocation/AppTest.java | 2 +- .../invocation/ThreadAsyncExecutorTest.java | 2 +- balking/pom.xml | 2 +- .../main/java/com/iluwatar/balking/App.java | 8 ++-- .../com/iluwatar/balking/DelayProvider.java | 2 +- .../com/iluwatar/balking/WashingMachine.java | 8 ++-- .../iluwatar/balking/WashingMachineState.java | 8 ++-- .../java/com/iluwatar/balking/AppTest.java | 9 ++--- .../iluwatar/balking/WashingMachineTest.java | 8 ++-- bridge/pom.xml | 2 +- .../main/java/com/iluwatar/bridge/App.java | 2 +- .../java/com/iluwatar/bridge/Enchantment.java | 2 +- .../iluwatar/bridge/FlyingEnchantment.java | 2 +- .../main/java/com/iluwatar/bridge/Hammer.java | 2 +- .../bridge/SoulEatingEnchantment.java | 2 +- .../main/java/com/iluwatar/bridge/Sword.java | 2 +- .../main/java/com/iluwatar/bridge/Weapon.java | 2 +- .../java/com/iluwatar/bridge/AppTest.java | 2 +- .../java/com/iluwatar/bridge/HammerTest.java | 2 +- .../java/com/iluwatar/bridge/SwordTest.java | 2 +- .../java/com/iluwatar/bridge/WeaponTest.java | 2 +- builder/pom.xml | 2 +- .../main/java/com/iluwatar/builder/App.java | 2 +- .../main/java/com/iluwatar/builder/Armor.java | 2 +- .../java/com/iluwatar/builder/HairColor.java | 2 +- .../java/com/iluwatar/builder/HairType.java | 2 +- .../main/java/com/iluwatar/builder/Hero.java | 2 +- .../java/com/iluwatar/builder/Profession.java | 2 +- .../java/com/iluwatar/builder/Weapon.java | 2 +- .../java/com/iluwatar/builder/AppTest.java | 2 +- .../java/com/iluwatar/builder/HeroTest.java | 2 +- business-delegate/pom.xml | 2 +- .../com/iluwatar/business/delegate/App.java | 2 +- .../business/delegate/BusinessDelegate.java | 2 +- .../business/delegate/BusinessLookup.java | 2 +- .../business/delegate/BusinessService.java | 2 +- .../iluwatar/business/delegate/Client.java | 2 +- .../business/delegate/EjbService.java | 2 +- .../business/delegate/JmsService.java | 2 +- .../business/delegate/ServiceType.java | 2 +- .../iluwatar/business/delegate/AppTest.java | 2 +- .../delegate/BusinessDelegateTest.java | 2 +- bytecode/pom.xml | 2 +- .../main/java/com/iluwatar/bytecode/App.java | 2 +- .../com/iluwatar/bytecode/Instruction.java | 2 +- .../com/iluwatar/bytecode/VirtualMachine.java | 2 +- .../java/com/iluwatar/bytecode/Wizard.java | 2 +- .../util/InstructionConverterUtil.java | 2 +- .../java/com/iluwatar/bytecode/AppTest.java | 2 +- .../iluwatar/bytecode/VirtualMachineTest.java | 2 +- .../util/InstructionConverterUtilTest.java | 2 +- caching/pom.xml | 2 +- .../main/java/com/iluwatar/caching/App.java | 2 +- .../java/com/iluwatar/caching/AppManager.java | 2 +- .../java/com/iluwatar/caching/CacheStore.java | 2 +- .../com/iluwatar/caching/CachingPolicy.java | 2 +- .../java/com/iluwatar/caching/DbManager.java | 2 +- .../java/com/iluwatar/caching/LruCache.java | 2 +- .../com/iluwatar/caching/UserAccount.java | 2 +- .../caching/constants/CachingConstants.java | 2 +- .../java/com/iluwatar/caching/AppTest.java | 2 +- .../com/iluwatar/caching/CachingTest.java | 2 +- callback/pom.xml | 2 +- .../main/java/com/iluwatar/callback/App.java | 2 +- .../java/com/iluwatar/callback/Callback.java | 2 +- .../com/iluwatar/callback/LambdasApp.java | 2 +- .../com/iluwatar/callback/SimpleTask.java | 2 +- .../main/java/com/iluwatar/callback/Task.java | 2 +- .../java/com/iluwatar/callback/AppTest.java | 2 +- .../com/iluwatar/callback/CallbackTest.java | 2 +- chain/pom.xml | 2 +- .../src/main/java/com/iluwatar/chain/App.java | 2 +- .../java/com/iluwatar/chain/OrcCommander.java | 2 +- .../main/java/com/iluwatar/chain/OrcKing.java | 2 +- .../java/com/iluwatar/chain/OrcOfficer.java | 2 +- .../java/com/iluwatar/chain/OrcSoldier.java | 2 +- .../main/java/com/iluwatar/chain/Request.java | 2 +- .../com/iluwatar/chain/RequestHandler.java | 2 +- .../java/com/iluwatar/chain/RequestType.java | 2 +- .../test/java/com/iluwatar/chain/AppTest.java | 2 +- .../java/com/iluwatar/chain/OrcKingTest.java | 2 +- checkstyle-suppressions.xml | 2 +- checkstyle.xml | 2 +- collection-pipeline/pom.xml | 2 +- .../com/iluwatar/collectionpipeline/App.java | 2 +- .../com/iluwatar/collectionpipeline/Car.java | 2 +- .../collectionpipeline/CarFactory.java | 2 +- .../iluwatar/collectionpipeline/Category.java | 2 +- .../FunctionalProgramming.java | 2 +- .../ImperativeProgramming.java | 2 +- .../iluwatar/collectionpipeline/Person.java | 2 +- .../iluwatar/collectionpipeline/AppTest.java | 2 +- command/etc/presentation.html | 2 +- command/pom.xml | 2 +- .../main/java/com/iluwatar/command/App.java | 2 +- .../java/com/iluwatar/command/Command.java | 2 +- .../java/com/iluwatar/command/Goblin.java | 2 +- .../iluwatar/command/InvisibilitySpell.java | 2 +- .../com/iluwatar/command/ShrinkSpell.java | 2 +- .../main/java/com/iluwatar/command/Size.java | 2 +- .../java/com/iluwatar/command/Target.java | 2 +- .../java/com/iluwatar/command/Visibility.java | 2 +- .../java/com/iluwatar/command/Wizard.java | 2 +- .../java/com/iluwatar/command/AppTest.java | 2 +- .../com/iluwatar/command/CommandTest.java | 2 +- commander/pom.xml | 2 +- commander/properties/log4j.properties | 2 +- .../commander/AppEmployeeDbFailCases.java | 3 +- .../commander/AppMessagingFailCases.java | 3 +- .../commander/AppPaymentFailCases.java | 3 +- .../iluwatar/commander/AppQueueFailCases.java | 3 +- .../commander/AppShippingFailCases.java | 3 +- .../com/iluwatar/commander/Commander.java | 3 +- .../java/com/iluwatar/commander/Database.java | 3 +- .../java/com/iluwatar/commander/Order.java | 3 +- .../java/com/iluwatar/commander/Retry.java | 3 +- .../java/com/iluwatar/commander/Service.java | 3 +- .../java/com/iluwatar/commander/User.java | 3 +- .../employeehandle/EmployeeDatabase.java | 3 +- .../employeehandle/EmployeeHandle.java | 3 +- .../DatabaseUnavailableException.java | 3 +- .../exceptions/IsEmptyException.java | 3 +- .../exceptions/ItemUnavailableException.java | 3 +- .../PaymentDetailsErrorException.java | 3 +- .../ShippingNotPossibleException.java | 3 +- .../messagingservice/MessagingDatabase.java | 3 +- .../messagingservice/MessagingService.java | 3 +- .../paymentservice/PaymentDatabase.java | 3 +- .../paymentservice/PaymentService.java | 3 +- .../com/iluwatar/commander/queue/Queue.java | 3 +- .../commander/queue/QueueDatabase.java | 3 +- .../iluwatar/commander/queue/QueueTask.java | 3 +- .../shippingservice/ShippingDatabase.java | 3 +- .../shippingservice/ShippingService.java | 3 +- .../com/iluwatar/commander/RetryTest.java | 3 +- composite/pom.xml | 2 +- .../main/java/com/iluwatar/composite/App.java | 2 +- .../java/com/iluwatar/composite/Letter.java | 2 +- .../iluwatar/composite/LetterComposite.java | 2 +- .../com/iluwatar/composite/Messenger.java | 2 +- .../java/com/iluwatar/composite/Sentence.java | 2 +- .../java/com/iluwatar/composite/Word.java | 2 +- .../java/com/iluwatar/composite/AppTest.java | 2 +- .../com/iluwatar/composite/MessengerTest.java | 2 +- converter/pom.xml | 2 +- .../main/java/com/iluwatar/converter/App.java | 8 ++-- .../com/iluwatar/converter/Converter.java | 9 ++--- .../java/com/iluwatar/converter/User.java | 9 ++--- .../com/iluwatar/converter/UserConverter.java | 9 ++--- .../java/com/iluwatar/converter/UserDto.java | 9 ++--- .../java/com/iluwatar/converter/AppTest.java | 2 +- .../com/iluwatar/converter/ConverterTest.java | 2 +- cqrs/pom.xml | 39 ++++++++++++------- .../main/java/com/iluwatar/cqrs/app/App.java | 2 +- .../cqrs/commandes/CommandServiceImpl.java | 2 +- .../cqrs/commandes/ICommandService.java | 2 +- .../iluwatar/cqrs/constants/AppConstants.java | 2 +- .../iluwatar/cqrs/domain/model/Author.java | 2 +- .../com/iluwatar/cqrs/domain/model/Book.java | 2 +- .../java/com/iluwatar/cqrs/dto/Author.java | 2 +- .../main/java/com/iluwatar/cqrs/dto/Book.java | 2 +- .../iluwatar/cqrs/queries/IQueryService.java | 2 +- .../cqrs/queries/QueryServiceImpl.java | 2 +- .../com/iluwatar/cqrs/util/HibernateUtil.java | 2 +- cqrs/src/main/resources/hibernate.cfg.xml | 2 +- cqrs/src/main/resources/logback.xml | 2 +- .../com/iluwatar/cqrs/IntegrationTest.java | 2 +- cqrs/src/test/resources/hibernate.cfg.xml | 2 +- cqrs/src/test/resources/logback.xml | 2 +- dao/pom.xml | 2 +- dao/src/main/java/com/iluwatar/dao/App.java | 3 +- .../com/iluwatar/dao/CustomException.java | 2 +- .../main/java/com/iluwatar/dao/Customer.java | 3 +- .../java/com/iluwatar/dao/CustomerDao.java | 3 +- .../com/iluwatar/dao/CustomerSchemaSql.java | 2 +- .../java/com/iluwatar/dao/DbCustomerDao.java | 3 +- .../com/iluwatar/dao/InMemoryCustomerDao.java | 3 +- dao/src/main/resources/log4j.xml | 2 +- .../test/java/com/iluwatar/dao/AppTest.java | 3 +- .../java/com/iluwatar/dao/CustomerTest.java | 3 +- .../com/iluwatar/dao/DbCustomerDaoTest.java | 2 +- .../iluwatar/dao/InMemoryCustomerDaoTest.java | 3 +- data-bus/pom.xml | 2 +- .../iluwatar/databus/AbstractDataType.java | 2 +- .../main/java/com/iluwatar/databus/App.java | 9 ++--- .../java/com/iluwatar/databus/DataBus.java | 9 ++--- .../java/com/iluwatar/databus/DataType.java | 2 +- .../java/com/iluwatar/databus/Member.java | 2 +- .../iluwatar/databus/data/MessageData.java | 9 ++--- .../iluwatar/databus/data/StartingData.java | 9 ++--- .../iluwatar/databus/data/StoppingData.java | 9 ++--- .../members/MessageCollectorMember.java | 9 ++--- .../databus/members/StatusMember.java | 9 ++--- .../com/iluwatar/databus/DataBusTest.java | 2 +- .../members/MessageCollectorMemberTest.java | 2 +- .../databus/members/StatusMemberTest.java | 2 +- data-locality/pom.xml | 2 +- .../iluwatar/data/locality/Application.java | 2 +- .../data/locality/game/GameEntity.java | 2 +- .../locality/game/component/AiComponent.java | 2 +- .../locality/game/component/Component.java | 2 +- .../game/component/PhysicsComponent.java | 2 +- .../game/component/RenderComponent.java | 2 +- .../component/manager/AiComponentManager.java | 2 +- .../manager/PhysicsComponentManager.java | 2 +- .../manager/RenderComponentManager.java | 2 +- .../data/locality/ApplicationTest.java | 8 ++-- data-mapper/pom.xml | 2 +- .../java/com/iluwatar/datamapper/App.java | 28 +++++++------ .../datamapper/DataMapperException.java | 28 +++++++------ .../java/com/iluwatar/datamapper/Student.java | 28 +++++++------ .../datamapper/StudentDataMapper.java | 28 +++++++------ .../datamapper/StudentDataMapperImpl.java | 28 +++++++------ data-mapper/src/main/resources/log4j.xml | 2 +- .../java/com/iluwatar/datamapper/AppTest.java | 28 +++++++------ .../iluwatar/datamapper/DataMapperTest.java | 28 +++++++------ .../com/iluwatar/datamapper/StudentTest.java | 28 +++++++------ data-transfer-object/pom.xml | 2 +- .../datatransfer/CustomerClientApp.java | 16 ++++---- .../iluwatar/datatransfer/CustomerDto.java | 16 ++++---- .../datatransfer/CustomerResource.java | 16 ++++---- .../datatransfer/CustomerResourceTest.java | 16 ++++---- decorator/pom.xml | 2 +- .../main/java/com/iluwatar/decorator/App.java | 2 +- .../com/iluwatar/decorator/ClubbedTroll.java | 2 +- .../com/iluwatar/decorator/SimpleTroll.java | 2 +- .../java/com/iluwatar/decorator/Troll.java | 2 +- .../java/com/iluwatar/decorator/AppTest.java | 2 +- .../iluwatar/decorator/ClubbedTrollTest.java | 2 +- .../iluwatar/decorator/SimpleTrollTest.java | 2 +- delegation/pom.xml | 3 +- .../com/iluwatar/delegation/simple/App.java | 2 +- .../iluwatar/delegation/simple/Printer.java | 2 +- .../delegation/simple/PrinterController.java | 2 +- .../simple/printers/CanonPrinter.java | 2 +- .../simple/printers/EpsonPrinter.java | 2 +- .../delegation/simple/printers/HpPrinter.java | 2 +- .../iluwatar/delegation/simple/AppTest.java | 2 +- .../delegation/simple/DelegateTest.java | 2 +- dependency-injection/pom.xml | 2 +- .../injection/AdvancedSorceress.java | 2 +- .../dependency/injection/AdvancedWizard.java | 2 +- .../iluwatar/dependency/injection/App.java | 8 ++-- .../dependency/injection/GuiceWizard.java | 2 +- .../dependency/injection/OldTobyTobacco.java | 2 +- .../injection/RivendellTobacco.java | 2 +- .../injection/SecondBreakfastTobacco.java | 2 +- .../dependency/injection/SimpleWizard.java | 2 +- .../dependency/injection/Tobacco.java | 2 +- .../dependency/injection/TobaccoModule.java | 2 +- .../iluwatar/dependency/injection/Wizard.java | 2 +- .../injection/AdvancedSorceressTest.java | 8 ++-- .../injection/AdvancedWizardTest.java | 2 +- .../dependency/injection/AppTest.java | 2 +- .../dependency/injection/GuiceWizardTest.java | 2 +- .../injection/SimpleWizardTest.java | 2 +- .../injection/utils/InMemoryAppender.java | 2 +- dirty-flag/pom.xml | 2 +- .../main/java/com/iluwatar/dirtyflag/App.java | 8 ++-- .../com/iluwatar/dirtyflag/DataFetcher.java | 2 +- .../java/com/iluwatar/dirtyflag/World.java | 2 +- dirty-flag/src/main/resources/world.txt | 2 +- .../src/test/java/org/dirty/flag/AppTest.java | 2 +- .../java/org/dirty/flag/DirtyFlagTest.java | 2 +- double-checked-locking/pom.xml | 2 +- .../iluwatar/doublechecked/locking/App.java | 2 +- .../doublechecked/locking/Inventory.java | 2 +- .../iluwatar/doublechecked/locking/Item.java | 2 +- .../src/main/resources/logback.xml | 2 +- .../doublechecked/locking/AppTest.java | 2 +- .../doublechecked/locking/InventoryTest.java | 2 +- double-dispatch/pom.xml | 2 +- .../java/com/iluwatar/doubledispatch/App.java | 2 +- .../doubledispatch/FlamingAsteroid.java | 2 +- .../iluwatar/doubledispatch/GameObject.java | 2 +- .../iluwatar/doubledispatch/Meteoroid.java | 2 +- .../iluwatar/doubledispatch/Rectangle.java | 2 +- .../doubledispatch/SpaceStationIss.java | 2 +- .../doubledispatch/SpaceStationMir.java | 2 +- .../constants/AppConstants.java | 2 +- .../com/iluwatar/doubledispatch/AppTest.java | 2 +- .../doubledispatch/CollisionTest.java | 2 +- .../doubledispatch/FlamingAsteroidTest.java | 2 +- .../doubledispatch/MeteoroidTest.java | 2 +- .../doubledispatch/RectangleTest.java | 2 +- .../doubledispatch/SpaceStationIssTest.java | 2 +- .../doubledispatch/SpaceStationMirTest.java | 2 +- eip-aggregator/pom.xml | 7 +++- .../java/com/iluwatar/eip/aggregator/App.java | 2 +- .../aggregator/routes/AggregatorRoute.java | 2 +- .../routes/MessageAggregationStrategy.java | 2 +- .../src/main/resources/application.properties | 2 +- .../com/iluwatar/eip/aggregator/AppTest.java | 2 +- .../routes/AggregatorRouteTest.java | 2 +- .../MessageAggregationStrategyTest.java | 2 +- .../resources/application-test.properties | 2 +- eip-message-channel/pom.xml | 2 +- .../com/iluwatar/eip/message/channel/App.java | 2 +- .../iluwatar/eip/message/channel/AppTest.java | 2 +- eip-publish-subscribe/pom.xml | 2 +- .../iluwatar/eip/publish/subscribe/App.java | 2 +- .../src/main/resources/logback.xml | 2 +- .../eip/publish/subscribe/AppTest.java | 2 +- eip-splitter/pom.xml | 7 +++- .../java/com/iluwatar/eip/splitter/App.java | 2 +- .../eip/splitter/routes/SplitterRoute.java | 2 +- .../src/main/resources/application.properties | 2 +- .../com/iluwatar/eip/splitter/AppTest.java | 2 +- .../splitter/routes/SplitterRouteTest.java | 2 +- .../resources/application-test.properties | 2 +- eip-wire-tap/pom.xml | 7 +++- .../java/com/iluwatar/eip/wiretap/App.java | 2 +- .../eip/wiretap/routes/WireTapRoute.java | 2 +- .../src/main/resources/application.properties | 2 +- .../com/iluwatar/eip/wiretap/AppTest.java | 2 +- .../eip/wiretap/routes/WireTapRouteTest.java | 2 +- .../resources/application-test.properties | 2 +- event-aggregator/pom.xml | 2 +- .../com/iluwatar/event/aggregator/App.java | 2 +- .../com/iluwatar/event/aggregator/Event.java | 2 +- .../event/aggregator/EventEmitter.java | 2 +- .../event/aggregator/EventObserver.java | 2 +- .../event/aggregator/KingJoffrey.java | 2 +- .../iluwatar/event/aggregator/KingsHand.java | 2 +- .../event/aggregator/LordBaelish.java | 2 +- .../iluwatar/event/aggregator/LordVarys.java | 2 +- .../com/iluwatar/event/aggregator/Scout.java | 2 +- .../iluwatar/event/aggregator/Weekday.java | 2 +- .../iluwatar/event/aggregator/AppTest.java | 2 +- .../event/aggregator/EventEmitterTest.java | 2 +- .../iluwatar/event/aggregator/EventTest.java | 2 +- .../event/aggregator/KingJoffreyTest.java | 2 +- .../event/aggregator/KingsHandTest.java | 2 +- .../event/aggregator/LordBaelishTest.java | 2 +- .../event/aggregator/LordVarysTest.java | 2 +- .../iluwatar/event/aggregator/ScoutTest.java | 2 +- .../event/aggregator/WeekdayTest.java | 2 +- event-asynchronous/pom.xml | 2 +- .../com/iluwatar/event/asynchronous/App.java | 28 +++++++------ .../iluwatar/event/asynchronous/Event.java | 28 +++++++------ .../EventDoesNotExistException.java | 28 +++++++------ .../event/asynchronous/EventManager.java | 28 +++++++------ .../iluwatar/event/asynchronous/IEvent.java | 28 +++++++------ .../InvalidOperationException.java | 28 +++++++------ .../LongRunningEventException.java | 28 +++++++------ .../MaxNumOfEventsAllowedException.java | 28 +++++++------ .../asynchronous/ThreadCompleteListener.java | 28 +++++++------ .../src/main/resources/config.properties | 2 +- .../iluwatar/event/asynchronous/AppTest.java | 28 +++++++------ .../asynchronous/EventAsynchronousTest.java | 28 +++++++------ event-driven-architecture/pom.xml | 2 +- .../src/main/java/com/iluwatar/eda/App.java | 2 +- .../com/iluwatar/eda/event/AbstractEvent.java | 2 +- .../iluwatar/eda/event/UserCreatedEvent.java | 2 +- .../iluwatar/eda/event/UserUpdatedEvent.java | 2 +- .../com/iluwatar/eda/framework/Event.java | 2 +- .../eda/framework/EventDispatcher.java | 2 +- .../com/iluwatar/eda/framework/Handler.java | 2 +- .../eda/handler/UserCreatedEventHandler.java | 2 +- .../eda/handler/UserUpdatedEventHandler.java | 2 +- .../java/com/iluwatar/eda/model/User.java | 2 +- .../test/java/com/iluwatar/eda/AppTest.java | 2 +- .../eda/event/UserCreatedEventTest.java | 2 +- .../eda/framework/EventDispatcherTest.java | 2 +- event-queue/pom.xml | 2 +- .../java/com/iluwatar/event/queue/App.java | 3 +- .../java/com/iluwatar/event/queue/Audio.java | 3 +- .../com/iluwatar/event/queue/PlayMessage.java | 3 +- .../com/iluwatar/event/queue/AudioTest.java | 3 +- event-sourcing/pom.xml | 2 +- .../com/iluwatar/event/sourcing/app/App.java | 2 +- .../event/sourcing/domain/Account.java | 2 +- .../sourcing/event/AccountCreateEvent.java | 2 +- .../event/sourcing/event/DomainEvent.java | 2 +- .../sourcing/event/MoneyDepositEvent.java | 2 +- .../sourcing/event/MoneyTransferEvent.java | 2 +- .../processor/DomainEventProcessor.java | 2 +- .../sourcing/processor/JsonFileJournal.java | 2 +- .../sourcing/state/AccountAggregate.java | 2 +- .../src/test/java/IntegrationTest.java | 3 +- execute-around/pom.xml | 2 +- .../java/com/iluwatar/execute/around/App.java | 2 +- .../execute/around/FileWriterAction.java | 2 +- .../execute/around/SimpleFileWriter.java | 2 +- .../com/iluwatar/execute/around/AppTest.java | 2 +- .../execute/around/SimpleFileWriterTest.java | 2 +- extension-objects/pom.xml | 2 +- extension-objects/src/main/java/App.java | 2 +- .../CommanderExtension.java | 2 +- .../abstractextensions/SergeantExtension.java | 2 +- .../abstractextensions/SoldierExtension.java | 2 +- .../abstractextensions/UnitExtension.java | 2 +- .../java/concreteextensions/Commander.java | 2 +- .../java/concreteextensions/Sergeant.java | 2 +- .../main/java/concreteextensions/Soldier.java | 2 +- .../src/main/java/units/CommanderUnit.java | 2 +- .../src/main/java/units/SergeantUnit.java | 2 +- .../src/main/java/units/SoldierUnit.java | 2 +- .../src/main/java/units/Unit.java | 2 +- extension-objects/src/test/java/AppTest.java | 3 +- .../concreteextensions/CommanderTest.java | 2 +- .../java/concreteextensions/SergeantTest.java | 2 +- .../java/concreteextensions/SoldierTest.java | 2 +- .../test/java/units/CommanderUnitTest.java | 2 +- .../src/test/java/units/SergeantUnitTest.java | 2 +- .../src/test/java/units/SoldierUnitTest.java | 2 +- .../src/test/java/units/UnitTest.java | 2 +- facade/pom.xml | 2 +- .../main/java/com/iluwatar/facade/App.java | 2 +- .../iluwatar/facade/DwarvenCartOperator.java | 2 +- .../iluwatar/facade/DwarvenGoldDigger.java | 2 +- .../facade/DwarvenGoldmineFacade.java | 2 +- .../iluwatar/facade/DwarvenMineWorker.java | 2 +- .../iluwatar/facade/DwarvenTunnelDigger.java | 2 +- .../java/com/iluwatar/facade/AppTest.java | 2 +- .../facade/DwarvenGoldmineFacadeTest.java | 2 +- factory-kit/pom.xml | 2 +- .../java/com/iluwatar/factorykit/App.java | 2 +- .../java/com/iluwatar/factorykit/Axe.java | 2 +- .../java/com/iluwatar/factorykit/Bow.java | 2 +- .../java/com/iluwatar/factorykit/Builder.java | 2 +- .../java/com/iluwatar/factorykit/Spear.java | 2 +- .../java/com/iluwatar/factorykit/Sword.java | 2 +- .../java/com/iluwatar/factorykit/Weapon.java | 2 +- .../iluwatar/factorykit/WeaponFactory.java | 2 +- .../com/iluwatar/factorykit/WeaponType.java | 2 +- .../com/iluwatar/factorykit/app/AppTest.java | 2 +- .../factorykit/factorykit/FactoryKitTest.java | 4 +- factory-method/etc/presentation.html | 2 +- factory-method/pom.xml | 2 +- .../java/com/iluwatar/factory/method/App.java | 2 +- .../iluwatar/factory/method/Blacksmith.java | 2 +- .../factory/method/ElfBlacksmith.java | 2 +- .../iluwatar/factory/method/ElfWeapon.java | 2 +- .../factory/method/OrcBlacksmith.java | 2 +- .../iluwatar/factory/method/OrcWeapon.java | 2 +- .../com/iluwatar/factory/method/Weapon.java | 2 +- .../iluwatar/factory/method/WeaponType.java | 2 +- .../com/iluwatar/factory/method/AppTest.java | 2 +- .../factory/method/FactoryMethodTest.java | 2 +- feature-toggle/pom.xml | 3 +- .../java/com/iluwatar/featuretoggle/App.java | 9 ++--- .../featuretoggle/pattern/Service.java | 8 ++-- .../PropertiesFeatureToggleVersion.java | 8 ++-- .../TieredFeatureToggleVersion.java | 8 ++-- .../com/iluwatar/featuretoggle/user/User.java | 8 ++-- .../featuretoggle/user/UserGroup.java | 8 ++-- .../PropertiesFeatureToggleVersionTest.java | 9 ++--- .../TieredFeatureToggleVersionTest.java | 8 ++-- .../featuretoggle/user/UserGroupTest.java | 8 ++-- fluentinterface/pom.xml | 2 +- .../com/iluwatar/fluentinterface/app/App.java | 2 +- .../fluentiterable/FluentIterable.java | 2 +- .../lazy/DecoratingIterator.java | 2 +- .../lazy/LazyFluentIterable.java | 2 +- .../simple/SimpleFluentIterable.java | 2 +- .../iluwatar/fluentinterface/app/AppTest.java | 2 +- .../fluentiterable/FluentIterableTest.java | 2 +- .../lazy/LazyFluentIterableTest.java | 2 +- .../simple/SimpleFluentIterableTest.java | 2 +- flux/pom.xml | 2 +- .../java/com/iluwatar/flux/action/Action.java | 2 +- .../com/iluwatar/flux/action/ActionType.java | 2 +- .../com/iluwatar/flux/action/Content.java | 2 +- .../iluwatar/flux/action/ContentAction.java | 2 +- .../com/iluwatar/flux/action/MenuAction.java | 2 +- .../com/iluwatar/flux/action/MenuItem.java | 2 +- .../main/java/com/iluwatar/flux/app/App.java | 2 +- .../iluwatar/flux/dispatcher/Dispatcher.java | 2 +- .../com/iluwatar/flux/store/ContentStore.java | 2 +- .../com/iluwatar/flux/store/MenuStore.java | 2 +- .../java/com/iluwatar/flux/store/Store.java | 2 +- .../com/iluwatar/flux/view/ContentView.java | 2 +- .../java/com/iluwatar/flux/view/MenuView.java | 2 +- .../java/com/iluwatar/flux/view/View.java | 2 +- .../com/iluwatar/flux/action/ContentTest.java | 2 +- .../iluwatar/flux/action/MenuItemTest.java | 2 +- .../java/com/iluwatar/flux/app/AppTest.java | 2 +- .../flux/dispatcher/DispatcherTest.java | 2 +- .../iluwatar/flux/store/ContentStoreTest.java | 2 +- .../iluwatar/flux/store/MenuStoreTest.java | 2 +- .../iluwatar/flux/view/ContentViewTest.java | 2 +- .../com/iluwatar/flux/view/MenuViewTest.java | 2 +- flyweight/pom.xml | 2 +- .../com/iluwatar/flyweight/AlchemistShop.java | 2 +- .../main/java/com/iluwatar/flyweight/App.java | 2 +- .../com/iluwatar/flyweight/HealingPotion.java | 2 +- .../iluwatar/flyweight/HolyWaterPotion.java | 2 +- .../flyweight/InvisibilityPotion.java | 2 +- .../com/iluwatar/flyweight/PoisonPotion.java | 2 +- .../java/com/iluwatar/flyweight/Potion.java | 2 +- .../com/iluwatar/flyweight/PotionFactory.java | 2 +- .../com/iluwatar/flyweight/PotionType.java | 2 +- .../iluwatar/flyweight/StrengthPotion.java | 2 +- .../iluwatar/flyweight/AlchemistShopTest.java | 2 +- .../java/com/iluwatar/flyweight/AppTest.java | 2 +- front-controller/pom.xml | 2 +- .../com/iluwatar/front/controller/App.java | 2 +- .../controller/ApplicationException.java | 2 +- .../front/controller/ArcherCommand.java | 2 +- .../iluwatar/front/controller/ArcherView.java | 2 +- .../front/controller/CatapultCommand.java | 2 +- .../front/controller/CatapultView.java | 2 +- .../iluwatar/front/controller/Command.java | 2 +- .../iluwatar/front/controller/ErrorView.java | 2 +- .../front/controller/FrontController.java | 2 +- .../front/controller/UnknownCommand.java | 2 +- .../com/iluwatar/front/controller/View.java | 2 +- .../iluwatar/front/controller/AppTest.java | 2 +- .../controller/ApplicationExceptionTest.java | 2 +- .../front/controller/CommandTest.java | 2 +- .../front/controller/FrontControllerTest.java | 2 +- .../iluwatar/front/controller/ViewTest.java | 2 +- .../controller/utils/InMemoryAppender.java | 2 +- guarded-suspension/pom.xml | 2 +- .../com/iluwatar/guarded/suspension/App.java | 2 +- .../guarded/suspension/GuardedQueue.java | 8 ++-- .../guarded/suspension/GuardedQueueTest.java | 8 ++-- half-sync-half-async/pom.xml | 2 +- .../com/iluwatar/halfsynchalfasync/App.java | 2 +- .../iluwatar/halfsynchalfasync/AsyncTask.java | 2 +- .../AsynchronousService.java | 2 +- .../iluwatar/halfsynchalfasync/AppTest.java | 2 +- .../AsynchronousServiceTest.java | 2 +- hexagonal/etc/ports_and_adapters.xml | 2 +- hexagonal/etc/presentation.html | 2 +- hexagonal/pom.xml | 2 +- .../main/java/com/iluwatar/hexagonal/App.java | 2 +- .../administration/ConsoleAdministration.java | 2 +- .../ConsoleAdministrationSrv.java | 2 +- .../ConsoleAdministrationSrvImpl.java | 2 +- .../hexagonal/banking/InMemoryBank.java | 2 +- .../iluwatar/hexagonal/banking/MongoBank.java | 2 +- .../hexagonal/banking/WireTransfers.java | 2 +- .../database/InMemoryTicketRepository.java | 2 +- .../database/LotteryTicketRepository.java | 2 +- .../database/MongoTicketRepository.java | 2 +- .../domain/LotteryAdministration.java | 2 +- .../hexagonal/domain/LotteryConstants.java | 2 +- .../hexagonal/domain/LotteryNumbers.java | 2 +- .../hexagonal/domain/LotteryService.java | 2 +- .../hexagonal/domain/LotteryTicket.java | 2 +- .../domain/LotteryTicketCheckResult.java | 2 +- .../hexagonal/domain/LotteryTicketId.java | 2 +- .../hexagonal/domain/LotteryUtils.java | 2 +- .../hexagonal/domain/PlayerDetails.java | 2 +- .../hexagonal/eventlog/LotteryEventLog.java | 2 +- .../hexagonal/eventlog/MongoEventLog.java | 2 +- .../hexagonal/eventlog/StdOutEventLog.java | 2 +- .../hexagonal/module/LotteryModule.java | 2 +- .../module/LotteryTestingModule.java | 2 +- .../MongoConnectionPropertiesLoader.java | 2 +- .../hexagonal/sampledata/SampleData.java | 2 +- .../hexagonal/service/ConsoleLottery.java | 2 +- .../service/LotteryConsoleService.java | 2 +- .../service/LotteryConsoleServiceImpl.java | 2 +- .../java/com/iluwatar/hexagonal/AppTest.java | 2 +- .../hexagonal/banking/InMemoryBankTest.java | 2 +- .../hexagonal/banking/MongoBankTest.java | 2 +- .../InMemoryTicketRepositoryTest.java | 2 +- .../database/MongoTicketRepositoryTest.java | 2 +- .../hexagonal/domain/LotteryNumbersTest.java | 2 +- .../hexagonal/domain/LotteryTest.java | 2 +- .../domain/LotteryTicketCheckResultTest.java | 2 +- .../hexagonal/domain/LotteryTicketIdTest.java | 2 +- .../hexagonal/domain/LotteryTicketTest.java | 2 +- .../hexagonal/domain/PlayerDetailsTest.java | 2 +- .../hexagonal/eventlog/MongoEventLogTest.java | 2 +- .../hexagonal/test/LotteryTestUtils.java | 2 +- intercepting-filter/pom.xml | 2 +- .../intercepting/filter/AbstractFilter.java | 2 +- .../intercepting/filter/AddressFilter.java | 2 +- .../com/iluwatar/intercepting/filter/App.java | 2 +- .../iluwatar/intercepting/filter/Client.java | 2 +- .../intercepting/filter/ContactFilter.java | 2 +- .../intercepting/filter/DepositFilter.java | 2 +- .../iluwatar/intercepting/filter/Filter.java | 2 +- .../intercepting/filter/FilterChain.java | 2 +- .../intercepting/filter/FilterManager.java | 2 +- .../intercepting/filter/NameFilter.java | 2 +- .../iluwatar/intercepting/filter/Order.java | 2 +- .../intercepting/filter/OrderFilter.java | 2 +- .../iluwatar/intercepting/filter/Target.java | 2 +- .../iluwatar/intercepting/filter/AppTest.java | 2 +- .../filter/FilterManagerTest.java | 2 +- .../intercepting/filter/FilterTest.java | 2 +- .../intercepting/filter/OrderTest.java | 2 +- interpreter/pom.xml | 2 +- .../java/com/iluwatar/interpreter/App.java | 2 +- .../com/iluwatar/interpreter/Expression.java | 2 +- .../iluwatar/interpreter/MinusExpression.java | 2 +- .../interpreter/MultiplyExpression.java | 2 +- .../interpreter/NumberExpression.java | 2 +- .../iluwatar/interpreter/PlusExpression.java | 2 +- .../com/iluwatar/interpreter/AppTest.java | 2 +- .../iluwatar/interpreter/ExpressionTest.java | 2 +- .../interpreter/MinusExpressionTest.java | 2 +- .../interpreter/MultiplyExpressionTest.java | 2 +- .../interpreter/NumberExpressionTest.java | 2 +- .../interpreter/PlusExpressionTest.java | 2 +- iterator/pom.xml | 2 +- .../main/java/com/iluwatar/iterator/App.java | 28 +++++++------ .../java/com/iluwatar/iterator/Iterator.java | 28 +++++++------ .../iluwatar/iterator/bst/BstIterator.java | 28 +++++++------ .../com/iluwatar/iterator/bst/TreeNode.java | 28 +++++++------ .../java/com/iluwatar/iterator/list/Item.java | 2 +- .../com/iluwatar/iterator/list/ItemType.java | 2 +- .../iluwatar/iterator/list/TreasureChest.java | 28 +++++++------ .../list/TreasureChestItemIterator.java | 28 +++++++------ .../java/com/iluwatar/iterator/AppTest.java | 35 +++++++++-------- .../iterator/bst/BstIteratorTest.java | 28 +++++++------ .../iterator/list/TreasureChestTest.java | 28 +++++++------ layers/pom.xml | 2 +- .../main/java/com/iluwatar/layers/App.java | 2 +- .../main/java/com/iluwatar/layers/Cake.java | 2 +- .../iluwatar/layers/CakeBakingException.java | 2 +- .../iluwatar/layers/CakeBakingService.java | 2 +- .../layers/CakeBakingServiceImpl.java | 2 +- .../java/com/iluwatar/layers/CakeDao.java | 2 +- .../java/com/iluwatar/layers/CakeInfo.java | 2 +- .../java/com/iluwatar/layers/CakeLayer.java | 2 +- .../com/iluwatar/layers/CakeLayerDao.java | 2 +- .../com/iluwatar/layers/CakeLayerInfo.java | 2 +- .../java/com/iluwatar/layers/CakeTopping.java | 2 +- .../com/iluwatar/layers/CakeToppingDao.java | 2 +- .../com/iluwatar/layers/CakeToppingInfo.java | 2 +- .../com/iluwatar/layers/CakeViewImpl.java | 2 +- .../main/java/com/iluwatar/layers/View.java | 2 +- .../main/resources/META-INF/persistence.xml | 2 +- .../src/main/resources/applicationContext.xml | 2 +- layers/src/main/resources/logback.xml | 2 +- .../java/com/iluwatar/layers/AppTest.java | 2 +- .../layers/CakeBakingExceptionTest.java | 2 +- .../layers/CakeBakingServiceImplTest.java | 2 +- .../java/com/iluwatar/layers/CakeTest.java | 2 +- .../com/iluwatar/layers/CakeViewImplTest.java | 2 +- lazy-loading/pom.xml | 2 +- .../java/com/iluwatar/lazy/loading/App.java | 2 +- .../java/com/iluwatar/lazy/loading/Heavy.java | 2 +- .../iluwatar/lazy/loading/HolderNaive.java | 2 +- .../lazy/loading/HolderThreadSafe.java | 2 +- .../iluwatar/lazy/loading/Java8Holder.java | 2 +- .../lazy/loading/AbstractHolderTest.java | 2 +- .../com/iluwatar/lazy/loading/AppTest.java | 2 +- .../lazy/loading/HolderNaiveTest.java | 2 +- .../lazy/loading/HolderThreadSafeTest.java | 2 +- .../lazy/loading/Java8HolderTest.java | 2 +- leader-election/pom.xml | 4 +- .../leaderelection/AbstractInstance.java | 9 ++--- .../AbstractMessageManager.java | 9 ++--- .../com/iluwatar/leaderelection/Instance.java | 3 +- .../com/iluwatar/leaderelection/Message.java | 3 +- .../leaderelection/MessageManager.java | 3 +- .../iluwatar/leaderelection/MessageType.java | 3 +- .../leaderelection/bully/BullyApp.java | 9 ++--- .../leaderelection/bully/BullyInstance.java | 9 ++--- .../bully/BullyMessageManager.java | 9 ++--- .../iluwatar/leaderelection/ring/RingApp.java | 3 +- .../leaderelection/ring/RingInstance.java | 3 +- .../ring/RingMessageManager.java | 3 +- .../iluwatar/leaderelection/MessageTest.java | 9 ++--- .../leaderelection/bully/BullyAppTest.java | 9 ++--- .../bully/BullyMessageManagerTest.java | 9 ++--- .../bully/BullyinstanceTest.java | 9 ++--- .../leaderelection/ring/RingAppTest.java | 9 ++--- .../leaderelection/ring/RingInstanceTest.java | 9 ++--- .../ring/RingMessageManagerTest.java | 9 ++--- marker/pom.xml | 7 +++- marker/src/main/java/App.java | 2 +- marker/src/main/java/Guard.java | 2 +- marker/src/main/java/Permission.java | 2 +- marker/src/main/java/Thief.java | 2 +- marker/src/test/java/AppTest.java | 3 +- marker/src/test/java/GuardTest.java | 3 +- marker/src/test/java/ThiefTest.java | 3 +- master-worker-pattern/pom.xml | 2 +- .../java/com/iluwatar/masterworker/App.java | 3 +- .../com/iluwatar/masterworker/ArrayInput.java | 3 +- .../iluwatar/masterworker/ArrayResult.java | 3 +- .../masterworker/ArrayUtilityMethods.java | 3 +- .../java/com/iluwatar/masterworker/Input.java | 3 +- .../com/iluwatar/masterworker/Result.java | 3 +- .../system/ArrayTransposeMasterWorker.java | 3 +- .../masterworker/system/MasterWorker.java | 3 +- .../systemmaster/ArrayTransposeMaster.java | 3 +- .../system/systemmaster/Master.java | 3 +- .../systemworkers/ArrayTransposeWorker.java | 3 +- .../system/systemworkers/Worker.java | 3 +- .../iluwatar/masterworker/ArrayInputTest.java | 3 +- .../masterworker/ArrayUtilityMethodsTest.java | 2 +- .../ArrayTransposeMasterWorkerTest.java | 3 +- .../ArrayTransposeWorkerTest.java | 3 +- mediator/pom.xml | 2 +- .../java/com/iluwatar/mediator/Action.java | 2 +- .../main/java/com/iluwatar/mediator/App.java | 2 +- .../java/com/iluwatar/mediator/Hobbit.java | 2 +- .../java/com/iluwatar/mediator/Hunter.java | 2 +- .../java/com/iluwatar/mediator/Party.java | 2 +- .../java/com/iluwatar/mediator/PartyImpl.java | 2 +- .../com/iluwatar/mediator/PartyMember.java | 2 +- .../iluwatar/mediator/PartyMemberBase.java | 2 +- .../java/com/iluwatar/mediator/Rogue.java | 2 +- .../java/com/iluwatar/mediator/Wizard.java | 2 +- .../java/com/iluwatar/mediator/AppTest.java | 2 +- .../com/iluwatar/mediator/PartyImplTest.java | 2 +- .../iluwatar/mediator/PartyMemberTest.java | 2 +- memento/pom.xml | 2 +- .../main/java/com/iluwatar/memento/App.java | 2 +- .../main/java/com/iluwatar/memento/Star.java | 2 +- .../com/iluwatar/memento/StarMemento.java | 2 +- .../java/com/iluwatar/memento/StarType.java | 2 +- .../java/com/iluwatar/memento/AppTest.java | 2 +- .../java/com/iluwatar/memento/StarTest.java | 2 +- model-view-controller/pom.xml | 2 +- .../iluwatar/model/view/controller/App.java | 2 +- .../model/view/controller/Fatigue.java | 2 +- .../view/controller/GiantController.java | 2 +- .../model/view/controller/GiantModel.java | 2 +- .../model/view/controller/GiantView.java | 2 +- .../model/view/controller/Health.java | 2 +- .../model/view/controller/Nourishment.java | 2 +- .../model/view/controller/AppTest.java | 2 +- .../view/controller/GiantControllerTest.java | 2 +- .../model/view/controller/GiantModelTest.java | 2 +- .../model/view/controller/GiantViewTest.java | 2 +- model-view-presenter/etc/data/test.txt | 2 +- model-view-presenter/pom.xml | 2 +- .../iluwatar/model/view/presenter/App.java | 2 +- .../model/view/presenter/FileLoader.java | 2 +- .../view/presenter/FileSelectorJFrame.java | 2 +- .../view/presenter/FileSelectorPresenter.java | 2 +- .../view/presenter/FileSelectorStub.java | 2 +- .../view/presenter/FileSelectorView.java | 2 +- .../model/view/presenter/AppTest.java | 2 +- .../model/view/presenter/FileLoaderTest.java | 2 +- .../presenter/FileSelectorPresenterTest.java | 2 +- module/pom.xml | 2 +- .../main/java/com/iluwatar/module/App.java | 28 +++++++------ .../iluwatar/module/ConsoleLoggerModule.java | 28 +++++++------ .../com/iluwatar/module/FileLoggerModule.java | 28 +++++++------ module/src/main/resources/log4j.xml | 2 +- .../java/com/iluwatar/module/AppTest.java | 28 +++++++------ .../iluwatar/module/FileLoggerModuleTest.java | 28 +++++++------ monad/pom.xml | 2 +- .../src/main/java/com/iluwatar/monad/App.java | 2 +- .../src/main/java/com/iluwatar/monad/Sex.java | 2 +- .../main/java/com/iluwatar/monad/User.java | 2 +- .../java/com/iluwatar/monad/Validator.java | 2 +- .../test/java/com/iluwatar/monad/AppTest.java | 2 +- .../java/com/iluwatar/monad/MonadTest.java | 2 +- monostate/pom.xml | 2 +- .../main/java/com/iluwatar/monostate/App.java | 2 +- .../com/iluwatar/monostate/LoadBalancer.java | 2 +- .../java/com/iluwatar/monostate/Request.java | 2 +- .../java/com/iluwatar/monostate/Server.java | 2 +- .../java/com/iluwatar/monostate/AppTest.java | 2 +- .../iluwatar/monostate/LoadBalancerTest.java | 2 +- multiton/pom.xml | 2 +- .../main/java/com/iluwatar/multiton/App.java | 2 +- .../java/com/iluwatar/multiton/Nazgul.java | 2 +- .../com/iluwatar/multiton/NazgulEnum.java | 2 +- .../com/iluwatar/multiton/NazgulName.java | 2 +- .../java/com/iluwatar/multiton/AppTest.java | 2 +- .../com/iluwatar/multiton/NazgulEnumTest.java | 2 +- .../com/iluwatar/multiton/NazgulTest.java | 2 +- mute-idiom/pom.xml | 39 ++++++++++++------- .../src/main/java/com/iluwatar/mute/App.java | 3 +- .../com/iluwatar/mute/CheckedRunnable.java | 3 +- .../src/main/java/com/iluwatar/mute/Mute.java | 2 +- .../main/java/com/iluwatar/mute/Resource.java | 3 +- .../test/java/com/iluwatar/mute/AppTest.java | 3 +- .../test/java/com/iluwatar/mute/MuteTest.java | 3 +- mutex/pom.xml | 2 +- .../src/main/java/com/iluwatar/mutex/App.java | 2 +- .../src/main/java/com/iluwatar/mutex/Jar.java | 2 +- .../main/java/com/iluwatar/mutex/Lock.java | 2 +- .../main/java/com/iluwatar/mutex/Mutex.java | 2 +- .../main/java/com/iluwatar/mutex/Thief.java | 2 +- .../test/java/com/iluwatar/mutex/AppTest.java | 2 +- .../test/java/com/iluwatar/mutex/JarTest.java | 2 +- .../java/com/iluwatar/mutex/MutexTest.java | 2 +- naked-objects/dom/exclude-pmd.properties | 2 +- naked-objects/dom/pom.xml | 34 +++++++++++----- .../src/main/java/META-INF/persistence.xml | 38 ++++++++++-------- .../dom/app/homepage/HomePageService.java | 30 ++++++++------ .../dom/app/homepage/HomePageViewModel.java | 30 ++++++++------ .../dom/modules/simple/SimpleObject.java | 30 ++++++++------ .../dom/modules/simple/SimpleObjects.java | 30 ++++++++------ .../dom/modules/simple/SimpleObjectTest.java | 28 ++++++++----- .../dom/modules/simple/SimpleObjectsTest.java | 28 ++++++++----- naked-objects/fixture/pom.xml | 34 +++++++++++----- .../fixture/DomainAppFixturesProvider.java | 34 +++++++++------- .../modules/simple/SimpleObjectCreate.java | 31 +++++++++------ .../modules/simple/SimpleObjectsTearDown.java | 31 +++++++++------ .../scenarios/RecreateSimpleObjects.java | 31 +++++++++------ naked-objects/integtests/pom.xml | 34 +++++++++++----- .../bootstrap/SimpleAppSystemInitializer.java | 30 ++++++++------ .../specglue/BootstrappingGlue.java | 28 ++++++++----- .../specglue/CatalogOfFixturesGlue.java | 28 ++++++++----- .../modules/simple/SimpleObjectGlue.java | 28 ++++++++----- .../domainapp/integtests/specs/RunSpecs.java | 28 ++++++++----- .../integtests/tests/SimpleAppIntegTest.java | 34 +++++++++------- .../modules/simple/SimpleObjectIntegTest.java | 34 +++++++++------- .../simple/SimpleObjectsIntegTest.java | 34 +++++++++------- naked-objects/pom.xml | 34 +++++++++++----- .../webapp/ide/intellij/launch/README.txt | 2 +- .../intellij/launch/SimpleApp_PROTOTYPE.xml | 2 +- .../launch/SimpleApp__enhance_only_.xml | 2 +- naked-objects/webapp/pom.xml | 34 +++++++++++----- .../domainapp/webapp/SimpleApplication.java | 34 +++++++++------- .../resources/domainapp/webapp/welcome.html | 38 ++++++++++-------- .../src/main/webapp/WEB-INF/isis.properties | 38 ++++++++++-------- .../main/webapp/WEB-INF/persistor.properties | 38 ++++++++++-------- .../WEB-INF/persistor_datanucleus.properties | 38 ++++++++++-------- .../WEB-INF/viewer_restfulobjects.properties | 38 ++++++++++-------- .../webapp/WEB-INF/viewer_wicket.properties | 38 ++++++++++-------- .../webapp/src/main/webapp/WEB-INF/web.xml | 38 ++++++++++-------- .../webapp/src/main/webapp/about/index.html | 2 +- .../src/main/webapp/css/application.css | 35 +++++++++-------- .../src/main/webapp/scripts/application.js | 2 +- null-object/pom.xml | 2 +- .../java/com/iluwatar/nullobject/App.java | 2 +- .../java/com/iluwatar/nullobject/Node.java | 2 +- .../com/iluwatar/nullobject/NodeImpl.java | 2 +- .../com/iluwatar/nullobject/NullNode.java | 2 +- .../java/com/iluwatar/nullobject/AppTest.java | 2 +- .../com/iluwatar/nullobject/NullNodeTest.java | 2 +- .../com/iluwatar/nullobject/TreeTest.java | 2 +- object-mother/pom.xml | 2 +- .../java/com/iluwatar/objectmother/King.java | 2 +- .../java/com/iluwatar/objectmother/Queen.java | 2 +- .../com/iluwatar/objectmother/Royalty.java | 2 +- .../objectmother/RoyaltyObjectMother.java | 2 +- .../test/RoyaltyObjectMotherTest.java | 2 +- object-pool/pom.xml | 2 +- .../java/com/iluwatar/object/pool/App.java | 2 +- .../com/iluwatar/object/pool/ObjectPool.java | 2 +- .../com/iluwatar/object/pool/Oliphaunt.java | 2 +- .../iluwatar/object/pool/OliphauntPool.java | 2 +- .../com/iluwatar/object/pool/AppTest.java | 2 +- .../object/pool/OliphauntPoolTest.java | 2 +- observer/pom.xml | 2 +- .../main/java/com/iluwatar/observer/App.java | 2 +- .../java/com/iluwatar/observer/Hobbits.java | 2 +- .../main/java/com/iluwatar/observer/Orcs.java | 2 +- .../java/com/iluwatar/observer/Weather.java | 2 +- .../iluwatar/observer/WeatherObserver.java | 2 +- .../com/iluwatar/observer/WeatherType.java | 2 +- .../iluwatar/observer/generic/GHobbits.java | 2 +- .../com/iluwatar/observer/generic/GOrcs.java | 2 +- .../iluwatar/observer/generic/GWeather.java | 2 +- .../iluwatar/observer/generic/Observable.java | 2 +- .../iluwatar/observer/generic/Observer.java | 2 +- .../com/iluwatar/observer/generic/Race.java | 2 +- .../java/com/iluwatar/observer/AppTest.java | 2 +- .../com/iluwatar/observer/HobbitsTest.java | 2 +- .../java/com/iluwatar/observer/OrcsTest.java | 2 +- .../observer/WeatherObserverTest.java | 2 +- .../com/iluwatar/observer/WeatherTest.java | 2 +- .../observer/generic/GHobbitsTest.java | 2 +- .../observer/generic/GWeatherTest.java | 2 +- .../observer/generic/ObserverTest.java | 2 +- .../iluwatar/observer/generic/OrcsTest.java | 2 +- .../observer/utils/InMemoryAppender.java | 2 +- page-object/pom.xml | 2 +- page-object/sample-application/pom.xml | 2 +- .../java/com/iluwatar/pageobject/App.java | 2 +- .../main/resources/sample-ui/album-list.html | 2 +- .../main/resources/sample-ui/album-page.html | 2 +- .../resources/sample-ui/css/album-list.css | 2 +- .../main/resources/sample-ui/css/style.css | 2 +- .../src/main/resources/sample-ui/login.html | 2 +- .../java/com/iluwatar/pageobject/App.java | 2 +- .../main/resources/sample-ui/album-list.html | 2 +- .../main/resources/sample-ui/album-page.html | 2 +- .../resources/sample-ui/css/album-list.css | 2 +- .../main/resources/sample-ui/css/style.css | 2 +- .../src/main/resources/sample-ui/login.html | 2 +- .../pageobject/AlbumListPageTest.java | 8 ++-- .../iluwatar/pageobject/AlbumPageTest.java | 8 ++-- .../iluwatar/pageobject/LoginPageTest.java | 8 ++-- .../pageobject/pages/AlbumListPage.java | 8 ++-- .../iluwatar/pageobject/pages/AlbumPage.java | 8 ++-- .../iluwatar/pageobject/pages/LoginPage.java | 8 ++-- .../com/iluwatar/pageobject/pages/Page.java | 8 ++-- page-object/test-automation/pom.xml | 2 +- .../iluwatar/pageobject/AlbumListPage.java | 8 ++-- .../com/iluwatar/pageobject/AlbumPage.java | 8 ++-- .../com/iluwatar/pageobject/LoginPage.java | 8 ++-- .../java/com/iluwatar/pageobject/Page.java | 8 ++-- .../pageobject/AlbumListPageTest.java | 8 ++-- .../iluwatar/pageobject/AlbumPageTest.java | 8 ++-- .../iluwatar/pageobject/LoginPageTest.java | 8 ++-- partial-response/pom.xml | 2 +- .../com/iluwatar/partialresponse/App.java | 16 ++++---- .../partialresponse/FieldJsonMapper.java | 16 ++++---- .../com/iluwatar/partialresponse/Video.java | 16 ++++---- .../partialresponse/VideoResource.java | 16 ++++---- .../com/iluwatar/partialresponse/AppTest.java | 16 ++++---- .../partialresponse/FieldJsonMapperTest.java | 16 ++++---- .../partialresponse/VideoResourceTest.java | 16 ++++---- pipeline/pom.xml | 2 +- .../main/java/com.iluwatar.pipeline/App.java | 2 +- .../ConvertToCharArrayHandler.java | 8 ++-- .../java/com.iluwatar.pipeline/Handler.java | 2 +- .../java/com.iluwatar.pipeline/Pipeline.java | 2 +- .../RemoveAlphabetsHandler.java | 2 +- .../RemoveDigitsHandler.java | 2 +- .../java/com.iluwatar.pipeline/AppTest.java | 8 ++-- .../com.iluwatar.pipeline/PipelineTest.java | 8 ++-- poison-pill/pom.xml | 2 +- .../java/com/iluwatar/poison/pill/App.java | 2 +- .../com/iluwatar/poison/pill/Consumer.java | 2 +- .../com/iluwatar/poison/pill/Message.java | 2 +- .../iluwatar/poison/pill/MessageQueue.java | 2 +- .../iluwatar/poison/pill/MqPublishPoint.java | 2 +- .../poison/pill/MqSubscribePoint.java | 2 +- .../com/iluwatar/poison/pill/Producer.java | 2 +- .../iluwatar/poison/pill/SimpleMessage.java | 2 +- .../poison/pill/SimpleMessageQueue.java | 2 +- .../com/iluwatar/poison/pill/AppTest.java | 2 +- .../iluwatar/poison/pill/ConsumerTest.java | 2 +- .../poison/pill/PoisonMessageTest.java | 2 +- .../iluwatar/poison/pill/ProducerTest.java | 2 +- .../poison/pill/SimpleMessageTest.java | 2 +- pom.xml | 9 ++++- priority-queue/pom.xml | 2 +- .../iluwatar/priority/queue/Application.java | 8 ++-- .../com/iluwatar/priority/queue/Message.java | 2 +- .../priority/queue/PriorityMessageQueue.java | 8 ++-- .../iluwatar/priority/queue/QueueManager.java | 8 ++-- .../com/iluwatar/priority/queue/Worker.java | 8 ++-- .../queue/PriorityMessageQueueTest.java | 2 +- .../priority/queue/QueueManagerTest.java | 2 +- private-class-data/pom.xml | 2 +- .../com/iluwatar/privateclassdata/App.java | 2 +- .../privateclassdata/ImmutableStew.java | 2 +- .../com/iluwatar/privateclassdata/Stew.java | 2 +- .../iluwatar/privateclassdata/StewData.java | 2 +- .../iluwatar/privateclassdata/AppTest.java | 2 +- .../privateclassdata/ImmutableStewTest.java | 2 +- .../iluwatar/privateclassdata/StewTest.java | 2 +- .../utils/InMemoryAppender.java | 2 +- producer-consumer/pom.xml | 2 +- .../com/iluwatar/producer/consumer/App.java | 2 +- .../iluwatar/producer/consumer/Consumer.java | 2 +- .../com/iluwatar/producer/consumer/Item.java | 2 +- .../iluwatar/producer/consumer/ItemQueue.java | 2 +- .../iluwatar/producer/consumer/Producer.java | 2 +- .../iluwatar/producer/consumer/AppTest.java | 2 +- .../producer/consumer/ConsumerTest.java | 2 +- .../producer/consumer/ProducerTest.java | 2 +- promise/pom.xml | 2 +- .../main/java/com/iluwatar/promise/App.java | 2 +- .../java/com/iluwatar/promise/Promise.java | 2 +- .../com/iluwatar/promise/PromiseSupport.java | 2 +- .../java/com/iluwatar/promise/Utility.java | 2 +- .../java/com/iluwatar/promise/AppTest.java | 2 +- .../com/iluwatar/promise/PromiseTest.java | 2 +- property/pom.xml | 2 +- .../main/java/com/iluwatar/property/App.java | 2 +- .../java/com/iluwatar/property/Character.java | 2 +- .../java/com/iluwatar/property/Prototype.java | 2 +- .../java/com/iluwatar/property/Stats.java | 2 +- .../java/com/iluwatar/property/AppTest.java | 2 +- .../com/iluwatar/property/CharacterTest.java | 2 +- prototype/pom.xml | 2 +- .../main/java/com/iluwatar/prototype/App.java | 2 +- .../java/com/iluwatar/prototype/Beast.java | 2 +- .../java/com/iluwatar/prototype/ElfBeast.java | 2 +- .../java/com/iluwatar/prototype/ElfMage.java | 2 +- .../com/iluwatar/prototype/ElfWarlord.java | 2 +- .../com/iluwatar/prototype/HeroFactory.java | 2 +- .../iluwatar/prototype/HeroFactoryImpl.java | 2 +- .../java/com/iluwatar/prototype/Mage.java | 2 +- .../java/com/iluwatar/prototype/OrcBeast.java | 2 +- .../java/com/iluwatar/prototype/OrcMage.java | 2 +- .../com/iluwatar/prototype/OrcWarlord.java | 2 +- .../com/iluwatar/prototype/Prototype.java | 2 +- .../java/com/iluwatar/prototype/Warlord.java | 2 +- .../java/com/iluwatar/prototype/AppTest.java | 2 +- .../prototype/HeroFactoryImplTest.java | 2 +- .../com/iluwatar/prototype/PrototypeTest.java | 2 +- proxy/etc/presentation.html | 2 +- proxy/etc/proxy-concept.xml | 2 +- proxy/pom.xml | 2 +- .../src/main/java/com/iluwatar/proxy/App.java | 2 +- .../java/com/iluwatar/proxy/IvoryTower.java | 2 +- .../main/java/com/iluwatar/proxy/Wizard.java | 2 +- .../java/com/iluwatar/proxy/WizardTower.java | 2 +- .../com/iluwatar/proxy/WizardTowerProxy.java | 2 +- .../test/java/com/iluwatar/proxy/AppTest.java | 2 +- .../com/iluwatar/proxy/IvoryTowerTest.java | 2 +- .../java/com/iluwatar/proxy/WizardTest.java | 2 +- .../iluwatar/proxy/WizardTowerProxyTest.java | 2 +- .../proxy/utils/InMemoryAppender.java | 2 +- queue-load-leveling/pom.xml | 2 +- .../com/iluwatar/queue/load/leveling/App.java | 3 +- .../iluwatar/queue/load/leveling/Message.java | 2 +- .../queue/load/leveling/MessageQueue.java | 2 +- .../queue/load/leveling/ServiceExecutor.java | 3 +- .../iluwatar/queue/load/leveling/Task.java | 2 +- .../queue/load/leveling/TaskGenerator.java | 2 +- .../iluwatar/queue/load/leveling/AppTest.java | 2 +- .../queue/load/leveling/MessageQueueTest.java | 2 +- .../queue/load/leveling/MessageTest.java | 2 +- .../load/leveling/TaskGenSrvExeTest.java | 2 +- reactor/pom.xml | 2 +- .../java/com/iluwatar/reactor/app/App.java | 2 +- .../com/iluwatar/reactor/app/AppClient.java | 2 +- .../iluwatar/reactor/app/LoggingHandler.java | 2 +- .../reactor/framework/AbstractNioChannel.java | 2 +- .../reactor/framework/ChannelHandler.java | 2 +- .../reactor/framework/Dispatcher.java | 2 +- .../reactor/framework/NioDatagramChannel.java | 2 +- .../reactor/framework/NioReactor.java | 2 +- .../framework/NioServerSocketChannel.java | 2 +- .../framework/SameThreadDispatcher.java | 2 +- .../framework/ThreadPoolDispatcher.java | 2 +- .../com/iluwatar/reactor/app/ReactorTest.java | 2 +- reader-writer-lock/pom.xml | 3 +- .../com/iluwatar/reader/writer/lock/App.java | 3 +- .../iluwatar/reader/writer/lock/Reader.java | 2 +- .../reader/writer/lock/ReaderWriterLock.java | 2 +- .../iluwatar/reader/writer/lock/Writer.java | 2 +- .../iluwatar/reader/writer/lock/AppTest.java | 2 +- .../writer/lock/ReaderAndWriterTest.java | 3 +- .../reader/writer/lock/ReaderTest.java | 2 +- .../reader/writer/lock/WriterTest.java | 2 +- .../writer/lock/utils/InMemoryAppender.java | 2 +- repository/pom.xml | 2 +- .../java/com/iluwatar/repository/App.java | 2 +- .../com/iluwatar/repository/AppConfig.java | 2 +- .../java/com/iluwatar/repository/Person.java | 2 +- .../iluwatar/repository/PersonRepository.java | 2 +- .../repository/PersonSpecifications.java | 2 +- .../main/resources/META-INF/persistence.xml | 2 +- .../src/main/resources/applicationContext.xml | 2 +- repository/src/main/resources/logback.xml | 2 +- .../AnnotationBasedRepositoryTest.java | 2 +- .../iluwatar/repository/AppConfigTest.java | 2 +- .../java/com/iluwatar/repository/AppTest.java | 2 +- .../iluwatar/repository/RepositoryTest.java | 2 +- .../pom.xml | 2 +- .../acquisition/is/initialization/App.java | 2 +- .../is/initialization/SlidingDoor.java | 2 +- .../is/initialization/TreasureChest.java | 2 +- .../is/initialization/AppTest.java | 2 +- .../is/initialization/ClosableTest.java | 2 +- retry/pom.xml | 4 +- .../src/main/java/com/iluwatar/retry/App.java | 22 +++++------ .../com/iluwatar/retry/BusinessException.java | 22 +++++------ .../com/iluwatar/retry/BusinessOperation.java | 22 +++++------ .../retry/CustomerNotFoundException.java | 22 +++++------ .../retry/DatabaseNotAvailableException.java | 22 +++++------ .../java/com/iluwatar/retry/FindCustomer.java | 22 +++++------ .../main/java/com/iluwatar/retry/Retry.java | 22 +++++------ .../retry/RetryExponentialBackoff.java | 16 ++++---- .../com/iluwatar/retry/FindCustomerTest.java | 22 +++++------ .../retry/RetryExponentialBackoffTest.java | 16 ++++---- .../java/com/iluwatar/retry/RetryTest.java | 22 +++++------ semaphore/pom.xml | 2 +- .../main/java/com/iluwatar/semaphore/App.java | 2 +- .../java/com/iluwatar/semaphore/Customer.java | 2 +- .../java/com/iluwatar/semaphore/Fruit.java | 2 +- .../com/iluwatar/semaphore/FruitBowl.java | 2 +- .../com/iluwatar/semaphore/FruitShop.java | 2 +- .../java/com/iluwatar/semaphore/Lock.java | 2 +- .../com/iluwatar/semaphore/Semaphore.java | 2 +- .../java/com/iluwatar/semaphore/AppTest.java | 2 +- .../com/iluwatar/semaphore/FruitBowlTest.java | 2 +- .../com/iluwatar/semaphore/SemaphoreTest.java | 2 +- servant/pom.xml | 2 +- servant/src/etc/servant.xml | 2 +- .../main/java/com/iluwatar/servant/App.java | 2 +- .../main/java/com/iluwatar/servant/King.java | 2 +- .../main/java/com/iluwatar/servant/Queen.java | 2 +- .../java/com/iluwatar/servant/Royalty.java | 2 +- .../java/com/iluwatar/servant/Servant.java | 2 +- .../java/com/iluwatar/servant/AppTest.java | 2 +- .../java/com/iluwatar/servant/KingTest.java | 2 +- .../java/com/iluwatar/servant/QueenTest.java | 2 +- .../com/iluwatar/servant/ServantTest.java | 2 +- serverless/pom.xml | 7 +++- serverless/serverless.yml | 2 +- .../baas/api/AbstractDynamoDbHandler.java | 2 +- .../baas/api/FindPersonApiHandler.java | 2 +- .../baas/api/SavePersonApiHandler.java | 2 +- .../serverless/baas/model/Address.java | 2 +- .../serverless/baas/model/Person.java | 2 +- .../serverless/faas/ApiGatewayResponse.java | 2 +- .../iluwatar/serverless/faas/LambdaInfo.java | 2 +- .../faas/api/LambdaInfoApiHandler.java | 2 +- .../src/main/resources/log4j.properties | 2 +- .../baas/api/FindPersonApiHandlerTest.java | 2 +- .../baas/api/SavePersonApiHandlerTest.java | 2 +- .../faas/api/LambdaInfoApiHandlerTest.java | 8 ++-- service-layer/pom.xml | 2 +- .../com/iluwatar/servicelayer/app/App.java | 2 +- .../servicelayer/common/BaseEntity.java | 2 +- .../com/iluwatar/servicelayer/common/Dao.java | 2 +- .../servicelayer/common/DaoBaseImpl.java | 2 +- .../servicelayer/hibernate/HibernateUtil.java | 2 +- .../servicelayer/magic/MagicService.java | 2 +- .../servicelayer/magic/MagicServiceImpl.java | 2 +- .../iluwatar/servicelayer/spell/Spell.java | 2 +- .../iluwatar/servicelayer/spell/SpellDao.java | 2 +- .../servicelayer/spell/SpellDaoImpl.java | 2 +- .../servicelayer/spellbook/Spellbook.java | 2 +- .../servicelayer/spellbook/SpellbookDao.java | 2 +- .../spellbook/SpellbookDaoImpl.java | 2 +- .../iluwatar/servicelayer/wizard/Wizard.java | 2 +- .../servicelayer/wizard/WizardDao.java | 2 +- .../servicelayer/wizard/WizardDaoImpl.java | 2 +- service-layer/src/main/resources/logback.xml | 2 +- .../iluwatar/servicelayer/app/AppTest.java | 2 +- .../servicelayer/common/BaseDaoTest.java | 2 +- .../magic/MagicServiceImplTest.java | 2 +- .../servicelayer/spell/SpellDaoImplTest.java | 2 +- .../spellbook/SpellbookDaoImplTest.java | 2 +- .../wizard/WizardDaoImplTest.java | 2 +- service-locator/pom.xml | 2 +- .../java/com/iluwatar/servicelocator/App.java | 2 +- .../iluwatar/servicelocator/InitContext.java | 2 +- .../com/iluwatar/servicelocator/Service.java | 2 +- .../iluwatar/servicelocator/ServiceCache.java | 2 +- .../iluwatar/servicelocator/ServiceImpl.java | 2 +- .../servicelocator/ServiceLocator.java | 2 +- .../com/iluwatar/servicelocator/AppTest.java | 2 +- .../servicelocator/ServiceLocatorTest.java | 2 +- singleton/pom.xml | 2 +- .../main/java/com/iluwatar/singleton/App.java | 2 +- .../iluwatar/singleton/EnumIvoryTower.java | 2 +- .../InitializingOnDemandHolderIdiom.java | 2 +- .../com/iluwatar/singleton/IvoryTower.java | 2 +- .../ThreadSafeDoubleCheckLocking.java | 2 +- .../ThreadSafeLazyLoadedIvoryTower.java | 28 +++++++------ .../java/com/iluwatar/singleton/AppTest.java | 2 +- .../singleton/EnumIvoryTowerTest.java | 2 +- .../InitializingOnDemandHolderIdiomTest.java | 2 +- .../iluwatar/singleton/IvoryTowerTest.java | 2 +- .../com/iluwatar/singleton/SingletonTest.java | 2 +- .../ThreadSafeDoubleCheckLockingTest.java | 2 +- .../ThreadSafeLazyLoadedIvoryTowerTest.java | 2 +- spatial-partition/pom.xml | 2 +- .../com/iluwatar/spatialpartition/App.java | 3 +- .../com/iluwatar/spatialpartition/Bubble.java | 3 +- .../com/iluwatar/spatialpartition/Point.java | 3 +- .../iluwatar/spatialpartition/QuadTree.java | 3 +- .../com/iluwatar/spatialpartition/Rect.java | 3 +- .../SpatialPartitionBubbles.java | 3 +- .../SpatialPartitionGeneric.java | 3 +- .../iluwatar/spatialpartition/BubbleTest.java | 3 +- .../spatialpartition/QuadTreeTest.java | 3 +- .../iluwatar/spatialpartition/RectTest.java | 3 +- .../SpatialPartitionBubblesTest.java | 3 +- specification/pom.xml | 2 +- .../com/iluwatar/specification/app/App.java | 2 +- .../creature/AbstractCreature.java | 2 +- .../specification/creature/Creature.java | 2 +- .../specification/creature/Dragon.java | 2 +- .../specification/creature/Goblin.java | 2 +- .../specification/creature/KillerBee.java | 2 +- .../specification/creature/Octopus.java | 2 +- .../specification/creature/Shark.java | 2 +- .../specification/creature/Troll.java | 2 +- .../specification/property/Color.java | 2 +- .../specification/property/Movement.java | 2 +- .../iluwatar/specification/property/Size.java | 2 +- .../specification/selector/ColorSelector.java | 2 +- .../selector/MovementSelector.java | 2 +- .../specification/selector/SizeSelector.java | 2 +- .../iluwatar/specification/app/AppTest.java | 2 +- .../specification/creature/CreatureTest.java | 2 +- .../selector/ColorSelectorTest.java | 2 +- .../selector/MovementSelectorTest.java | 2 +- .../selector/SizeSelectorTest.java | 2 +- state/pom.xml | 2 +- .../java/com/iluwatar/state/AngryState.java | 2 +- .../src/main/java/com/iluwatar/state/App.java | 2 +- .../main/java/com/iluwatar/state/Mammoth.java | 2 +- .../com/iluwatar/state/PeacefulState.java | 2 +- .../main/java/com/iluwatar/state/State.java | 2 +- .../test/java/com/iluwatar/state/AppTest.java | 2 +- .../java/com/iluwatar/state/MammothTest.java | 2 +- step-builder/pom.xml | 2 +- .../java/com/iluwatar/stepbuilder/App.java | 2 +- .../com/iluwatar/stepbuilder/Character.java | 2 +- .../stepbuilder/CharacterStepBuilder.java | 2 +- .../com/iluwatar/stepbuilder/AppTest.java | 2 +- .../stepbuilder/CharacterStepBuilderTest.java | 2 +- strategy/pom.xml | 2 +- .../main/java/com/iluwatar/strategy/App.java | 2 +- .../com/iluwatar/strategy/DragonSlayer.java | 2 +- .../strategy/DragonSlayingStrategy.java | 2 +- .../com/iluwatar/strategy/MeleeStrategy.java | 2 +- .../iluwatar/strategy/ProjectileStrategy.java | 2 +- .../com/iluwatar/strategy/SpellStrategy.java | 2 +- .../java/com/iluwatar/strategy/AppTest.java | 2 +- .../iluwatar/strategy/DragonSlayerTest.java | 2 +- .../strategy/DragonSlayingStrategyTest.java | 2 +- template-method/pom.xml | 2 +- .../java/com/iluwatar/templatemethod/App.java | 2 +- .../templatemethod/HalflingThief.java | 2 +- .../templatemethod/HitAndRunMethod.java | 2 +- .../templatemethod/StealingMethod.java | 2 +- .../iluwatar/templatemethod/SubtleMethod.java | 2 +- .../com/iluwatar/templatemethod/AppTest.java | 2 +- .../templatemethod/HalflingThiefTest.java | 2 +- .../templatemethod/HitAndRunMethodTest.java | 2 +- .../templatemethod/StealingMethodTest.java | 2 +- .../templatemethod/SubtleMethodTest.java | 2 +- thread-pool/pom.xml | 2 +- .../java/com/iluwatar/threadpool/App.java | 2 +- .../iluwatar/threadpool/CoffeeMakingTask.java | 2 +- .../threadpool/PotatoPeelingTask.java | 2 +- .../java/com/iluwatar/threadpool/Task.java | 2 +- .../java/com/iluwatar/threadpool/Worker.java | 2 +- .../java/com/iluwatar/threadpool/AppTest.java | 2 +- .../threadpool/CoffeeMakingTaskTest.java | 2 +- .../threadpool/PotatoPeelingTaskTest.java | 2 +- .../com/iluwatar/threadpool/TaskTest.java | 2 +- .../com/iluwatar/threadpool/WorkerTest.java | 2 +- throttling/pom.xml | 2 +- .../java/com/iluwatar/throttling/App.java | 3 +- .../com/iluwatar/throttling/B2BService.java | 2 +- .../com/iluwatar/throttling/CallsCount.java | 2 +- .../java/com/iluwatar/throttling/Tenant.java | 2 +- .../throttling/timer/ThrottleTimerImpl.java | 2 +- .../iluwatar/throttling/timer/Throttler.java | 2 +- .../java/com/iluwatar/throttling/AppTest.java | 2 +- .../iluwatar/throttling/B2BServiceTest.java | 2 +- .../com/iluwatar/throttling/TenantTest.java | 2 +- tls/pom.xml | 3 +- tls/src/main/java/com/iluwatar/tls/App.java | 3 +- .../com/iluwatar/tls/DateFormatCallable.java | 3 +- .../main/java/com/iluwatar/tls/Result.java | 2 +- .../test/java/com/iluwatar/tls/AppTest.java | 3 +- .../iluwatar/tls/DateFormatCallableTest.java | 3 +- ...FormatCallableTestIncorrectDateFormat.java | 3 +- .../DateFormatCallableTestMultiThread.java | 3 +- tolerant-reader/pom.xml | 2 +- .../java/com/iluwatar/tolerantreader/App.java | 2 +- .../iluwatar/tolerantreader/RainbowFish.java | 2 +- .../tolerantreader/RainbowFishSerializer.java | 2 +- .../tolerantreader/RainbowFishV2.java | 2 +- .../com/iluwatar/tolerantreader/AppTest.java | 2 +- .../RainbowFishSerializerTest.java | 2 +- .../tolerantreader/RainbowFishTest.java | 2 +- .../tolerantreader/RainbowFishV2Test.java | 2 +- trampoline/pom.xml | 2 +- .../com/iluwatar/trampoline/Trampoline.java | 2 +- .../iluwatar/trampoline/TrampolineApp.java | 9 ++--- .../trampoline/TrampolineAppTest.java | 2 +- twin/pom.xml | 2 +- twin/src/main/java/com/iluwatar/twin/App.java | 2 +- .../main/java/com/iluwatar/twin/BallItem.java | 3 +- .../java/com/iluwatar/twin/BallThread.java | 3 +- .../main/java/com/iluwatar/twin/GameItem.java | 3 +- .../test/java/com/iluwatar/twin/AppTest.java | 2 +- .../java/com/iluwatar/twin/BallItemTest.java | 2 +- .../com/iluwatar/twin/BallThreadTest.java | 2 +- typeobjectpattern/pom.xml | 2 +- .../java/com/iluwatar/typeobject/App.java | 3 +- .../java/com/iluwatar/typeobject/Candy.java | 3 +- .../com/iluwatar/typeobject/CandyGame.java | 3 +- .../java/com/iluwatar/typeobject/Cell.java | 3 +- .../com/iluwatar/typeobject/CellPool.java | 3 +- .../com/iluwatar/typeobject/JsonParser.java | 3 +- .../iluwatar/typeobject/CandyGameTest.java | 3 +- .../com/iluwatar/typeobject/CellPoolTest.java | 3 +- .../com/iluwatar/typeobject/CellTest.java | 3 +- unit-of-work/pom.xml | 2 +- .../java/com/iluwatar/unitofwork/App.java | 16 ++++---- .../com/iluwatar/unitofwork/IUnitOfWork.java | 16 ++++---- .../java/com/iluwatar/unitofwork/Student.java | 16 ++++---- .../iluwatar/unitofwork/StudentDatabase.java | 16 ++++---- .../unitofwork/StudentRepository.java | 16 ++++---- .../java/com/iluwatar/unitofwork/AppTest.java | 16 ++++---- .../unitofwork/StudentRepositoryTest.java | 16 ++++---- update-ghpages.sh | 2 +- value-object/pom.xml | 2 +- .../java/com/iluwatar/value/object/App.java | 2 +- .../com/iluwatar/value/object/HeroStat.java | 2 +- .../com/iluwatar/value/object/AppTest.java | 2 +- .../iluwatar/value/object/HeroStatTest.java | 2 +- visitor/pom.xml | 2 +- .../main/java/com/iluwatar/visitor/App.java | 2 +- .../java/com/iluwatar/visitor/Commander.java | 2 +- .../iluwatar/visitor/CommanderVisitor.java | 2 +- .../java/com/iluwatar/visitor/Sergeant.java | 2 +- .../com/iluwatar/visitor/SergeantVisitor.java | 2 +- .../java/com/iluwatar/visitor/Soldier.java | 2 +- .../com/iluwatar/visitor/SoldierVisitor.java | 2 +- .../main/java/com/iluwatar/visitor/Unit.java | 2 +- .../com/iluwatar/visitor/UnitVisitor.java | 2 +- .../java/com/iluwatar/visitor/AppTest.java | 2 +- .../com/iluwatar/visitor/CommanderTest.java | 2 +- .../visitor/CommanderVisitorTest.java | 2 +- .../com/iluwatar/visitor/SergeantTest.java | 2 +- .../iluwatar/visitor/SergeantVisitorTest.java | 2 +- .../com/iluwatar/visitor/SoldierTest.java | 2 +- .../iluwatar/visitor/SoldierVisitorTest.java | 2 +- .../java/com/iluwatar/visitor/UnitTest.java | 2 +- .../com/iluwatar/visitor/VisitorTest.java | 2 +- 1421 files changed, 3147 insertions(+), 2877 deletions(-) diff --git a/.sonarcloud.properties b/.sonarcloud.properties index 1bd690065c42..c6b26bf5df8b 100644 --- a/.sonarcloud.properties +++ b/.sonarcloud.properties @@ -1,6 +1,6 @@ # # The MIT License -# Copyright (c) 2014 Ilkka Seppälä +# Copyright © 2014-2019 Ilkka Seppälä # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/abstract-document/pom.xml b/abstract-document/pom.xml index c3f783184d33..ec1bd16dc633 100644 --- a/abstract-document/pom.xml +++ b/abstract-document/pom.xml @@ -2,7 +2,7 @@ + diff --git a/cqrs/src/main/java/com/iluwatar/cqrs/app/App.java b/cqrs/src/main/java/com/iluwatar/cqrs/app/App.java index 0f766e5c727f..7f79116268a0 100644 --- a/cqrs/src/main/java/com/iluwatar/cqrs/app/App.java +++ b/cqrs/src/main/java/com/iluwatar/cqrs/app/App.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cqrs/src/main/java/com/iluwatar/cqrs/commandes/CommandServiceImpl.java b/cqrs/src/main/java/com/iluwatar/cqrs/commandes/CommandServiceImpl.java index a15f8a45716d..dd7914d7eb3e 100644 --- a/cqrs/src/main/java/com/iluwatar/cqrs/commandes/CommandServiceImpl.java +++ b/cqrs/src/main/java/com/iluwatar/cqrs/commandes/CommandServiceImpl.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cqrs/src/main/java/com/iluwatar/cqrs/commandes/ICommandService.java b/cqrs/src/main/java/com/iluwatar/cqrs/commandes/ICommandService.java index 1da3f6c42392..acaef10726ba 100644 --- a/cqrs/src/main/java/com/iluwatar/cqrs/commandes/ICommandService.java +++ b/cqrs/src/main/java/com/iluwatar/cqrs/commandes/ICommandService.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cqrs/src/main/java/com/iluwatar/cqrs/constants/AppConstants.java b/cqrs/src/main/java/com/iluwatar/cqrs/constants/AppConstants.java index 07a8b96190b3..52de88d34adc 100644 --- a/cqrs/src/main/java/com/iluwatar/cqrs/constants/AppConstants.java +++ b/cqrs/src/main/java/com/iluwatar/cqrs/constants/AppConstants.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cqrs/src/main/java/com/iluwatar/cqrs/domain/model/Author.java b/cqrs/src/main/java/com/iluwatar/cqrs/domain/model/Author.java index 9825de9f7b25..179be3da32c2 100644 --- a/cqrs/src/main/java/com/iluwatar/cqrs/domain/model/Author.java +++ b/cqrs/src/main/java/com/iluwatar/cqrs/domain/model/Author.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cqrs/src/main/java/com/iluwatar/cqrs/domain/model/Book.java b/cqrs/src/main/java/com/iluwatar/cqrs/domain/model/Book.java index 8a11fcdd4166..14e141412a54 100644 --- a/cqrs/src/main/java/com/iluwatar/cqrs/domain/model/Book.java +++ b/cqrs/src/main/java/com/iluwatar/cqrs/domain/model/Book.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cqrs/src/main/java/com/iluwatar/cqrs/dto/Author.java b/cqrs/src/main/java/com/iluwatar/cqrs/dto/Author.java index c5473354dd59..1715e1718fc9 100644 --- a/cqrs/src/main/java/com/iluwatar/cqrs/dto/Author.java +++ b/cqrs/src/main/java/com/iluwatar/cqrs/dto/Author.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cqrs/src/main/java/com/iluwatar/cqrs/dto/Book.java b/cqrs/src/main/java/com/iluwatar/cqrs/dto/Book.java index f121a2ca7c2c..720e5655d96a 100644 --- a/cqrs/src/main/java/com/iluwatar/cqrs/dto/Book.java +++ b/cqrs/src/main/java/com/iluwatar/cqrs/dto/Book.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cqrs/src/main/java/com/iluwatar/cqrs/queries/IQueryService.java b/cqrs/src/main/java/com/iluwatar/cqrs/queries/IQueryService.java index 9c0252b0aeab..e5f040b7a47d 100644 --- a/cqrs/src/main/java/com/iluwatar/cqrs/queries/IQueryService.java +++ b/cqrs/src/main/java/com/iluwatar/cqrs/queries/IQueryService.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cqrs/src/main/java/com/iluwatar/cqrs/queries/QueryServiceImpl.java b/cqrs/src/main/java/com/iluwatar/cqrs/queries/QueryServiceImpl.java index 86eb4dd2f351..b6a8c6275ea6 100644 --- a/cqrs/src/main/java/com/iluwatar/cqrs/queries/QueryServiceImpl.java +++ b/cqrs/src/main/java/com/iluwatar/cqrs/queries/QueryServiceImpl.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cqrs/src/main/java/com/iluwatar/cqrs/util/HibernateUtil.java b/cqrs/src/main/java/com/iluwatar/cqrs/util/HibernateUtil.java index a5b59e20dc27..1a762537575d 100644 --- a/cqrs/src/main/java/com/iluwatar/cqrs/util/HibernateUtil.java +++ b/cqrs/src/main/java/com/iluwatar/cqrs/util/HibernateUtil.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cqrs/src/main/resources/hibernate.cfg.xml b/cqrs/src/main/resources/hibernate.cfg.xml index 4ea1421667e1..019cd3917c84 100644 --- a/cqrs/src/main/resources/hibernate.cfg.xml +++ b/cqrs/src/main/resources/hibernate.cfg.xml @@ -2,7 +2,7 @@ - diff --git a/delegation/src/main/java/com/iluwatar/delegation/simple/App.java b/delegation/src/main/java/com/iluwatar/delegation/simple/App.java index 83e00fd1fb1c..4f8a363abc93 100644 --- a/delegation/src/main/java/com/iluwatar/delegation/simple/App.java +++ b/delegation/src/main/java/com/iluwatar/delegation/simple/App.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/delegation/src/main/java/com/iluwatar/delegation/simple/Printer.java b/delegation/src/main/java/com/iluwatar/delegation/simple/Printer.java index ee4d54938a86..64739467847c 100644 --- a/delegation/src/main/java/com/iluwatar/delegation/simple/Printer.java +++ b/delegation/src/main/java/com/iluwatar/delegation/simple/Printer.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/delegation/src/main/java/com/iluwatar/delegation/simple/PrinterController.java b/delegation/src/main/java/com/iluwatar/delegation/simple/PrinterController.java index c54f611ee213..a0ceed8dbc1d 100644 --- a/delegation/src/main/java/com/iluwatar/delegation/simple/PrinterController.java +++ b/delegation/src/main/java/com/iluwatar/delegation/simple/PrinterController.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/delegation/src/main/java/com/iluwatar/delegation/simple/printers/CanonPrinter.java b/delegation/src/main/java/com/iluwatar/delegation/simple/printers/CanonPrinter.java index 8f024122f15f..5c1785d9119a 100644 --- a/delegation/src/main/java/com/iluwatar/delegation/simple/printers/CanonPrinter.java +++ b/delegation/src/main/java/com/iluwatar/delegation/simple/printers/CanonPrinter.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/delegation/src/main/java/com/iluwatar/delegation/simple/printers/EpsonPrinter.java b/delegation/src/main/java/com/iluwatar/delegation/simple/printers/EpsonPrinter.java index fb763d21a862..3d12e0b63358 100644 --- a/delegation/src/main/java/com/iluwatar/delegation/simple/printers/EpsonPrinter.java +++ b/delegation/src/main/java/com/iluwatar/delegation/simple/printers/EpsonPrinter.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/delegation/src/main/java/com/iluwatar/delegation/simple/printers/HpPrinter.java b/delegation/src/main/java/com/iluwatar/delegation/simple/printers/HpPrinter.java index d80bb7aa7c9f..47d1057d2918 100644 --- a/delegation/src/main/java/com/iluwatar/delegation/simple/printers/HpPrinter.java +++ b/delegation/src/main/java/com/iluwatar/delegation/simple/printers/HpPrinter.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/delegation/src/test/java/com/iluwatar/delegation/simple/AppTest.java b/delegation/src/test/java/com/iluwatar/delegation/simple/AppTest.java index ffdc96b807bd..1a62f34d6269 100644 --- a/delegation/src/test/java/com/iluwatar/delegation/simple/AppTest.java +++ b/delegation/src/test/java/com/iluwatar/delegation/simple/AppTest.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/delegation/src/test/java/com/iluwatar/delegation/simple/DelegateTest.java b/delegation/src/test/java/com/iluwatar/delegation/simple/DelegateTest.java index 422da5685ffc..452f9dd76aa0 100644 --- a/delegation/src/test/java/com/iluwatar/delegation/simple/DelegateTest.java +++ b/delegation/src/test/java/com/iluwatar/delegation/simple/DelegateTest.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dependency-injection/pom.xml b/dependency-injection/pom.xml index 2347cb14f946..fd9584ed2ac8 100644 --- a/dependency-injection/pom.xml +++ b/dependency-injection/pom.xml @@ -2,7 +2,7 @@ - diff --git a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/App.java b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/App.java index 351936b2cd64..b5271ee0836c 100644 --- a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/App.java +++ b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/App.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 @@ -20,7 +20,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - package com.iluwatar.featuretoggle; import com.iluwatar.featuretoggle.pattern.Service; diff --git a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/Service.java b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/Service.java index 284ccf2ab2cb..9b5bcc035b44 100644 --- a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/Service.java +++ b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/Service.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersion.java b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersion.java index 1ded334ec7d7..4a0fbc4b5b73 100644 --- a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersion.java +++ b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersion.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersion.java b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersion.java index 887c9f663bfe..00277c9e093e 100644 --- a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersion.java +++ b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersion.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/user/User.java b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/user/User.java index baf25aa8b7d6..a90c13e7deaf 100644 --- a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/user/User.java +++ b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/user/User.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/user/UserGroup.java b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/user/UserGroup.java index cb84ec533274..17d21d705c7e 100644 --- a/feature-toggle/src/main/java/com/iluwatar/featuretoggle/user/UserGroup.java +++ b/feature-toggle/src/main/java/com/iluwatar/featuretoggle/user/UserGroup.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java index 8b85e93496ae..7d87c1f4d601 100644 --- a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java +++ b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 @@ -20,7 +20,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - package com.iluwatar.featuretoggle.pattern.propertiesversion; import com.iluwatar.featuretoggle.pattern.Service; diff --git a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java index 4755d569e09e..ca374a90462a 100644 --- a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java +++ b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java index 2771655ddefa..4489b86c9896 100644 --- a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java +++ b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/fluentinterface/pom.xml b/fluentinterface/pom.xml index 23fc5d806866..1e76ea628f9d 100644 --- a/fluentinterface/pom.xml +++ b/fluentinterface/pom.xml @@ -2,7 +2,7 @@ - + diff --git a/mute-idiom/src/main/java/com/iluwatar/mute/App.java b/mute-idiom/src/main/java/com/iluwatar/mute/App.java index c35559dcd97f..f8ac25f5c42c 100644 --- a/mute-idiom/src/main/java/com/iluwatar/mute/App.java +++ b/mute-idiom/src/main/java/com/iluwatar/mute/App.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - package com.iluwatar.mute; import org.slf4j.Logger; diff --git a/mute-idiom/src/main/java/com/iluwatar/mute/CheckedRunnable.java b/mute-idiom/src/main/java/com/iluwatar/mute/CheckedRunnable.java index 7a37ef03dfe0..9a3feefc1033 100644 --- a/mute-idiom/src/main/java/com/iluwatar/mute/CheckedRunnable.java +++ b/mute-idiom/src/main/java/com/iluwatar/mute/CheckedRunnable.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - package com.iluwatar.mute; /** diff --git a/mute-idiom/src/main/java/com/iluwatar/mute/Mute.java b/mute-idiom/src/main/java/com/iluwatar/mute/Mute.java index d5d9b802849f..6c2c417017ae 100644 --- a/mute-idiom/src/main/java/com/iluwatar/mute/Mute.java +++ b/mute-idiom/src/main/java/com/iluwatar/mute/Mute.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/mute-idiom/src/main/java/com/iluwatar/mute/Resource.java b/mute-idiom/src/main/java/com/iluwatar/mute/Resource.java index 11bb3a6ec875..366f014b4fba 100644 --- a/mute-idiom/src/main/java/com/iluwatar/mute/Resource.java +++ b/mute-idiom/src/main/java/com/iluwatar/mute/Resource.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - package com.iluwatar.mute; import java.io.Closeable; diff --git a/mute-idiom/src/test/java/com/iluwatar/mute/AppTest.java b/mute-idiom/src/test/java/com/iluwatar/mute/AppTest.java index 31624c99449b..8d2299492197 100644 --- a/mute-idiom/src/test/java/com/iluwatar/mute/AppTest.java +++ b/mute-idiom/src/test/java/com/iluwatar/mute/AppTest.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - package com.iluwatar.mute; import org.junit.jupiter.api.Test; diff --git a/mute-idiom/src/test/java/com/iluwatar/mute/MuteTest.java b/mute-idiom/src/test/java/com/iluwatar/mute/MuteTest.java index 07498645e83c..9d946810fee0 100644 --- a/mute-idiom/src/test/java/com/iluwatar/mute/MuteTest.java +++ b/mute-idiom/src/test/java/com/iluwatar/mute/MuteTest.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - package com.iluwatar.mute; import org.junit.jupiter.api.Test; diff --git a/mutex/pom.xml b/mutex/pom.xml index 2075fb4a2462..05f9295eead8 100644 --- a/mutex/pom.xml +++ b/mutex/pom.xml @@ -2,7 +2,7 @@ + 4.0.0 diff --git a/naked-objects/dom/src/main/java/META-INF/persistence.xml b/naked-objects/dom/src/main/java/META-INF/persistence.xml index 8824aa1ace92..fd916b0456bd 100644 --- a/naked-objects/dom/src/main/java/META-INF/persistence.xml +++ b/naked-objects/dom/src/main/java/META-INF/persistence.xml @@ -1,21 +1,27 @@ - + 4.0.0 diff --git a/naked-objects/fixture/src/main/java/domainapp/fixture/DomainAppFixturesProvider.java b/naked-objects/fixture/src/main/java/domainapp/fixture/DomainAppFixturesProvider.java index ccc11f2b8ece..4496d2e32dd2 100644 --- a/naked-objects/fixture/src/main/java/domainapp/fixture/DomainAppFixturesProvider.java +++ b/naked-objects/fixture/src/main/java/domainapp/fixture/DomainAppFixturesProvider.java @@ -1,16 +1,24 @@ -/* - * 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. +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * 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 domainapp.fixture; diff --git a/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectCreate.java b/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectCreate.java index 58b656a9816f..89eadad31f0c 100644 --- a/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectCreate.java +++ b/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectCreate.java @@ -1,18 +1,25 @@ -/* - * 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 +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * 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: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * 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. + * 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 domainapp.fixture.modules.simple; import org.apache.isis.applib.fixturescripts.FixtureScript; diff --git a/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectsTearDown.java b/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectsTearDown.java index c0319d95383e..a5092c2ec70e 100644 --- a/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectsTearDown.java +++ b/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectsTearDown.java @@ -1,18 +1,25 @@ -/* - * 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 +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * 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: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * 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. + * 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 domainapp.fixture.modules.simple; import org.apache.isis.applib.fixturescripts.FixtureScript; diff --git a/naked-objects/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java b/naked-objects/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java index be891158a0d7..33e5570a6063 100644 --- a/naked-objects/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java +++ b/naked-objects/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java @@ -1,18 +1,25 @@ -/* - * 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 +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * 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: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * 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. + * 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 domainapp.fixture.scenarios; import java.util.Arrays; diff --git a/naked-objects/integtests/pom.xml b/naked-objects/integtests/pom.xml index 7365a71a9acb..62d25df032c9 100644 --- a/naked-objects/integtests/pom.xml +++ b/naked-objects/integtests/pom.xml @@ -1,14 +1,28 @@ - + 4.0.0 diff --git a/naked-objects/integtests/src/test/java/domainapp/integtests/bootstrap/SimpleAppSystemInitializer.java b/naked-objects/integtests/src/test/java/domainapp/integtests/bootstrap/SimpleAppSystemInitializer.java index 3ac5a1d75f2e..d5f0cd55265a 100644 --- a/naked-objects/integtests/src/test/java/domainapp/integtests/bootstrap/SimpleAppSystemInitializer.java +++ b/naked-objects/integtests/src/test/java/domainapp/integtests/bootstrap/SimpleAppSystemInitializer.java @@ -1,16 +1,24 @@ -/* - * 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 +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * 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: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * 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. + * 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 domainapp.integtests.bootstrap; diff --git a/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/BootstrappingGlue.java b/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/BootstrappingGlue.java index e41399fdd7d8..b53e88af0c0e 100644 --- a/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/BootstrappingGlue.java +++ b/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/BootstrappingGlue.java @@ -1,16 +1,24 @@ /** - * O * 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 + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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: * - * 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. + * 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 domainapp.integtests.specglue; diff --git a/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/CatalogOfFixturesGlue.java b/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/CatalogOfFixturesGlue.java index 7a75a038139f..acc1485eca51 100644 --- a/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/CatalogOfFixturesGlue.java +++ b/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/CatalogOfFixturesGlue.java @@ -1,16 +1,24 @@ /** - * 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 + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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: * - * 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. + * 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 domainapp.integtests.specglue; diff --git a/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java b/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java index b7af9f05232d..6c98b008c462 100644 --- a/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java +++ b/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/modules/simple/SimpleObjectGlue.java @@ -1,16 +1,24 @@ /** - * 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 + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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: * - * 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. + * 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 domainapp.integtests.specglue.modules.simple; diff --git a/naked-objects/integtests/src/test/java/domainapp/integtests/specs/RunSpecs.java b/naked-objects/integtests/src/test/java/domainapp/integtests/specs/RunSpecs.java index 8a842a0f3140..8f197985d6b5 100644 --- a/naked-objects/integtests/src/test/java/domainapp/integtests/specs/RunSpecs.java +++ b/naked-objects/integtests/src/test/java/domainapp/integtests/specs/RunSpecs.java @@ -1,16 +1,24 @@ /** - * 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 + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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: * - * 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. + * 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 domainapp.integtests.specs; diff --git a/naked-objects/integtests/src/test/java/domainapp/integtests/tests/SimpleAppIntegTest.java b/naked-objects/integtests/src/test/java/domainapp/integtests/tests/SimpleAppIntegTest.java index 66deaeb84034..0db09fceb69f 100644 --- a/naked-objects/integtests/src/test/java/domainapp/integtests/tests/SimpleAppIntegTest.java +++ b/naked-objects/integtests/src/test/java/domainapp/integtests/tests/SimpleAppIntegTest.java @@ -1,20 +1,24 @@ -/* - * 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 +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * 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: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * 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. + * 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 domainapp.integtests.tests; diff --git a/naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java b/naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java index 3d9009bf88af..0fc7c8f0b0e1 100644 --- a/naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java +++ b/naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectIntegTest.java @@ -1,20 +1,24 @@ -/* - * 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 +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * 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: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * 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. + * 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 domainapp.integtests.tests.modules.simple; diff --git a/naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectsIntegTest.java b/naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectsIntegTest.java index 168d4865a574..a150bdb5a726 100644 --- a/naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectsIntegTest.java +++ b/naked-objects/integtests/src/test/java/domainapp/integtests/tests/modules/simple/SimpleObjectsIntegTest.java @@ -1,20 +1,24 @@ -/* - * 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 +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * 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: * - * http://www.apache.org/licenses/LICENSE-2.0 + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * 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. + * 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 domainapp.integtests.tests.modules.simple; diff --git a/naked-objects/pom.xml b/naked-objects/pom.xml index 271a07705589..b035c3894058 100644 --- a/naked-objects/pom.xml +++ b/naked-objects/pom.xml @@ -1,14 +1,28 @@ - + 4.0.0 diff --git a/naked-objects/webapp/ide/intellij/launch/README.txt b/naked-objects/webapp/ide/intellij/launch/README.txt index 6659454efdbe..2977f3068716 100644 --- a/naked-objects/webapp/ide/intellij/launch/README.txt +++ b/naked-objects/webapp/ide/intellij/launch/README.txt @@ -1,6 +1,6 @@ ==== The MIT License - Copyright (c) 2014-2016 Ilkka Seppälä + Copyright © 2014-2019 Ilkka Seppälä Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/naked-objects/webapp/ide/intellij/launch/SimpleApp_PROTOTYPE.xml b/naked-objects/webapp/ide/intellij/launch/SimpleApp_PROTOTYPE.xml index 9831f9a1f7bf..c27b5fbdd00a 100644 --- a/naked-objects/webapp/ide/intellij/launch/SimpleApp_PROTOTYPE.xml +++ b/naked-objects/webapp/ide/intellij/launch/SimpleApp_PROTOTYPE.xml @@ -1,7 +1,7 @@ + 4.0.0 diff --git a/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java b/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java index 459e4b7de9e0..cf15632faf53 100644 --- a/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java +++ b/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java @@ -1,16 +1,24 @@ -/* - * 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. +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * + * 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 domainapp.webapp; diff --git a/naked-objects/webapp/src/main/resources/domainapp/webapp/welcome.html b/naked-objects/webapp/src/main/resources/domainapp/webapp/welcome.html index a87d67384a9f..e81389640efc 100644 --- a/naked-objects/webapp/src/main/resources/domainapp/webapp/welcome.html +++ b/naked-objects/webapp/src/main/resources/domainapp/webapp/welcome.html @@ -1,21 +1,27 @@

Apache Isis™ is a platform to let you rapidly develop diff --git a/naked-objects/webapp/src/main/webapp/WEB-INF/isis.properties b/naked-objects/webapp/src/main/webapp/WEB-INF/isis.properties index 929d1775a8b9..2ebd42968626 100644 --- a/naked-objects/webapp/src/main/webapp/WEB-INF/isis.properties +++ b/naked-objects/webapp/src/main/webapp/WEB-INF/isis.properties @@ -1,19 +1,25 @@ -# 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. +# +# The MIT License +# Copyright © 2014-2019 Ilkka Seppälä +# +# 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/naked-objects/webapp/src/main/webapp/WEB-INF/persistor.properties b/naked-objects/webapp/src/main/webapp/WEB-INF/persistor.properties index c73af73c78d4..594b97edec95 100644 --- a/naked-objects/webapp/src/main/webapp/WEB-INF/persistor.properties +++ b/naked-objects/webapp/src/main/webapp/WEB-INF/persistor.properties @@ -1,19 +1,25 @@ -# 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. +# +# The MIT License +# Copyright © 2014-2019 Ilkka Seppälä +# +# 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/naked-objects/webapp/src/main/webapp/WEB-INF/persistor_datanucleus.properties b/naked-objects/webapp/src/main/webapp/WEB-INF/persistor_datanucleus.properties index 675ced3bf8c0..572b2e194c95 100644 --- a/naked-objects/webapp/src/main/webapp/WEB-INF/persistor_datanucleus.properties +++ b/naked-objects/webapp/src/main/webapp/WEB-INF/persistor_datanucleus.properties @@ -1,19 +1,25 @@ -# 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. +# +# The MIT License +# Copyright © 2014-2019 Ilkka Seppälä +# +# 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. +# # # configuration file for the JDO/DataNucleus objectstore diff --git a/naked-objects/webapp/src/main/webapp/WEB-INF/viewer_restfulobjects.properties b/naked-objects/webapp/src/main/webapp/WEB-INF/viewer_restfulobjects.properties index 0a85fb681bc9..34f639a549fd 100644 --- a/naked-objects/webapp/src/main/webapp/WEB-INF/viewer_restfulobjects.properties +++ b/naked-objects/webapp/src/main/webapp/WEB-INF/viewer_restfulobjects.properties @@ -1,19 +1,25 @@ -# 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. +# +# The MIT License +# Copyright © 2014-2019 Ilkka Seppälä +# +# 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. +# # # configuration file for the Restful Objects viewer diff --git a/naked-objects/webapp/src/main/webapp/WEB-INF/viewer_wicket.properties b/naked-objects/webapp/src/main/webapp/WEB-INF/viewer_wicket.properties index ba9eaaffb873..b52c7fa6e42e 100644 --- a/naked-objects/webapp/src/main/webapp/WEB-INF/viewer_wicket.properties +++ b/naked-objects/webapp/src/main/webapp/WEB-INF/viewer_wicket.properties @@ -1,19 +1,25 @@ -# 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. +# +# The MIT License +# Copyright © 2014-2019 Ilkka Seppälä +# +# 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. +# # # configuration file for the Wicket viewer diff --git a/naked-objects/webapp/src/main/webapp/WEB-INF/web.xml b/naked-objects/webapp/src/main/webapp/WEB-INF/web.xml index bb6098f0bcfa..6a3ecd65dfdc 100644 --- a/naked-objects/webapp/src/main/webapp/WEB-INF/web.xml +++ b/naked-objects/webapp/src/main/webapp/WEB-INF/web.xml @@ -1,21 +1,27 @@ + * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/page-object/src/test/java/com/iluwatar/pageobject/AlbumPageTest.java b/page-object/src/test/java/com/iluwatar/pageobject/AlbumPageTest.java index 4b567fcad2ed..9f8419be1af7 100644 --- a/page-object/src/test/java/com/iluwatar/pageobject/AlbumPageTest.java +++ b/page-object/src/test/java/com/iluwatar/pageobject/AlbumPageTest.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/page-object/src/test/java/com/iluwatar/pageobject/LoginPageTest.java b/page-object/src/test/java/com/iluwatar/pageobject/LoginPageTest.java index 59f69552bc22..911ee5769656 100644 --- a/page-object/src/test/java/com/iluwatar/pageobject/LoginPageTest.java +++ b/page-object/src/test/java/com/iluwatar/pageobject/LoginPageTest.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/page-object/src/test/java/com/iluwatar/pageobject/pages/AlbumListPage.java b/page-object/src/test/java/com/iluwatar/pageobject/pages/AlbumListPage.java index d212b33f301a..20673c8779dd 100644 --- a/page-object/src/test/java/com/iluwatar/pageobject/pages/AlbumListPage.java +++ b/page-object/src/test/java/com/iluwatar/pageobject/pages/AlbumListPage.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/page-object/src/test/java/com/iluwatar/pageobject/pages/AlbumPage.java b/page-object/src/test/java/com/iluwatar/pageobject/pages/AlbumPage.java index 7d2318257930..e33ffc4af32a 100644 --- a/page-object/src/test/java/com/iluwatar/pageobject/pages/AlbumPage.java +++ b/page-object/src/test/java/com/iluwatar/pageobject/pages/AlbumPage.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/page-object/src/test/java/com/iluwatar/pageobject/pages/LoginPage.java b/page-object/src/test/java/com/iluwatar/pageobject/pages/LoginPage.java index b648dfdafc36..843a5e1dc433 100644 --- a/page-object/src/test/java/com/iluwatar/pageobject/pages/LoginPage.java +++ b/page-object/src/test/java/com/iluwatar/pageobject/pages/LoginPage.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/page-object/src/test/java/com/iluwatar/pageobject/pages/Page.java b/page-object/src/test/java/com/iluwatar/pageobject/pages/Page.java index f292588d2951..fbdc1b28c7be 100644 --- a/page-object/src/test/java/com/iluwatar/pageobject/pages/Page.java +++ b/page-object/src/test/java/com/iluwatar/pageobject/pages/Page.java @@ -1,17 +1,17 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä - *

+ * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/page-object/test-automation/pom.xml b/page-object/test-automation/pom.xml index f657a8dab0b6..5b275084c4cf 100644 --- a/page-object/test-automation/pom.xml +++ b/page-object/test-automation/pom.xml @@ -2,7 +2,7 @@ @@ -25,7 +30,7 @@ java-design-patterns 1.22.0-SNAPSHOT pom - 2014 + 2014-2019 UTF-8 5.2.18.Final diff --git a/priority-queue/pom.xml b/priority-queue/pom.xml index aaf172ef3953..3e5ac50e81ab 100644 --- a/priority-queue/pom.xml +++ b/priority-queue/pom.xml @@ -2,7 +2,7 @@ - 4.0.0 diff --git a/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/App.java b/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/App.java index 42335f313f1c..2ee3fa948845 100644 --- a/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/App.java +++ b/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/App.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - package com.iluwatar.reader.writer.lock; import java.util.concurrent.ExecutorService; diff --git a/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/Reader.java b/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/Reader.java index b0ccecabadaf..3bc46c4524f7 100644 --- a/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/Reader.java +++ b/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/Reader.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/ReaderWriterLock.java b/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/ReaderWriterLock.java index f0f5a009040a..d35703801c67 100644 --- a/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/ReaderWriterLock.java +++ b/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/ReaderWriterLock.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/Writer.java b/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/Writer.java index dc379eef97ba..4aa5ab5a9571 100644 --- a/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/Writer.java +++ b/reader-writer-lock/src/main/java/com/iluwatar/reader/writer/lock/Writer.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/AppTest.java b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/AppTest.java index fbdf3f846a97..8815e6c8e451 100644 --- a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/AppTest.java +++ b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/AppTest.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderAndWriterTest.java b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderAndWriterTest.java index c8de8c511b55..d190dfb9ef4c 100644 --- a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderAndWriterTest.java +++ b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderAndWriterTest.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - package com.iluwatar.reader.writer.lock; import com.iluwatar.reader.writer.lock.utils.InMemoryAppender; diff --git a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderTest.java b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderTest.java index 8fe5912ea3a5..d49a472e05a8 100644 --- a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderTest.java +++ b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderTest.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/WriterTest.java b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/WriterTest.java index bb01e11b09eb..55a8b7f95685 100644 --- a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/WriterTest.java +++ b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/WriterTest.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/utils/InMemoryAppender.java b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/utils/InMemoryAppender.java index b8ad531ce856..c6b8319d2a5d 100644 --- a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/utils/InMemoryAppender.java +++ b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/utils/InMemoryAppender.java @@ -1,6 +1,6 @@ /** * The MIT License - * Copyright (c) 2014-2016 Ilkka Seppälä + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/repository/pom.xml b/repository/pom.xml index f0340f1260ef..906389282945 100644 --- a/repository/pom.xml +++ b/repository/pom.xml @@ -2,7 +2,7 @@ 4.0.0 diff --git a/retry/src/main/java/com/iluwatar/retry/App.java b/retry/src/main/java/com/iluwatar/retry/App.java index 20205bdf3973..76ec43363525 100644 --- a/retry/src/main/java/com/iluwatar/retry/App.java +++ b/retry/src/main/java/com/iluwatar/retry/App.java @@ -1,27 +1,25 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Ilkka Seppälä - * +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * * 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 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. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ - package com.iluwatar.retry; import org.slf4j.Logger; diff --git a/retry/src/main/java/com/iluwatar/retry/BusinessException.java b/retry/src/main/java/com/iluwatar/retry/BusinessException.java index eefbf2813cbf..d88aa8a105b7 100644 --- a/retry/src/main/java/com/iluwatar/retry/BusinessException.java +++ b/retry/src/main/java/com/iluwatar/retry/BusinessException.java @@ -1,27 +1,25 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Ilkka Seppälä - * +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * * 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 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. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ - package com.iluwatar.retry; /** diff --git a/retry/src/main/java/com/iluwatar/retry/BusinessOperation.java b/retry/src/main/java/com/iluwatar/retry/BusinessOperation.java index aefb589c79c3..37846f54d751 100644 --- a/retry/src/main/java/com/iluwatar/retry/BusinessOperation.java +++ b/retry/src/main/java/com/iluwatar/retry/BusinessOperation.java @@ -1,27 +1,25 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Ilkka Seppälä - * +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * * 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 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. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ - package com.iluwatar.retry; /** diff --git a/retry/src/main/java/com/iluwatar/retry/CustomerNotFoundException.java b/retry/src/main/java/com/iluwatar/retry/CustomerNotFoundException.java index 596d8584d67b..990229ebed04 100644 --- a/retry/src/main/java/com/iluwatar/retry/CustomerNotFoundException.java +++ b/retry/src/main/java/com/iluwatar/retry/CustomerNotFoundException.java @@ -1,27 +1,25 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Ilkka Seppälä - * +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * * 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 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. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ - package com.iluwatar.retry; /** diff --git a/retry/src/main/java/com/iluwatar/retry/DatabaseNotAvailableException.java b/retry/src/main/java/com/iluwatar/retry/DatabaseNotAvailableException.java index 2a93e992d333..be78a9e6fd8b 100644 --- a/retry/src/main/java/com/iluwatar/retry/DatabaseNotAvailableException.java +++ b/retry/src/main/java/com/iluwatar/retry/DatabaseNotAvailableException.java @@ -1,27 +1,25 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Ilkka Seppälä - * +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * * 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 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. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ - package com.iluwatar.retry; /** diff --git a/retry/src/main/java/com/iluwatar/retry/FindCustomer.java b/retry/src/main/java/com/iluwatar/retry/FindCustomer.java index 421f450e59f1..83ab9a25c3f4 100644 --- a/retry/src/main/java/com/iluwatar/retry/FindCustomer.java +++ b/retry/src/main/java/com/iluwatar/retry/FindCustomer.java @@ -1,27 +1,25 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Ilkka Seppälä - * +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * * 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 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. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ - package com.iluwatar.retry; import java.util.ArrayDeque; diff --git a/retry/src/main/java/com/iluwatar/retry/Retry.java b/retry/src/main/java/com/iluwatar/retry/Retry.java index da5c76d5d3ac..d5d16bf30e62 100644 --- a/retry/src/main/java/com/iluwatar/retry/Retry.java +++ b/retry/src/main/java/com/iluwatar/retry/Retry.java @@ -1,27 +1,25 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Ilkka Seppälä - * +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * * 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 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. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ - package com.iluwatar.retry; import java.util.ArrayList; diff --git a/retry/src/main/java/com/iluwatar/retry/RetryExponentialBackoff.java b/retry/src/main/java/com/iluwatar/retry/RetryExponentialBackoff.java index b24bebbce192..551914dad138 100644 --- a/retry/src/main/java/com/iluwatar/retry/RetryExponentialBackoff.java +++ b/retry/src/main/java/com/iluwatar/retry/RetryExponentialBackoff.java @@ -1,7 +1,6 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Ilkka Seppälä +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -10,18 +9,17 @@ * 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 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. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ - package com.iluwatar.retry; import java.util.ArrayList; diff --git a/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java b/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java index 5c0cc66ed36b..d1cd87b21772 100644 --- a/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java +++ b/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java @@ -1,27 +1,25 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Ilkka Seppälä - * +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * * 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 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. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ - package com.iluwatar.retry; import org.junit.jupiter.api.Test; diff --git a/retry/src/test/java/com/iluwatar/retry/RetryExponentialBackoffTest.java b/retry/src/test/java/com/iluwatar/retry/RetryExponentialBackoffTest.java index d14b1eef68a6..23fd8add732c 100644 --- a/retry/src/test/java/com/iluwatar/retry/RetryExponentialBackoffTest.java +++ b/retry/src/test/java/com/iluwatar/retry/RetryExponentialBackoffTest.java @@ -1,7 +1,6 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Ilkka Seppälä +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -10,18 +9,17 @@ * 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 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. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ - package com.iluwatar.retry; import org.junit.jupiter.api.Test; diff --git a/retry/src/test/java/com/iluwatar/retry/RetryTest.java b/retry/src/test/java/com/iluwatar/retry/RetryTest.java index d435c7e84331..5366b525bc1e 100644 --- a/retry/src/test/java/com/iluwatar/retry/RetryTest.java +++ b/retry/src/test/java/com/iluwatar/retry/RetryTest.java @@ -1,27 +1,25 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014-2016 Ilkka Seppälä - * +/** + * The MIT License + * Copyright © 2014-2019 Ilkka Seppälä + * * 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 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. + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. */ - package com.iluwatar.retry; import org.junit.jupiter.api.Test; diff --git a/semaphore/pom.xml b/semaphore/pom.xml index 3761e5e49a8f..1ae865f02442 100644 --- a/semaphore/pom.xml +++ b/semaphore/pom.xml @@ -2,7 +2,7 @@ + * Copyright © 2014-2019 Ilkka Seppälä + * * 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 diff --git a/service-layer/pom.xml b/service-layer/pom.xml index 057a701341a7..31fc6f625b68 100644 --- a/service-layer/pom.xml +++ b/service-layer/pom.xml @@ -2,7 +2,7 @@ - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.jacoco - - jacoco-maven-plugin - - - [0.6.2,) - - - prepare-agent - - - - - - - - - - org.apache.maven.plugins maven-compiler-plugin @@ -410,20 +379,6 @@ - - org.jacoco - jacoco-maven-plugin - ${jacoco.version} - - - prepare-agent - - prepare-agent - - - - - @@ -471,6 +426,27 @@ + + + org.jacoco + jacoco-maven-plugin + ${jacoco.version} + + + prepare-agent + + prepare-agent + + + + report + + report + + + + + From cfdfedbd2e2ed4b140c0f82e6322d335a1e4f39d Mon Sep 17 00:00:00 2001 From: Joshua Jimenez Date: Mon, 14 Oct 2019 04:41:11 +0800 Subject: [PATCH 22/30] #970 single logging framework should be enforced (#982) * #496 Add pipeline module to parent pom :sparkles: * #496: Add main application class and test for pipeline * #496: Checkstyle format and add log messages on pipeline stages :art: * #496: Fill readme sections of pipeline :sparkles: * #496: Javadocs and checkstyle formatting :art: * #496: Follow PMD checks and add more explanation as block comment on App.java * #496: Apply requested PR changes by iluwatar :art: * #970: Replace log4j usage on commander pattern to Slf4j API :art: * #970: Replace log4j usage on dao pattern to Slf4j API :art: * #970: Replace log4j usage on data mapper pattern to Slf4j API :art: * #970: Remove log4j dependency on data transfer object pom :fire: * #970: Replace log4j usage on module pattern to Slf4j API :art: * #970: Replace log4j usage on serverless pattern to Slf4j API :art: This also removes the aws log4j dependency * #970: Remove unnecessary gitignore line for log4j.xml :fire: * #970: Remove remaining remnants of log4j :fire: * #970: Replace System.out logging with appropriate logging methods :art: * #970: Replace System.out method references to Logger::info :art: --- .gitignore | 1 - .../iluwatar/collectionpipeline/AppTest.java | 7 ++- commander/pom.xml | 5 -- commander/properties/log4j.properties | 41 ---------------- .../com/iluwatar/commander/Commander.java | 19 +++---- .../messagingservice/MessagingService.java | 5 +- .../main/java/com/iluwatar/converter/App.java | 14 ++++-- dao/pom.xml | 49 ------------------- dao/src/main/java/com/iluwatar/dao/App.java | 9 ++-- .../java/com/iluwatar/dao/DbCustomerDao.java | 7 +-- dao/src/main/resources/log4j.xml | 41 ---------------- data-mapper/pom.xml | 4 -- .../java/com/iluwatar/datamapper/App.java | 7 +-- data-mapper/src/main/resources/log4j.xml | 41 ---------------- data-transfer-object/pom.xml | 4 -- .../main/java/com/iluwatar/dirtyflag/App.java | 9 +++- .../com/iluwatar/dirtyflag/DataFetcher.java | 8 ++- .../java/com/iluwatar/event/queue/App.java | 7 ++- .../administration/ConsoleAdministration.java | 2 +- .../hexagonal/service/ConsoleLottery.java | 2 +- .../service/LotteryConsoleServiceImpl.java | 2 +- .../java/com/iluwatar/masterworker/App.java | 8 +-- .../masterworker/ArrayUtilityMethods.java | 10 ++-- module/pom.xml | 4 -- .../iluwatar/module/ConsoleLoggerModule.java | 7 +-- .../com/iluwatar/module/FileLoggerModule.java | 7 +-- module/src/main/resources/log4j.xml | 41 ---------------- .../iluwatar/module/FileLoggerModuleTest.java | 5 +- naked-objects/dom/exclude-pmd.properties | 24 --------- naked-objects/dom/pom.xml | 1 - .../bootstrap/SimpleAppSystemInitializer.java | 1 - .../specglue/BootstrappingGlue.java | 1 - .../integtests/tests/SimpleAppIntegTest.java | 1 - naked-objects/webapp/pom.xml | 20 -------- .../domainapp/webapp/SimpleApplication.java | 5 +- .../ConvertToCharArrayHandler.java | 4 +- .../RemoveAlphabetsHandler.java | 4 +- .../RemoveDigitsHandler.java | 4 +- pom.xml | 7 --- serverless/pom.xml | 5 -- .../baas/api/FindPersonApiHandler.java | 11 +++-- .../baas/api/SavePersonApiHandler.java | 5 +- .../faas/api/LambdaInfoApiHandler.java | 7 ++- .../src/main/resources/log4j.properties | 29 ----------- .../com/iluwatar/spatialpartition/App.java | 14 ++++-- .../com/iluwatar/spatialpartition/Bubble.java | 6 ++- tls/src/main/java/com/iluwatar/tls/App.java | 15 ++++-- .../com/iluwatar/tls/DateFormatCallable.java | 9 +++- .../java/com/iluwatar/typeobject/App.java | 17 ++++--- .../com/iluwatar/typeobject/CandyGame.java | 17 ++++--- 50 files changed, 163 insertions(+), 410 deletions(-) delete mode 100644 commander/properties/log4j.properties delete mode 100644 dao/src/main/resources/log4j.xml delete mode 100644 data-mapper/src/main/resources/log4j.xml delete mode 100644 module/src/main/resources/log4j.xml delete mode 100644 naked-objects/dom/exclude-pmd.properties delete mode 100644 serverless/src/main/resources/log4j.properties diff --git a/.gitignore b/.gitignore index fd0bb7810faf..ada1e7d10ce5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,4 @@ datanucleus.log /bin/ /bin/ *.log -data-mapper/src/main/resources/log4j.xml event-sourcing/Journal.json diff --git a/collection-pipeline/src/test/java/com/iluwatar/collectionpipeline/AppTest.java b/collection-pipeline/src/test/java/com/iluwatar/collectionpipeline/AppTest.java index 83756985fe06..938cce195a27 100644 --- a/collection-pipeline/src/test/java/com/iluwatar/collectionpipeline/AppTest.java +++ b/collection-pipeline/src/test/java/com/iluwatar/collectionpipeline/AppTest.java @@ -30,12 +30,15 @@ import java.util.Map; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Tests that Collection Pipeline methods work as expected. */ public class AppTest { - + private static final Logger LOGGER = LoggerFactory.getLogger(AppTest.class); + private List cars = CarFactory.createCars(); @Test @@ -61,7 +64,7 @@ public void testGetGroupingOfCarsByCategory() { new Car("Jeep", "Comanche", 1990, Category.JEEP))); Map> modelsFunctional = FunctionalProgramming.getGroupingOfCarsByCategory(cars); Map> modelsImperative = ImperativeProgramming.getGroupingOfCarsByCategory(cars); - System.out.println("Category " + modelsFunctional); + LOGGER.info("Category " + modelsFunctional); assertEquals(modelsExpected, modelsFunctional); assertEquals(modelsExpected, modelsImperative); } diff --git a/commander/pom.xml b/commander/pom.xml index 4db6b12e7e06..fbe45337707e 100644 --- a/commander/pom.xml +++ b/commander/pom.xml @@ -36,10 +36,5 @@ junit-jupiter-engine test - - log4j - log4j - 1.2.17 - diff --git a/commander/properties/log4j.properties b/commander/properties/log4j.properties deleted file mode 100644 index 6569015544ba..000000000000 --- a/commander/properties/log4j.properties +++ /dev/null @@ -1,41 +0,0 @@ -# -# The MIT License -# Copyright © 2014-2019 Ilkka Seppälä -# -# 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. -# - -#Define root logger options -log4j.rootLogger=TRACE, file, console - -#Define console appender -log4j.appender.console=org.apache.log4j.ConsoleAppender -logrj.appender.console.Target=System.out -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd} %d{HH:mm:ss} %5p[%t] %m%n - -#Define rolling file appender -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.File=/log/logFile.log -log4j.appender.file.Append=true -log4j.appender.file.ImmediateFlush=true -log4j.appender.file.MaxFileSize=10MB -log4j.appender.file.MaxBackupIndex=5 -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d %d{HH:mm:ss} %5p[%t] %m%n diff --git a/commander/src/main/java/com/iluwatar/commander/Commander.java b/commander/src/main/java/com/iluwatar/commander/Commander.java index 8729ea75aeef..dee12df1cee8 100644 --- a/commander/src/main/java/com/iluwatar/commander/Commander.java +++ b/commander/src/main/java/com/iluwatar/commander/Commander.java @@ -23,7 +23,6 @@ package com.iluwatar.commander; import java.util.ArrayList; -import org.apache.log4j.Logger; import com.iluwatar.commander.employeehandle.EmployeeHandle; import com.iluwatar.commander.exceptions.DatabaseUnavailableException; import com.iluwatar.commander.exceptions.ItemUnavailableException; @@ -37,6 +36,8 @@ import com.iluwatar.commander.queue.QueueTask; import com.iluwatar.commander.queue.QueueTask.TaskType; import com.iluwatar.commander.shippingservice.ShippingService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

Commander pattern is used to handle all issues that can come up while making a @@ -86,7 +87,7 @@ public class Commander { private final long messageTime; private final long employeeTime; private boolean finalSiteMsgShown; - static final Logger LOG = Logger.getLogger(Commander.class); + static final Logger LOG = LoggerFactory.getLogger(Commander.class); //we could also have another db where it stores all orders Commander(EmployeeHandle empDb, PaymentService pService, ShippingService sService, @@ -125,27 +126,27 @@ private void sendShippingRequest(Order order) throws Exception { String transactionId = shippingService.receiveRequest(order.item, order.user.address); //could save this transaction id in a db too LOG.info("Order " + order.id + ": Shipping placed successfully, transaction id: " + transactionId); - System.out.println("Order has been placed and will be shipped to you. Please wait while we make your" + LOG.info("Order has been placed and will be shipped to you. Please wait while we make your" + " payment... "); sendPaymentRequest(order); return; }; Retry.HandleErrorIssue handleError = (o,err) -> { if (ShippingNotPossibleException.class.isAssignableFrom(err.getClass())) { - System.out.println("Shipping is currently not possible to your address. We are working on the problem " + LOG.info("Shipping is currently not possible to your address. We are working on the problem " + "and will get back to you asap."); finalSiteMsgShown = true; LOG.info("Order " + order.id + ": Shipping not possible to address, trying to add problem to employee db.."); employeeHandleIssue(o); } else if (ItemUnavailableException.class.isAssignableFrom(err.getClass())) { - System.out.println("This item is currently unavailable. We will inform you as soon as the item becomes " + LOG.info("This item is currently unavailable. We will inform you as soon as the item becomes " + "available again."); finalSiteMsgShown = true; LOG.info("Order " + order.id + ": Item " + order.item + " unavailable, trying to add problem to employee " + "handle.."); employeeHandleIssue(o); } else { - System.out.println("Sorry, there was a problem in creating your order. Please try later."); + LOG.info("Sorry, there was a problem in creating your order. Please try later."); LOG.error("Order " + order.id + ": Shipping service unavailable, order not placed.."); finalSiteMsgShown = true; } @@ -183,7 +184,7 @@ public void run() { order.paid = PaymentStatus.Done; LOG.info("Order " + order.id + ": Payment successful, transaction Id: " + transactionId); if (!finalSiteMsgShown) { - System.out.println("Payment made successfully, thank you for shopping with us!!"); + LOG.info("Payment made successfully, thank you for shopping with us!!"); finalSiteMsgShown = true; } sendSuccessMessage(order); @@ -193,7 +194,7 @@ public void run() { Retry.HandleErrorIssue handleError = (o,err) -> { if (PaymentDetailsErrorException.class.isAssignableFrom(err.getClass())) { if (!finalSiteMsgShown) { - System.out.println("There was an error in payment. Your account/card details may have been incorrect. " + LOG.info("There was an error in payment. Your account/card details may have been incorrect. " + "Meanwhile, your order has been converted to COD and will be shipped."); finalSiteMsgShown = true; } @@ -204,7 +205,7 @@ public void run() { try { if (o.messageSent.equals(MessageSent.NoneSent)) { if (!finalSiteMsgShown) { - System.out.println("There was an error in payment. We are on it, and will get back to you " + LOG.info("There was an error in payment. We are on it, and will get back to you " + "asap. Don't worry, your order has been placed and will be shipped."); finalSiteMsgShown = true; } diff --git a/commander/src/main/java/com/iluwatar/commander/messagingservice/MessagingService.java b/commander/src/main/java/com/iluwatar/commander/messagingservice/MessagingService.java index 27c1eee3f1f2..5023cfa1faa2 100644 --- a/commander/src/main/java/com/iluwatar/commander/messagingservice/MessagingService.java +++ b/commander/src/main/java/com/iluwatar/commander/messagingservice/MessagingService.java @@ -24,6 +24,8 @@ import com.iluwatar.commander.Service; import com.iluwatar.commander.exceptions.DatabaseUnavailableException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The MessagingService is used to send messages to user regarding their order and @@ -32,6 +34,7 @@ */ public class MessagingService extends Service { + private static final Logger LOGGER = LoggerFactory.getLogger(MessagingService.class); enum MessageToSend { PaymentFail, PaymentTrying, PaymentSuccessful @@ -74,7 +77,7 @@ protected String updateDb(Object...parameters) throws DatabaseUnavailableExcepti MessageRequest req = (MessageRequest) parameters[0]; if (this.database.get(req.reqId) == null) { //idempotence, in case db fails here database.add(req); //if successful: - System.out.println(sendMessage(req.msg)); + LOGGER.info(sendMessage(req.msg)); return req.reqId; } return null; diff --git a/converter/src/main/java/com/iluwatar/converter/App.java b/converter/src/main/java/com/iluwatar/converter/App.java index 7d0821c5b501..b21d4dd6afe8 100644 --- a/converter/src/main/java/com/iluwatar/converter/App.java +++ b/converter/src/main/java/com/iluwatar/converter/App.java @@ -24,6 +24,8 @@ import com.google.common.collect.Lists; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; @@ -35,6 +37,8 @@ * objects between types. */ public class App { + + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); /** * Program entry point * @@ -45,16 +49,16 @@ public static void main(String[] args) { UserDto dtoUser = new UserDto("John", "Doe", true, "whatever[at]wherever.com"); User user = userConverter.convertFromDto(dtoUser); - System.out.println("Entity converted from DTO:" + user); + LOGGER.info("Entity converted from DTO:" + user); ArrayList users = Lists.newArrayList(new User("Camile", "Tough", false, "124sad"), new User("Marti", "Luther", true, "42309fd"), new User("Kate", "Smith", true, "if0243")); - System.out.println("Domain entities:"); - users.forEach(System.out::println); + LOGGER.info("Domain entities:"); + users.stream().map(User::toString).forEach(LOGGER::info); - System.out.println("DTO entities converted from domain:"); + LOGGER.info("DTO entities converted from domain:"); List dtoEntities = userConverter.createFromEntities(users); - dtoEntities.forEach(System.out::println); + dtoEntities.stream().map(UserDto::toString).forEach(LOGGER::info); } } diff --git a/dao/pom.xml b/dao/pom.xml index b8453f6a574d..5d6bc94546fa 100644 --- a/dao/pom.xml +++ b/dao/pom.xml @@ -40,10 +40,6 @@ junit-jupiter-engine test - - log4j - log4j - com.h2database h2 @@ -53,49 +49,4 @@ mockito-core - - - - - - - - src/main/resources - - - src/main/resources - - log4j.xml - - .. - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.6 - - - log4j.xml - - - - true - - - - - - - diff --git a/dao/src/main/java/com/iluwatar/dao/App.java b/dao/src/main/java/com/iluwatar/dao/App.java index 5824d48cfea6..08d0a42bda3d 100644 --- a/dao/src/main/java/com/iluwatar/dao/App.java +++ b/dao/src/main/java/com/iluwatar/dao/App.java @@ -31,8 +31,9 @@ import javax.sql.DataSource; -import org.apache.log4j.Logger; import org.h2.jdbcx.JdbcDataSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Data Access Object (DAO) is an object that provides an abstract interface to some type of @@ -50,7 +51,7 @@ */ public class App { private static final String DB_URL = "jdbc:h2:~/dao"; - private static Logger log = Logger.getLogger(App.class); + private static Logger log = LoggerFactory.getLogger(App.class); private static final String ALL_CUSTOMERS = "customerDao.getAllCustomers(): "; /** @@ -94,7 +95,7 @@ private static void performOperationsUsing(final CustomerDao customerDao) throws addCustomers(customerDao); log.info(ALL_CUSTOMERS); try (Stream customerStream = customerDao.getAll()) { - customerStream.forEach((customer) -> log.info(customer)); + customerStream.forEach((customer) -> log.info(customer.toString())); } log.info("customerDao.getCustomerById(2): " + customerDao.getById(2)); final Customer customer = new Customer(4, "Dan", "Danson"); @@ -105,7 +106,7 @@ private static void performOperationsUsing(final CustomerDao customerDao) throws customerDao.update(customer); log.info(ALL_CUSTOMERS); try (Stream customerStream = customerDao.getAll()) { - customerStream.forEach((cust) -> log.info(cust)); + customerStream.forEach((cust) -> log.info(cust.toString())); } customerDao.delete(customer); log.info(ALL_CUSTOMERS + customerDao.getAll()); diff --git a/dao/src/main/java/com/iluwatar/dao/DbCustomerDao.java b/dao/src/main/java/com/iluwatar/dao/DbCustomerDao.java index 9d183e91284e..d8640dcb911d 100644 --- a/dao/src/main/java/com/iluwatar/dao/DbCustomerDao.java +++ b/dao/src/main/java/com/iluwatar/dao/DbCustomerDao.java @@ -22,6 +22,9 @@ */ package com.iluwatar.dao; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -35,15 +38,13 @@ import javax.sql.DataSource; -import org.apache.log4j.Logger; - /** * An implementation of {@link CustomerDao} that persists customers in RDBMS. * */ public class DbCustomerDao implements CustomerDao { - private static final Logger LOGGER = Logger.getLogger(DbCustomerDao.class); + private static final Logger LOGGER = LoggerFactory.getLogger(DbCustomerDao.class); private final DataSource dataSource; diff --git a/dao/src/main/resources/log4j.xml b/dao/src/main/resources/log4j.xml deleted file mode 100644 index 5c7e49d51a98..000000000000 --- a/dao/src/main/resources/log4j.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/data-mapper/pom.xml b/data-mapper/pom.xml index cf53fdf65814..7da70f8fd243 100644 --- a/data-mapper/pom.xml +++ b/data-mapper/pom.xml @@ -37,9 +37,5 @@ junit-jupiter-engine test - - log4j - log4j - diff --git a/data-mapper/src/main/java/com/iluwatar/datamapper/App.java b/data-mapper/src/main/java/com/iluwatar/datamapper/App.java index 3504ebbe1c94..6b1d9925333f 100644 --- a/data-mapper/src/main/java/com/iluwatar/datamapper/App.java +++ b/data-mapper/src/main/java/com/iluwatar/datamapper/App.java @@ -22,9 +22,10 @@ */ package com.iluwatar.datamapper; -import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import org.apache.log4j.Logger; +import java.util.Optional; /** * The Data Mapper (DM) is a layer of software that separates the in-memory objects from the @@ -39,7 +40,7 @@ */ public final class App { - private static Logger log = Logger.getLogger(App.class); + private static Logger log = LoggerFactory.getLogger(App.class); private static final String STUDENT_STRING = "App.main(), student : "; diff --git a/data-mapper/src/main/resources/log4j.xml b/data-mapper/src/main/resources/log4j.xml deleted file mode 100644 index 5c7e49d51a98..000000000000 --- a/data-mapper/src/main/resources/log4j.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/data-transfer-object/pom.xml b/data-transfer-object/pom.xml index 20c8a52f6c0a..ebdb15afa3dd 100644 --- a/data-transfer-object/pom.xml +++ b/data-transfer-object/pom.xml @@ -37,9 +37,5 @@ junit-jupiter-engine test - - log4j - log4j - diff --git a/dirty-flag/src/main/java/com/iluwatar/dirtyflag/App.java b/dirty-flag/src/main/java/com/iluwatar/dirtyflag/App.java index af95b57bca88..e5368bc3a5a6 100644 --- a/dirty-flag/src/main/java/com/iluwatar/dirtyflag/App.java +++ b/dirty-flag/src/main/java/com/iluwatar/dirtyflag/App.java @@ -22,6 +22,9 @@ */ package com.iluwatar.dirtyflag; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -48,6 +51,8 @@ * when needed. {@link World} mainly serves the data to the front-end. */ public class App { + + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); /** * Program execution point */ @@ -59,9 +64,9 @@ public void run() { @Override public void run() { List countries = world.fetch(); - System.out.println("Our world currently has the following countries:-"); + LOGGER.info("Our world currently has the following countries:-"); for (String country : countries) { - System.out.println("\t" + country); + LOGGER.info("\t" + country); } } }, 0, 15, TimeUnit.SECONDS); // Run at every 15 seconds. diff --git a/dirty-flag/src/main/java/com/iluwatar/dirtyflag/DataFetcher.java b/dirty-flag/src/main/java/com/iluwatar/dirtyflag/DataFetcher.java index 3b91ccd7debb..eca422a86165 100644 --- a/dirty-flag/src/main/java/com/iluwatar/dirtyflag/DataFetcher.java +++ b/dirty-flag/src/main/java/com/iluwatar/dirtyflag/DataFetcher.java @@ -22,6 +22,10 @@ */ package com.iluwatar.dirtyflag; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.xml.crypto.Data; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -37,6 +41,8 @@ */ public class DataFetcher { + private static final Logger LOGGER = LoggerFactory.getLogger(DataFetcher.class); + private final String filename = "world.txt"; private long lastFetched; @@ -62,7 +68,7 @@ public List fetch() { File file = new File(classLoader.getResource(filename).getFile()); if (isDirty(file.lastModified())) { - System.out.println(filename + " is dirty! Re-fetching file content..."); + LOGGER.info(filename + " is dirty! Re-fetching file content..."); List data = new ArrayList(); try (BufferedReader br = new BufferedReader(new FileReader(file))) { diff --git a/event-queue/src/main/java/com/iluwatar/event/queue/App.java b/event-queue/src/main/java/com/iluwatar/event/queue/App.java index 88cc0bf570ae..87ad78ae6d40 100644 --- a/event-queue/src/main/java/com/iluwatar/event/queue/App.java +++ b/event-queue/src/main/java/com/iluwatar/event/queue/App.java @@ -22,6 +22,9 @@ */ package com.iluwatar.event.queue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -39,6 +42,8 @@ * items from the queue at a later time. */ public class App { + + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); /** * Program entry point. * @@ -51,7 +56,7 @@ public static void main(String[] args) throws UnsupportedAudioFileException, IOE audio.playSound(audio.getAudioStream("./etc/Bass-Drum-1.wav"), -10.0f); audio.playSound(audio.getAudioStream("./etc/Closed-Hi-Hat-1.wav"), -8.0f); - System.out.println("Press Enter key to stop the program..."); + LOGGER.info("Press Enter key to stop the program..."); try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { br.read(); } diff --git a/hexagonal/src/main/java/com/iluwatar/hexagonal/administration/ConsoleAdministration.java b/hexagonal/src/main/java/com/iluwatar/hexagonal/administration/ConsoleAdministration.java index f2aa6d681ba5..4d51710b9d04 100644 --- a/hexagonal/src/main/java/com/iluwatar/hexagonal/administration/ConsoleAdministration.java +++ b/hexagonal/src/main/java/com/iluwatar/hexagonal/administration/ConsoleAdministration.java @@ -81,7 +81,7 @@ private static void printMainMenu() { } private static String readString(Scanner scanner) { - System.out.print("> "); + LOGGER.info("> "); return scanner.next(); } } diff --git a/hexagonal/src/main/java/com/iluwatar/hexagonal/service/ConsoleLottery.java b/hexagonal/src/main/java/com/iluwatar/hexagonal/service/ConsoleLottery.java index 583bf348fc7e..3a41e1ef322f 100644 --- a/hexagonal/src/main/java/com/iluwatar/hexagonal/service/ConsoleLottery.java +++ b/hexagonal/src/main/java/com/iluwatar/hexagonal/service/ConsoleLottery.java @@ -82,7 +82,7 @@ private static void printMainMenu() { } private static String readString(Scanner scanner) { - System.out.print("> "); + LOGGER.info("> "); return scanner.next(); } } diff --git a/hexagonal/src/main/java/com/iluwatar/hexagonal/service/LotteryConsoleServiceImpl.java b/hexagonal/src/main/java/com/iluwatar/hexagonal/service/LotteryConsoleServiceImpl.java index 17f5f1a9bc09..d61ec9108156 100644 --- a/hexagonal/src/main/java/com/iluwatar/hexagonal/service/LotteryConsoleServiceImpl.java +++ b/hexagonal/src/main/java/com/iluwatar/hexagonal/service/LotteryConsoleServiceImpl.java @@ -122,7 +122,7 @@ public void queryLotteryAccountFunds(WireTransfers bank, Scanner scanner) { } private String readString(Scanner scanner) { - System.out.print( "> " ); + logger.info( "> " ); return scanner.next(); } } diff --git a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/App.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/App.java index ce1f7b625653..46c0baf8d16c 100644 --- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/App.java +++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/App.java @@ -23,6 +23,8 @@ package com.iluwatar.masterworker; import com.iluwatar.masterworker.system.ArrayTransposeMasterWorker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

The Master-Worker pattern is used when the problem at hand can be solved by dividing into @@ -45,7 +47,8 @@ */ public class App { - + + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); /** * Program entry point. * @param args command line args @@ -60,10 +63,9 @@ public static void main(String[] args) { ArrayResult result = (ArrayResult) mw.getResult(input); if (result != null) { ArrayUtilityMethods.printMatrix(inputMatrix); - System.out.println(""); ArrayUtilityMethods.printMatrix(result.data); } else { - System.out.println("Please enter non-zero input"); + LOGGER.info("Please enter non-zero input"); } } diff --git a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayUtilityMethods.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayUtilityMethods.java index e3125abe8032..fb27e5b486a4 100644 --- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayUtilityMethods.java +++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayUtilityMethods.java @@ -22,6 +22,9 @@ */ package com.iluwatar.masterworker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Random; /** @@ -29,7 +32,8 @@ */ public class ArrayUtilityMethods { - + + private static final Logger LOGGER = LoggerFactory.getLogger(ArrayUtilityMethods.class); /** * Method arraysSame compares 2 arrays @param a1 and @param a2 * and @return whether their values are equal (boolean). @@ -100,9 +104,9 @@ public static void printMatrix(int[][] matrix) { //prints out int[][] for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[0].length; j++) { - System.out.print(matrix[i][j] + " "); + LOGGER.info(matrix[i][j] + " "); } - System.out.println(""); + LOGGER.info(""); } } diff --git a/module/pom.xml b/module/pom.xml index 920efc01c9da..0a60960b53c6 100644 --- a/module/pom.xml +++ b/module/pom.xml @@ -37,9 +37,5 @@ junit-jupiter-engine test - - log4j - log4j - diff --git a/module/src/main/java/com/iluwatar/module/ConsoleLoggerModule.java b/module/src/main/java/com/iluwatar/module/ConsoleLoggerModule.java index 6ab358777f6e..12eaae1d9be4 100644 --- a/module/src/main/java/com/iluwatar/module/ConsoleLoggerModule.java +++ b/module/src/main/java/com/iluwatar/module/ConsoleLoggerModule.java @@ -22,9 +22,10 @@ */ package com.iluwatar.module; -import java.io.PrintStream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import org.apache.log4j.Logger; +import java.io.PrintStream; /** * The ConsoleLoggerModule is responsible for showing logs on System Console @@ -34,7 +35,7 @@ */ public final class ConsoleLoggerModule { - private static final Logger LOGGER = Logger.getLogger(ConsoleLoggerModule.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleLoggerModule.class); private static ConsoleLoggerModule singleton = null; diff --git a/module/src/main/java/com/iluwatar/module/FileLoggerModule.java b/module/src/main/java/com/iluwatar/module/FileLoggerModule.java index 1ec85ea47547..65f954b6cccd 100644 --- a/module/src/main/java/com/iluwatar/module/FileLoggerModule.java +++ b/module/src/main/java/com/iluwatar/module/FileLoggerModule.java @@ -22,12 +22,13 @@ */ package com.iluwatar.module; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; -import org.apache.log4j.Logger; - /** * The FileLoggerModule is responsible for showing logs on File System *

@@ -36,7 +37,7 @@ */ public final class FileLoggerModule { - private static final Logger LOGGER = Logger.getLogger(FileLoggerModule.class); + private static final Logger LOGGER = LoggerFactory.getLogger(FileLoggerModule.class); private static FileLoggerModule singleton = null; diff --git a/module/src/main/resources/log4j.xml b/module/src/main/resources/log4j.xml deleted file mode 100644 index 5c7e49d51a98..000000000000 --- a/module/src/main/resources/log4j.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/module/src/test/java/com/iluwatar/module/FileLoggerModuleTest.java b/module/src/test/java/com/iluwatar/module/FileLoggerModuleTest.java index 5f7616f02321..30f0baae5703 100644 --- a/module/src/test/java/com/iluwatar/module/FileLoggerModuleTest.java +++ b/module/src/test/java/com/iluwatar/module/FileLoggerModuleTest.java @@ -22,8 +22,9 @@ */ package com.iluwatar.module; -import org.apache.log4j.Logger; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.BufferedReader; import java.io.FileNotFoundException; @@ -45,7 +46,7 @@ */ public final class FileLoggerModuleTest { - private static final Logger LOGGER = Logger.getLogger(FileLoggerModuleTest.class); + private static final Logger LOGGER = LoggerFactory.getLogger(FileLoggerModuleTest.class); private static final String OUTPUT_FILE = "output.txt"; private static final String ERROR_FILE = "error.txt"; diff --git a/naked-objects/dom/exclude-pmd.properties b/naked-objects/dom/exclude-pmd.properties deleted file mode 100644 index e281170f75a4..000000000000 --- a/naked-objects/dom/exclude-pmd.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# The MIT License -# Copyright © 2014-2019 Ilkka Seppälä -# -# 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. -# - -domainapp.dom.modules.simple.QSimpleObject=UnusedFormalParameter \ No newline at end of file diff --git a/naked-objects/dom/pom.xml b/naked-objects/dom/pom.xml index b8a04a53bb24..2709edda03f4 100644 --- a/naked-objects/dom/pom.xml +++ b/naked-objects/dom/pom.xml @@ -143,7 +143,6 @@ ${datanucleus-maven-plugin.version} false - ${basedir}/log4j.properties true ${basedir}/datanucleus.properties diff --git a/naked-objects/integtests/src/test/java/domainapp/integtests/bootstrap/SimpleAppSystemInitializer.java b/naked-objects/integtests/src/test/java/domainapp/integtests/bootstrap/SimpleAppSystemInitializer.java index d5f0cd55265a..930a805d5fe2 100644 --- a/naked-objects/integtests/src/test/java/domainapp/integtests/bootstrap/SimpleAppSystemInitializer.java +++ b/naked-objects/integtests/src/test/java/domainapp/integtests/bootstrap/SimpleAppSystemInitializer.java @@ -49,7 +49,6 @@ public static void initIsft() { private static class SimpleAppSystemBuilder extends IsisSystemForTest.Builder { public SimpleAppSystemBuilder() { - withLoggingAt(org.apache.log4j.Level.INFO); with(testConfiguration()); with(new DataNucleusPersistenceMechanismInstaller()); diff --git a/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/BootstrappingGlue.java b/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/BootstrappingGlue.java index b53e88af0c0e..4b22615ecc96 100644 --- a/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/BootstrappingGlue.java +++ b/naked-objects/integtests/src/test/java/domainapp/integtests/specglue/BootstrappingGlue.java @@ -36,7 +36,6 @@ public class BootstrappingGlue extends CukeGlueAbstract { @Before(value = {"@integration"}, order = 100) public void beforeScenarioIntegrationScope() { - org.apache.log4j.PropertyConfigurator.configure("logging.properties"); SimpleAppSystemInitializer.initIsft(); before(ScenarioExecutionScope.INTEGRATION); diff --git a/naked-objects/integtests/src/test/java/domainapp/integtests/tests/SimpleAppIntegTest.java b/naked-objects/integtests/src/test/java/domainapp/integtests/tests/SimpleAppIntegTest.java index 0db09fceb69f..0c19714253ba 100644 --- a/naked-objects/integtests/src/test/java/domainapp/integtests/tests/SimpleAppIntegTest.java +++ b/naked-objects/integtests/src/test/java/domainapp/integtests/tests/SimpleAppIntegTest.java @@ -36,7 +36,6 @@ public abstract class SimpleAppIntegTest extends IntegrationTestAbstract { @BeforeClass public static void initClass() { - org.apache.log4j.PropertyConfigurator.configure("logging.properties"); SimpleAppSystemInitializer.initIsft(); // instantiating will install onto ThreadLocal diff --git a/naked-objects/webapp/pom.xml b/naked-objects/webapp/pom.xml index e26c5f5610ad..e0697b855b31 100644 --- a/naked-objects/webapp/pom.xml +++ b/naked-objects/webapp/pom.xml @@ -216,26 +216,6 @@ hsqldb - - - - - - - org.lazyluke - log4jdbc-remix - - - org.slf4j - slf4j-api - - - - - junit junit diff --git a/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java b/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java index cf15632faf53..875212963b67 100644 --- a/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java +++ b/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java @@ -50,6 +50,8 @@ import de.agilecoders.wicket.core.settings.IBootstrapSettings; import de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchTheme; import de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchThemeProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -72,6 +74,7 @@ */ public class SimpleApplication extends IsisWicketApplication { + private static final Logger LOGGER = LoggerFactory.getLogger(SimpleApplication.class); private static final long serialVersionUID = 1L; /** @@ -124,7 +127,7 @@ public WebRequest newWebRequest(HttpServletRequest servletRequest, String filter servletRequest.getSession().invalidate(); } } catch (Exception e) { - System.out.println(e); + LOGGER.error(e.getMessage()); } return super.newWebRequest(servletRequest, filterPath); } diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/ConvertToCharArrayHandler.java b/pipeline/src/main/java/com.iluwatar.pipeline/ConvertToCharArrayHandler.java index 3e8df8eefe3f..6a418fef4cf1 100644 --- a/pipeline/src/main/java/com.iluwatar.pipeline/ConvertToCharArrayHandler.java +++ b/pipeline/src/main/java/com.iluwatar.pipeline/ConvertToCharArrayHandler.java @@ -32,12 +32,12 @@ */ class ConvertToCharArrayHandler implements Handler { - private final Logger logger = LoggerFactory.getLogger(ConvertToCharArrayHandler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ConvertToCharArrayHandler.class); @Override public char[] process(String input) { char[] characters = input.toCharArray(); - logger.info(String.format("Current handler: %s, input is %s of type %s, output is %s, of type %s", + LOGGER.info(String.format("Current handler: %s, input is %s of type %s, output is %s, of type %s", ConvertToCharArrayHandler.class, input, String.class, Arrays.toString(characters), Character[].class)); return characters; diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/RemoveAlphabetsHandler.java b/pipeline/src/main/java/com.iluwatar.pipeline/RemoveAlphabetsHandler.java index 76219249d312..342ed86c23c7 100644 --- a/pipeline/src/main/java/com.iluwatar.pipeline/RemoveAlphabetsHandler.java +++ b/pipeline/src/main/java/com.iluwatar.pipeline/RemoveAlphabetsHandler.java @@ -30,7 +30,7 @@ */ class RemoveAlphabetsHandler implements Handler { - private final Logger logger = LoggerFactory.getLogger(RemoveAlphabetsHandler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(RemoveAlphabetsHandler.class); @Override public String process(String input) { @@ -46,7 +46,7 @@ public String process(String input) { } String inputWithoutAlphabetsStr = inputWithoutAlphabets.toString(); - logger.info(String.format("Current handler: %s, input is %s of type %s, output is %s, of type %s", + LOGGER.info(String.format("Current handler: %s, input is %s of type %s, output is %s, of type %s", RemoveAlphabetsHandler.class, input, String.class, inputWithoutAlphabetsStr, String.class)); return inputWithoutAlphabetsStr; diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/RemoveDigitsHandler.java b/pipeline/src/main/java/com.iluwatar.pipeline/RemoveDigitsHandler.java index d1785c340858..a5320a0a55c4 100644 --- a/pipeline/src/main/java/com.iluwatar.pipeline/RemoveDigitsHandler.java +++ b/pipeline/src/main/java/com.iluwatar.pipeline/RemoveDigitsHandler.java @@ -30,7 +30,7 @@ */ class RemoveDigitsHandler implements Handler { - private final Logger logger = LoggerFactory.getLogger(RemoveDigitsHandler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(RemoveDigitsHandler.class); @Override public String process(String input) { @@ -46,7 +46,7 @@ public String process(String input) { } String inputWithoutDigitsStr = inputWithoutDigits.toString(); - logger.info(String.format("Current handler: %s, input is %s of type %s, output is %s, of type %s", + LOGGER.info(String.format("Current handler: %s, input is %s of type %s, output is %s, of type %s", RemoveDigitsHandler.class, input, String.class, inputWithoutDigitsStr, String.class)); return inputWithoutDigitsStr; diff --git a/pom.xml b/pom.xml index d6cd3a6e60c3..50e7c7de5439 100644 --- a/pom.xml +++ b/pom.xml @@ -56,10 +56,8 @@ 1.2.3 1.1.0 1.11.289 - 1.0.0 2.0.1 2.8.5 - 1.2.17 2.3.1 2.3.2 1.3.2 @@ -304,11 +302,6 @@ mongo-java-driver ${mongo-java-driver.version} - - log4j - log4j - ${log4j.version} - javax.xml.bind jaxb-api diff --git a/serverless/pom.xml b/serverless/pom.xml index 9e142cb3aa30..292df78c55f1 100644 --- a/serverless/pom.xml +++ b/serverless/pom.xml @@ -60,11 +60,6 @@ aws-lambda-java-events ${aws-lambda-java-events.version} - - com.amazonaws - aws-lambda-java-log4j - ${aws-lambda-log4j.version} - com.fasterxml.jackson.core jackson-core diff --git a/serverless/src/main/java/com/iluwatar/serverless/baas/api/FindPersonApiHandler.java b/serverless/src/main/java/com/iluwatar/serverless/baas/api/FindPersonApiHandler.java index 0dac4c614b33..14f2b25a5153 100644 --- a/serverless/src/main/java/com/iluwatar/serverless/baas/api/FindPersonApiHandler.java +++ b/serverless/src/main/java/com/iluwatar/serverless/baas/api/FindPersonApiHandler.java @@ -27,7 +27,10 @@ import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; import com.iluwatar.serverless.baas.model.Person; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; /** * find person from persons collection @@ -36,13 +39,15 @@ public class FindPersonApiHandler extends AbstractDynamoDbHandler implements RequestHandler { - private static final Logger LOG = Logger.getLogger(FindPersonApiHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(FindPersonApiHandler.class); private static final Integer SUCCESS_STATUS_CODE = 200; @Override public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent apiGatewayProxyRequestEvent, Context context) { - LOG.info(apiGatewayProxyRequestEvent.getPathParameters()); + Map pathParameters = apiGatewayProxyRequestEvent.getPathParameters(); + pathParameters.keySet().stream().map(key -> key + "=" + pathParameters.get(key)).forEach(LOG::info); + Person person = this.getDynamoDbMapper().load(Person.class, apiGatewayProxyRequestEvent .getPathParameters().get("id")); diff --git a/serverless/src/main/java/com/iluwatar/serverless/baas/api/SavePersonApiHandler.java b/serverless/src/main/java/com/iluwatar/serverless/baas/api/SavePersonApiHandler.java index d77687d23b1f..8ef4b839ec63 100644 --- a/serverless/src/main/java/com/iluwatar/serverless/baas/api/SavePersonApiHandler.java +++ b/serverless/src/main/java/com/iluwatar/serverless/baas/api/SavePersonApiHandler.java @@ -27,7 +27,8 @@ import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; import com.iluwatar.serverless.baas.model.Person; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; @@ -38,7 +39,7 @@ public class SavePersonApiHandler extends AbstractDynamoDbHandler implements RequestHandler { - private static final Logger LOG = Logger.getLogger(SavePersonApiHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(SavePersonApiHandler.class); private static final Integer CREATED_STATUS_CODE = 201; private static final Integer BAD_REQUEST_STATUS_CODE = 400; diff --git a/serverless/src/main/java/com/iluwatar/serverless/faas/api/LambdaInfoApiHandler.java b/serverless/src/main/java/com/iluwatar/serverless/faas/api/LambdaInfoApiHandler.java index 1157c962cb7c..174e409c35c6 100644 --- a/serverless/src/main/java/com/iluwatar/serverless/faas/api/LambdaInfoApiHandler.java +++ b/serverless/src/main/java/com/iluwatar/serverless/faas/api/LambdaInfoApiHandler.java @@ -27,8 +27,8 @@ import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.RequestHandler; import com.iluwatar.serverless.faas.LambdaInfo; -import org.apache.log4j.BasicConfigurator; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.Map; @@ -39,13 +39,12 @@ */ public class LambdaInfoApiHandler implements RequestHandler, ApiGatewayResponse> { - private static final Logger LOG = Logger.getLogger(LambdaInfoApiHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(LambdaInfoApiHandler.class); private static final Integer SUCCESS_STATUS_CODE = 200; @Override public ApiGatewayResponse handleRequest(Map input, Context context) { - BasicConfigurator.configure(); LOG.info("received: " + input); return new ApiGatewayResponse diff --git a/serverless/src/main/resources/log4j.properties b/serverless/src/main/resources/log4j.properties deleted file mode 100644 index 2c666e2869ad..000000000000 --- a/serverless/src/main/resources/log4j.properties +++ /dev/null @@ -1,29 +0,0 @@ -# -# The MIT License -# Copyright © 2014-2019 Ilkka Seppälä -# -# 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. -# - -log = . -log4j.rootLogger = DEBUG, LAMBDA - -log4j.appender.LAMBDA=com.amazonaws.services.lambda.runtime.log4j.LambdaAppender -log4j.appender.LAMBDA.layout=org.apache.log4j.PatternLayout -log4j.appender.LAMBDA.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} <%X{AWSRequestId}> %-5p %c:%L - %m%n diff --git a/spatial-partition/src/main/java/com/iluwatar/spatialpartition/App.java b/spatial-partition/src/main/java/com/iluwatar/spatialpartition/App.java index 179f11d045f2..f6a07de62f6a 100644 --- a/spatial-partition/src/main/java/com/iluwatar/spatialpartition/App.java +++ b/spatial-partition/src/main/java/com/iluwatar/spatialpartition/App.java @@ -22,6 +22,9 @@ */ package com.iluwatar.spatialpartition; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; @@ -52,6 +55,7 @@ */ public class App { + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); static void noSpatialPartition(int height, int width, int numOfMovements, Hashtable bubbles) { @@ -73,7 +77,7 @@ static void noSpatialPartition(int height, int width, } for (Integer key : bubbles.keySet()) { //bubbles not popped - System.out.println("Bubble " + key + " not popped"); + LOGGER.info("Bubble " + key + " not popped"); } } @@ -101,7 +105,7 @@ static void withSpatialPartition(int height, int width, } for (Integer key : bubbles.keySet()) { //bubbles not popped - System.out.println("Bubble " + key + " not popped"); + LOGGER.info("Bubble " + key + " not popped"); } } @@ -119,7 +123,7 @@ public static void main(String[] args) { Bubble b = new Bubble(rand.nextInt(300), rand.nextInt(300), i, rand.nextInt(2) + 1); bubbles1.put(i, b); bubbles2.put(i, b); - System.out.println("Bubble " + i + " with radius " + b.radius + " added at (" + b.x + "," + b.y + ")"); + LOGGER.info("Bubble " + i + " with radius " + b.radius + " added at (" + b.x + "," + b.y + ")"); } long start1 = System.currentTimeMillis(); @@ -128,8 +132,8 @@ public static void main(String[] args) { long start2 = System.currentTimeMillis(); App.withSpatialPartition(300,300,20,bubbles2); long end2 = System.currentTimeMillis(); - System.out.println("Without spatial partition takes " + (end1 - start1) + "ms"); - System.out.println("With spatial partition takes " + (end2 - start2) + "ms"); + LOGGER.info("Without spatial partition takes " + (end1 - start1) + "ms"); + LOGGER.info("With spatial partition takes " + (end2 - start2) + "ms"); } } diff --git a/spatial-partition/src/main/java/com/iluwatar/spatialpartition/Bubble.java b/spatial-partition/src/main/java/com/iluwatar/spatialpartition/Bubble.java index 3e3d418373ff..01faa8371378 100644 --- a/spatial-partition/src/main/java/com/iluwatar/spatialpartition/Bubble.java +++ b/spatial-partition/src/main/java/com/iluwatar/spatialpartition/Bubble.java @@ -22,6 +22,9 @@ */ package com.iluwatar.spatialpartition; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; import java.util.Hashtable; import java.util.Random; @@ -32,6 +35,7 @@ */ public class Bubble extends Point { + private static final Logger LOGGER = LoggerFactory.getLogger(Bubble.class); final int radius; @@ -54,7 +58,7 @@ boolean touches(Bubble b) { } void pop(Hashtable allBubbles) { - System.out.println("Bubble " + this.id + " popped at (" + this.x + "," + this.y + ")!"); + LOGGER.info("Bubble " + this.id + " popped at (" + this.x + "," + this.y + ")!"); allBubbles.remove(this.id); } diff --git a/tls/src/main/java/com/iluwatar/tls/App.java b/tls/src/main/java/com/iluwatar/tls/App.java index cd216ac75f1e..33f8c312907f 100644 --- a/tls/src/main/java/com/iluwatar/tls/App.java +++ b/tls/src/main/java/com/iluwatar/tls/App.java @@ -22,6 +22,9 @@ */ package com.iluwatar.tls; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Calendar; import java.util.Date; import java.util.concurrent.ExecutorService; @@ -64,6 +67,8 @@ * @author Thomas Bauer, 2017 */ public class App { + + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); /** * Program entry point * @@ -99,11 +104,11 @@ public static void main(String[] args) { // a correct run should deliver 20 times 15.12.2015 // and a correct run shouldn't deliver any exception - System.out.println("The List dateList contains " + counterDateValues + " date values"); - System.out.println("The List exceptionList contains " + counterExceptions + " exceptions"); + LOGGER.info("The List dateList contains " + counterDateValues + " date values"); + LOGGER.info("The List exceptionList contains " + counterExceptions + " exceptions"); } catch (Exception e) { - System.out.println("Abnormal end of program. Program throws exception: " + e); + LOGGER.info("Abnormal end of program. Program throws exception: " + e); } executor.shutdown(); } @@ -121,7 +126,7 @@ private static int printAndCountDates(Result res) { Calendar cal = Calendar.getInstance(); cal.setTime(dt); // Formatted output of the date value: DD.MM.YYYY - System.out.println( + LOGGER.info( cal.get(Calendar.DAY_OF_MONTH) + "." + cal.get(Calendar.MONTH) + "." + +cal.get(Calendar.YEAR)); } return counter; @@ -138,7 +143,7 @@ private static int printAndCountExceptions(Result res) { int counter = 0; for (String ex : res.getExceptionList()) { counter++; - System.out.println(ex); + LOGGER.info(ex); } return counter; } diff --git a/tls/src/main/java/com/iluwatar/tls/DateFormatCallable.java b/tls/src/main/java/com/iluwatar/tls/DateFormatCallable.java index 8018e7996cb9..a047828ce3e6 100644 --- a/tls/src/main/java/com/iluwatar/tls/DateFormatCallable.java +++ b/tls/src/main/java/com/iluwatar/tls/DateFormatCallable.java @@ -22,6 +22,9 @@ */ package com.iluwatar.tls; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.concurrent.Callable; @@ -40,6 +43,8 @@ * @author Thomas Bauer, 2017 */ public class DateFormatCallable implements Callable { + + private static final Logger LOGGER = LoggerFactory.getLogger(DateFormatCallable.class); // class variables (members) private ThreadLocal df; //TLTL // private DateFormat df; //NTLNTL @@ -72,7 +77,7 @@ protected DateFormat initialValue() { //TLTL */ @Override public Result call() { - System.out.println(Thread.currentThread() + " started executing..."); + LOGGER.info(Thread.currentThread() + " started executing..."); Result result = new Result(); // Convert date value to date 5 times @@ -90,7 +95,7 @@ public Result call() { } - System.out.println(Thread.currentThread() + " finished processing part of the thread"); + LOGGER.info(Thread.currentThread() + " finished processing part of the thread"); return result; } diff --git a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/App.java b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/App.java index 93e7a4ea84b9..2e6db9dd68a3 100644 --- a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/App.java +++ b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/App.java @@ -25,6 +25,8 @@ import java.io.FileNotFoundException; import java.io.IOException; import org.json.simple.parser.ParseException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /**

Type object pattern is the pattern we use when the OOP concept of creating a base class and * inheriting from it just doesn't work for the case in hand. This happens when we either don't know @@ -45,6 +47,7 @@ public class App { + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); /** * Program entry point. * @param args command line args @@ -62,9 +65,9 @@ public static void main(String[] args) throws FileNotFoundException, IOException CellPool pool = new CellPool(numOfRows * numOfRows + 5); CandyGame cg = new CandyGame(numOfRows, pool); if (round > 1) { - System.out.println("Refreshing.."); + LOGGER.info("Refreshing.."); } else { - System.out.println("Starting game.."); + LOGGER.info("Starting game.."); } cg.printGameStatus(); end = System.currentTimeMillis(); @@ -72,13 +75,13 @@ public static void main(String[] args) throws FileNotFoundException, IOException pointsWon += cg.totalPoints; end = System.currentTimeMillis(); } - System.out.println("Game Over"); + LOGGER.info("Game Over"); if (pointsWon >= toWin) { - System.out.println(pointsWon); - System.out.println("You win!!"); + LOGGER.info("" + pointsWon); + LOGGER.info("You win!!"); } else { - System.out.println(pointsWon); - System.out.println("Sorry, you lose!"); + LOGGER.info("" + pointsWon); + LOGGER.info("Sorry, you lose!"); } } } diff --git a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CandyGame.java b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CandyGame.java index 200a96f8b9c5..516b4cf76bfd 100644 --- a/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CandyGame.java +++ b/typeobjectpattern/src/main/java/com/iluwatar/typeobject/CandyGame.java @@ -24,6 +24,8 @@ import java.util.ArrayList; import com.iluwatar.typeobject.Candy.Type; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The CandyGame class contains the rules for the continuation of the game and has @@ -31,6 +33,9 @@ */ public class CandyGame { + + private static final Logger LOGGER = LoggerFactory.getLogger(CandyGame.class); + Cell[][] cells; CellPool pool; int totalPoints; @@ -57,21 +62,21 @@ static String numOfSpaces(int num) { } void printGameStatus() { - System.out.println(""); + LOGGER.info(""); for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells.length; j++) { String candyName = cells[i][j].candy.name; if (candyName.length() < 20) { int totalSpaces = 20 - candyName.length(); - System.out.print(numOfSpaces(totalSpaces / 2) + cells[i][j].candy.name + LOGGER.info(numOfSpaces(totalSpaces / 2) + cells[i][j].candy.name + numOfSpaces(totalSpaces - totalSpaces / 2) + "|"); } else { - System.out.print(candyName + "|"); + LOGGER.info(candyName + "|"); } } - System.out.println(""); + LOGGER.info(""); } - System.out.println(""); + LOGGER.info(""); } ArrayList adjacentCells(int yIndex, int xIndex) { @@ -121,7 +126,7 @@ boolean continueRound() { } void handleChange(int points) { - System.out.println("+" + points + " points!"); + LOGGER.info("+" + points + " points!"); this.totalPoints += points; printGameStatus(); } From 47d92bbffb0e75fcbf9ea6d80dec8e15402834f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Mon, 14 Oct 2019 08:17:52 +0300 Subject: [PATCH 23/30] #996 set sonar host url --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6cd971428327..f8d204071a49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ addons: secure: "FpHwMYPMkdWU6CeIB7+O3qIeIM4vJMp47UjkKK53f0w0s6tPZofZZkab+gcL2TqKSil7sFVB/AQXU1cUubflRszwcLbNsc8H2yFehD79o0o0Mqd1Dd5ip/q0KQbHkkln+InFlVLfvrLB4Xd4mlQVxbGhqpULBhXjKzFzQlRFcuU=" script: # the following command line builds the project, runs the tests with coverage and then execute the SonarCloud analysis - - mvn clean verify sonar:sonar -Dsonar.projectKey=iluwatar_java-design-patterns + - mvn clean verify sonar:sonar -Dsonar.projectKey=iluwatar_java-design-patterns -Dsonar.host.url=https://sonarcloud.io after_success: - bash update-ghpages.sh From 088bb764f35ec5d37e58ef1eb66bfce80378db5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20Sepp=C3=A4l=C3=A4?= Date: Mon, 14 Oct 2019 20:25:35 +0300 Subject: [PATCH 24/30] #996 disable sonar analysis for pull requests (#999) --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f8d204071a49..bfb6d8422e29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,8 +18,10 @@ addons: token: secure: "FpHwMYPMkdWU6CeIB7+O3qIeIM4vJMp47UjkKK53f0w0s6tPZofZZkab+gcL2TqKSil7sFVB/AQXU1cUubflRszwcLbNsc8H2yFehD79o0o0Mqd1Dd5ip/q0KQbHkkln+InFlVLfvrLB4Xd4mlQVxbGhqpULBhXjKzFzQlRFcuU=" script: - # the following command line builds the project, runs the tests with coverage and then execute the SonarCloud analysis - - mvn clean verify sonar:sonar -Dsonar.projectKey=iluwatar_java-design-patterns -Dsonar.host.url=https://sonarcloud.io + # Because of Travis security restrictions, SonarCloud analysis cannot be run on pull requests originated from forks + # See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then mvn clean verify; fi' + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then mvn clean verify sonar:sonar -Dsonar.projectKey=iluwatar_java-design-patterns -Dsonar.host.url=https://sonarcloud.io; fi' after_success: - bash update-ghpages.sh From 7e698a90dd7664e119ec0b082883ea48dc12ae2e Mon Sep 17 00:00:00 2001 From: Aditya Pal Date: Tue, 15 Oct 2019 00:02:19 +0530 Subject: [PATCH 25/30] Fix for issue #413: Circuit Breaker Pattern (#986) * Fix Issue #413: Circuit-Breaker Pattern * Fix Image Links * Remove Javadoc plugin to ensure correct build * Implementing code review feedback * Sync README with actual code --- circuit-breaker/README.md | 188 ++++++++++++++++++ circuit-breaker/etc/ServiceDiagram.PNG | Bin 0 -> 24371 bytes circuit-breaker/etc/StateDiagram.PNG | Bin 0 -> 19396 bytes circuit-breaker/pom.xml | 40 ++++ .../java/com/iluwatar/circuitbreaker/App.java | 86 ++++++++ .../circuitbreaker/CircuitBreaker.java | 128 ++++++++++++ .../circuitbreaker/DelayedService.java | 61 ++++++ .../circuitbreaker/MonitoringService.java | 50 +++++ .../com/iluwatar/circuitbreaker/State.java | 33 +++ .../circuitbreaker/CircuitBreakerTest.java | 80 ++++++++ .../circuitbreaker/DelayedServiceTest.java | 42 ++++ .../circuitbreaker/MonitoringServiceTest.java | 63 ++++++ pom.xml | 1 + 13 files changed, 772 insertions(+) create mode 100644 circuit-breaker/README.md create mode 100644 circuit-breaker/etc/ServiceDiagram.PNG create mode 100644 circuit-breaker/etc/StateDiagram.PNG create mode 100644 circuit-breaker/pom.xml create mode 100644 circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/App.java create mode 100644 circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/CircuitBreaker.java create mode 100644 circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/DelayedService.java create mode 100644 circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/MonitoringService.java create mode 100644 circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/State.java create mode 100644 circuit-breaker/src/test/java/com/iluwatar/circuitbreaker/CircuitBreakerTest.java create mode 100644 circuit-breaker/src/test/java/com/iluwatar/circuitbreaker/DelayedServiceTest.java create mode 100644 circuit-breaker/src/test/java/com/iluwatar/circuitbreaker/MonitoringServiceTest.java diff --git a/circuit-breaker/README.md b/circuit-breaker/README.md new file mode 100644 index 000000000000..db75ca58c0d0 --- /dev/null +++ b/circuit-breaker/README.md @@ -0,0 +1,188 @@ +--- +layout: pattern +title: CircuitBreaker +folder: circuit-breaker +permalink: /patterns/circuit-breaker/ +categories: Other +tags: + - Java + - Performance + - Difficulty-Intermediate +--- + +## Intent + +Handle costly remote *procedure/service* calls in such a way that the failure of a **single** service/component cannot bring the whole application down, and we can reconnect to the service as soon as possible. + +## Explanation + +Real world example + +> Imagine a Web App that has both local (example: files and images) and remote (example: database entries) to serve. The database might not be responding due to a variety of reasons, so if the application keeps trying to read from the database using multiple threads/processes, soon all of them will hang and our entire web application will crash. We should be able to detect this situation and show the user an appropriate message so that he/she can explore other parts of the app unaffected by the database failure without any problem. + +In plain words + +> Allows us to save resources when we know a remote service failed. Useful when all parts of our application are highly decoupled from each other, and failure of one component doesn't mean the other parts will stop working. + +Wikipedia says + +> **Circuit breaker** is a design pattern used in modern software development. It is used to detect failures and encapsulates the logic of preventing a failure from constantly recurring, during maintenance, temporary external system failure or unexpected system difficulties. + +So, how does this all come together? + +## Programmatic Example +With the above example in mind we will imitate the functionality in a simple manner. We have two services: A *monitoring service* which will mimic the web app and will make both **local** and **remote** calls. + +The service architecture is as follows: + +![alt text](./etc/ServiceDiagram.PNG "Service Diagram") + +In terms of code, the End user application is: + +```java +public class App { + + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); + + public static void main(String[] args) { + var obj = new MonitoringService(); + var circuitBreaker = new CircuitBreaker(3000, 1, 2000 * 1000 * 1000); + var serverStartTime = System.nanoTime(); + while (true) { + LOGGER.info(obj.localResourceResponse()); + LOGGER.info(obj.remoteResourceResponse(circuitBreaker, serverStartTime)); + LOGGER.info(circuitBreaker.getState()); + try { + Thread.sleep(5 * 1000); + } catch (InterruptedException e) { + LOGGER.error(e.getMessage()); + } + } + } +} +``` + +The monitoring service is: + +``` java +public class MonitoringService { + + public String localResourceResponse() { + return "Local Service is working"; + } + + public String remoteResourceResponse(CircuitBreaker circuitBreaker, long serverStartTime) { + try { + return circuitBreaker.call("delayedService", serverStartTime); + } catch (Exception e) { + return e.getMessage(); + } + } +} +``` +As it can be seen, it does the call to get local resources directly, but it wraps the call to remote (costly) service in a circuit breaker object, which prevents faults as follows: + +```java +public class CircuitBreaker { + private final long timeout; + private final long retryTimePeriod; + long lastFailureTime; + int failureCount; + private final int failureThreshold; + private State state; + private final long futureTime = 1000 * 1000 * 1000 * 1000; + + CircuitBreaker(long timeout, int failureThreshold, long retryTimePeriod) { + this.state = State.CLOSED; + this.failureThreshold = failureThreshold; + this.timeout = timeout; + this.retryTimePeriod = retryTimePeriod; + this.lastFailureTime = System.nanoTime() + futureTime; + this.failureCount = 0; + } + + private void reset() { + this.failureCount = 0; + this.lastFailureTime = System.nanoTime() + futureTime; + this.state = State.CLOSED; + } + + private void recordFailure() { + failureCount = failureCount + 1; + this.lastFailureTime = System.nanoTime(); + } + + protected void setState() { + if (failureCount > failureThreshold) { + if ((System.nanoTime() - lastFailureTime) > retryTimePeriod) { + state = State.HALF_OPEN; + } else { + state = State.OPEN; + } + } else { + state = State.CLOSED; + } + } + + public String getState() { + return state.name(); + } + + public void setStateForBypass(State state) { + this.state = state; + } + + public String call(String serviceToCall, long serverStartTime) throws Exception { + setState(); + if (state == State.OPEN) { + return "This is stale response from API"; + } else { + if (serviceToCall.equals("delayedService")) { + var delayedService = new DelayedService(20); + var response = delayedService.response(serverStartTime); + if (response.split(" ")[3].equals("working")) { + reset(); + return response; + } else { + recordFailure(); + throw new Exception("Remote service not responding"); + } + } else { + throw new Exception("Unknown Service Name"); + } + } + } +} +``` + +How does the above pattern prevent failures? Let's understand via this finite state machine implemented by it. + +![alt text](./etc/StateDiagram.PNG "State Diagram") + +- We initialize the Circuit Breaker object with certain parameters: **timeout**, **failureThreshold** and **retryTimePeriod** which help determine how resilient the API is. +- Initially, we are in the **closed** state and the remote call to API happens. +- Every time the call succeeds, we reset the state to as it was in the beginning. +- If the number of failures cross a certain threshold, we move to the **open** state, which acts just like an open circuit and prevents remote service calls from being made, thus saving resources. (Here, we return the response called ```stale response from API```) +- Once we exceed the retry timeout period, we move to the **half-open** state and make another call to the remote service again to check if the service is working so that we can serve fresh content. A *failure* sets it back to **open** state and another attempt is made after retry timeout period, while a *success* sets it to **closed** state so that everything starts working normally again. + + +## Applicability +Use the Circuit Breaker pattern when + +- Building a fault-tolerant application where failure of some services shouldn't bring the entire application down. +- Building an continuously incremental/continuous delivery application, as some of it's components can be upgraded without shutting it down entirely. + +## Related Patterns + +- [Retry Pattern](https://github.com/iluwatar/java-design-patterns/tree/master/retry) + +## Real world examples +* [Spring Circuit Breaker module](https://spring.io/guides/gs/circuit-breaker) +* [Netflix Hystrix API](https://github.com/Netflix/Hystrix) + +## Credits + +* [Understanding Circuit Breaker Pattern](https://itnext.io/understand-circuitbreaker-design-pattern-with-simple-practical-example-92a752615b42) +* [Martin Fowler on Circuit Breaker](https://martinfowler.com/bliki/CircuitBreaker.html) +* [Fault tolerance in a high volume, distributed system](https://medium.com/netflix-techblog/fault-tolerance-in-a-high-volume-distributed-system-91ab4faae74a) +* [Microsoft docs](https://docs.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker) diff --git a/circuit-breaker/etc/ServiceDiagram.PNG b/circuit-breaker/etc/ServiceDiagram.PNG new file mode 100644 index 0000000000000000000000000000000000000000..661f1a1058181b689b0724418e598f7b5b245c31 GIT binary patch literal 24371 zcmdqJcTf{yxGx+FD4?JMqEssg2&fQ{8nA#$@4bn%K#&%CQ4kRou+c&<0-^U_1Vof7 zB|!)ssi8wCfsp&I=iEDU|Ge|foHOV9!@-a&yV-sBd4BELFby@O)Aa20Fc|Fg<3|s) zV6dZ+;2+ybTJRgn*D_u3D+Y}a>vk&a)HDec-dwAM-%*G8_@5EThANGJFd2zB&uh2}@>o^Q1f9-UTG5A%Aj=cjuFLm}T z`2WX@eAC+KwUgk3kNWWW#!CP3L3`q0A)m}q80^xgGV?%6)PH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me8GN_-&7goiA4ZUDqlgLotM8~CO zf(1Qv_($wIJ+t)4T+(tyEFU7uw)>4|$V~m>KBN(itnrWK4F?pD zgoW^j9jtk%%Q)^$yLH-7wR^Cvi5z|`NOFv|)ZgCw$-olHo_Q+>uBV~bXUt;%856y7 z=ZjGf)t3E;2ah(62^*^q6b#ut9K!XLDHaQrP#~sNAY*x}fa|4BA|~ z%pK{>+z{7%#b(E0o+aSkXSVw4G#%7(INB#mHIBk$ zgr|17k&AlA@kToxF@Z|3gTvDI?>Y&FQW(G5jf9gq{rIe*{7%;PlV^Bq=A{=zkg7cg z8}^mDMA~RHp7dXYL9==!Lo6;dJN-e!^8geG_5q5YPmAAQ5>=0{P&~OWhaLVx4)o?Y zV2ushIUpCb1Kqf%D`6TBZszaUck>zUL-R1^6VIBY20|RqCjIa91Xw}-W77G*G3>xy f{~rf@;7hh$$hypLZIiJA4g^`7+g~AHx{>%lET70d literal 0 HcmV?d00001 diff --git a/circuit-breaker/etc/StateDiagram.PNG b/circuit-breaker/etc/StateDiagram.PNG new file mode 100644 index 0000000000000000000000000000000000000000..38485526d34288bac6d2b0435437c13503f3c567 GIT binary patch literal 19396 zcmeIac|6qr|MxqTmhq7a$=+VbQrTrmNtE3fyOb=$*mnjgBq2#;U$V^@`#KCoMcJ1b zj4fmxLt<=WIIsEqu5+&2?VRh6>wM2SxAV{SM~xXXZ}08(d_5lb=i@a|dO8|xP+lkm z0%6m9aL)h&VeW)Lm|h<{0$w>Q$Gr(2m^=+M)F36@{EOhpVf#DUcOa1RIMzKI7V!MI z+XGWi2;{_9#y_S+(Gz?S$U{@jdv}cdtSIBh)3m7vZEJBS-(ByUgXf$dd3`}&-{8Et zdUMs)jfd*2RCcV^$MTFIJSoBRR;K|Uu90N6@x&zvNx4iF)#n8uZoyk0< z_HhGaft#}m>&lrlC3|Ri%Rk`Ht6D_*sW5>bzTSDv*k$IE$>3QiyB1!{GM;f zVBb7=^OS!lk2m;^rn)vcMny%{_^mxL#|Kp7*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E@c&?7ymEH+S+dhjHybrub1hg2vbu5TRELOJ!h_2)QNkc) zjr73URE4^bKOQ1KlVffuIxF0EjuI0USURIlR9Z^DG>CpCYJ4fOR(ad6z+g6@P`kM- zaH(#wb0{gmnd!0XVY^>hupcSZ`hEmnR%%w?j;G#6*V>vEr%V=DCj{}E%eo$mY+u`a zV4E@_v!UernAaS+t~<47+LX4Xd?-h#^~|kFkJ;9>ZM^OJ%mUFhX%vcC7&n?P;y8hy zczAUj8U0bYwW16esOe~ERc`V9qGie~a-?xT8;!Ghu8!PS%JExzwlVWOj^y3N!*lgGKw;yQ1{EROx zI9uKnT{==~a>GWUQLJ*>h~My#o1V#uj=`E|R(S~SypfvsRPE7w7m~Sg))|=rcXD6* z-9PxODJKd4r;V`2Y9JB$BlDS6b_}n5Fes>Iw_bi(>;1acm3f{O!ehAoMRHX-^o8cyQ|zPcDH*Tre^PH;9P2W* z@pi?J@(N&|KLg=lA>?3tQcJ5{DwkH-O|~U7{DbB{+s}B16EDMuW3{@luhrhBPCk@b zV(D^yK2lzd)rwgHUrXRm^Xt8}`7ZysFRPZ7u=fZIn457p?C9nQrj zFoq+~i_6Kxrie{ou1lq>=>&~@)m*_oK>+3QbN8EJzSjDm{U`;i^@qcWvX;(?QcWN5 zB`<50+=*h1_hBjU%DWNlG0Sm-GkTq|Sfh#HAe;BTZ+@C4oX{8!Yu{_BJg|$vMlX;4 z8H;@+5aM&b^5xAbst(7?Tosj+d1rI?jYMLpCG|aBpe(leHr>cpz+R%%X}p2J#;&>Q z=UVPc{pgf6!!?niFoi_9zmM@~YmAac;7fN9{h>2QAcBITN3%ZbQ@s`f_b-0Cy+701 zkC8b9Ir##_SD^VI^A*rK;Co%NG(k7< re*m`syGH!)bMgOuNwAzSa&YMBspiun?LM!;$03^PI`>M{9*6yJecIR9 literal 0 HcmV?d00001 diff --git a/circuit-breaker/pom.xml b/circuit-breaker/pom.xml new file mode 100644 index 000000000000..b6587b061f7a --- /dev/null +++ b/circuit-breaker/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + + com.iluwatar + java-design-patterns + 1.22.0-SNAPSHOT + + circuit-breaker + + + org.junit.jupiter + junit-jupiter-engine + test + + + diff --git a/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/App.java b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/App.java new file mode 100644 index 000000000000..d1d361b16063 --- /dev/null +++ b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/App.java @@ -0,0 +1,86 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * 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 com.iluwatar.circuitbreaker; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + *

+ * The intention of the Circuit Builder pattern is to handle remote failures + * robustly, which is to mean that if a service is dependant on n number of + * other services, and m of them fail, we should be able to recover from that + * failure by ensuring that the user can still use the services that are actually + * functional, and resources are not tied up by uselessly by the services which + * are not working. However, we should also be able to detect when any of the m + * failing services become operational again, so that we can use it + *

+ *

+ * In this example, the circuit breaker pattern is demonstrated by using two services: + * {@link MonitoringService} and {@link DelayedService}. The monitoring service + * is responsible for calling two services: a local service and a remote service {@link DelayedService} + * , and by using the circuit breaker construction we ensure that if the call to + * remote service is going to fail, we are going to save our resources and not make the + * function call at all, by wrapping our call to the remote service in the circuit + * breaker object. + *

+ *

+ * This works as follows: The {@link CircuitBreaker} object can be in one of three + * states: Open, Closed and Half-Open, which represents the real + * world circuits. If the state is closed (initial), we assume everything is alright + * and perform the function call. However, every time the call fails, we note it + * and once it crosses a threshold, we set the state to Open, preventing any further + * calls to the remote server. Then, after a certain retry period (during which we + * expect thee service to recover), we make another call to the remote server and + * this state is called the Half-Open state, where it stays till the service is down, + * and once it recovers, it goes back to the closed state and the cycle continues. + *

+ */ +public class App { + + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); + + /** + * Program entry point + * + * @param args command line args + */ + public static void main(String[] args) { + //Create an object of monitoring service which makes both local and remote calls + var obj = new MonitoringService(); + //Set the circuit Breaker parameters + var circuitBreaker = new CircuitBreaker(3000, 1, 2000 * 1000 * 1000); + var serverStartTime = System.nanoTime(); + while (true) { + LOGGER.info(obj.localResourceResponse()); + LOGGER.info(obj.remoteResourceResponse(circuitBreaker, serverStartTime)); + LOGGER.info(circuitBreaker.getState()); + try { + Thread.sleep(5 * 1000); + } catch (InterruptedException e) { + LOGGER.error(e.getMessage()); + } + } + } +} diff --git a/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/CircuitBreaker.java b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/CircuitBreaker.java new file mode 100644 index 000000000000..ad014f9fdae0 --- /dev/null +++ b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/CircuitBreaker.java @@ -0,0 +1,128 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * 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 com.iluwatar.circuitbreaker; + +/** + * The circuit breaker class with all configurations + */ +public class CircuitBreaker { + private final long timeout; + private final long retryTimePeriod; + long lastFailureTime; + int failureCount; + private final int failureThreshold; + private State state; + private final long futureTime = 1000 * 1000 * 1000 * 1000; + + /** + * Constructor to create an instance of Circuit Breaker + * @param timeout Timeout for the API request. Not necessary for this simple example + * @param failureThreshold Number of failures we receive from the depended service before changing state to 'OPEN' + * @param retryTimePeriod Time period after which a new request is made to remote service for status check. + */ + CircuitBreaker(long timeout, int failureThreshold, long retryTimePeriod) { + // We start in a closed state hoping that everything is fine + this.state = State.CLOSED; + this.failureThreshold = failureThreshold; + // Timeout for the API request. Used to break the calls made to remote resource if it exceeds the limit + this.timeout = timeout; + this.retryTimePeriod = retryTimePeriod; + //An absurd amount of time in future which basically indicates the last failure never happened + this.lastFailureTime = System.nanoTime() + futureTime; + this.failureCount = 0; + } + + //Reset everything to defaults + private void reset() { + this.failureCount = 0; + this.lastFailureTime = System.nanoTime() + futureTime; + this.state = State.CLOSED; + } + + private void recordFailure() { + failureCount = failureCount + 1; + this.lastFailureTime = System.nanoTime(); + } + + protected void setState() { + if (failureCount > failureThreshold) { //Then something is wrong with remote service + if ((System.nanoTime() - lastFailureTime) > retryTimePeriod) { + //We have waited long enough and should try checking if service is up + state = State.HALF_OPEN; + } else { + //Service would still probably be down + state = State.OPEN; + } + } else { + //Everything is working fine + state = State.CLOSED; + } + } + + public String getState() { + return state.name(); + } + + /** + * Break the circuit beforehand if it is known service is down + * Or connect the circuit manually if service comes online before expected + * @param state State at which circuit is in + */ + public void setStateForBypass(State state) { + this.state = state; + } + + /** + * @param serviceToCall The name of the service in String. Can be changed to data URLs in case of web applications + * @param serverStartTime Time at which actual server was started which makes calls to this service + * @return Value from the remote resource, stale response or a custom exception + */ + public String call(String serviceToCall, long serverStartTime) throws Exception { + setState(); + if (state == State.OPEN) { + // return cached response if no the circuit is in OPEN state + return "This is stale response from API"; + } else { + // Make the API request if the circuit is not OPEN + if (serviceToCall.equals("delayedService")) { + var delayedService = new DelayedService(20); + var response = delayedService.response(serverStartTime); + //In a real application, this would be run in a thread and the timeout + //parameter of the circuit breaker would be utilized to know if service + //is working. Here, we simulate that based on server response itself + if (response.split(" ")[3].equals("working")) { + // Yay!! the API responded fine. Let's reset everything. + reset(); + return response; + } else { + // Uh-oh!! the call still failed. Let's update that in our records. + recordFailure(); + throw new Exception("Remote service not responding"); + } + } else { + throw new Exception("Unknown Service Name"); + } + } + } +} \ No newline at end of file diff --git a/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/DelayedService.java b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/DelayedService.java new file mode 100644 index 000000000000..33217b8e721b --- /dev/null +++ b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/DelayedService.java @@ -0,0 +1,61 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * 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 com.iluwatar.circuitbreaker; + +/** +* This simulates the remote service +* It responds only after a certain timeout period (default set to 20 seconds) +*/ +public class DelayedService { + private final int delay; + + /** + * Constructor to create an instance of DelayedService, which is down for first few seconds + * @param delay the delay after which service would behave properly, in seconds + */ + public DelayedService(int delay) { + this.delay = delay; + } + + public DelayedService() { + this.delay = 60; + } + + /** + * @param serverStartTime Time at which actual server was started which makes calls to this service + * @return The state of the service + */ + public String response(long serverStartTime) { + var currentTime = System.nanoTime(); + //Since currentTime and serverStartTime are both in nanoseconds, we convert it to + //seconds by diving by 10e9 and ensure floating point division by multiplying it + //with 1.0 first. We then check if it is greater or less than specified delay and then + //send the reply + if ((currentTime - serverStartTime) * 1.0 / (1000 * 1000 * 1000) < delay) { + //Can use Thread.sleep() here to block and simulate a hung server + return "Delayed service is down"; + } else { + return "Delayed service is working"; + } + } +} diff --git a/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/MonitoringService.java b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/MonitoringService.java new file mode 100644 index 000000000000..e301ff3ca52b --- /dev/null +++ b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/MonitoringService.java @@ -0,0 +1,50 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * 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 com.iluwatar.circuitbreaker; + +/** + * The service class which makes local and remote calls + * Uses {@link CircuitBreaker} object to ensure remote calls don't use up resources + */ +public class MonitoringService { + + //Assumption: Local service won't fail, no need to wrap it in a circuit breaker logic + public String localResourceResponse() { + return "Local Service is working"; + } + + /** + * Try to get result from remote server + * @param circuitBreaker The circuitBreaker object with all parameters + * @param serverStartTime Time at which actual server was started which makes calls to this service + * @return result from the remote response or exception raised by it. + */ + public String remoteResourceResponse(CircuitBreaker circuitBreaker, long serverStartTime) { + try { + return circuitBreaker.call("delayedService", serverStartTime); + } catch (Exception e) { + return e.getMessage(); + } + } +} \ No newline at end of file diff --git a/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/State.java b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/State.java new file mode 100644 index 000000000000..87982153ccd0 --- /dev/null +++ b/circuit-breaker/src/main/java/com/iluwatar/circuitbreaker/State.java @@ -0,0 +1,33 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * 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 com.iluwatar.circuitbreaker; + +/** + * Enumeration for states the circuit breaker could be in + */ +public enum State { + CLOSED, + OPEN, + HALF_OPEN +} \ No newline at end of file diff --git a/circuit-breaker/src/test/java/com/iluwatar/circuitbreaker/CircuitBreakerTest.java b/circuit-breaker/src/test/java/com/iluwatar/circuitbreaker/CircuitBreakerTest.java new file mode 100644 index 000000000000..5780e9355c58 --- /dev/null +++ b/circuit-breaker/src/test/java/com/iluwatar/circuitbreaker/CircuitBreakerTest.java @@ -0,0 +1,80 @@ +/** + * The MIT License + * Copyright (c) 2014 Ilkka Seppälä + * + * 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 com.iluwatar.circuitbreaker; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + +/** + * + * Circuit Breaker test + * + */ +public class CircuitBreakerTest { + + //long timeout, int failureThreshold, long retryTimePeriod + @Test + public void testSetState() { + var circuitBreaker = new CircuitBreaker(1,1,100); + //Right now, failureCountfailureThreshold, and lastFailureTime is nearly equal to current time, + //state should be half-open + assertEquals(circuitBreaker.getState(), "HALF_OPEN"); + //Since failureCount>failureThreshold, and lastFailureTime is much lesser current time, + //state should be open + circuitBreaker.lastFailureTime = System.nanoTime() - 1000 * 1000 * 1000 * 1000; + circuitBreaker.setState(); + assertEquals(circuitBreaker.getState(), "OPEN"); + //Now set it back again to closed to test idempotency + circuitBreaker.failureCount = 0; + circuitBreaker.setState(); + assertEquals(circuitBreaker.getState(), "CLOSED"); + } + + @Test + public void testSetStateForBypass() { + var circuitBreaker = new CircuitBreaker(1,1,100); + //Right now, failureCountbytecode leader-election data-locality + circuit-breaker From e6c71b63fcfe9b2dd3c98821e8650cac9dd72445 Mon Sep 17 00:00:00 2001 From: Christopher O'Connell Date: Tue, 15 Oct 2019 12:14:08 -0400 Subject: [PATCH 26/30] 988: Replaced all of the Apache HttpClients with Java's java.net.http (#1003) * 988: Took out the apache http component from root pom.xml * 988: Updated the aggregator sub projects to use java.net.http instead of apache * 988: Updated the api-gateway-service sub projects to use java.net.http instead of apache * Applied the code style formatter --- .../aggregator-service/pom.xml | 4 --- .../ProductInformationClientImpl.java | 28 ++++++++--------- .../ProductInventoryClientImpl.java | 29 +++++++++-------- api-gateway/api-gateway-service/pom.xml | 4 --- .../iluwatar/api/gateway/ImageClientImpl.java | 30 +++++++++++------- .../iluwatar/api/gateway/PriceClientImpl.java | 31 ++++++++++++------- pom.xml | 6 ---- 7 files changed, 64 insertions(+), 68 deletions(-) diff --git a/aggregator-microservices/aggregator-service/pom.xml b/aggregator-microservices/aggregator-service/pom.xml index 62695d9e9cba..d6ebc823c307 100644 --- a/aggregator-microservices/aggregator-service/pom.xml +++ b/aggregator-microservices/aggregator-service/pom.xml @@ -53,10 +53,6 @@ mockito-core test - - org.apache.httpcomponents - httpclient - diff --git a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java index 2588fac81e01..b42b5b55a337 100644 --- a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java +++ b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java @@ -22,18 +22,16 @@ */ package com.iluwatar.aggregator.microservices; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import java.io.IOException; - /** * An adapter to communicate with information micro-service. */ @@ -45,15 +43,15 @@ public class ProductInformationClientImpl implements ProductInformationClient { @Override public String getProductTitle() { String response = null; - try (CloseableHttpClient httpClient = HttpClients.createDefault()) { - HttpGet httpGet = new HttpGet("http://localhost:51515/information"); - try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { - response = EntityUtils.toString(httpResponse.getEntity()); - } - } catch (ClientProtocolException cpe) { - LOGGER.error("ClientProtocolException Occured", cpe); + HttpRequest request = HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:51515/information")).build(); + HttpClient client = HttpClient.newHttpClient(); + try { + HttpResponse httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString()); + response = httpResponse.body(); } catch (IOException ioe) { LOGGER.error("IOException Occurred", ioe); + } catch (InterruptedException ie) { + LOGGER.error("InterruptedException Occurred", ie); } return response; } diff --git a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java index 586699f85629..59a050c9e563 100644 --- a/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java +++ b/aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java @@ -22,18 +22,16 @@ */ package com.iluwatar.aggregator.microservices; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import java.io.IOException; - /** * An adapter to communicate with inventory micro-service. */ @@ -45,15 +43,16 @@ public class ProductInventoryClientImpl implements ProductInventoryClient { @Override public int getProductInventories() { String response = "0"; - try (CloseableHttpClient httpClient = HttpClients.createDefault()) { - HttpGet httpGet = new HttpGet("http://localhost:51516/inventories"); - try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { - response = EntityUtils.toString(httpResponse.getEntity()); - } - } catch (ClientProtocolException cpe) { - LOGGER.error("ClientProtocolException Occured", cpe); + + HttpRequest request = HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:51516/inventories")).build(); + HttpClient client = HttpClient.newHttpClient(); + try { + HttpResponse httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString()); + response = httpResponse.body(); } catch (IOException ioe) { LOGGER.error("IOException Occurred", ioe); + } catch (InterruptedException ie) { + LOGGER.error("InterruptedException Occurred", ie); } return Integer.parseInt(response); } diff --git a/api-gateway/api-gateway-service/pom.xml b/api-gateway/api-gateway-service/pom.xml index 8821d6b4f21c..fa3e7286ba85 100644 --- a/api-gateway/api-gateway-service/pom.xml +++ b/api-gateway/api-gateway-service/pom.xml @@ -39,10 +39,6 @@ org.springframework spring-webmvc - - org.apache.httpcomponents - httpclient - org.springframework.boot spring-boot-starter-web diff --git a/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/ImageClientImpl.java b/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/ImageClientImpl.java index e94657a6cd0b..dddd0dc20f60 100644 --- a/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/ImageClientImpl.java +++ b/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/ImageClientImpl.java @@ -22,14 +22,14 @@ */ package com.iluwatar.api.gateway; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; -import org.springframework.stereotype.Component; - import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; + +import org.springframework.stereotype.Component; /** * An adapter to communicate with the Image microservice @@ -38,19 +38,25 @@ public class ImageClientImpl implements ImageClient { /** * Makes a simple HTTP Get request to the Image microservice + * * @return The path to the image */ @Override public String getImagePath() { String response = null; - try (CloseableHttpClient httpClient = HttpClients.createDefault()) { - HttpGet httpGet = new HttpGet("http://localhost:50005/image-path"); - try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { - response = EntityUtils.toString(httpResponse.getEntity()); - } + + HttpClient httpClient = HttpClient.newHttpClient(); + HttpRequest httpGet = HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:50005/image-path")).build(); + + try { + HttpResponse httpResponse = httpClient.send(httpGet, BodyHandlers.ofString()); + response = httpResponse.body(); } catch (IOException e) { e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); } + return response; } } diff --git a/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/PriceClientImpl.java b/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/PriceClientImpl.java index 4a645b809f24..25d7f0b1169c 100644 --- a/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/PriceClientImpl.java +++ b/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/PriceClientImpl.java @@ -22,14 +22,14 @@ */ package com.iluwatar.api.gateway; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; -import org.springframework.stereotype.Component; - import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; + +import org.springframework.stereotype.Component; /** * An adapter to communicate with the Price microservice @@ -38,19 +38,26 @@ public class PriceClientImpl implements PriceClient { /** * Makes a simple HTTP Get request to the Price microservice + * * @return The price of the product */ @Override public String getPrice() { + String response = null; - try (CloseableHttpClient httpClient = HttpClients.createDefault()) { - HttpGet httpGet = new HttpGet("http://localhost:50006/price"); - try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { - response = EntityUtils.toString(httpResponse.getEntity()); - } + + HttpClient httpClient = HttpClient.newHttpClient(); + HttpRequest httpGet = HttpRequest.newBuilder().GET().uri(URI.create("http://localhost:50006/price")).build(); + + try { + HttpResponse httpResponse = httpClient.send(httpGet, BodyHandlers.ofString()); + response = httpResponse.body(); } catch (IOException e) { e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); } + return response; } } diff --git a/pom.xml b/pom.xml index 9e61e716b864..d330bbfcb6cd 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,6 @@ 2.24.0 19.0 1.10.19 - 4.5.10 2.22 4.0 3.3.0 @@ -216,11 +215,6 @@ spring-webmvc ${spring.version} - - org.apache.httpcomponents - httpclient - ${apache-httpcomponents.version} - com.h2database h2 From dd5997b49502495ec5a6b978fa48fe294dac708c Mon Sep 17 00:00:00 2001 From: Christopher O'Connell Date: Tue, 15 Oct 2019 12:21:07 -0400 Subject: [PATCH 27/30] 993: Fixed the pipeines project layout so that it will load in Eclipse (#1004) The source directory was not working in the 2019.09 version of Eclipse. The problem was in the layout of the project: after the src/main/java and src/test/java, the directory was naed com.iluwatar.pipeline. It should've been com/iluwatar/pipeline. This follows the hierarchy of all of the other patterns. Once these files were moved, the Pipeline project compiled without errors. --- .../{com.iluwatar.pipeline => com/iluwatar/pipeline}/App.java | 0 .../iluwatar/pipeline}/ConvertToCharArrayHandler.java | 0 .../{com.iluwatar.pipeline => com/iluwatar/pipeline}/Handler.java | 0 .../iluwatar/pipeline}/Pipeline.java | 0 .../iluwatar/pipeline}/RemoveAlphabetsHandler.java | 0 .../iluwatar/pipeline}/RemoveDigitsHandler.java | 0 .../{com.iluwatar.pipeline => com/iluwatar/pipeline}/AppTest.java | 0 .../iluwatar/pipeline}/PipelineTest.java | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename pipeline/src/main/java/{com.iluwatar.pipeline => com/iluwatar/pipeline}/App.java (100%) rename pipeline/src/main/java/{com.iluwatar.pipeline => com/iluwatar/pipeline}/ConvertToCharArrayHandler.java (100%) rename pipeline/src/main/java/{com.iluwatar.pipeline => com/iluwatar/pipeline}/Handler.java (100%) rename pipeline/src/main/java/{com.iluwatar.pipeline => com/iluwatar/pipeline}/Pipeline.java (100%) rename pipeline/src/main/java/{com.iluwatar.pipeline => com/iluwatar/pipeline}/RemoveAlphabetsHandler.java (100%) rename pipeline/src/main/java/{com.iluwatar.pipeline => com/iluwatar/pipeline}/RemoveDigitsHandler.java (100%) rename pipeline/src/test/java/{com.iluwatar.pipeline => com/iluwatar/pipeline}/AppTest.java (100%) rename pipeline/src/test/java/{com.iluwatar.pipeline => com/iluwatar/pipeline}/PipelineTest.java (100%) diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/App.java b/pipeline/src/main/java/com/iluwatar/pipeline/App.java similarity index 100% rename from pipeline/src/main/java/com.iluwatar.pipeline/App.java rename to pipeline/src/main/java/com/iluwatar/pipeline/App.java diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/ConvertToCharArrayHandler.java b/pipeline/src/main/java/com/iluwatar/pipeline/ConvertToCharArrayHandler.java similarity index 100% rename from pipeline/src/main/java/com.iluwatar.pipeline/ConvertToCharArrayHandler.java rename to pipeline/src/main/java/com/iluwatar/pipeline/ConvertToCharArrayHandler.java diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/Handler.java b/pipeline/src/main/java/com/iluwatar/pipeline/Handler.java similarity index 100% rename from pipeline/src/main/java/com.iluwatar.pipeline/Handler.java rename to pipeline/src/main/java/com/iluwatar/pipeline/Handler.java diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/Pipeline.java b/pipeline/src/main/java/com/iluwatar/pipeline/Pipeline.java similarity index 100% rename from pipeline/src/main/java/com.iluwatar.pipeline/Pipeline.java rename to pipeline/src/main/java/com/iluwatar/pipeline/Pipeline.java diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/RemoveAlphabetsHandler.java b/pipeline/src/main/java/com/iluwatar/pipeline/RemoveAlphabetsHandler.java similarity index 100% rename from pipeline/src/main/java/com.iluwatar.pipeline/RemoveAlphabetsHandler.java rename to pipeline/src/main/java/com/iluwatar/pipeline/RemoveAlphabetsHandler.java diff --git a/pipeline/src/main/java/com.iluwatar.pipeline/RemoveDigitsHandler.java b/pipeline/src/main/java/com/iluwatar/pipeline/RemoveDigitsHandler.java similarity index 100% rename from pipeline/src/main/java/com.iluwatar.pipeline/RemoveDigitsHandler.java rename to pipeline/src/main/java/com/iluwatar/pipeline/RemoveDigitsHandler.java diff --git a/pipeline/src/test/java/com.iluwatar.pipeline/AppTest.java b/pipeline/src/test/java/com/iluwatar/pipeline/AppTest.java similarity index 100% rename from pipeline/src/test/java/com.iluwatar.pipeline/AppTest.java rename to pipeline/src/test/java/com/iluwatar/pipeline/AppTest.java diff --git a/pipeline/src/test/java/com.iluwatar.pipeline/PipelineTest.java b/pipeline/src/test/java/com/iluwatar/pipeline/PipelineTest.java similarity index 100% rename from pipeline/src/test/java/com.iluwatar.pipeline/PipelineTest.java rename to pipeline/src/test/java/com/iluwatar/pipeline/PipelineTest.java From c438ec0557b31cdc58a6c0bdbba0987a0525621e Mon Sep 17 00:00:00 2001 From: Sharad Paul Date: Tue, 15 Oct 2019 22:03:36 +0530 Subject: [PATCH 28/30] Intermittent test failure in Spatial Partition pattern #1001 (#1006) * Intermittent test failure in Spatial Partition pattern #1001 * Intermittent test failure in Spatial Partition pattern #1001 --- .../java/com/iluwatar/spatialpartition/QuadTreeTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spatial-partition/src/test/java/com/iluwatar/spatialpartition/QuadTreeTest.java b/spatial-partition/src/test/java/com/iluwatar/spatialpartition/QuadTreeTest.java index 0f9dc1e4ea57..15f1022fdae9 100644 --- a/spatial-partition/src/test/java/com/iluwatar/spatialpartition/QuadTreeTest.java +++ b/spatial-partition/src/test/java/com/iluwatar/spatialpartition/QuadTreeTest.java @@ -26,6 +26,8 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.Random; + + import org.junit.jupiter.api.Test; /** @@ -50,12 +52,12 @@ void queryTest() { static Hashtable quadTreeTest(ArrayList points, Rect field, Rect queryRange) { //creating quadtree and inserting all points - QuadTree qTree = new QuadTree(field, 4); + QuadTree qTree = new QuadTree(queryRange, 4); for (int i = 0; i < points.size(); i++) { qTree.insert(points.get(i)); } - ArrayList queryResult = qTree.query(queryRange, new ArrayList()); + ArrayList queryResult = qTree.query(field, new ArrayList()); Hashtable result = new Hashtable(); for (int i = 0; i < queryResult.size(); i++) { Point p = queryResult.get(i); From 27c131c2cb850a92b5b346b24dce20eae91cc84f Mon Sep 17 00:00:00 2001 From: Michele Giacobazzi Date: Tue, 15 Oct 2019 18:37:35 +0200 Subject: [PATCH 29/30] #1001 fix intermittent test failure (#1008) --- .../main/java/com/iluwatar/spatialpartition/Rect.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spatial-partition/src/main/java/com/iluwatar/spatialpartition/Rect.java b/spatial-partition/src/main/java/com/iluwatar/spatialpartition/Rect.java index 3d2f01d77d3d..71d4eda5bfa7 100644 --- a/spatial-partition/src/main/java/com/iluwatar/spatialpartition/Rect.java +++ b/spatial-partition/src/main/java/com/iluwatar/spatialpartition/Rect.java @@ -28,14 +28,14 @@ */ public class Rect { - int x; - int y; - int width; - int height; + double x; + double y; + double width; + double height; //(x,y) - centre of rectangle - Rect(int x, int y, int width, int height) { + Rect(double x, double y, double width, double height) { this.x = x; this.y = y; this.width = width; From a5646b63c19455051fb49fd5a455a28159708d49 Mon Sep 17 00:00:00 2001 From: Azureyjt Date: Wed, 16 Oct 2019 23:21:06 +0800 Subject: [PATCH 30/30] #554: Subclass Sandbox pattern (#998) * Fix issue #761: ThreadSafeDoubleCheckLocking.java: Instantiating by Reflection call will be successful if you do that firstly * Create leader election module * Create Interface of Instance and MessageManager * Create implementations with token ring algorithm * Change package structure. Create basic message system. * Implement heartbeat and heartbeat invoking message system * Implement election message handler * Add leader message handler * Add main entry point * Add comments * Update README.md * Fix checkstyle issue * Add Unit Tests * Add Unit Tests * Add bully leader selection * Change System.out to log print. Add MIT license in each file. * Add More java doc comments * Add unit test * Add unit tests * Add subclass-sandbox * Add Unit Test * Add Unit Test * Fix Typo * Move dependency into parent pom.xml * Change local valuable reference to be var --- pom.xml | 9 +- subclass-sandbox/README.md | 29 ++++++ subclass-sandbox/pom.xml | 49 ++++++++++ .../com/iluwatar/subclasssandbox/App.java | 53 +++++++++++ .../iluwatar/subclasssandbox/GroundDive.java | 44 +++++++++ .../iluwatar/subclasssandbox/SkyLaunch.java | 44 +++++++++ .../iluwatar/subclasssandbox/Superpower.java | 69 ++++++++++++++ .../com/iluwatar/subclasssandbox/AppTest.java | 38 ++++++++ .../subclasssandbox/GroundDiveTest.java | 92 +++++++++++++++++++ .../subclasssandbox/SkyLaunchTest.java | 91 ++++++++++++++++++ 10 files changed, 517 insertions(+), 1 deletion(-) create mode 100644 subclass-sandbox/README.md create mode 100644 subclass-sandbox/pom.xml create mode 100644 subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/App.java create mode 100644 subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/GroundDive.java create mode 100644 subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/SkyLaunch.java create mode 100644 subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/Superpower.java create mode 100644 subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/AppTest.java create mode 100644 subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/GroundDiveTest.java create mode 100644 subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/SkyLaunchTest.java diff --git a/pom.xml b/pom.xml index d330bbfcb6cd..020c784c62fd 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,7 @@ 2.3.1 2.3.2 1.3.2 + 1.19.0 abstract-factory @@ -180,8 +181,8 @@ bytecode leader-election data-locality + subclass-sandbox circuit-breaker - @@ -317,6 +318,12 @@ javassist 3.25.0-GA + + com.github.stefanbirkner + system-rules + ${system-rules.version} + test + diff --git a/subclass-sandbox/README.md b/subclass-sandbox/README.md new file mode 100644 index 000000000000..674991f0895c --- /dev/null +++ b/subclass-sandbox/README.md @@ -0,0 +1,29 @@ + +--- +layout: pattern +title: Subclass Sandbox +folder: subclass-sandbox +permalink: /patterns/subclass-sandbox/ +categories: Other +tags: + - Java + - Difficulty-Beginner +--- + +## Intent +The subclass sandbox pattern describes a basic idea, while not having a lot of detailed mechanics. You will need the pattern when you have several similar subclasses. If you have to make a tiny change, then change the base class, while all subclasses shouldn't have to be touched. So the base class has to be able to provide all of the operations a derived class needs to perform. + +## Applicability +The Subclass Sandbox pattern is a very simple, common pattern lurking in lots of codebases, even outside of games. If you have a non-virtual protected method laying around, you’re probably already using something like this. Subclass Sandbox is a good fit when: + +- You have a base class with a number of derived classes. + +- The base class is able to provide all of the operations that a derived class may need to perform. + +- There is behavioral overlap in the subclasses and you want to make it easier to share code between them. + +- You want to minimize coupling between those derived classes and the rest of the program. + +## Credits + +* [Game Programming Patterns - Subclass Sandbox]([http://gameprogrammingpatterns.com/subclass-sandbox.html](http://gameprogrammingpatterns.com/subclass-sandbox.html)) \ No newline at end of file diff --git a/subclass-sandbox/pom.xml b/subclass-sandbox/pom.xml new file mode 100644 index 000000000000..8016ba471ed0 --- /dev/null +++ b/subclass-sandbox/pom.xml @@ -0,0 +1,49 @@ + + + + + java-design-patterns + com.iluwatar + 1.22.0-SNAPSHOT + + 4.0.0 + + subclass-sandbox + + + + junit + junit + + + com.github.stefanbirkner + system-rules + + + + \ No newline at end of file diff --git a/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/App.java b/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/App.java new file mode 100644 index 000000000000..2e1f41c056c4 --- /dev/null +++ b/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/App.java @@ -0,0 +1,53 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.subclasssandbox; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The subclass sandbox pattern describes a basic idea, while not having a lot + * of detailed mechanics. You will need the pattern when you have several similar + * subclasses. If you have to make a tiny change, then change the base class, + * while all subclasses shouldn't have to be touched. So the base class has to be + * able to provide all of the operations a derived class needs to perform. + */ +public class App { + + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); + + /** + * Entry point of the main program. + * @param args Program runtime arguments. + */ + public static void main(String[] args) { + LOGGER.info("Use superpower: sky launch"); + var skyLaunch = new SkyLaunch(); + skyLaunch.activate(); + LOGGER.info("Use superpower: ground dive"); + var groundDive = new GroundDive(); + groundDive.activate(); + } + +} diff --git a/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/GroundDive.java b/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/GroundDive.java new file mode 100644 index 000000000000..f284e125fba7 --- /dev/null +++ b/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/GroundDive.java @@ -0,0 +1,44 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.subclasssandbox; + +import org.slf4j.LoggerFactory; + +/** + * GroundDive superpower. + */ +public class GroundDive extends Superpower { + + public GroundDive() { + super(); + logger = LoggerFactory.getLogger(GroundDive.class); + } + + @Override + protected void activate() { + move(0, 0, -20); + playSound("GROUNDDIVE_SOUND", 5); + spawnParticles("GROUNDDIVE_PARTICLE", 20); + } +} diff --git a/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/SkyLaunch.java b/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/SkyLaunch.java new file mode 100644 index 000000000000..16c94bd0ca57 --- /dev/null +++ b/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/SkyLaunch.java @@ -0,0 +1,44 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.subclasssandbox; + +import org.slf4j.LoggerFactory; + +/** + * SkyLaunch superpower. + */ +public class SkyLaunch extends Superpower { + + public SkyLaunch() { + super(); + logger = LoggerFactory.getLogger(SkyLaunch.class); + } + + @Override + protected void activate() { + move(0, 0, 20); + playSound("SKYLAUNCH_SOUND", 1); + spawnParticles("SKYLAUNCH_PARTICLE", 100); + } +} diff --git a/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/Superpower.java b/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/Superpower.java new file mode 100644 index 000000000000..d4875d586d62 --- /dev/null +++ b/subclass-sandbox/src/main/java/com/iluwatar/subclasssandbox/Superpower.java @@ -0,0 +1,69 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.subclasssandbox; + +import org.slf4j.Logger; + +/** + * Superpower abstract class. In this class the basic operations of all types of + * superpowers are provided as protected methods. + */ +public abstract class Superpower { + + protected Logger logger; + + /** + * Subclass of superpower should implement this sandbox method by calling the + * methods provided in this super class. + */ + protected abstract void activate(); + + /** + * Move to (x, y, z). + * @param x X coordinate. + * @param y Y coordinate. + * @param z Z coordinate. + */ + protected void move(double x, double y, double z) { + logger.info("Move to ( " + x + ", " + y + ", " + z + " )"); + } + + /** + * Play sound effect for the superpower. + * @param soundName Sound name. + * @param volumn Value of volumn. + */ + protected void playSound(String soundName, int volumn) { + logger.info("Play " + soundName + " with volumn " + volumn); + } + + /** + * Spawn particles for the superpower. + * @param particleType Particle type. + * @param count Count of particles to be spawned. + */ + protected void spawnParticles(String particleType, int count) { + logger.info("Spawn " + count + " particle with type " + particleType); + } +} diff --git a/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/AppTest.java b/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/AppTest.java new file mode 100644 index 000000000000..207c71ef9ef0 --- /dev/null +++ b/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/AppTest.java @@ -0,0 +1,38 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.subclasssandbox; + +import org.junit.Test; + +/** + * App unit tests. + */ +public class AppTest { + + @Test + public void testMain() { + String[] args = {}; + App.main(args); + } +} diff --git a/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/GroundDiveTest.java b/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/GroundDiveTest.java new file mode 100644 index 000000000000..7b4645742376 --- /dev/null +++ b/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/GroundDiveTest.java @@ -0,0 +1,92 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.subclasssandbox; + +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.SystemOutRule; + +/** + * GroundDive unit tests. + */ +public class GroundDiveTest { + + @Rule + public SystemOutRule log = new SystemOutRule().enableLog(); + + @Test + public void testMove() { + log.clearLog(); + var groundDive = new GroundDive(); + groundDive.move(1.0, 1.0, 1.0); + var outputLog = getLogContent(log.getLog()); + var expectedLog = "Move to ( 1.0, 1.0, 1.0 )"; + Assert.assertEquals(outputLog, expectedLog); + } + + @Test + public void testPlaySound() { + log.clearLog(); + var groundDive = new GroundDive(); + groundDive.playSound("SOUND_NAME", 1); + var outputLog = getLogContent(log.getLog()); + var expectedLog = "Play SOUND_NAME with volumn 1"; + Assert.assertEquals(outputLog, expectedLog); + } + + @Test + public void testSpawnParticles() { + log.clearLog(); + var groundDive = new GroundDive(); + groundDive.spawnParticles("PARTICLE_TYPE", 100); + final var outputLog = getLogContent(log.getLog()); + final var expectedLog = "Spawn 100 particle with type PARTICLE_TYPE"; + Assert.assertEquals(outputLog, expectedLog); + } + + @Test + public void testActivate() { + log.clearLog(); + var groundDive = new GroundDive(); + groundDive.activate();; + String[] logs = log.getLog().split("\n"); + final var expectedSize = 3; + final var log1 = logs[0].split("-")[1].trim() + " -" + logs[0].split("-")[2].trim(); + final var expectedLog1 = "Move to ( 0.0, 0.0, -20.0 )"; + final var log2 = getLogContent(logs[1]); + final var expectedLog2 = "Play GROUNDDIVE_SOUND with volumn 5"; + final var log3 = getLogContent(logs[2]); + final var expectedLog3 = "Spawn 20 particle with type GROUNDDIVE_PARTICLE"; + Assert.assertEquals(logs.length, expectedSize); + Assert.assertEquals(log1, expectedLog1); + Assert.assertEquals(log2, expectedLog2); + Assert.assertEquals(log3, expectedLog3); + } + + private String getLogContent(String log) { + return log.split("-")[1].trim(); + } + +} diff --git a/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/SkyLaunchTest.java b/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/SkyLaunchTest.java new file mode 100644 index 000000000000..5ba84c0b55cc --- /dev/null +++ b/subclass-sandbox/src/test/java/com/iluwatar/subclasssandbox/SkyLaunchTest.java @@ -0,0 +1,91 @@ +/** + * The MIT License + * Copyright (c) 2014-2016 Ilkka Seppälä + *

+ * 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 com.iluwatar.subclasssandbox; + +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.SystemOutRule; + +/** + * SkyLaunch unit tests. + */ +public class SkyLaunchTest { + + @Rule + public SystemOutRule log = new SystemOutRule().enableLog(); + + @Test + public void testMove() { + log.clearLog(); + var skyLaunch = new SkyLaunch(); + skyLaunch.move(1.0, 1.0, 1.0); + var outputLog = getLogContent(log.getLog()); + var expectedLog = "Move to ( 1.0, 1.0, 1.0 )"; + Assert.assertEquals(outputLog, expectedLog); + } + + @Test + public void testPlaySound() { + log.clearLog(); + var skyLaunch = new SkyLaunch(); + skyLaunch.playSound("SOUND_NAME", 1); + var outputLog = getLogContent(log.getLog()); + var expectedLog = "Play SOUND_NAME with volumn 1"; + Assert.assertEquals(outputLog, expectedLog); + } + + @Test + public void testSpawnParticles() { + log.clearLog(); + var skyLaunch = new SkyLaunch(); + skyLaunch.spawnParticles("PARTICLE_TYPE", 100); + var outputLog = getLogContent(log.getLog()); + var expectedLog = "Spawn 100 particle with type PARTICLE_TYPE"; + Assert.assertEquals(outputLog, expectedLog); + } + + @Test + public void testActivate() { + log.clearLog(); + var skyLaunch = new SkyLaunch(); + skyLaunch.activate();; + String[] logs = log.getLog().split("\n"); + final var expectedSize = 3; + final var log1 = getLogContent(logs[0]); + final var expectedLog1 = "Move to ( 0.0, 0.0, 20.0 )"; + final var log2 = getLogContent(logs[1]); + final var expectedLog2 = "Play SKYLAUNCH_SOUND with volumn 1"; + final var log3 = getLogContent(logs[2]); + final var expectedLog3 = "Spawn 100 particle with type SKYLAUNCH_PARTICLE"; + Assert.assertEquals(logs.length, expectedSize); + Assert.assertEquals(log1, expectedLog1); + Assert.assertEquals(log2, expectedLog2); + Assert.assertEquals(log3, expectedLog3); + } + + private String getLogContent(String log) { + return log.split("-")[1].trim(); + } +}