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 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+ 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..556d725da0b1
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractInstance.java
@@ -0,0 +1,147 @@
+/**
+ * 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 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..687ac4b7d623
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/AbstractMessageManager.java
@@ -0,0 +1,72 @@
+/**
+ * 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 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..dc64936e28ba
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/Instance.java
@@ -0,0 +1,48 @@
+/**
+ * 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 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..8b033a6d421b
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/Message.java
@@ -0,0 +1,75 @@
+/**
+ * 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 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..3c642b99152f
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/MessageManager.java
@@ -0,0 +1,59 @@
+/**
+ * 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 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..bbaee2d5be34
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/MessageType.java
@@ -0,0 +1,61 @@
+/**
+ * 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 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..4ee86e789209
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyApp.java
@@ -0,0 +1,76 @@
+/**
+ * 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 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..62e786a705a5
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyInstance.java
@@ -0,0 +1,120 @@
+/**
+ * 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 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..c2bab0742a85
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/bully/BullyMessageManager.java
@@ -0,0 +1,116 @@
+/**
+ * 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 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..de81d2d987ee
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingApp.java
@@ -0,0 +1,76 @@
+/**
+ * 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 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..850c804cf0b8
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingInstance.java
@@ -0,0 +1,132 @@
+/**
+ * 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 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..c20368765f98
--- /dev/null
+++ b/leader-election/src/main/java/com/iluwatar/leaderelection/ring/RingMessageManager.java
@@ -0,0 +1,95 @@
+/**
+ * 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 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..719d333c702f
--- /dev/null
+++ b/leader-election/src/test/java/com/iluwatar/leaderelection/MessageTest.java
@@ -0,0 +1,47 @@
+/**
+ * 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 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..1e84ee0fe4b4
--- /dev/null
+++ b/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyAppTest.java
@@ -0,0 +1,38 @@
+/**
+ * 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 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..0e8e1390fd60
--- /dev/null
+++ b/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyMessageManagerTest.java
@@ -0,0 +1,150 @@
+/**
+ * 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 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..4523ad087b6d
--- /dev/null
+++ b/leader-election/src/test/java/com/iluwatar/leaderelection/bully/BullyinstanceTest.java
@@ -0,0 +1,77 @@
+/**
+ * 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 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..2a48b09dc876
--- /dev/null
+++ b/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingAppTest.java
@@ -0,0 +1,38 @@
+/**
+ * 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 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..d9e34a5f6e93
--- /dev/null
+++ b/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingInstanceTest.java
@@ -0,0 +1,75 @@
+/**
+ * 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 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..0089a268df68
--- /dev/null
+++ b/leader-election/src/test/java/com/iluwatar/leaderelection/ring/RingMessageManagerTest.java
@@ -0,0 +1,122 @@
+/**
+ * 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 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/marker/pom.xml b/marker/pom.xml
index afa82f4db4bf..d8166ab86c32 100644
--- a/marker/pom.xml
+++ b/marker/pom.xml
@@ -1,15 +1,19 @@
The Master-Worker pattern is used when the problem at hand can be solved by dividing into
@@ -46,7 +47,8 @@
*/
public class App {
-
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Program entry point.
* @param args command line args
@@ -61,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/ArrayInput.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayInput.java
index fe435b064dca..fcd4ab977eb7 100644
--- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayInput.java
+++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayInput.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.masterworker;
import java.util.ArrayList;
diff --git a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayResult.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayResult.java
index 30a446477d18..47c0d364a0f7 100644
--- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayResult.java
+++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayResult.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.masterworker;
/**
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 3e399a11e453..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
@@ -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,9 +20,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-
package com.iluwatar.masterworker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.Random;
/**
@@ -30,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).
@@ -101,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/master-worker-pattern/src/main/java/com/iluwatar/masterworker/Input.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/Input.java
index 994c6b56d0b1..6e89e9476bf8 100644
--- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/Input.java
+++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/Input.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.masterworker;
import java.util.ArrayList;
diff --git a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/Result.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/Result.java
index a63e083d4ada..0e73e21b3f04 100644
--- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/Result.java
+++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/Result.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.masterworker;
/**
diff --git a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/ArrayTransposeMasterWorker.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/ArrayTransposeMasterWorker.java
index d7b931b2e8aa..aba8c92d62b9 100644
--- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/ArrayTransposeMasterWorker.java
+++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/ArrayTransposeMasterWorker.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.masterworker.system;
import com.iluwatar.masterworker.system.systemmaster.ArrayTransposeMaster;
diff --git a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/MasterWorker.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/MasterWorker.java
index 4342e7fbb54e..142b5fd7c2cc 100644
--- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/MasterWorker.java
+++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/MasterWorker.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.masterworker.system;
import com.iluwatar.masterworker.Input;
diff --git a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemmaster/ArrayTransposeMaster.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemmaster/ArrayTransposeMaster.java
index 9f446b96a6b7..81068878b984 100644
--- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemmaster/ArrayTransposeMaster.java
+++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemmaster/ArrayTransposeMaster.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.masterworker.system.systemmaster;
import java.util.ArrayList;
diff --git a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemmaster/Master.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemmaster/Master.java
index 8df46e12ee08..4a2d98f34093 100644
--- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemmaster/Master.java
+++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemmaster/Master.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.masterworker.system.systemmaster;
import java.util.ArrayList;
diff --git a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemworkers/ArrayTransposeWorker.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemworkers/ArrayTransposeWorker.java
index 7781bd365c57..9820284657d6 100644
--- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemworkers/ArrayTransposeWorker.java
+++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemworkers/ArrayTransposeWorker.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.masterworker.system.systemworkers;
import com.iluwatar.masterworker.ArrayInput;
diff --git a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemworkers/Worker.java b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemworkers/Worker.java
index 3ff27e5477e3..99c769a4a087 100644
--- a/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemworkers/Worker.java
+++ b/master-worker-pattern/src/main/java/com/iluwatar/masterworker/system/systemworkers/Worker.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.masterworker.system.systemworkers;
import com.iluwatar.masterworker.Input;
diff --git a/master-worker-pattern/src/test/java/com/iluwatar/masterworker/ArrayInputTest.java b/master-worker-pattern/src/test/java/com/iluwatar/masterworker/ArrayInputTest.java
index 666d469a5e1e..46b2cce9d27a 100644
--- a/master-worker-pattern/src/test/java/com/iluwatar/masterworker/ArrayInputTest.java
+++ b/master-worker-pattern/src/test/java/com/iluwatar/masterworker/ArrayInputTest.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.masterworker;
import static org.junit.jupiter.api.Assertions.*;
diff --git a/master-worker-pattern/src/test/java/com/iluwatar/masterworker/ArrayUtilityMethodsTest.java b/master-worker-pattern/src/test/java/com/iluwatar/masterworker/ArrayUtilityMethodsTest.java
index 5ee89a94ad96..72282b0df825 100644
--- a/master-worker-pattern/src/test/java/com/iluwatar/masterworker/ArrayUtilityMethodsTest.java
+++ b/master-worker-pattern/src/test/java/com/iluwatar/masterworker/ArrayUtilityMethodsTest.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/master-worker-pattern/src/test/java/com/iluwatar/masterworker/system/ArrayTransposeMasterWorkerTest.java b/master-worker-pattern/src/test/java/com/iluwatar/masterworker/system/ArrayTransposeMasterWorkerTest.java
index 0ac9f67e161e..fd97b37ad457 100644
--- a/master-worker-pattern/src/test/java/com/iluwatar/masterworker/system/ArrayTransposeMasterWorkerTest.java
+++ b/master-worker-pattern/src/test/java/com/iluwatar/masterworker/system/ArrayTransposeMasterWorkerTest.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.masterworker.system;
import static org.junit.jupiter.api.Assertions.*;
diff --git a/master-worker-pattern/src/test/java/com/iluwatar/masterworker/system/systemworkers/ArrayTransposeWorkerTest.java b/master-worker-pattern/src/test/java/com/iluwatar/masterworker/system/systemworkers/ArrayTransposeWorkerTest.java
index 307696e0c97e..e1f0433c9fa0 100644
--- a/master-worker-pattern/src/test/java/com/iluwatar/masterworker/system/systemworkers/ArrayTransposeWorkerTest.java
+++ b/master-worker-pattern/src/test/java/com/iluwatar/masterworker/system/systemworkers/ArrayTransposeWorkerTest.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.masterworker.system.systemworkers;
import static org.junit.jupiter.api.Assertions.*;
diff --git a/mediator/pom.xml b/mediator/pom.xml
index 14aadac8dd9b..7fba84dd11ab 100644
--- a/mediator/pom.xml
+++ b/mediator/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
@@ -36,6 +50,17 @@
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${compiler.version}
+
+ 8
+ 8
+
+
+
@@ -78,7 +103,7 @@
true
- 4.0.1
+ 5.2.1
@@ -118,7 +143,6 @@
${datanucleus-maven-plugin.version}
false
- ${basedir}/log4j.properties
true
${basedir}/datanucleus.properties
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 c4dd52dcf652..62d25df032c9 100644
--- a/naked-objects/integtests/pom.xml
+++ b/naked-objects/integtests/pom.xml
@@ -1,14 +1,28 @@
-
+
4.0.0
@@ -90,6 +104,11 @@
hsqldb
+
+ javax.annotation
+ javax.annotation-api
+
+
-
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..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
@@ -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;
@@ -41,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 e41399fdd7d8..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
@@ -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;
@@ -28,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/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..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
@@ -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;
@@ -32,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/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 8c21504bb6f5..b035c3894058 100644
--- a/naked-objects/pom.xml
+++ b/naked-objects/pom.xml
@@ -1,14 +1,28 @@
-
+
4.0.0
@@ -17,23 +31,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
@@ -90,31 +95,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/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
@@ -202,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 459e4b7de9e0..875212963b67 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;
@@ -42,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;
/**
@@ -64,6 +74,7 @@
*/
public class SimpleApplication extends IsisWicketApplication {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SimpleApplication.class);
private static final long serialVersionUID = 1L;
/**
@@ -116,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/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 @@
+
+ 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..581e414606bd
--- /dev/null
+++ b/pipeline/src/main/java/com/iluwatar/pipeline/App.java
@@ -0,0 +1,66 @@
+/**
+ * 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 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..6a418fef4cf1
--- /dev/null
+++ b/pipeline/src/main/java/com/iluwatar/pipeline/ConvertToCharArrayHandler.java
@@ -0,0 +1,45 @@
+/**
+ * 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 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 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",
+ 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..b00e20a281fe
--- /dev/null
+++ b/pipeline/src/main/java/com/iluwatar/pipeline/Handler.java
@@ -0,0 +1,32 @@
+/**
+ * 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 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..476c9f0a5931
--- /dev/null
+++ b/pipeline/src/main/java/com/iluwatar/pipeline/Pipeline.java
@@ -0,0 +1,46 @@
+/**
+ * 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 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..342ed86c23c7
--- /dev/null
+++ b/pipeline/src/main/java/com/iluwatar/pipeline/RemoveAlphabetsHandler.java
@@ -0,0 +1,54 @@
+/**
+ * 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 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 static 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..a5320a0a55c4
--- /dev/null
+++ b/pipeline/src/main/java/com/iluwatar/pipeline/RemoveDigitsHandler.java
@@ -0,0 +1,54 @@
+/**
+ * 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 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 static 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..552cd99bd488
--- /dev/null
+++ b/pipeline/src/test/java/com/iluwatar/pipeline/AppTest.java
@@ -0,0 +1,37 @@
+/**
+ * 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 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..590dfc62e59a
--- /dev/null
+++ b/pipeline/src/test/java/com/iluwatar/pipeline/PipelineTest.java
@@ -0,0 +1,45 @@
+/**
+ * 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 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/poison-pill/pom.xml b/poison-pill/pom.xml
index 16ee086c7088..b10b54c008ff 100644
--- a/poison-pill/pom.xml
+++ b/poison-pill/pom.xml
@@ -2,7 +2,7 @@
@@ -25,36 +30,37 @@
java-design-patterns
1.22.0-SNAPSHOT
pom
- 2014
+ 2014-2019
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
${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
+ 2.24.0
19.0
1.10.19
- 4.5.2
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
2.0.1
2.8.5
+ 2.3.1
+ 2.3.2
+ 1.3.2
+ 1.19.0
abstract-factory
@@ -94,6 +100,7 @@
property
intercepting-filter
producer-consumer
+ pipeline
poison-pill
reader-writer-lock
lazy-loading
@@ -172,7 +179,10 @@
commander
typeobjectpattern
bytecode
+ leader-election
data-locality
+ subclass-sandbox
+ circuit-breaker
@@ -189,11 +199,6 @@
hibernate-core
${hibernate.version}
-
- org.hibernate
- hibernate-entitymanager
- ${hibernate.version}
-
org.springframework.boot
spring-boot-dependencies
@@ -211,16 +216,6 @@
spring-webmvc
${spring.version}
-
- org.springframework.boot
- spring-boot-starter-web
- ${spring-boot.version}
-
-
- org.apache.httpcomponents
- httpclient
- ${apache-httpcomponents.version}
-
com.h2database
h2
@@ -303,6 +298,32 @@
mongo-java-driver
${mongo-java-driver.version}
+
+ javax.xml.bind
+ jaxb-api
+ ${jaxb-api.version}
+
+
+ javax.annotation
+ javax.annotation-api
+ ${annotation-api.version}
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ ${jaxb-impl.version}
+
+
+ org.javassist
+ javassist
+ 3.25.0-GA
+
+
+ com.github.stefanbirkner
+ system-rules
+ ${system-rules.version}
+ test
+
@@ -327,72 +348,39 @@
-
- org.eclipse.m2e
- lifecycle-mapping
- 1.0.0
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${compiler.version}
-
-
-
-
- org.jacoco
-
- jacoco-maven-plugin
-
-
- [0.6.2,)
-
-
- prepare-agent
-
-
-
-
-
-
-
-
+ 11
+ 11
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+ -Xmx1024M ${argLine}
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring-boot.version}
+
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${compiler.version}
-
- 1.8
- 1.8
-
-
-
- org.jacoco
- jacoco-maven-plugin
- ${jacoco.version}
-
-
- prepare-agent
-
- prepare-agent
-
-
-
-
-
org.apache.maven.plugins
maven-checkstyle-plugin
- 2.17
+ 3.1.0
validate
@@ -411,46 +399,11 @@
-
- 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
-
- true
- 5
- true
-
-
-
-
- check
-
-
- exclude-pmd.properties
-
-
-
-
com.mycila
license-maven-plugin
- 2.11
+ 3.0
com/mycila/maven/plugin/license/templates/MIT.txt
@@ -468,6 +421,27 @@
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ ${jacoco.version}
+
+
+ prepare-agent
+
+ prepare-agent
+
+
+
+ report
+
+ report
+
+
+
+
+
@@ -475,8 +449,8 @@
org.apache.maven.plugins
- maven-pmd-plugin
- 3.6
+ maven-jxr-plugin
+ 3.0.0
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 48bca0cf2ba8..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 a8307d1cd9f3..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;
@@ -43,7 +41,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 +66,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 +91,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/pom.xml b/semaphore/pom.xml
index 3761e5e49a8f..1ae865f02442 100644
--- a/semaphore/pom.xml
+++ b/semaphore/pom.xml
@@ -2,7 +2,7 @@
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/serverless.yml b/serverless/serverless.yml
index c463395df226..bbf9a71c47c2 100644
--- a/serverless/serverless.yml
+++ b/serverless/serverless.yml
@@ -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/serverless/src/main/java/com/iluwatar/serverless/baas/api/AbstractDynamoDbHandler.java b/serverless/src/main/java/com/iluwatar/serverless/baas/api/AbstractDynamoDbHandler.java
index ac27a9a4a4b7..0295f03a6694 100644
--- a/serverless/src/main/java/com/iluwatar/serverless/baas/api/AbstractDynamoDbHandler.java
+++ b/serverless/src/main/java/com/iluwatar/serverless/baas/api/AbstractDynamoDbHandler.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/serverless/src/main/java/com/iluwatar/serverless/baas/api/FindPersonApiHandler.java b/serverless/src/main/java/com/iluwatar/serverless/baas/api/FindPersonApiHandler.java
index fab448d5c2dd..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
@@ -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
@@ -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 b66b997d2ec7..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
@@ -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
@@ -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/baas/model/Address.java b/serverless/src/main/java/com/iluwatar/serverless/baas/model/Address.java
index 7331cea2b5c9..8c6232c4efd1 100644
--- a/serverless/src/main/java/com/iluwatar/serverless/baas/model/Address.java
+++ b/serverless/src/main/java/com/iluwatar/serverless/baas/model/Address.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/serverless/src/main/java/com/iluwatar/serverless/baas/model/Person.java b/serverless/src/main/java/com/iluwatar/serverless/baas/model/Person.java
index 75604999ea34..2a83448501bd 100644
--- a/serverless/src/main/java/com/iluwatar/serverless/baas/model/Person.java
+++ b/serverless/src/main/java/com/iluwatar/serverless/baas/model/Person.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/serverless/src/main/java/com/iluwatar/serverless/faas/ApiGatewayResponse.java b/serverless/src/main/java/com/iluwatar/serverless/faas/ApiGatewayResponse.java
index 98e2de64fe3c..665c3dec659d 100644
--- a/serverless/src/main/java/com/iluwatar/serverless/faas/ApiGatewayResponse.java
+++ b/serverless/src/main/java/com/iluwatar/serverless/faas/ApiGatewayResponse.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/serverless/src/main/java/com/iluwatar/serverless/faas/LambdaInfo.java b/serverless/src/main/java/com/iluwatar/serverless/faas/LambdaInfo.java
index 03932a9f0143..bae73281bc60 100644
--- a/serverless/src/main/java/com/iluwatar/serverless/faas/LambdaInfo.java
+++ b/serverless/src/main/java/com/iluwatar/serverless/faas/LambdaInfo.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/serverless/src/main/java/com/iluwatar/serverless/faas/api/LambdaInfoApiHandler.java b/serverless/src/main/java/com/iluwatar/serverless/faas/api/LambdaInfoApiHandler.java
index 67e1835f9e13..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
@@ -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
@@ -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 15a25e61b87a..000000000000
--- a/serverless/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# 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.
-#
-
-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/serverless/src/test/java/com/iluwatar/serverless/baas/api/FindPersonApiHandlerTest.java b/serverless/src/test/java/com/iluwatar/serverless/baas/api/FindPersonApiHandlerTest.java
index 561281ab3b58..193346ab8ead 100644
--- a/serverless/src/test/java/com/iluwatar/serverless/baas/api/FindPersonApiHandlerTest.java
+++ b/serverless/src/test/java/com/iluwatar/serverless/baas/api/FindPersonApiHandlerTest.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/serverless/src/test/java/com/iluwatar/serverless/baas/api/SavePersonApiHandlerTest.java b/serverless/src/test/java/com/iluwatar/serverless/baas/api/SavePersonApiHandlerTest.java
index 83008bdff309..da31f8ac4fd6 100644
--- a/serverless/src/test/java/com/iluwatar/serverless/baas/api/SavePersonApiHandlerTest.java
+++ b/serverless/src/test/java/com/iluwatar/serverless/baas/api/SavePersonApiHandlerTest.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/serverless/src/test/java/com/iluwatar/serverless/faas/api/LambdaInfoApiHandlerTest.java b/serverless/src/test/java/com/iluwatar/serverless/faas/api/LambdaInfoApiHandlerTest.java
index 876489ed2262..9922c1a5c55e 100644
--- a/serverless/src/test/java/com/iluwatar/serverless/faas/api/LambdaInfoApiHandlerTest.java
+++ b/serverless/src/test/java/com/iluwatar/serverless/faas/api/LambdaInfoApiHandlerTest.java
@@ -1,17 +1,17 @@
/**
* 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
* 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 403a896a4613..31fc6f625b68 100644
--- a/service-layer/pom.xml
+++ b/service-layer/pom.xml
@@ -2,7 +2,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+ 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();
+ }
+}
diff --git a/template-method/pom.xml b/template-method/pom.xml
index e1f24ae251db..0f4a03a5fec2 100644
--- a/template-method/pom.xml
+++ b/template-method/pom.xml
@@ -2,7 +2,7 @@