Skip to content

Commit

Permalink
Revert 1184dd0
Browse files Browse the repository at this point in the history
  • Loading branch information
kalaiyarasiganeshalingam committed Nov 17, 2024
1 parent 1184dd0 commit 4b1d24e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void serviceDeployment() throws Exception {
}

@Test(groups = "wso2.dss", description = "dbConsole available test case")
public void dbConsoleAvailableTest() throws XPathExpressionException, IOException, InterruptedException {
public void dbConsoleAvailableTest() throws XPathExpressionException, IOException {
String webAppUrl = dssContext.getContextUrls().getWebAppURL();
String url = webAppUrl + "/" + "dbconsole/login.jsp?region=region5&item=dbconsole";
Map<String, String> headers = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void validateETagRetrievalTestCase() throws Exception {
headers.put("Accept", "application/json");
Object[] response = sendPOST(endpoint, content, headers);
Assert.assertEquals(response[0], ODataTestUtils.CREATED);
endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES('WSO2PROD')";
endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD')";
response = sendGET(endpoint, headers);
Assert.assertEquals(response[0], ODataTestUtils.OK);
String etag = getETag(response[1].toString());
Expand All @@ -87,11 +87,11 @@ public void validateETagGenerationTestCase() throws Exception {
headers.put("Accept", "application/json");
Object[] response = sendPOST(endpoint, content, headers);
Assert.assertEquals(response[0], ODataTestUtils.CREATED);
endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES('WSO2')";
endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2\')";
response = sendGET(endpoint, headers);
Assert.assertEquals(response[0], ODataTestUtils.OK);
String etag = getETag(response[1].toString());
endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES('WSO2')";
endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2\')";
content = "{\"TYPE\" : \"USJP\"}";
int responseCode = sendPUT(endpoint, content, headers);
Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT);
Expand All @@ -103,7 +103,7 @@ 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')";
String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')";
Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
Object[] response = sendGET(endpoint, headers);
Expand Down Expand Up @@ -163,7 +163,7 @@ public void validateETagConcurrentHandlingTestCaseForPutMethod() throws Exceptio

@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')";
String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2\')";
Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
Object[] response = sendGET(endpoint, headers);
Expand Down Expand Up @@ -230,7 +230,7 @@ public void validateETagConcurrentHandlingTestCaseForDeleteMethod() throws Excep
headers.put("Accept", "application/json");
Object[] response = sendPOST(endpoint, content, headers);
Assert.assertEquals(response[0], ODataTestUtils.CREATED);
endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES('WSO2PROD')";
endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')";
response = sendGET(endpoint, headers);
Assert.assertEquals(response[0], ODataTestUtils.OK);
String etag = ODataTestUtils.getETag(response[1].toString());
Expand Down Expand Up @@ -331,8 +331,8 @@ public void validateETagConcurrentHandlingTestCaseForUpdatePropertyWithPutMethod
public void validateETagConcurrentHandlingTestCaseForUpdatePropertyWithPatchMethod() throws Exception {
if (!Boolean.parseBoolean(System.getenv("CI_BUILD_SKIP"))) {
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";
String entityEndpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')";
String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')/TYPE";
Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
Object[] response = sendGET(entityEndpoint, headers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,28 @@ public void run() {
case "POST":
try {
ODataTestUtils.sendPOST(endpoint, content, headers);
} catch (IOException|InterruptedException e) {
} catch (IOException e) {
e.printStackTrace();
}
break;
case "PUT":
try {
ODataTestUtils.sendPUT(endpoint, content, headers);
} catch (IOException|InterruptedException e) {
} catch (IOException e) {
e.printStackTrace();
}
break;
case "PATCH":
try {
ODataTestUtils.sendPATCH(endpoint, content, headers);
} catch (IOException|InterruptedException e) {
} catch (IOException e) {
e.printStackTrace();
}
break;
case "DELETE":
try {
ODataTestUtils.sendDELETE(endpoint, headers);
} catch (IOException|InterruptedException e) {
} catch (IOException e) {
e.printStackTrace();
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class ODataTestUtils {
public static final int PRE_CONDITION_FAILED = 412;
public static final int NOT_FOUND = 404;

public static Object[] sendPOST(String endpoint, String content, Map<String, String> headers) throws IOException, InterruptedException {
public static Object[] sendPOST(String endpoint, String content, Map<String, String> headers) throws IOException {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(endpoint);
for (String headerType : headers.keySet()) {
Expand All @@ -63,7 +63,6 @@ public static Object[] sendPOST(String endpoint, String content, Map<String, Str
httpPost.setEntity(httpEntity);
}
try (CloseableHttpResponse httpResponse = httpClient.execute(httpPost)) {
Thread.sleep(1000);
if (httpResponse.getEntity() != null) {
BufferedReader reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
String inputLine;
Expand All @@ -83,14 +82,13 @@ public static Object[] sendPOST(String endpoint, String content, Map<String, Str
}
}

public static Object[] sendGET(String endpoint, Map<String, String> headers) throws IOException, InterruptedException {
public static Object[] sendGET(String endpoint, Map<String, String> headers) throws IOException {
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)) {
Thread.sleep(1000);
if (httpResponse.getEntity() != null) {
BufferedReader reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
String inputLine;
Expand All @@ -110,7 +108,7 @@ public static Object[] sendGET(String endpoint, Map<String, String> headers) thr
}
}

public static int sendPUT(String endpoint, String content, Map<String, String> headers) throws IOException, InterruptedException {
public static int sendPUT(String endpoint, String content, Map<String, String> headers) throws IOException {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPut httpPut = new HttpPut(endpoint);
for (String headerType : headers.keySet()) {
Expand All @@ -124,15 +122,14 @@ public static int sendPUT(String endpoint, String content, Map<String, String> h
httpPut.setEntity(httpEntity);
}
try (CloseableHttpResponse response = httpClient.execute(httpPut)) {
Thread.sleep(1000);
return response.getStatusLine().getStatusCode();
}
} catch (IOException e) {
throw new IOException(e.getMessage());
}
}

public static int sendPATCH(String endpoint, String content, Map<String, String> headers) throws IOException, InterruptedException {
public static int sendPATCH(String endpoint, String content, Map<String, String> headers) throws IOException {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPatch httpPatch = new HttpPatch(endpoint);
for (String headerType : headers.keySet()) {
Expand All @@ -146,22 +143,20 @@ public static int sendPATCH(String endpoint, String content, Map<String, String>
httpPatch.setEntity(httpEntity);
}
try (CloseableHttpResponse response = httpClient.execute(httpPatch)) {
Thread.sleep(1000);
return response.getStatusLine().getStatusCode();
}
} catch (IOException e) {
throw new IOException(e.getMessage());
}
}

public static int sendDELETE(String endpoint, Map<String, String> headers) throws IOException, InterruptedException {
public static int sendDELETE(String endpoint, Map<String, String> headers) throws IOException {
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)) {
Thread.sleep(1000);
return response.getStatusLine().getStatusCode();
}
} catch (IOException e) {
Expand Down

0 comments on commit 4b1d24e

Please sign in to comment.