diff --git a/.github/workflows/jdk-17-tests.yml b/.github/workflows/jdk-17-tests.yml index 015d1b8811..f7d19ccc69 100644 --- a/.github/workflows/jdk-17-tests.yml +++ b/.github/workflows/jdk-17-tests.yml @@ -35,7 +35,7 @@ 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 with: @@ -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 index 5dae1fc056..897592cf59 100644 --- a/.github/workflows/jdk-21-tests.yml +++ b/.github/workflows/jdk-21-tests.yml @@ -1,4 +1,4 @@ -name: Integration tests (Ubuntu, OpenJDK17) +name: Integration tests (Ubuntu, OpenJDK21) on: [push, pull_request] @@ -34,8 +34,12 @@ jobs: 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 -B clean install -DskipTests --file pom.xml + run: mvn clean install -DskipTests --file pom.xml - name: Set up JDK 21 uses: actions/setup-java@v2 with: @@ -48,4 +52,4 @@ jobs: - name: Print segment run: echo "Running build for segment ${{ matrix.profile }}" - name: JDK 21 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/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 7376563b70..0000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Integration tests (Ubuntu, OpenJDK21) - -on: - push: - branches: - - '*' # Runs on push to any branch - pull_request: - branches: - - '*' # Runs on any pull request - workflow_dispatch: - -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@v2 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2 - restore-keys: ${{ runner.os }}-m2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - distribution: 'temurin' - java-version: '11.0.12+7' - - name: check mvn version - run: echo "MAVEN_VERSION=$(mvn -v)" - continue-on-error: true - - name: check java version - run: echo "JAVA_VERSION=$(java -version)" - continue-on-error: true - - name: Build in jdk11 - run: mvn -B clean install -DskipTests --file pom.xml - - name: Set up JDK 21 - uses: actions/setup-java@v2 - with: - distribution: 'temurin' - java-version: '21.0.4' - - name: check mvn version - run: echo "MAVEN_VERSION=$(mvn -v)" - continue-on-error: true - - name: check java version - run: echo "JAVA_VERSION=$(java -version)" - continue-on-error: true -# - name: Build in jdk21 -# run: mvn -B clean install -DskipTests --file pom.xml -# continue-on-error: true - - name: Print segment - run: echo "Running build for segment ${{ matrix.profile }}" - continue-on-error: true - - name: JDK 21 Tests - run: mvn -B clean install --file integration/pom.xml - continue-on-error: true diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index 6701034397..0000000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,55 +0,0 @@ -#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@v2 -# with: -# path: ~/.m2 -# key: ${{ runner.os }}-m2 -# restore-keys: ${{ runner.os }}-m2 -# - name: Set up JDK 11 -# uses: actions/setup-java@v2 -# 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 -B clean install -DskipTests --file pom.xml -# - name: Set up JDK 21 -# uses: actions/setup-java@v2 -# 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 -B 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..04d6b21597 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@v2 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..47ceb70d1a 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@v2 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@v2 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@v2 with: distribution: 'adopt' java-version: 11 diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/pom.xml b/integration/dataservice-hosting-tests/tests-integration/tests/pom.xml index c13d34f68f..c41b5ef52c 100644 --- a/integration/dataservice-hosting-tests/tests-integration/tests/pom.xml +++ b/integration/dataservice-hosting-tests/tests-integration/tests/pom.xml @@ -38,7 +38,12 @@ 2.22.2 - -Xmx1024m + + -Xmx1024m + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/java.lang.reflect=ALL-UNNAMED + --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED + false false 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 cf877fb8d8..a3292f06cd 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,103 +50,118 @@ public class ODataTestUtils { public static final int NOT_FOUND = 404; public static Object[] sendPOST(String endpoint, String content, Map headers) throws IOException, InterruptedException { - 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); - Thread.sleep(1000); - 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, InterruptedException { - 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); - Thread.sleep(1000); - 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, InterruptedException { - 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); - Thread.sleep(1000); - return httpResponse.getStatusLine().getStatusCode(); } public static int sendPATCH(String endpoint, String content, Map headers) throws IOException, InterruptedException { - 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); - Thread.sleep(1000); - return httpResponse.getStatusLine().getStatusCode(); } public static int sendDELETE(String endpoint, Map headers) throws IOException, InterruptedException { - 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); - Thread.sleep(1000); - return httpResponse.getStatusLine().getStatusCode(); } public static String getETag(String content) throws ParseException, JSONException { @@ -157,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/pom.xml b/pom.xml index c4ffee3012..4a7e166aef 100644 --- a/pom.xml +++ b/pom.xml @@ -1932,6 +1932,11 @@ 0.31.1.wso2v3 22.3.4 71.1 + + -Djdk.util.zip.disableZip64ExtraFieldValidation=true + -Djdk.nio.zipfs.allowDotZipEntry=true + --add-opens=java.base/java.net=ALL-UNNAMED + @@ -2129,6 +2134,13 @@ org.apache.maven.plugins maven-surefire-plugin ${maven.surefire.plugin.version} + + + -Djdk.util.zip.disableZip64ExtraFieldValidation=true + -Djdk.nio.zipfs.allowDotZipEntry=true + --add-opens=java.base/java.net=ALL-UNNAMED + + org.jacoco