From f42c426568deae1096aabbb1a83cf39a5beb40bf Mon Sep 17 00:00:00 2001 From: GDLMadushanka Date: Tue, 3 Dec 2024 20:55:32 +0530 Subject: [PATCH] Add integration tests for synapse expressions Add integration tests for synapse expressions Related to wso2/product-micro-integrator/issues/3749 --- .../test/SynapseExpressionTestCase.java | 80 ++++++++++++++++++ .../SynapseExpressionTestCase_1.0.0.car | Bin 0 -> 6293 bytes .../tests-other/src/test/resources/testng.xml | 6 ++ pom.xml | 2 +- 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 integration/mediation-tests/tests-other/src/test/java/org/wso2/carbon/esb/synapse/expression/test/SynapseExpressionTestCase.java create mode 100644 integration/mediation-tests/tests-other/src/test/resources/artifacts/ESB/server/repository/deployment/server/carbonapps/SynapseExpressionTestCase_1.0.0.car diff --git a/integration/mediation-tests/tests-other/src/test/java/org/wso2/carbon/esb/synapse/expression/test/SynapseExpressionTestCase.java b/integration/mediation-tests/tests-other/src/test/java/org/wso2/carbon/esb/synapse/expression/test/SynapseExpressionTestCase.java new file mode 100644 index 0000000000..fe11aa73dc --- /dev/null +++ b/integration/mediation-tests/tests-other/src/test/java/org/wso2/carbon/esb/synapse/expression/test/SynapseExpressionTestCase.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. 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.synapse.expression.test; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.esb.integration.common.utils.CarbonLogReader; +import org.wso2.esb.integration.common.utils.ESBIntegrationTest; +import org.wso2.esb.integration.common.utils.clients.SimpleHttpClient; + +import java.util.HashMap; +import java.util.Map; + +import static org.testng.Assert.assertTrue; + +/** + * Testcase to test Synapse Expressions to fetch registry, registry property, path query and function params + */ +public class SynapseExpressionTestCase extends ESBIntegrationTest { + + private CarbonLogReader carbonLogReader; + private static final String targetApiName = "synapseexpression_api"; + + @BeforeClass(alwaysRun = true) + public void uploadSynapseConfig() throws Exception { + super.init(); + verifyAPIExistence(targetApiName); + carbonLogReader = new CarbonLogReader(); + carbonLogReader.start(); + } + + @Test(groups = "wso2.esb", description = "Testcase to test Synapse Expressions to fetch registry, registry " + + "property, path query and function params") + public void testSynapseExpressions() throws Exception { + String contentType = "application/json"; + String payload = "{\"hello\": \"world\"}"; + String url = getApiInvocationURL(targetApiName); + url = url + "/abc/hello/pqr?qparam1=zxc&qparam2=uio"; + + Map headers = new HashMap<>(1); + headers.put("Content-Type", contentType); + + SimpleHttpClient httpClient = new SimpleHttpClient(); + httpClient.doPost(url, headers, payload, contentType); + + carbonLogReader.checkForLog("pathParam1 = abc, pathParam2 = pqr, queryParam1 = zxc, queryParam2 = uio," + + " regProp = hello world, regValue = John", DEFAULT_TIMEOUT); + String logs = carbonLogReader.getLogs(); + assertTrue(logs.contains("pathParam1 = abc")); + assertTrue(logs.contains("pathParam2 = pqr")); + assertTrue(logs.contains("queryParam1 = zxc")); + assertTrue(logs.contains("queryParam2 = uio")); + assertTrue(logs.contains("regProp = hello world")); + assertTrue(logs.contains("regValue = John")); + assertTrue(logs.contains("funcParam1 = hello")); + assertTrue(logs.contains("funcParam2 = world")); + carbonLogReader.stop(); + } + + @AfterClass(alwaysRun = true) + public void destroy() throws Exception { + super.cleanup(); + } +} diff --git a/integration/mediation-tests/tests-other/src/test/resources/artifacts/ESB/server/repository/deployment/server/carbonapps/SynapseExpressionTestCase_1.0.0.car b/integration/mediation-tests/tests-other/src/test/resources/artifacts/ESB/server/repository/deployment/server/carbonapps/SynapseExpressionTestCase_1.0.0.car new file mode 100644 index 0000000000000000000000000000000000000000..bca27bca969c18a281cc45a041c920e3e905f229 GIT binary patch literal 6293 zcmbVQ2{e>#8y>rik3ymB`;wU=#Y^!fvBmeL1RZQnt=%9AKbe;(#gfq z)><3_gTSCf-_n1_$-Gv`Wt$VZiI(;toWMu9wF)pVpUNNan=Hcg-gs__1ie?&R zpSvtbp6S1k&b+6DS~>vzzyv#KATk$QWSmub>Ot?LYt}9ts>K^%&d4T37O>*Y%rb*? z67b*+@wfmhm=t;dCJSdQ8HAp~Uf~3Ic>Q{2<}uDnZ4wZUmtT>{{38$U&Yo^Iw(fsL zC(o~8{yQRwgS#^-Htr~WC~S9wmmH z)T7F9J@6d{vP}3**voUfT znd3wr$x6%u(#^yEEYijU@TcQ(FKKFFyTj&uqDrvRzMm6r35K6k=j7^eGHc?@5L%kC z3g^gdhaKXKVSgt+$?TSwNh!NT^*U{QE&D#5%TudL#+X)L)cvm&A4YlU5CI2ChT~V0 zoJ8M96d50IzI1O~@RdYCQz>Sg>&s!O(OP3yhKHrj={3S)rC zJz`AQA7T=+7Z5KFxK6lNpt`$!c801jqd-Aunf)g&J#C9(X0naJ(6;)93`hkQgN1iB zJ2o&1@1GNq-AA>1k}^mJb!VtI>oa4Aw!`T|A49_151G6!grg%~GEl$Q7?ks0l%=}M zI^2jlG%Cd>^du+gX=Ox8F0*s{1J@X)CN;-)>BO`8*%FBwanEk7WTek&sjsM~R>>ug z<(IuU2{^}O#>X3JIGe_HWK!o3t=^GsvCT{exKp8_ynY>Q_u#5%0i&q+%P>SgJeWmk z@2-L-ZHPTzQDGBTZh zLlOOOimSU|Mmg133x1k>8QXRtGdGg{c`qwWDbYXB|9;cCatOa!sAsrICOlL>C0N_T z{B}%x*8JOfJGqQOwOS^=wik81?k_A0!(2hN-m&DXMKZ`*dDNhjxfX;P?PoC+ zc8+7DNVO!@Y^P@_Q%AM(WyrIrb1F-BB{29G8Idb0)}Q$nu*b--=k#=rq@j1N%>iD2 zRM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di`Oa)%_BtP z!$C_@C%Xl!;8_Vb$}S~bswCAhJI?_YJW&4e>&f1(ibvcJbvL>u9MUi8a|M>FAA)-_ z4QtF^(>T$rVPUo?RUs8~HtDek{H~>jS>?@acGvu8tQw`x@-53$V~;&2&0?{I6P5OX zjCO2js7Ri`G-uGVN)QPUgfnb1iKe(*gWfUM9RAyrB}_g6aTs6*3iG0=-*6 z#B=6V%t4qzZh{)Tqqa{5;W_yxu z51k{A)j}R?vK=D4DJl70?l)BGs^NnXM_WuI*eoc^q~QQSfv;}br%arIY4gw&2rl`DC9Oq)-XIWE`=3icw6VCJaS0JRd!nD+?V2}RDZOr+h6YNR}2i9&6 z^jE(Rgy_E(iOgIKQ)QqNlX9_Ozoa?9kT!C5iN(WNcsOF$u%NS!?)fGYe~T|yqU%{P zzRAVcbm~Jqb9DyKJ{x5<=3Z#hI$*e=(~P-e-nQRt&YyegRo@-&%{UB{YkCN@|C6}q z*G>rBR%}`1zS+PhZdSufSVdelWOHPnEh2N^H}P$08r9t^Ji*eZj(ONfu{Ufo)L8#1 z@5Cxwo)u?4!=Qnr>Bo_Qmrk^r|Hh>+S^4iTZ$55`6^j@%)x5RN;~jtvIaLdpJxglR z&t`_u&n4-cRTlrIk~Jhy@8$m46j!|e?* z7O-|p4dBiLFX}kACBoXe0U-tyoc&Ye9#GUjdoYa7+7%#=-f2Qw_ zHsL2MVzYpawuk}-LA*#&{%m9XSV)XS*yjUdAYMX#gY={7+lE5ojR-q!U~IrkCH2lK z?{or$tt!x^<0S{zpKev6-}xHQ%HpM*2EP(YYzFYz7V|(OiT)1bWAB2I0GIN%=!EVF|Go3r>C^z&EfRsA1~0;Nzujg_ zi|_jon?P8^fsO_*=)cDPxt&`I?7$;oB?bBgycE&@t${lcNm#G8*QBD|L{%E0LxBru R5U!vxfnMR>O7;MM{SW(_rNaOK literal 0 HcmV?d00001 diff --git a/integration/mediation-tests/tests-other/src/test/resources/testng.xml b/integration/mediation-tests/tests-other/src/test/resources/testng.xml index fb04855801..f1fddd84eb 100644 --- a/integration/mediation-tests/tests-other/src/test/resources/testng.xml +++ b/integration/mediation-tests/tests-other/src/test/resources/testng.xml @@ -61,6 +61,12 @@ + + + + + + diff --git a/pom.xml b/pom.xml index b56428be11..7944442c58 100644 --- a/pom.xml +++ b/pom.xml @@ -1606,7 +1606,7 @@ 2.4.0-b180830.0359 2.3.0 2.3.1 - 4.0.0-wso2v143 + 4.0.0-wso2v144 [4.0.0, 4.0.1) 4.7.215 1.1.3