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..000000000
--- a/tls/etc/tls.ucls
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tls/etc/tls.urm.puml b/tls/etc/tls.urm.puml
deleted file mode 100644
index 12bcea064..000000000
--- a/tls/etc/tls.urm.puml
+++ /dev/null
@@ -1,25 +0,0 @@
-@startuml
-package com.iluwatar.tls {
- class App {
- - LOGGER : Logger {static}
- + App()
- + main(args : String[]) {static}
- - printAndCountDates(res : Result) : int {static}
- - printAndCountExceptions(res : Result) : int {static}
- }
- class DateFormatCallable {
- - LOGGER : Logger {static}
- - dateValue : String
- - df : ThreadLocal
- + DateFormatCallable(inDateFormat : String, inDateValue : String)
- + call() : Result
- }
- class Result {
- - dateList : List
- - exceptionList : List
- + Result()
- + getDateList() : List
- + getExceptionList() : List
- }
-}
-@enduml
\ No newline at end of file
diff --git a/tls/src/main/java/com/iluwatar/tls/App.java b/tls/src/main/java/com/iluwatar/tls/App.java
deleted file mode 100644
index 5932b72b5..000000000
--- a/tls/src/main/java/com/iluwatar/tls/App.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
- *
- * The MIT License
- * Copyright © 2014-2022 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.tls;
-
-import java.util.Calendar;
-import java.util.concurrent.Executors;
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * ThreadLocal pattern
- *
- * This App shows how to create an isolated space per each thread. In this example the usage of
- * SimpleDateFormat is made to be thread-safe. This is an example of the ThreadLocal pattern.
- *
- *
By applying the ThreadLocal pattern you can keep track of application instances or locale
- * settings throughout the handling of a request. The ThreadLocal class works like a static
- * variable, with the exception that it is only bound to the current thread! This allows us to use
- * static variables in a thread-safe way.
- *
- *
In Java, thread-local variables are implemented by the ThreadLocal class object. ThreadLocal
- * holds a variable of type T, which is accessible via get/set methods.
- *
- *
SimpleDateFormat is one of the basic Java classes and is not thread-safe. If you do not
- * isolate the instance of SimpleDateFormat per each thread then problems arise.
- *
- *
App converts the String date value 15/12/2015 to the Date format using the Java class
- * SimpleDateFormat. It does this 20 times using 4 threads, each doing it 5 times. With the usage of
- * as ThreadLocal in DateFormatCallable everything runs well. But if you comment out the ThreadLocal
- * variant (marked with "//TLTL") and comment in the non ThreadLocal variant (marked with
- * "//NTLNTL") you can see what will happen without the ThreadLocal. Most likely you will get
- * incorrect date values and / or exceptions.
- *
- *
This example clearly show what will happen when using non thread-safe classes in a thread. In
- * real life this may happen one in of 1.000 or 10.000 conversions and those are really hard to find
- * errors.
- *
- * @author Thomas Bauer, 2017
- */
-@Slf4j
-public class App {
-
- /**
- * Program entry point.
- *
- * @param args command line args
- */
- public static void main(String[] args) {
- var counterDateValues = 0;
- var counterExceptions = 0;
-
- // Create a callable
- var callableDf = new DateFormatCallable("dd/MM/yyyy", "15/12/2015");
- // start 4 threads, each using the same Callable instance
- var executor = Executors.newCachedThreadPool();
-
- var futureResult1 = executor.submit(callableDf);
- var futureResult2 = executor.submit(callableDf);
- var futureResult3 = executor.submit(callableDf);
- var futureResult4 = executor.submit(callableDf);
- try {
- var result = new Result[4];
- result[0] = futureResult1.get();
- result[1] = futureResult2.get();
- result[2] = futureResult3.get();
- result[3] = futureResult4.get();
-
- // Print results of thread executions (converted dates and raised exceptions)
- // and count them
- for (var value : result) {
- counterDateValues = counterDateValues + printAndCountDates(value);
- counterExceptions = counterExceptions + printAndCountExceptions(value);
- }
-
- // a correct run should deliver 20 times 15.12.2015
- // and a correct run shouldn't deliver any exception
- LOGGER.info("The List dateList contains " + counterDateValues + " date values");
- LOGGER.info("The List exceptionList contains " + counterExceptions + " exceptions");
-
- } catch (Exception e) {
- LOGGER.info("Abnormal end of program. Program throws exception: " + e);
- }
- executor.shutdown();
- }
-
- /**
- * Print result (date values) of a thread execution and count dates.
- *
- * @param res contains results of a thread execution
- */
- private static int printAndCountDates(Result res) {
- // a correct run should deliver 5 times 15.12.2015 per each thread
- var counter = 0;
- for (var dt : res.getDateList()) {
- counter++;
- var cal = Calendar.getInstance();
- cal.setTime(dt);
- // Formatted output of the date value: DD.MM.YYYY
- LOGGER.info(cal.get(Calendar.DAY_OF_MONTH) + "."
- + cal.get(Calendar.MONTH) + "."
- + cal.get(Calendar.YEAR)
- );
- }
- return counter;
- }
-
- /**
- * Print result (exceptions) of a thread execution and count exceptions.
- *
- * @param res contains results of a thread execution
- * @return number of dates
- */
- private static int printAndCountExceptions(Result res) {
- // a correct run shouldn't deliver any exception
- var counter = 0;
- for (var ex : res.getExceptionList()) {
- counter++;
- LOGGER.info(ex);
- }
- return counter;
- }
-}
diff --git a/tls/src/main/java/com/iluwatar/tls/DateFormatCallable.java b/tls/src/main/java/com/iluwatar/tls/DateFormatCallable.java
deleted file mode 100644
index e6d7ef9b4..000000000
--- a/tls/src/main/java/com/iluwatar/tls/DateFormatCallable.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
- *
- * The MIT License
- * Copyright © 2014-2022 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.tls;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.concurrent.Callable;
-import java.util.stream.IntStream;
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * DateFormatCallable converts string dates to a date format using SimpleDateFormat. The date format
- * and the date value will be passed to the Callable by the constructor. The constructor creates a
- * instance of SimpleDateFormat and stores it in a ThreadLocal class variable. For the complete
- * description of the example see {@link App}.
- *
- *
You can comment out the code marked with //TLTL and comment in the code marked //NTLNTL. Then
- * you can see what will happen if you do not use the ThreadLocal. For details see the description
- * of {@link App}
- *
- * @author Thomas Bauer, 2017
- */
-@Slf4j
-public class DateFormatCallable implements Callable {
-
- // class variables (members)
- private final ThreadLocal df; //TLTL
- // private DateFormat df; //NTLNTL
-
- private final String dateValue; // for dateValue Thread Local not needed
-
-
- /**
- * The date format and the date value are passed to the constructor.
- *
- * @param inDateFormat string date format string, e.g. "dd/MM/yyyy"
- * @param inDateValue string date value, e.g. "21/06/2016"
- */
- public DateFormatCallable(String inDateFormat, String inDateValue) {
- final var idf = inDateFormat; //TLTL
- this.df = ThreadLocal.withInitial(() -> { //TLTL
- return new SimpleDateFormat(idf); //TLTL
- }); //TLTL
- // this.df = new SimpleDateFormat(inDateFormat); //NTLNTL
- this.dateValue = inDateValue;
- }
-
- @Override
- public Result call() {
- LOGGER.info(Thread.currentThread() + " started executing...");
- var result = new Result();
-
- // Convert date value to date 5 times
- IntStream.rangeClosed(1, 5).forEach(i -> {
- try {
- // this is the statement where it is important to have the
- // instance of SimpleDateFormat locally
- // Create the date value and store it in dateList
- result.getDateList().add(this.df.get().parse(this.dateValue)); //TLTL
- // result.getDateList().add(this.df.parse(this.dateValue)); //NTLNTL
- } catch (Exception e) {
- // write the Exception to a list and continue work
- result.getExceptionList().add(e.getClass() + ": " + e.getMessage());
- }
- });
-
- LOGGER.info("{} finished processing part of the thread", Thread.currentThread());
-
- return result;
- }
-}
diff --git a/tls/src/main/java/com/iluwatar/tls/Result.java b/tls/src/main/java/com/iluwatar/tls/Result.java
deleted file mode 100644
index 48e30a525..000000000
--- a/tls/src/main/java/com/iluwatar/tls/Result.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
- *
- * The MIT License
- * Copyright © 2014-2022 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.
- */
-/*
- * Fiducia IT AG, All rights reserved. Use is subject to license terms.
- */
-
-package com.iluwatar.tls;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * Result object that will be returned by the Callable {@link DateFormatCallable} used in {@link
- * App}.
- *
- * @author Thomas Bauer, 2017
- */
-public class Result {
- // A list to collect the date values created in one thread
- private final List dateList = new ArrayList<>();
-
- // A list to collect Exceptions thrown in one threads (should be none in
- // this example)
- private final List exceptionList = new ArrayList<>();
-
- /**
- * Get list of date values collected within a thread execution.
- *
- * @return List of date values collected within an thread execution
- */
- public List getDateList() {
- return dateList;
- }
-
- /**
- * Get list of exceptions thrown within a thread execution.
- *
- * @return List of exceptions thrown within an thread execution
- */
- public List getExceptionList() {
- return exceptionList;
- }
-}
diff --git a/tls/src/test/java/com/iluwatar/tls/AppTest.java b/tls/src/test/java/com/iluwatar/tls/AppTest.java
deleted file mode 100644
index fa53ee34d..000000000
--- a/tls/src/test/java/com/iluwatar/tls/AppTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
- *
- * The MIT License
- * Copyright © 2014-2022 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.tls;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-
-/**
- * Tests that thread local storage example runs without errors.
- *
- * @author Thomas Bauer, January 2017
- */
-class AppTest {
- @Test
- void shouldExecuteApplicationWithoutException() {
- assertDoesNotThrow(() -> App.main(new String[]{}));
- }
-}
diff --git a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTest.java b/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTest.java
deleted file mode 100644
index 3bd9497be..000000000
--- a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
- *
- * The MIT License
- * Copyright © 2014-2022 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.tls;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.concurrent.Executors;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test of the Callable
- *
- * In this test {@link DateFormatCallable} is tested with only one thread (i.e. without concurrency
- * situation)
- *
- * After a successful run 5 date values should be in the result object. All dates should have the
- * same value (15.11.2015). To avoid problems with time zone not the date instances themselves are
- * compared by the test. For the test the dates are converted into string format DD.MM.YYY
- *
- * Additionally the number of list entries are tested for both the list with the date values and the
- * list with the exceptions
- *
- * @author Thomas Bauer, January 2017
- */
-class DateFormatCallableTest {
-
- // Class variables used in setup() have to be static because setup() has to be static
- /**
- * Result object given back by DateFormatCallable -- Array with converted date values -- Array
- * with thrown exceptions
- */
- private static Result result;
-
- /**
- * The date values created by the run of of DateFormatRunnalbe. List will be filled in the setup()
- * method
- */
- private static List createdDateValues = new ArrayList<>();
-
- /**
- * Expected number of date values in the date value list created by the run of DateFormatRunnalbe
- */
- private final int expectedCounterDateValues = 5;
-
- /**
- * Expected number of exceptions in the exception list created by the run of DateFormatRunnalbe.
- */
- private final int expectedCounterExceptions = 0;
-
- /**
- * Expected content of the list containing the date values created by the run of
- * DateFormatRunnalbe
- */
- private final List expectedDateValues =
- List.of("15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015");
-
- /**
- * Run Callable and prepare results for usage in the test methods
- */
- @BeforeAll
- public static void setup() {
- // Create a callable
- var callableDf = new DateFormatCallable("dd/MM/yyyy", "15/12/2015");
- // start thread using the Callable instance
- var executor = Executors.newCachedThreadPool();
- var futureResult = executor.submit(callableDf);
- try {
- result = futureResult.get();
- createdDateValues = convertDatesToString(result);
- } catch (Exception e) {
- fail("Setup failed: " + e);
- }
- executor.shutdown();
- }
-
- private static List convertDatesToString(Result res) {
- // Format date value as DD.MM.YYYY
- if (res == null || res.getDateList() == null || res.getDateList().size() == 0) {
- return null;
- }
- var returnList = new ArrayList();
-
- for (var dt : res.getDateList()) {
- var cal = Calendar.getInstance();
- cal.setTime(dt);
- returnList.add(cal.get(Calendar.DAY_OF_MONTH) + "."
- + cal.get(Calendar.MONTH) + "."
- + cal.get(Calendar.YEAR)
- );
- }
- return returnList;
- }
-
- /**
- * Test date values after the run of DateFormatRunnalbe. A correct run should deliver 5 times
- * 15.12.2015
- */
- @Test
- void testDateValues() {
- assertEquals(expectedDateValues, createdDateValues);
- }
-
- /**
- * Test number of dates in the list after the run of DateFormatRunnalbe. A correct run should
- * deliver 5 date values
- */
- @Test
- void testCounterDateValues() {
- assertEquals(expectedCounterDateValues, result.getDateList().size());
- }
-
- /**
- * Test number of Exceptions in the list after the run of DateFormatRunnalbe. A correct run should
- * deliver no exceptions
- */
- @Test
- void testCounterExceptions() {
- assertEquals(expectedCounterExceptions, result.getExceptionList().size());
- }
-}
diff --git a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestIncorrectDateFormat.java b/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestIncorrectDateFormat.java
deleted file mode 100644
index 69489d4d0..000000000
--- a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestIncorrectDateFormat.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
- *
- * The MIT License
- * Copyright © 2014-2022 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.tls;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.util.List;
-import java.util.concurrent.Executors;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test of the Callable
- *
- * In this test {@link DateFormatCallable} is tested with only one thread (i.e. without concurrency
- * situation)
- *
- * An incorrect formatted date is passed to the Callable After a successful run 0 date values and 5
- * exceptions should be in the result object.
- *
- * @author Thomas Bauer, January 2017
- */
-public class DateFormatCallableTestIncorrectDateFormat {
-
- // Class variables used in setup() have to be static because setup() has to be static
- /**
- * Result object given back by DateFormatCallable -- Array with converted date values -- Array
- * with thrown exceptions
- */
- private static Result result;
-
- /**
- * Expected number of date values in the date value list created by the run of DateFormatRunnalbe
- */
- private final int expectedCounterDateValues = 0;
-
- /**
- * Expected number of exceptions in the exception list created by the run of DateFormatRunnalbe.
- */
- private final int expectedCounterExceptions = 5;
-
- /**
- * Expected content of the list containing the exceptions created by the run of
- * DateFormatRunnalbe
- */
- private final List expectedExceptions = List.of(
- "class java.text.ParseException: Unparseable date: \"15.12.2015\"",
- "class java.text.ParseException: Unparseable date: \"15.12.2015\"",
- "class java.text.ParseException: Unparseable date: \"15.12.2015\"",
- "class java.text.ParseException: Unparseable date: \"15.12.2015\"",
- "class java.text.ParseException: Unparseable date: \"15.12.2015\""
- );
-
- /**
- * Run Callable and prepare results for usage in the test methods
- */
- @BeforeAll
- public static void setup() {
- // Create a callable. Pass a string date value not matching the format string
- var callableDf = new DateFormatCallable("dd/MM/yyyy", "15.12.2015");
- // start thread using the Callable instance
- var executor = Executors.newCachedThreadPool();
- var futureResult = executor.submit(callableDf);
- try {
- result = futureResult.get();
- } catch (Exception e) {
- fail("Setup failed: " + e);
- }
- executor.shutdown();
- }
-
- /**
- * Test Exceptions after the run of DateFormatRunnalbe. A correct run should deliver 5 times the
- * same exception
- */
- @Test
- void testExceptions() {
- assertEquals(expectedExceptions, result.getExceptionList());
- }
-
- /**
- * Test number of dates in the list after the run of DateFormatRunnalbe. A correct run should
- * deliver no date values
- */
- @Test
- void testCounterDateValues() {
- assertEquals(expectedCounterDateValues, result.getDateList().size());
- }
-
- /**
- * Test number of Exceptions in the list after the run of DateFormatRunnalbe. A correct run should
- * deliver 5 exceptions
- */
- @Test
- void testCounterExceptions() {
- assertEquals(expectedCounterExceptions, result.getExceptionList().size());
- }
-}
diff --git a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestMultiThread.java b/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestMultiThread.java
deleted file mode 100644
index f8b7f952a..000000000
--- a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestMultiThread.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
- *
- * The MIT License
- * Copyright © 2014-2022 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.tls;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.concurrent.Executors;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test of the Callable
- *
- * In this test {@link DateFormatCallable} is used by 4 threads in parallel
- *
- * After a successful run 5 date values should be in the result object of each thread. All dates
- * should have the same value (15.11.2015). To avoid problems with time zone not the date instances
- * themselves are compared by the test. For the test the dates are converted into string format
- * DD.MM.YYY
- *
- * Additionally the number of list entries are tested for both the list with the date values and the
- * list with the exceptions
- *
- * @author Thomas Bauer, January 2017
- */
-public class DateFormatCallableTestMultiThread {
-
- // Class variables used in setup() have to be static because setup() has to be static
- /**
- * Result object given back by DateFormatCallable, one for each thread -- Array with converted
- * date values -- Array with thrown exceptions
- */
- private static final Result[] result = new Result[4];
-
- /**
- * The date values created by the run of of DateFormatRunnalbe. List will be filled in the setup()
- * method
- */
- @SuppressWarnings("serial")
- private static class StringArrayList extends ArrayList {
- /* nothing needed here */
- }
-
- private static final List[] createdDateValues = new StringArrayList[4];
-
- /**
- * Expected number of date values in the date value list created by each thread
- */
- private final int expectedCounterDateValues = 5;
-
- /**
- * Expected number of exceptions in the exception list created by each thread
- */
- private final int expectedCounterExceptions = 0;
-
- /**
- * Expected content of the list containing the date values created by each thread
- */
- private final List expectedDateValues =
- List.of("15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015");
-
- /**
- * Run Callable and prepare results for usage in the test methods
- */
- @BeforeAll
- public static void setup() {
- // Create a callable
- var callableDf = new DateFormatCallable("dd/MM/yyyy", "15/12/2015");
- // start thread using the Callable instance
- var executor = Executors.newCachedThreadPool();
- var futureResult1 = executor.submit(callableDf);
- var futureResult2 = executor.submit(callableDf);
- var futureResult3 = executor.submit(callableDf);
- var futureResult4 = executor.submit(callableDf);
- try {
- result[0] = futureResult1.get();
- result[1] = futureResult2.get();
- result[2] = futureResult3.get();
- result[3] = futureResult4.get();
- for (var i = 0; i < result.length; i++) {
- createdDateValues[i] = convertDatesToString(result[i]);
- }
- } catch (Exception e) {
- fail("Setup failed: " + e);
- }
- executor.shutdown();
- }
-
- private static List convertDatesToString(Result res) {
- // Format date value as DD.MM.YYYY
- if (res == null || res.getDateList() == null || res.getDateList().size() == 0) {
- return null;
- }
- var returnList = new StringArrayList();
-
- for (var dt : res.getDateList()) {
- var cal = Calendar.getInstance();
- cal.setTime(dt);
- returnList.add(cal.get(Calendar.DAY_OF_MONTH) + "."
- + cal.get(Calendar.MONTH) + "."
- + cal.get(Calendar.YEAR)
- );
- }
- return returnList;
- }
-
- /**
- * Test date values after the run of DateFormatRunnalbe. A correct run should deliver 5 times
- * 15.12.2015 by each thread
- */
- @Test
- void testDateValues() {
- for (var createdDateValue : createdDateValues) {
- assertEquals(expectedDateValues, createdDateValue);
- }
- }
-
- /**
- * Test number of dates in the list after the run of DateFormatRunnalbe. A correct run should
- * deliver 5 date values by each thread
- */
- @Test
- void testCounterDateValues() {
- for (var value : result) {
- assertEquals(expectedCounterDateValues, value.getDateList().size());
- }
- }
-
- /**
- * Test number of Exceptions in the list after the run of DateFormatRunnalbe. A correct run should
- * deliver no exceptions
- */
- @Test
- void testCounterExceptions() {
- for (var value : result) {
- assertEquals(expectedCounterExceptions, value.getExceptionList().size());
- }
- }
-}