diff --git a/.github/workflows/cluster-tests.yml b/.github/workflows/cluster-tests.yml index fb33f9258b..e6af1fd0e2 100644 --- a/.github/workflows/cluster-tests.yml +++ b/.github/workflows/cluster-tests.yml @@ -22,5 +22,12 @@ jobs: with: distribution: 'temurin' java-version: '17.0.6' - - name: Cluster Tests + - name: Cluster Tests with JDK 17 + run: mvn -B clean install --file integration/pom.xml -P cluster-tests + - name: Set up JDK 21 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '21.0.4' + - name: Cluster Tests with JDK 21 run: mvn -B clean install --file integration/pom.xml -P cluster-tests diff --git a/.github/workflows/jdk-17-tests.yml b/.github/workflows/jdk-17-tests.yml index 015d1b8811..22d28dcbc1 100644 --- a/.github/workflows/jdk-17-tests.yml +++ b/.github/workflows/jdk-17-tests.yml @@ -20,13 +20,13 @@ jobs: steps: - uses: actions/checkout@v3 - name: Cache Maven packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.m2 key: ${{ runner.os }}-m2 restore-keys: ${{ runner.os }}-m2 - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '11.0.12+7' @@ -35,9 +35,9 @@ jobs: - name: check java version run: echo "JAVA_VERSION=$(java -version)" - name: Build in jdk11 - run: mvn -B clean install -DskipTests --file pom.xml + run: mvn clean install -DskipTests --file pom.xml - name: Set up JDK 17 - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '17.0.6' @@ -48,4 +48,4 @@ jobs: - name: Print segment run: echo "Running build for segment ${{ matrix.profile }}" - name: JDK 17 Tests - run: mvn -B clean install --file integration/pom.xml -P ${{ matrix.profile }} -fae + run: mvn clean install --file integration/pom.xml -P ${{ matrix.profile }} -fae diff --git a/.github/workflows/jdk-21-tests.yml b/.github/workflows/jdk-21-tests.yml new file mode 100644 index 0000000000..a472eb80b4 --- /dev/null +++ b/.github/workflows/jdk-21-tests.yml @@ -0,0 +1,55 @@ +name: Integration tests (Ubuntu, OpenJDK21) + +on: [push, pull_request] + +jobs: + ubuntu: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - id: 1 + profile: tests-mediators_tests-other_tests-sample + - id: 2 + profile: tests-service_tests-patches_service-samples + - id: 3 + profile: tests-transport_tests-platform + - id: 4 + profile: management-api_dss-tests + fail-fast: false + steps: + - uses: actions/checkout@v3 + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2 + restore-keys: ${{ runner.os }}-m2 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11.0.12+7' + - name: check mvn version + run: echo "MAVEN_VERSION=$(mvn -v)" + - name: check java version + run: echo "JAVA_VERSION=$(java -version)" + - name: Set JAVA_TOOL_OPTIONS + run: | + NEW_JAVA_TOOL_OPTIONS="${{ env.JAVA_TOOL_OPTIONS }} -Djdk.util.zip.disableZip64ExtraFieldValidation=true -Djdk.nio.zipfs.allowDotZipEntry=true --add-opens=java.base/java.net=ALL-UNNAMED" + echo "JAVA_TOOL_OPTIONS=$NEW_JAVA_TOOL_OPTIONS" >> $GITHUB_ENV + - name: Build in jdk11 + run: mvn clean install -DskipTests --file pom.xml + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '21.0.4' + - name: check mvn version + run: echo "MAVEN_VERSION=$(mvn -v)" + - name: check java version + run: echo "JAVA_VERSION=$(java -version)" + - name: Print segment + run: echo "Running build for segment ${{ matrix.profile }}" + - name: JDK 21 Tests + run: mvn clean install --file integration/pom.xml -P ${{ matrix.profile }} -fae diff --git a/.github/workflows/smoke-tests.yml b/.github/workflows/smoke-tests.yml index efb6c5535b..a5ff042b77 100644 --- a/.github/workflows/smoke-tests.yml +++ b/.github/workflows/smoke-tests.yml @@ -19,9 +19,7 @@ jobs: - name: Build with Maven run: mvn -B clean install -P smoke-tests --file pom.xml -fae windows: - runs-on: windows-latest - steps: - name: Configure Git to support long paths run: git config --global core.longpaths true @@ -29,7 +27,7 @@ jobs: run: git config --global core.longpaths - uses: actions/checkout@v2 - name: Set up JDK 11 - uses: joschi/setup-jdk@v2 + uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '11.0.12+7' diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index e6a3555022..4100c57511 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -1,4 +1,4 @@ -name: Integration tests (Windows, OpenJDK8) +name: Integration tests (Windows, OpenJDK11) on: [push] @@ -12,7 +12,7 @@ jobs: run: git config --system core.longpaths true - uses: actions/checkout@v2 - name: Set up JDK 11 - uses: joschi/setup-jdk@v2 + uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: 11 @@ -28,7 +28,7 @@ jobs: run: git config --system core.longpaths true - uses: actions/checkout@v2 - name: Set up JDK 11 - uses: joschi/setup-jdk@v2 + uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: 11 @@ -44,7 +44,7 @@ jobs: run: git config --system core.longpaths true - uses: actions/checkout@v2 - name: Set up JDK 11 - uses: joschi/setup-jdk@v2 + uses: actions/setup-java@v3 with: distribution: 'adopt' java-version: 11 diff --git a/README.md b/README.md index b877a00fdf..0abc3f6453 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Please follow the steps below to build WSO2 Micro Integrator from the source cod 2. Run the maven command `mvn clean install` from the root directory of the repository. 3. The generated Micro Integrator distribution can be found at `micro-integrator/distribution/target/wso2mi-.zip`. -Please note that the product can be build using only JDK 11 but the integration tests can be run in either JDK 11 or 17. +Please note that the product can be build using only JDK 11 but the integration tests can be run in either JDK 11, 17 or 21. #### Building the Docker image diff --git a/components/org.wso2.micro.integrator.initializer/src/test/java/org/wso2/carbon/mediation/initializer/MediationPersistenceTest.java b/components/org.wso2.micro.integrator.initializer/src/test/java/org/wso2/carbon/mediation/initializer/MediationPersistenceTest.java index 4a6d5dafe5..df106017b8 100644 --- a/components/org.wso2.micro.integrator.initializer/src/test/java/org/wso2/carbon/mediation/initializer/MediationPersistenceTest.java +++ b/components/org.wso2.micro.integrator.initializer/src/test/java/org/wso2/carbon/mediation/initializer/MediationPersistenceTest.java @@ -44,6 +44,7 @@ import javax.xml.stream.XMLStreamException; import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -75,13 +76,14 @@ public void setUp() { } protected SynapseConfiguration getConfigurationFromSynapseXML() { - try { - FileInputStream fin = new FileInputStream(path + File.separator + "synapse.xml"); + try (FileInputStream fin = new FileInputStream(path + File.separator + "synapse.xml")) { return XMLConfigurationBuilder.getConfiguration(fin, new Properties()); } catch (FileNotFoundException e) { - fail("The synapse.xml file does not exist"); + fail("The synapse.xml file does not exist at the path: " + path); } catch (XMLStreamException e) { - fail("Error parsing the synapse.xml"); + fail("Error parsing the synapse.xml file at the path: " + path); + } catch (IOException e) { + fail("IO error while reading the synapse.xml file at the path: " + path); } return null; } diff --git a/distribution/src/scripts/micro-integrator.bat b/distribution/src/scripts/micro-integrator.bat index ef06cb8107..d67fb29b2e 100644 --- a/distribution/src/scripts/micro-integrator.bat +++ b/distribution/src/scripts/micro-integrator.bat @@ -158,7 +158,7 @@ goto supportedJdk :unknownJdk echo Starting WSO2 MI (in unsupported JDK %JAVA_VERSION%) -echo [ERROR] WSO2 MI is supported only between JDK 11 and JDK 17" +echo [ERROR] WSO2 MI is supported only between JDK 11 and JDK 21" goto end :supportedJdk diff --git a/integration/automation-extensions/src/main/java/org/wso2/esb/integration/common/extensions/carbonserver/CarbonServerManager.java b/integration/automation-extensions/src/main/java/org/wso2/esb/integration/common/extensions/carbonserver/CarbonServerManager.java index 9ba50e3391..58efba38c5 100644 --- a/integration/automation-extensions/src/main/java/org/wso2/esb/integration/common/extensions/carbonserver/CarbonServerManager.java +++ b/integration/automation-extensions/src/main/java/org/wso2/esb/integration/common/extensions/carbonserver/CarbonServerManager.java @@ -45,7 +45,6 @@ import java.util.Arrays; import java.util.Map; import java.util.Set; -import java.util.concurrent.TimeUnit; import java.util.function.BooleanSupplier; import javax.xml.xpath.XPathExpressionException; @@ -316,10 +315,10 @@ private Process startProcess(String workingDirectory, String[] cmdArray) throws } private void waitTill(BooleanSupplier predicate, int maxWaitTime, String task) throws InterruptedException { - long time = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(maxWaitTime); + long time = System.currentTimeMillis() + maxWaitTime * 1000L; while (predicate.getAsBoolean() && System.currentTimeMillis() < time) { log.info("waiting for server " + task); - TimeUnit.SECONDS.sleep(1); + Thread.sleep(1000); } } diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataETagTestCase.java b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataETagTestCase.java index f8d036997d..face3e1a0b 100644 --- a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataETagTestCase.java +++ b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataETagTestCase.java @@ -24,11 +24,9 @@ import org.testng.annotations.Test; import org.wso2.ei.dataservice.integration.test.DSSIntegrationTest; -import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import static org.wso2.ei.dataservice.integration.test.odata.ODataTestUtils.getETag; import static org.wso2.ei.dataservice.integration.test.odata.ODataTestUtils.sendDELETE; @@ -61,24 +59,28 @@ public void destroy() throws Exception { public void validateETagRetrievalTestCase() throws Exception { String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES"; String content = "{\"FILENAME\": \"WSO2PROD\" ,\"TYPE\" : \"dss\"}"; - Map headers = new HashMap<>(); + ConcurrentHashMap headers = new ConcurrentHashMap<>(); headers.put("Accept", "application/json"); Object[] response = sendPOST(endpoint, content, headers); Assert.assertEquals(response[0], ODataTestUtils.CREATED); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD')"; response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String etag = getETag(response[1].toString()); headers.put("If-Match", "1212122"); response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.PRE_CONDITION_FAILED); headers.remove("If-Match"); headers.put("If-None-Match", etag); response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.PRE_CONDITION_FAILED); headers.remove("If-None-Match"); headers.put("If-Match", etag); response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); } @@ -86,19 +88,23 @@ public void validateETagRetrievalTestCase() throws Exception { public void validateETagGenerationTestCase() throws Exception { String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES"; String content = "{\"FILENAME\": \"WSO2\" ,\"TYPE\" : \"bam\"}"; - Map headers = new HashMap<>(); + ConcurrentHashMap headers = new ConcurrentHashMap<>(); headers.put("Accept", "application/json"); Object[] response = sendPOST(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.CREATED); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2\')"; response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String etag = getETag(response[1].toString()); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2\')"; content = "{\"TYPE\" : \"USJP\"}"; int responseCode = sendPUT(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String tempETag = getETag(response[1].toString()); Assert.assertNotEquals(etag, tempETag); @@ -107,9 +113,10 @@ public void validateETagGenerationTestCase() throws Exception { @Test(groups = "wso2.dss", description = "etag concurrent handling with put method test", dependsOnMethods = "validateETagGenerationTestCase") public void validateETagConcurrentHandlingTestCaseForPutMethod() throws Exception { String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')"; - Map headers = new HashMap<>(); + ConcurrentHashMap headers = new ConcurrentHashMap<>(); headers.put("Accept", "application/json"); Object[] response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String etag = getETag(response[1].toString()); //modifying data - E-Tag should be changed after processing the below request @@ -117,17 +124,20 @@ public void validateETagConcurrentHandlingTestCaseForPutMethod() throws Exceptio String content = "{\"TYPE\" : \"ml\"}"; int responseCode = sendPUT(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); // Data has been modified therefore E-Tag has been changed, Then If-None-Match should be worked with previous E-Tag headers.remove("If-Match"); headers.put("If-None-Match", etag); content = "{\"TYPE\" : \"test\"}"; responseCode = sendPUT(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); //testing concurrent test with put method // get the E-Tag response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); etag = getETag(response[1].toString()); content = "{\"TYPE\" : \"SriLanka\"}"; @@ -136,15 +146,18 @@ public void validateETagConcurrentHandlingTestCaseForPutMethod() throws Exceptio threadExecutor.run(); Thread.sleep(1000); response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String tempETag = getETag(response[1].toString()); Assert.assertNotEquals(etag, tempETag); headers.put("If-Match", etag); content = "{\"TYPE\" : \"MB\"}"; responseCode = sendPUT(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); headers.put("If-Match", tempETag); response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); // Data validation Assert.assertFalse(response[1].toString().contains("MB"), "E-Tag with put method failed"); @@ -153,6 +166,7 @@ public void validateETagConcurrentHandlingTestCaseForPutMethod() throws Exceptio //testing concurrent test with delete method // get the E-Tag response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); headers.remove("If-Match"); threadExecutor = new ODataRequestThreadExecutor("DELETE", null, headers, endpoint); @@ -161,32 +175,37 @@ public void validateETagConcurrentHandlingTestCaseForPutMethod() throws Exceptio headers.put("If-Match", etag); content = "{\"TYPE\" : \"MB\"}"; responseCode = sendPUT(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NOT_FOUND); } @Test(groups = "wso2.dss", description = "etag concurrent handling with patch method test", dependsOnMethods = "validateETagConcurrentHandlingTestCaseForPutMethod") public void validateETagConcurrentHandlingTestCaseForPatchMethod() throws Exception { String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2\')"; - Map headers = new HashMap<>(); + ConcurrentHashMap headers = new ConcurrentHashMap<>(); headers.put("Accept", "application/json"); Object[] response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String etag = getETag(response[1].toString()); //modifying data - E-Tag should be changed after processing the below request headers.put("If-Match", etag); String content = "{\"TYPE\" : \"ml\"}"; int responseCode = sendPATCH(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); // Data has been modified therefore E-Tag has been changed, Then If-None-Match should be worked with previous E-Tag headers.remove("If-Match"); headers.put("If-None-Match", etag); content = "{\"TYPE\" : \"test\"}"; responseCode = sendPATCH(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); //testing concurrent test with put method // get the E-Tag response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); etag = getETag(response[1].toString()); content = "{\"TYPE\" : \"SriLanka\"}"; @@ -195,15 +214,18 @@ public void validateETagConcurrentHandlingTestCaseForPatchMethod() throws Except threadExecutor.run(); Thread.sleep(1000); response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String tempETag = getETag(response[1].toString()); Assert.assertNotEquals(etag, tempETag); headers.put("If-Match", etag); content = "{\"TYPE\" : \"MB\"}"; responseCode = sendPATCH(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); headers.put("If-Match", tempETag); response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); // Data validation Assert.assertFalse(response[1].toString().contains("MB"), "E-Tag with put method failed"); @@ -212,6 +234,7 @@ public void validateETagConcurrentHandlingTestCaseForPatchMethod() throws Except //testing concurrent test with delete method // get the E-Tag response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); headers.remove("If-Match"); threadExecutor = new ODataRequestThreadExecutor("DELETE", null, headers, endpoint); @@ -220,6 +243,7 @@ public void validateETagConcurrentHandlingTestCaseForPatchMethod() throws Except headers.put("If-Match", etag); content = "{\"TYPE\" : \"MB\"}"; responseCode = sendPATCH(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NOT_FOUND); } @@ -229,22 +253,27 @@ public void validateETagConcurrentHandlingTestCaseForDeleteMethod() throws Excep System.out.println("This test is temporarily skipped for this workflow"); String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES"; String content = "{\"FILENAME\": \"WSO2PROD\" ,\"TYPE\" : \"dss\"}"; - Map headers = new HashMap<>(); + ConcurrentHashMap headers = new ConcurrentHashMap<>(); headers.put("Accept", "application/json"); Object[] response = sendPOST(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.CREATED); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')"; response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String etag = ODataTestUtils.getETag(response[1].toString()); headers.put("If-None-Match", etag); int responseCode = sendDELETE(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); headers.remove("If-None-Match"); headers.put("If-Match", etag); responseCode = sendDELETE(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); responseCode = sendDELETE(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NOT_FOUND); // To insert values @@ -253,6 +282,7 @@ public void validateETagConcurrentHandlingTestCaseForDeleteMethod() throws Excep //testing concurrent test with put method // get the E-Tag response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); etag = getETag(response[1].toString()); content = "{\"TYPE\" : \"SriLanka\"}"; @@ -261,16 +291,20 @@ public void validateETagConcurrentHandlingTestCaseForDeleteMethod() throws Excep threadExecutor.run(); Thread.sleep(1000); response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String tempETag = getETag(response[1].toString()); Assert.assertNotEquals(etag, tempETag); headers.put("If-Match", etag); responseCode = sendDELETE(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); headers.put("If-Match", tempETag); responseCode = sendDELETE(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); responseCode = sendDELETE(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, 404); } } @@ -281,28 +315,33 @@ public void validateETagConcurrentHandlingTestCaseForUpdatePropertyWithPutMethod if (!Boolean.parseBoolean(System.getenv("CI_BUILD_SKIP"))) { String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES"; String content = "{\"FILENAME\": \"WSO2PROD\" ,\"TYPE\" : \"dss\"}"; - Map headers = new HashMap<>(); + ConcurrentHashMap headers = new ConcurrentHashMap<>(); headers.put("Accept", "application/json"); Object[] response = sendPOST(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.CREATED); String entityEndpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')"; response = sendGET(entityEndpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String etag = getETag(response[1].toString()); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')/TYPE"; content = "{\"value\" : \"Jayasooriya\"}"; headers.put("If-None-Match", etag); int responseCode = sendPUT(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); headers.remove("If-None-Match"); headers.put("If-Match", etag); responseCode = sendPUT(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); //testing concurrent test with put method // get the E-Tag headers.remove("If-Match"); response = sendGET(entityEndpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); etag = getETag(response[1].toString()); content = "{\"value\" : \"SriLanka\"}"; @@ -310,21 +349,25 @@ public void validateETagConcurrentHandlingTestCaseForUpdatePropertyWithPutMethod threadExecutor.run(); Thread.sleep(1000); response = sendGET(entityEndpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String tempETag = getETag(response[1].toString()); Assert.assertNotEquals(etag, tempETag); headers.put("If-Match", etag); content = "{\"value\" : \"DSS Server\"}"; responseCode = sendPUT(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); // Data validation headers.remove("If-Match"); response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); Assert.assertFalse(response[1].toString().contains("DSS Server"), "E-Tag with put method failed"); Assert.assertTrue(response[1].toString().contains("SriLanka"), "E-Tag with put method failed"); headers.put("If-Match", tempETag); responseCode = sendPUT(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); } @@ -336,24 +379,28 @@ public void validateETagConcurrentHandlingTestCaseForUpdatePropertyWithPatchMeth System.out.println("This test is temporarily skipped for this workflow"); String entityEndpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')"; String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')/TYPE"; - Map headers = new HashMap<>(); + ConcurrentHashMap headers = new ConcurrentHashMap<>(); headers.put("Accept", "application/json"); Object[] response = sendGET(entityEndpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String etag = getETag(response[1].toString()); String content = "{\"value\" : \"Jayasooriya\"}"; headers.put("If-None-Match", etag); int responseCode = sendPATCH(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); headers.remove("If-None-Match"); headers.put("If-Match", etag); responseCode = sendPATCH(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); //testing concurrent test with put method // get the E-Tag headers.remove("If-Match"); response = sendGET(entityEndpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); etag = getETag(response[1].toString()); content = "{\"value\" : \"SriLanka\"}"; @@ -361,21 +408,25 @@ public void validateETagConcurrentHandlingTestCaseForUpdatePropertyWithPatchMeth threadExecutor.run(); Thread.sleep(1000); response = sendGET(entityEndpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); String tempETag = getETag(response[1].toString()); Assert.assertNotEquals(etag, tempETag); headers.put("If-Match", etag); content = "{\"value\" : \"DSS Server\"}"; responseCode = sendPATCH(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); // Data validation headers.remove("If-Match"); response = sendGET(entityEndpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); Assert.assertFalse(response[1].toString().contains("DSS Server"), "E-Tag with patch method failed"); Assert.assertTrue(response[1].toString().contains("SriLanka"), "E-Tag with patch method failed"); headers.put("If-Match", tempETag); responseCode = sendPATCH(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); } diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataReferenceTestCase.java b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataReferenceTestCase.java index 59c6f782ff..f8e88eb55c 100644 --- a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataReferenceTestCase.java +++ b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataReferenceTestCase.java @@ -24,10 +24,7 @@ import org.testng.annotations.Test; import org.wso2.ei.dataservice.integration.test.DSSIntegrationTest; -import java.io.File; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; import static org.wso2.ei.dataservice.integration.test.odata.ODataTestUtils.sendDELETE; @@ -61,12 +58,14 @@ public void validateNavigationPropertyReferencesTestCase() throws Exception { Map headers = new HashMap<>(); headers.put("Accept", "application/json"); Object[] response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); Assert.assertTrue( response[1].toString().contains("FILERECORDS(1)") && response[1].toString().contains("FILERECORDS(4)"), "Navigation property reference retrieval failed"); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILERECORDS(2)/FILES/$ref"; response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); Assert.assertTrue(response[1].toString().contains("FILES('WSO2DSS')"), "Navigation property reference retrieval failed"); @@ -78,6 +77,7 @@ public void validateNavigationPropertyTestCase() throws Exception { Map headers = new HashMap<>(); headers.put("Accept", "application/json"); Object[] response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); } @@ -93,6 +93,7 @@ public void validateUpdateReferenceTestCase() throws Exception { Assert.assertEquals(response[0], ODataTestUtils.NO_CONTENT); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILERECORDS(5)/FILES/$ref"; response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); Assert.assertTrue(response[1].toString().contains("FILES('WSO2DSS')"), "Navigation property reference retrieval failed"); @@ -101,9 +102,11 @@ public void validateUpdateReferenceTestCase() throws Exception { + "/FILES('WSO2ML')\"} "; headers.put("Accept", "application/json"); int responseCode = sendPUT(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES('WSO2ML')/FILERECORDS/$ref"; response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); Assert.assertTrue(response[1].toString().contains("FILERECORDS(5)"), "Navigation property reference retrieval failed"); @@ -117,14 +120,18 @@ public void validateDeleteReferenceTestCase() throws Exception { Map headers = new HashMap<>(); headers.put("Accept", "application/json"); int responseCode = sendDELETE(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILERECORDS(5)/FILES/$ref"; Object[] response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.NO_CONTENT); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILERECORDS(1)/FILES/$ref"; responseCode = sendDELETE(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.NO_CONTENT); } @@ -137,13 +144,16 @@ public void validateAddEntityWithReferenceTestCase() throws Exception { Map headers = new HashMap<>(); headers.put("Accept", "application/json"); Object[] response = sendPOST(endpoint, content, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.CREATED); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILERECORDS(11)/FILES/$ref"; response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); Assert.assertTrue(response[1].toString().contains("FILES('WSO2DSS')")); endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILERECORDS(11)"; response = sendGET(endpoint, headers); + Thread.sleep(1000); Assert.assertEquals(response[0], ODataTestUtils.OK); Assert.assertTrue(response[1].toString().contains("\"FILENAME\":\"WSO2DSS\"")); } diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataRequestThreadExecutor.java b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataRequestThreadExecutor.java index 384a70645b..24019bce9d 100644 --- a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataRequestThreadExecutor.java +++ b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataRequestThreadExecutor.java @@ -26,10 +26,10 @@ */ public class ODataRequestThreadExecutor extends Thread { - private String httpMethod; - private String content; - private Map headers; - private String endpoint; + private final String httpMethod; + private final String content; + private final Map headers; + private final String endpoint; public ODataRequestThreadExecutor(String httpMethod, String content, Map headers, String endpoint) { this.content = content; diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataTestUtils.java b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataTestUtils.java index 8677ce4f48..a394d8429d 100644 --- a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataTestUtils.java +++ b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataTestUtils.java @@ -19,15 +19,15 @@ package org.wso2.ei.dataservice.integration.test.odata; import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPatch; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; import org.json.JSONException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -37,6 +37,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.Map; public class ODataTestUtils { @@ -49,98 +50,118 @@ public class ODataTestUtils { public static final int NOT_FOUND = 404; public static Object[] sendPOST(String endpoint, String content, Map headers) throws IOException { - HttpClient httpClient = new DefaultHttpClient(); - HttpPost httpPost = new HttpPost(endpoint); - for (String headerType : headers.keySet()) { - httpPost.setHeader(headerType, headers.get(headerType)); - } - if (null != content) { - HttpEntity httpEntity = new ByteArrayEntity(content.getBytes("UTF-8")); - if (headers.get("Content-Type") == null) { - httpPost.setHeader("Content-Type", "application/json"); + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { + HttpPost httpPost = new HttpPost(endpoint); + for (String headerType : headers.keySet()) { + httpPost.setHeader(headerType, headers.get(headerType)); } - httpPost.setEntity(httpEntity); - } - HttpResponse httpResponse = httpClient.execute(httpPost); - if (httpResponse.getEntity() != null) { - BufferedReader reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); - String inputLine; - StringBuilder response = new StringBuilder(); + if (null != content) { + HttpEntity httpEntity = new ByteArrayEntity(content.getBytes(StandardCharsets.UTF_8)); + if (headers.get("Content-Type") == null) { + httpPost.setHeader("Content-Type", "application/json"); + } + httpPost.setEntity(httpEntity); + } + try (CloseableHttpResponse httpResponse = httpClient.execute(httpPost)) { + if (httpResponse.getEntity() != null) { + BufferedReader reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); + String inputLine; + StringBuilder response = new StringBuilder(); - while ((inputLine = reader.readLine()) != null) { - response.append(inputLine); + while ((inputLine = reader.readLine()) != null) { + response.append(inputLine); + } + reader.close(); + return new Object[] { httpResponse.getStatusLine().getStatusCode(), response.toString() }; + } else { + return new Object[] { httpResponse.getStatusLine().getStatusCode() }; + } } - reader.close(); - return new Object[] { httpResponse.getStatusLine().getStatusCode(), response.toString() }; - } else { - return new Object[] { httpResponse.getStatusLine().getStatusCode() }; + } catch (IOException e) { + throw new IOException(e.getMessage()); } } public static Object[] sendGET(String endpoint, Map headers) throws IOException { - HttpClient httpClient = new DefaultHttpClient(); - HttpGet httpGet = new HttpGet(endpoint); - for (String headerType : headers.keySet()) { - httpGet.setHeader(headerType, headers.get(headerType)); - } - HttpResponse httpResponse = httpClient.execute(httpGet); - if (httpResponse.getEntity() != null) { - BufferedReader reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); - String inputLine; - StringBuilder response = new StringBuilder(); + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { + HttpGet httpGet = new HttpGet(endpoint); + for (String headerType : headers.keySet()) { + httpGet.setHeader(headerType, headers.get(headerType)); + } + try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { + if (httpResponse.getEntity() != null) { + BufferedReader reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); + String inputLine; + StringBuilder response = new StringBuilder(); - while ((inputLine = reader.readLine()) != null) { - response.append(inputLine); + while ((inputLine = reader.readLine()) != null) { + response.append(inputLine); + } + reader.close(); + return new Object[] { httpResponse.getStatusLine().getStatusCode(), response.toString() }; + } else { + return new Object[] { httpResponse.getStatusLine().getStatusCode() }; + } } - reader.close(); - return new Object[] { httpResponse.getStatusLine().getStatusCode(), response.toString() }; - } else { - return new Object[] { httpResponse.getStatusLine().getStatusCode() }; + } catch (IOException e) { + throw new IOException(e.getMessage()); } } public static int sendPUT(String endpoint, String content, Map headers) throws IOException { - HttpClient httpClient = new DefaultHttpClient(); - HttpPut httpPut = new HttpPut(endpoint); - for (String headerType : headers.keySet()) { - httpPut.setHeader(headerType, headers.get(headerType)); - } - if (null != content) { - HttpEntity httpEntity = new ByteArrayEntity(content.getBytes("UTF-8")); - if (headers.get("Content-Type") == null) { - httpPut.setHeader("Content-Type", "application/json"); + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { + HttpPut httpPut = new HttpPut(endpoint); + for (String headerType : headers.keySet()) { + httpPut.setHeader(headerType, headers.get(headerType)); } - httpPut.setEntity(httpEntity); + if (null != content) { + HttpEntity httpEntity = new ByteArrayEntity(content.getBytes(StandardCharsets.UTF_8)); + if (headers.get("Content-Type") == null) { + httpPut.setHeader("Content-Type", "application/json"); + } + httpPut.setEntity(httpEntity); + } + try (CloseableHttpResponse response = httpClient.execute(httpPut)) { + return response.getStatusLine().getStatusCode(); + } + } catch (IOException e) { + throw new IOException(e.getMessage()); } - HttpResponse httpResponse = httpClient.execute(httpPut); - return httpResponse.getStatusLine().getStatusCode(); } public static int sendPATCH(String endpoint, String content, Map headers) throws IOException { - HttpClient httpClient = new DefaultHttpClient(); - HttpPatch httpPatch = new HttpPatch(endpoint); - for (String headerType : headers.keySet()) { - httpPatch.setHeader(headerType, headers.get(headerType)); - } - if (null != content) { - HttpEntity httpEntity = new ByteArrayEntity(content.getBytes("UTF-8")); - if (headers.get("Content-Type") == null) { - httpPatch.setHeader("Content-Type", "application/json"); + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { + HttpPatch httpPatch = new HttpPatch(endpoint); + for (String headerType : headers.keySet()) { + httpPatch.setHeader(headerType, headers.get(headerType)); + } + if (null != content) { + HttpEntity httpEntity = new ByteArrayEntity(content.getBytes(StandardCharsets.UTF_8)); + if (headers.get("Content-Type") == null) { + httpPatch.setHeader("Content-Type", "application/json"); + } + httpPatch.setEntity(httpEntity); } - httpPatch.setEntity(httpEntity); + try (CloseableHttpResponse response = httpClient.execute(httpPatch)) { + return response.getStatusLine().getStatusCode(); + } + } catch (IOException e) { + throw new IOException(e.getMessage()); } - HttpResponse httpResponse = httpClient.execute(httpPatch); - return httpResponse.getStatusLine().getStatusCode(); } public static int sendDELETE(String endpoint, Map headers) throws IOException { - HttpClient httpClient = new DefaultHttpClient(); - HttpDelete httpDelete = new HttpDelete(endpoint); - for (String headerType : headers.keySet()) { - httpDelete.setHeader(headerType, headers.get(headerType)); + try (CloseableHttpClient httpClient = HttpClients.createDefault()) { + HttpDelete httpDelete = new HttpDelete(endpoint); + for (String headerType : headers.keySet()) { + httpDelete.setHeader(headerType, headers.get(headerType)); + } + try (CloseableHttpResponse response = httpClient.execute(httpDelete)) { + return response.getStatusLine().getStatusCode(); + } + } catch (IOException e) { + throw new IOException(e.getMessage()); } - HttpResponse httpResponse = httpClient.execute(httpDelete); - return httpResponse.getStatusLine().getStatusCode(); } public static String getETag(String content) throws ParseException, JSONException { @@ -152,5 +173,4 @@ public static String getETag(String content) throws ParseException, JSONExceptio return ((JSONObject) ((JSONArray) ((JSONObject) obj).get("value")).get(0)).get("@odata.etag").toString(); } } - } diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/samples/InMemoryDSSampleTestCase.java b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/samples/InMemoryDSSampleTestCase.java index 5c2cc03c9d..ae1adb3a7a 100755 --- a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/samples/InMemoryDSSampleTestCase.java +++ b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/samples/InMemoryDSSampleTestCase.java @@ -144,7 +144,7 @@ private void addDataSources() throws Exception { echoSampleSourceMetaInfo.setDefinition(echoSampleDSDefinition); dataSourceAdminClient.addDataSource(echoSampleSourceMetaInfo); - Thread.sleep(1000); + Thread.sleep(5000); } private void removeDataSources() throws Exception { @@ -152,6 +152,6 @@ private void removeDataSources() throws Exception { dssContext.getContextUrls().getBackEndUrl(), sessionCookie); dataSourceAdminClient.deleteDataSource("IN_MEMORY_SAMPLE_DS"); dataSourceAdminClient.deleteDataSource("ECHO_SAMPLE_DS"); - Thread.sleep(1000); + Thread.sleep(5000); } } diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2server.sh b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2server.sh index 829c4a7773..01c1f868cc 100755 --- a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2server.sh +++ b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2server.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2server1.sh b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2server1.sh index e1822606da..b8dd5a06a7 100755 --- a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2server1.sh +++ b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2server1.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2serverLegacyMode.sh b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2serverLegacyMode.sh index e2171e9c16..cb733d9068 100755 --- a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2serverLegacyMode.sh +++ b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2serverLegacyMode.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2serverLegacyMode1.sh b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2serverLegacyMode1.sh index 5a81bf52a3..99dcbf703c 100755 --- a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2serverLegacyMode1.sh +++ b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/artifacts/DSS/serverConfigs/wso2serverLegacyMode1.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/bin/integrator.sh b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/bin/integrator.sh index f59e001127..2a6a189918 100755 --- a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/bin/integrator.sh +++ b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/resources/bin/integrator.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/mediation-tests/tests-mediator-1/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-mediator-1/src/test/resources/bin/integrator.sh index f59e001127..2a6a189918 100755 --- a/integration/mediation-tests/tests-mediator-1/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-mediator-1/src/test/resources/bin/integrator.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/mediation-tests/tests-mediator-2/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-mediator-2/src/test/resources/bin/integrator.sh index f59e001127..2a6a189918 100755 --- a/integration/mediation-tests/tests-mediator-2/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-mediator-2/src/test/resources/bin/integrator.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/mediation-tests/tests-other/src/test/java/org/wso2/carbon/esb/serviceCatalog/test/ServiceCatalogTestCase.java b/integration/mediation-tests/tests-other/src/test/java/org/wso2/carbon/esb/serviceCatalog/test/ServiceCatalogTestCase.java index 396e3a50df..3a925cd6ec 100644 --- a/integration/mediation-tests/tests-other/src/test/java/org/wso2/carbon/esb/serviceCatalog/test/ServiceCatalogTestCase.java +++ b/integration/mediation-tests/tests-other/src/test/java/org/wso2/carbon/esb/serviceCatalog/test/ServiceCatalogTestCase.java @@ -218,8 +218,8 @@ public void testServiceCatalogMetadataWithEnv() @Test(groups = {"wso2.esb"}, description = "Test the ZIP file created by the service catalog", priority = 7) - public void testServiceCatalogZipFile() throws CarbonException, FileNotFoundException { - File extracted = chekAndExtractPayloadZip(); + public void testServiceCatalogZipFile() throws CarbonException, FileNotFoundException, InterruptedException { + File extracted = checkAndExtractPayloadZip(); assertTrue(extracted.exists(), "Error occurred while extracting the ZIP"); File metadataFile = new File(extracted, "healthcare_v1.0.0-SNAPSHOT"); File yamlFile = new File(metadataFile, "metadata.yaml"); @@ -244,7 +244,7 @@ public void testUploadOnlyNewAPIs() File.separator + TOML_FILE)); assertTrue(Utils.checkForLog(carbonLogReader, "Successfully updated the service catalog", 10), "Did not receive the expected info log"); - File extracted = chekAndExtractPayloadZip(); + File extracted = checkAndExtractPayloadZip(); assertTrue(extracted.exists(), "Error occurred while extracting the ZIP"); assertFalse(checkMetadataFileExists(extracted, "healthcare_v1.0.0-SNAPSHOT"), "healthcare API should not be uploaded again"); @@ -269,7 +269,7 @@ public void testUploadOnlyModifiedAPIs() File.separator + TOML_FILE)); assertTrue(Utils.checkForLog(carbonLogReader, "Successfully updated the service catalog", 10), "Did not receive the expected info log"); - File extracted = chekAndExtractPayloadZip(); + File extracted = checkAndExtractPayloadZip(); assertTrue(extracted.exists(), "Error occurred while extracting the ZIP"); assertFalse(checkMetadataFileExists(extracted, "healthcare_v1.0.0-SNAPSHOT"), "healthcare API should not be uploaded again"); @@ -316,7 +316,7 @@ public void testServiceCatalogProxyServiceMetadata() serverConfigurationManager.restartMicroIntegrator(); assertTrue(Utils.checkForLog(carbonLogReader, "Successfully updated the service catalog", 10), "Did not receive the expected info log"); - File extracted = chekAndExtractPayloadZip(); + File extracted = checkAndExtractPayloadZip(); assertTrue(extracted.exists(), "Error occurred while extracting the ZIP"); File metadataFile = new File(extracted, "SampleProxyService_proxy_v1.0.0"); File yamlFile = new File(metadataFile, "metadata.yaml"); @@ -326,7 +326,8 @@ public void testServiceCatalogProxyServiceMetadata() } } - private static File chekAndExtractPayloadZip() throws CarbonException { + private static File checkAndExtractPayloadZip() throws CarbonException, InterruptedException { + Thread.sleep(1000); String payloadZipPath = CarbonBaseUtils.getCarbonHome() + File.separator + "tmp" + File.separator + SERVICE_CATALOG_FOLDER_NAME + File.separator + ZIP_FILE_NAME; File zipFile = new File(payloadZipPath); @@ -354,7 +355,7 @@ public void destroy() throws Exception { serverConfigurationManager.restartGracefully(); } - private class FirstController implements HttpHandler { + private static class FirstController implements HttpHandler { @Override public void handle(HttpExchange exchange) throws IOException { try (OutputStream responseBody = exchange.getResponseBody()) { diff --git a/integration/mediation-tests/tests-patches-with-smb2/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-patches-with-smb2/src/test/resources/bin/integrator.sh index f59e001127..2a6a189918 100755 --- a/integration/mediation-tests/tests-patches-with-smb2/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-patches-with-smb2/src/test/resources/bin/integrator.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/mediation-tests/tests-patches/src/test/java/org/wso2/carbon/esb/mediators/store/ESBJAVA4470StoreMediatorEmptyOMArraySerializeException.java b/integration/mediation-tests/tests-patches/src/test/java/org/wso2/carbon/esb/mediators/store/ESBJAVA4470StoreMediatorEmptyOMArraySerializeException.java index 2193bc6339..7290ff386c 100644 --- a/integration/mediation-tests/tests-patches/src/test/java/org/wso2/carbon/esb/mediators/store/ESBJAVA4470StoreMediatorEmptyOMArraySerializeException.java +++ b/integration/mediation-tests/tests-patches/src/test/java/org/wso2/carbon/esb/mediators/store/ESBJAVA4470StoreMediatorEmptyOMArraySerializeException.java @@ -24,8 +24,6 @@ import org.wso2.esb.integration.common.utils.CarbonLogReader; import org.wso2.esb.integration.common.utils.ESBIntegrationTest; -import java.util.concurrent.TimeUnit; - import static org.testng.Assert.assertFalse; public class ESBJAVA4470StoreMediatorEmptyOMArraySerializeException extends ESBIntegrationTest { @@ -42,7 +40,7 @@ public void testStoreMediatorEmptyOMArrayPropertySerialize() throws Exception { String url = getApiInvocationURL("SerializeProperty") + "/serializeOMArray"; SimpleHttpClient httpClient = new SimpleHttpClient(); httpClient.doGet(url, null); - TimeUnit.SECONDS.sleep(10); + Thread.sleep(10000); boolean logFound = carbonLogReader.checkForLog("Index: 0, Size: 0", DEFAULT_TIMEOUT) && carbonLogReader.checkForLog("ERROR", DEFAULT_TIMEOUT); diff --git a/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/passthru/transport/enableCorrelation/micro-integrator.sh b/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/passthru/transport/enableCorrelation/micro-integrator.sh index 8c3a7d29f6..01ffcb3087 100644 --- a/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/passthru/transport/enableCorrelation/micro-integrator.sh +++ b/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/passthru/transport/enableCorrelation/micro-integrator.sh @@ -192,9 +192,9 @@ fi # ---------- Handle the SSL Issue with proper JDK version -------------------- java_version=$("$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}') java_version_formatted=$(echo "$java_version" | awk -F. '{printf("%02d%02d",$1,$2);}') -if [ $java_version_formatted -lt 1100 ] || [ $java_version_formatted -gt 1700 ]; then +if [ $java_version_formatted -lt 1100 ] || [ $java_version_formatted -gt 2100 ]; then echo " Starting WSO2 MI (in unsupported JDK)" - echo " [ERROR] WSO2 MI is supported only between JDK 11 and JDK 17" + echo " [ERROR] WSO2 MI is supported only between JDK 11 and JDK 21" exit 0 fi diff --git a/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.bat b/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.bat index 749d336833..48e2beb9ec 100644 --- a/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.bat +++ b/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.bat @@ -160,7 +160,7 @@ goto supportedJdk :unknownJdk echo Starting WSO2 MI (in unsupported JDK %JAVA_VERSION%) -echo [ERROR] WSO2 MI is supported only between JDK 11 and JDK 17" +echo [ERROR] WSO2 MI is supported only between JDK 11 and JDK 21" goto end :supportedJdk diff --git a/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.sh b/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.sh index 47636c2e8b..6c65c36eaa 100755 --- a/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.sh +++ b/integration/mediation-tests/tests-patches/src/test/resources/artifacts/ESB/vfs/micro-integrator.sh @@ -199,9 +199,9 @@ fi # ---------- Handle the SSL Issue with proper JDK version -------------------- java_version=$("$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}') java_version_formatted=$(echo "$java_version" | awk -F. '{printf("%02d%02d",$1,$2);}') -if [ $java_version_formatted -lt 1100 ] || [ $java_version_formatted -gt 1700 ]; then +if [ $java_version_formatted -lt 1100 ] || [ $java_version_formatted -gt 2100 ]; then echo " Starting WSO2 MI (in unsupported JDK)" - echo " [ERROR] WSO2 MI is supported only between JDK 11 and JDK 17" + echo " [ERROR] WSO2 MI is supported only between JDK 11 and JDK 21" exit 0 fi diff --git a/integration/mediation-tests/tests-patches/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-patches/src/test/resources/bin/integrator.sh index f59e001127..2a6a189918 100755 --- a/integration/mediation-tests/tests-patches/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-patches/src/test/resources/bin/integrator.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/mediation-tests/tests-platform/tests-rabbitmq/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-platform/tests-rabbitmq/src/test/resources/bin/integrator.sh index f59e001127..2a6a189918 100755 --- a/integration/mediation-tests/tests-platform/tests-rabbitmq/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-platform/tests-rabbitmq/src/test/resources/bin/integrator.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/mediation-tests/tests-platform/tests-wso2mb/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-platform/tests-wso2mb/src/test/resources/bin/integrator.sh index f59e001127..2a6a189918 100755 --- a/integration/mediation-tests/tests-platform/tests-wso2mb/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-platform/tests-wso2mb/src/test/resources/bin/integrator.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/mediation-tests/tests-sample/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-sample/src/test/resources/bin/integrator.sh index f59e001127..2a6a189918 100755 --- a/integration/mediation-tests/tests-sample/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-sample/src/test/resources/bin/integrator.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/mediation-tests/tests-service/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-service/src/test/resources/bin/integrator.sh index f59e001127..2a6a189918 100755 --- a/integration/mediation-tests/tests-service/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-service/src/test/resources/bin/integrator.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/mediation-tests/tests-transport/src/test/java/org/wso2/carbon/esb/jms/transport/test/MSMPCronForwarderCase.java b/integration/mediation-tests/tests-transport/src/test/java/org/wso2/carbon/esb/jms/transport/test/MSMPCronForwarderCase.java index ac9bdc9439..4c48298083 100644 --- a/integration/mediation-tests/tests-transport/src/test/java/org/wso2/carbon/esb/jms/transport/test/MSMPCronForwarderCase.java +++ b/integration/mediation-tests/tests-transport/src/test/java/org/wso2/carbon/esb/jms/transport/test/MSMPCronForwarderCase.java @@ -19,25 +19,21 @@ package org.wso2.carbon.esb.jms.transport.test; import org.awaitility.Awaitility; +import org.awaitility.core.ConditionFactory; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import org.wso2.carbon.automation.extensions.servers.jmsserver.controller.config.JMSBrokerConfigurationProvider; -import org.wso2.carbon.automation.extensions.servers.tomcatserver.TomcatServerManager; -import org.wso2.carbon.automation.extensions.servers.tomcatserver.TomcatServerType; import org.wso2.carbon.automation.test.utils.http.client.HttpRequestUtil; import org.wso2.carbon.automation.test.utils.http.client.HttpResponse; -import org.wso2.carbon.esb.jms.utils.JMSBroker; import org.wso2.esb.integration.common.extensions.jmsserver.ActiveMQServerExtension; import org.wso2.esb.integration.common.utils.CarbonLogReader; import org.wso2.esb.integration.common.utils.ESBIntegrationTest; -import org.wso2.esb.integration.services.jaxrs.customersample.CustomerConfig; import java.net.URL; +import java.time.Duration; import java.util.HashMap; import java.util.Map; import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -59,8 +55,10 @@ protected void init() throws Exception { log.info("ActiveMQ Server is not started. Hence starting the MQServer"); ActiveMQServerExtension.startMQServer(); Thread.sleep(60000); - Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(300, - TimeUnit.SECONDS).until(isServerStarted()); + Awaitility.await() + .pollInterval(org.awaitility.Duration.ONE_MINUTE) + .atMost(org.awaitility.Duration.FIVE_MINUTES) + .until(isLogWritten()); } else { log.info("ActiveMQ Server has already started."); } @@ -91,8 +89,10 @@ public void testMessageProcessorCronForwader() throws Exception { // WAIT FOR THE MESSAGE PROCESSOR TO TRIGGER // Thread.sleep(60000); - Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(300, - TimeUnit.SECONDS).until(isLogWritten()); + Awaitility.await() + .pollInterval(org.awaitility.Duration.ONE_MINUTE) + .atMost(org.awaitility.Duration.FIVE_MINUTES) + .until(isLogWritten()); assertTrue(carbonLogReader.checkForLog("Jack", 60, NUMBER_OF_MESSAGES)); } } diff --git a/integration/mediation-tests/tests-transport/src/test/resources/bin/integrator.sh b/integration/mediation-tests/tests-transport/src/test/resources/bin/integrator.sh index f59e001127..2a6a189918 100755 --- a/integration/mediation-tests/tests-transport/src/test/resources/bin/integrator.sh +++ b/integration/mediation-tests/tests-transport/src/test/resources/bin/integrator.sh @@ -211,10 +211,10 @@ elif [ "$CMD" = "version" ]; then fi # ---------- Handle the SSL Issue with proper JDK version -------------------- -jdk_17=`$JAVA_HOME/bin/java -version 2>&1 | grep "1.[7|8]"` -if [ "$jdk_17" = "" ]; then - echo " Starting WSO2 Carbon (in unsupported JDK)" - echo " [ERROR] CARBON is supported only on JDK 1.7 and 1.8" +jdk_version=`$JAVA_HOME/bin/java -version 2>&1 | grep -E "1\.(7|8)|21"` +if [ -z "$jdk_version" ]; then + echo "Starting WSO2 Carbon (in unsupported JDK)" + echo "[ERROR] CARBON is supported only on JDK 1.7, 1.8, or 21" fi CARBON_XBOOTCLASSPATH="" diff --git a/integration/tests-common/integration-test-utils/src/main/java/org/wso2/esb/integration/common/utils/Utils.java b/integration/tests-common/integration-test-utils/src/main/java/org/wso2/esb/integration/common/utils/Utils.java index 80ea57295e..db7ac8f45e 100644 --- a/integration/tests-common/integration-test-utils/src/main/java/org/wso2/esb/integration/common/utils/Utils.java +++ b/integration/tests-common/integration-test-utils/src/main/java/org/wso2/esb/integration/common/utils/Utils.java @@ -39,7 +39,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.rmi.RemoteException; -import java.util.concurrent.TimeUnit; import javax.xml.stream.XMLStreamException; public class Utils { @@ -151,7 +150,7 @@ public static boolean logExists(CarbonLogReader logReader, String expected, int throws InterruptedException { boolean logExists = false; for (int i = 0; i < timeout; i++) { - TimeUnit.SECONDS.sleep(1); + Thread.sleep(5000); if (logReader.getLogs().contains(expected)) { logExists = true; logReader.stop(); @@ -174,7 +173,7 @@ public static boolean checkForLog(CarbonLogReader logReader, String expected, in throws InterruptedException { boolean logExists = false; for (int i = 0; i < timeout; i++) { - TimeUnit.SECONDS.sleep(1); + Thread.sleep(1000); if (logReader.getLogs().contains(expected)) { logExists = true; break; @@ -189,7 +188,7 @@ public static boolean checkForFileExistence(Path filePath, int timeout) throws I if (Files.exists(filePath)) { return true; } - TimeUnit.SECONDS.sleep(1); + Thread.sleep(1000); } log.error("File does not exists in " + filePath, new Throwable()); return false; diff --git a/integration/tests-common/integration-test-utils/src/main/java/org/wso2/esb/integration/common/utils/common/ServerConfigurationManager.java b/integration/tests-common/integration-test-utils/src/main/java/org/wso2/esb/integration/common/utils/common/ServerConfigurationManager.java index 42081fc076..be512b3327 100644 --- a/integration/tests-common/integration-test-utils/src/main/java/org/wso2/esb/integration/common/utils/common/ServerConfigurationManager.java +++ b/integration/tests-common/integration-test-utils/src/main/java/org/wso2/esb/integration/common/utils/common/ServerConfigurationManager.java @@ -43,10 +43,10 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; +import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.Properties; -import java.util.concurrent.TimeUnit; import java.util.function.BooleanSupplier; import javax.xml.xpath.XPathExpressionException; @@ -406,10 +406,10 @@ private Process startProcess(String workingDirectory, String[] cmdArray) throws return processBuilder.start(); } - private void waitTill(BooleanSupplier predicate, int maxWaitTime, TimeUnit timeUnit) throws InterruptedException { - long time = System.currentTimeMillis() + timeUnit.toMillis(maxWaitTime); - while (predicate.getAsBoolean() && System.currentTimeMillis() < time) { - TimeUnit.MILLISECONDS.sleep(1); + private void waitTill(BooleanSupplier predicate, int maxWaitTime, Duration timeUnit) throws InterruptedException { + long endTime = System.currentTimeMillis() + timeUnit.toMillis(); + while (predicate.getAsBoolean() && System.currentTimeMillis() < endTime) { + Thread.sleep(1000); } }