Skip to content

Commit

Permalink
Merge pull request #3735 from Ibaqu/PoisonMessageIntermittent
Browse files Browse the repository at this point in the history
Test cases for Issue 3330/1 EnrichMediatorIssue
  • Loading branch information
Nirothipan authored Apr 17, 2019
2 parents 4058c5f + 56ee37d commit d9e272c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
4 changes: 4 additions & 0 deletions integration/mediation-tests/tests-mediator-1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@
<groupId>org.wso2.ei</groupId>
<artifactId>service-samples</artifactId>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<!-- Jacoco Dependency-->
<dependency>
<groupId>org.jacoco</groupId>
Expand Down
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);
}

}
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>

0 comments on commit d9e272c

Please sign in to comment.