-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3735 from Ibaqu/PoisonMessageIntermittent
Test cases for Issue 3330/1 EnrichMediatorIssue
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...-mediator-1/src/test/java/org/wso2/carbon/esb/mediator/test/enrich/EnrichJSONPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
*Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
*WSO2 Inc. licenses this file to you under the Apache License, | ||
*Version 2.0 (the "License"); you may not use this file except | ||
*in compliance with the License. | ||
*You may obtain a copy of the License at | ||
* | ||
*http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
*Unless required by applicable law or agreed to in writing, | ||
*software distributed under the License is distributed on an | ||
*"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
*KIND, either express or implied. See the License for the | ||
*specific language governing permissions and limitations | ||
*under the License. | ||
*/ | ||
|
||
package org.wso2.carbon.esb.mediator.test.enrich; | ||
|
||
|
||
import com.sun.jersey.api.client.Client; | ||
import com.sun.jersey.api.client.ClientResponse; | ||
import com.sun.jersey.api.client.WebResource; | ||
import org.testng.Assert; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
import org.wso2.esb.integration.common.utils.ESBIntegrationTest; | ||
|
||
|
||
public class EnrichJSONPayload extends ESBIntegrationTest { | ||
|
||
private Client client = Client.create(); | ||
private String JSON_Payload | ||
= "{ \"resourceId\": \"f4d3c43d-0c10-42c5-854a-5335469cf3d0\", \"assetCode\": \"000002\" }"; | ||
private String Expected_Response | ||
= "{\"resourceId\":\"f4d3c43d-0c10-42c5-854a-5335469cf3d0\",\"assetCode\":[{}]}"; | ||
|
||
//Creates the API | ||
@BeforeClass(alwaysRun = true) | ||
public void setEnvironment() throws Exception { | ||
super.init(); | ||
loadESBConfigurationFromClasspath("artifacts/ESB/jaxrs/EnrichJSONPayload_API.xml"); | ||
} | ||
|
||
@Test(groups = "wso2.esb", description = "Testing json requests with enrich mediator in API") | ||
public void testJSONWithEnrichMediator() throws Exception { | ||
WebResource webResource = client.resource(getApiInvocationURL("addMusic") + "/music"); | ||
ClientResponse getResponse = webResource.type("application/json").post(ClientResponse.class, JSON_Payload); | ||
String response = getResponse.getEntity(String.class); | ||
Assert.assertEquals(response, Expected_Response); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...n-tests/tests-mediator-1/src/test/resources/artifacts/ESB/jaxrs/EnrichJSONPayload_API.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<definitions xmlns="http://ws.apache.org/ns/synapse"> | ||
<api name="AddMusic" context="/addMusic"> | ||
<resource methods="POST" uri-template="/music*"> | ||
<inSequence> | ||
<enrich> | ||
<source type="inline" clone="false">[{}]</source> | ||
<target xpath="json-eval($.assetCode)"/> | ||
</enrich> | ||
<respond/> | ||
</inSequence> | ||
<outSequence/> | ||
</resource> | ||
</api> | ||
</definitions> |