   /*
    * Copyright (c) 2021, DB Systel GmbH
    * All rights reserved.
    *
    * SPDX-License-Identifier: Apache-2.0
    *
    * Licensed 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.
    *
    * Author: Frank Schwab, DB Systel GmbH
    *
    * Changes:
    *     2021-08-13: V1.0.0: Created. fhs
    */
   package de.db.bcm.tupw.crypto;

   import org.junit.*;

   import static org.junit.Assert.*;

   /**
    * Test case for SecureRandomFactory
    *
    * @author Frank Schwab, DB Systel GmbH
    * @version 1.0.0
    */
   public class TestSecureRandomFactory {

      private static final String LINUX_NAME = "Linux";
      private static final String NATIVE_NAME = "Native";
      private static final String NONBLOCKING_NAME = "Nonblocking";
      private static final String WINDOWS_NAME = "Windows";

      /*
       * Private constants
       */
      public TestSecureRandomFactory() {
      }

      @BeforeClass
      public static void setUpClass() {
      }

      @AfterClass
      public static void tearDownClass() {
      }

      @Before
      public void setUp() {
      }

      @After
      public void tearDown() {
      }

      @Test
      public void TestOSMatch() {
         final String optimalAlgorithm = SecureRandomFactory.getSensibleInstance().getAlgorithm();

         final String thisOS = getOsName();

         if (startsWithIgnoreCase(thisOS, WINDOWS_NAME)) {
            assertTrue("OS is '" + thisOS + "' but optimal algorithm '" + optimalAlgorithm + "' does not start with '" + WINDOWS_NAME + "'", startsWithIgnoreCase(optimalAlgorithm, WINDOWS_NAME));
         } else if (startsWithIgnoreCase(thisOS, LINUX_NAME)) {
            assertTrue("OS is '" + thisOS + "' but optimal algorithm '" + optimalAlgorithm + "' does not start with '" + NATIVE_NAME + "'", startsWithIgnoreCase(optimalAlgorithm, NATIVE_NAME));
            assertTrue("OS is '" + thisOS + "' but optimal algorithm '" + optimalAlgorithm + "' does not end with '" + NONBLOCKING_NAME + "'", startsWithIgnoreCase(optimalAlgorithm, NONBLOCKING_NAME));
         }
      }

      // Private methods

      /***
       * Gets the name of the operating system this program is running on
       *
       * @return Name of the operating system
       */
      private static String getOsName() {
         return System.getProperty("os.name");
      }

      /***
       * Tests if this string starts with the specified prefix ignoring the case.
       *
       * @param testString String to test
       * @param prefix The prefix to look for
       * @return true: The string starts with the specified prefix,
       * false: The string does not start with the specified prefix
       */
      private static boolean startsWithIgnoreCase(final String testString, final String prefix) {
         if (testString == null || prefix == null) {
            return (testString == null && prefix == null);
         }

         if (prefix.length() > testString.length()) {
            return false;
         }

         return testString.regionMatches(true, 0, prefix, 0, prefix.length());
      }
   }

@@ -1092,17 +1092,16 @@
 ctory %7B%0A
-%0A
       pr
@@ -1333,16 +1333,67 @@
 indows%22;
+%0A      private static final String END_QUOTE = %22'%22;
 %0A%0A      
@@ -1928,81 +1928,42 @@
     
-if (startsWithIgnoreCase(thisOS, WINDOWS_NAME)) %7B%0A            assertTrue(
+final String errorMessagePrefix = 
 %22OS 
@@ -2053,16 +2053,119 @@
  with '%22
+;%0A%0A         if (startsWithIgnoreCase(thisOS, WINDOWS_NAME)) %7B%0A            assertTrue(errorMessagePrefix
  + WINDO
@@ -2166,35 +2166,41 @@
  WINDOWS_NAME + 
-%22'%22
+END_QUOTE
 , startsWithIgno
@@ -2331,103 +2331,26 @@
 rue(
-%22OS is '%22 + thisOS + %22' but optimal algorithm '%22 + optimalAlgorithm + %22' does not start with '%22
+errorMessagePrefix
  + N
@@ -2354,35 +2354,41 @@
 + NATIVE_NAME + 
-%22'%22
+END_QUOTE
 , startsWithIgno
@@ -2454,101 +2454,26 @@
 rue(
-%22OS is '%22 + thisOS + %22' but optimal algorithm '%22 + optimalAlgorithm + %22' does not end with '%22
+errorMessagePrefix
  + N
@@ -2490,19 +2490,25 @@
 _NAME + 
-%22'%22
+END_QUOTE
 , starts

Clean up of new SecureRandomFactoryTest.