-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
889e41a
commit 2f21553
Showing
4 changed files
with
238 additions
and
34 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
81 changes: 47 additions & 34 deletions
81
src/test/java/org/wso2/soaptorest/SOAPToRESTConverterTest.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 |
---|---|---|
@@ -1,57 +1,70 @@ | ||
/* | ||
* Copyright (c) 2022, 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 | ||
* 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. | ||
* 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.soaptorest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.junit.jupiter.api.Test; | ||
import org.wso2.soaptorest.exceptions.SOAPToRESTException; | ||
import org.wso2.soaptorest.models.SOAPtoRESTConversionData; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
class SOAPToRESTConverterTest { | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
@Test | ||
void testFileGetSOAPtoRESTConversionData() throws SOAPToRESTException { | ||
|
||
class SOAPToRESTConverterTest { | ||
SOAPtoRESTConversionData soaPtoRESTConversionData = | ||
SOAPToRESTConverter.getSOAPtoRESTConversionData( | ||
"src/test/resources" + "/calculator/calculator.wsdl", "Test API", "1.0.0"); | ||
assertTrue(StringUtils.isNotBlank(soaPtoRESTConversionData.getOASString())); | ||
assertEquals(soaPtoRESTConversionData.getAllSOAPRequestBodies().size(), 4); | ||
assertEquals(soaPtoRESTConversionData.getSoapService(), "CalculatorService"); | ||
assertEquals(soaPtoRESTConversionData.getSoapPort(), "CalculatorPort"); | ||
|
||
} | ||
|
||
@Test | ||
void testURLGetSOAPtoRESTConversionData() throws MalformedURLException, SOAPToRESTException { | ||
|
||
@Test | ||
void testFileGetSOAPtoRESTConversionData() throws SOAPToRESTException { | ||
URL url = new URL( | ||
"https://raw.githubusercontent.com/wso2/soap-to-rest/main/src/test/resources/calculator-remote/calculator.wsdl"); | ||
SOAPtoRESTConversionData soaPtoRESTConversionData = | ||
SOAPToRESTConverter.getSOAPtoRESTConversionData(url, "Test API", "1.0.0"); | ||
assertTrue(StringUtils.isNotBlank(soaPtoRESTConversionData.getOASString())); | ||
assertEquals(soaPtoRESTConversionData.getAllSOAPRequestBodies().size(), 4); | ||
assertEquals(soaPtoRESTConversionData.getSoapService(), "CalculatorService"); | ||
assertEquals(soaPtoRESTConversionData.getSoapPort(), "CalculatorPort"); | ||
|
||
SOAPtoRESTConversionData soaPtoRESTConversionData = SOAPToRESTConverter.getSOAPtoRESTConversionData("src/test/resources" + | ||
"/calculator/calculator.wsdl", "Test API", "1.0.0"); | ||
assertTrue(StringUtils.isNotBlank(soaPtoRESTConversionData.getOASString())); | ||
assertEquals(soaPtoRESTConversionData.getAllSOAPRequestBodies().size(), 4); | ||
assertEquals(soaPtoRESTConversionData.getSoapService(), "CalculatorService"); | ||
assertEquals(soaPtoRESTConversionData.getSoapPort(), "CalculatorPort"); | ||
} | ||
|
||
} | ||
@Test | ||
void testIssue28() throws MalformedURLException, SOAPToRESTException { | ||
|
||
@Test | ||
void testURLGetSOAPtoRESTConversionData() throws MalformedURLException, SOAPToRESTException { | ||
URL url = new URL( | ||
"https://raw.githubusercontent.com/wso2/soap-to-rest/main/src/test/resources/issue-28/failing.wsdl"); | ||
SOAPtoRESTConversionData soaPtoRESTConversionData = | ||
SOAPToRESTConverter.getSOAPtoRESTConversionData(url, "Test API", "1.0.0"); | ||
assertTrue(StringUtils.isNotBlank(soaPtoRESTConversionData.getOASString())); | ||
assertEquals(soaPtoRESTConversionData.getAllSOAPRequestBodies().size(), 4); | ||
assertEquals(soaPtoRESTConversionData.getSoapService(), "CalculatorService"); | ||
assertEquals(soaPtoRESTConversionData.getSoapPort(), "CalculatorPort"); | ||
|
||
URL url = new URL("https://raw.githubusercontent.com/wso2/soap-to-rest/main/src/test/resources/calculator-remote/calculator.wsdl"); | ||
SOAPtoRESTConversionData soaPtoRESTConversionData = SOAPToRESTConverter.getSOAPtoRESTConversionData(url, "Test API", "1.0.0"); | ||
assertTrue(StringUtils.isNotBlank(soaPtoRESTConversionData.getOASString())); | ||
assertEquals(soaPtoRESTConversionData.getAllSOAPRequestBodies().size(), 4); | ||
assertEquals(soaPtoRESTConversionData.getSoapService(), "CalculatorService"); | ||
assertEquals(soaPtoRESTConversionData.getSoapPort(), "CalculatorPort"); | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
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,92 @@ | ||
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
xmlns:tns="urn:ServerWsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="myServer" | ||
targetNamespace="urn:ServerWsdl"> | ||
<wsdl:types> | ||
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:ServerWsdl"> | ||
<xsd:complexType name="getRequestType"> | ||
<xsd:sequence> | ||
<xsd:element name="header" type="tns:standardheaderType" /> | ||
<xsd:element name="body" type="tns:getRequestBodyType" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="getResultType"> | ||
<xsd:sequence> | ||
<xsd:element name="result" type="tns:resultType" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element name="error" type="tns:errorType" maxOccurs="1" minOccurs="0" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="standardheaderType"> | ||
<xsd:sequence> | ||
<xsd:element name="applicationversionnr" type="xsd:string" maxOccurs="1" minOccurs="1" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="getRequestBodyType"> | ||
<xsd:sequence> | ||
<xsd:element name="transactioncode" type="xsd:string" maxOccurs="1" minOccurs="1" /> | ||
<xsd:element name="languageisocode" type="xsd:string" maxOccurs="1" minOccurs="1" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="disclosureinformationType"> | ||
<xsd:sequence> | ||
<xsd:element name="companyname" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element | ||
name="street" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element | ||
name="countryisocode" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element | ||
name="city" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element name="postcode" | ||
type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="clientinformationType"> | ||
<xsd:sequence> | ||
<xsd:element name="fieldname" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element name="fieldvalue" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="resultType"> | ||
<xsd:sequence> | ||
<xsd:element name="transactioncode" type="xsd:string" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="errorType"> | ||
<xsd:sequence> | ||
<xsd:element name="errorcode" type="xsd:string" /> | ||
<xsd:element name="errortext" type="xsd:string" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
</xsd:schema> | ||
</wsdl:types> | ||
<wsdl:message name="getRequest"> | ||
<wsdl:part name="getRequest" type="tns:getRequestType" /> | ||
</wsdl:message> | ||
<wsdl:message name="getResponse"> | ||
<wsdl:part name="getResponse" type="tns:getResultType" /> | ||
</wsdl:message> | ||
<wsdl:portType name="myServer"> | ||
<wsdl:operation name="get"> | ||
<wsdl:input message="tns:getRequest" /> | ||
<wsdl:output message="tns:getResponse" /> | ||
</wsdl:operation> | ||
</wsdl:portType> | ||
<wsdl:binding name="myServerSOAP" type="tns:myServer"> | ||
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> | ||
<wsdl:operation name="get"> | ||
<soap:operation soapAction="urn:ServerWsdl/get" /> | ||
<wsdl:input> | ||
<soap:body namespace="urn:ServerWsdl" use="literal" /> | ||
</wsdl:input> | ||
<wsdl:output> | ||
<soap:body namespace="urn:ServerWsdl" use="literal" /> | ||
</wsdl:output> | ||
</wsdl:operation> | ||
</wsdl:binding> | ||
<wsdl:service name="myServer"> | ||
<wsdl:port binding="tns:myServerSOAP" name="myServerSOAP"> | ||
<soap:address | ||
location="https://some.server.de/myServer.php" /> | ||
</wsdl:port> | ||
</wsdl:service> | ||
</wsdl:definitions> |
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,92 @@ | ||
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
xmlns:tns="urn:ServerWsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="myServer" | ||
targetNamespace="urn:ServerWsdl"> | ||
<wsdl:types> | ||
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:ServerWsdl"> | ||
<xsd:complexType name="getRequestType"> | ||
<xsd:sequence> | ||
<xsd:element name="header" type="tns:standardheaderType" /> | ||
<xsd:element name="body" type="tns:getRequestBodyType" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="getResultType"> | ||
<xsd:sequence> | ||
<xsd:element name="result" type="tns:resultType" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element name="error" type="tns:errorType" maxOccurs="1" minOccurs="0" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="standardheaderType"> | ||
<xsd:sequence> | ||
<xsd:element name="applicationversionnr" type="xsd:string" maxOccurs="1" minOccurs="1" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="getRequestBodyType"> | ||
<xsd:sequence> | ||
<xsd:element name="transactioncode" type="xsd:string" maxOccurs="1" minOccurs="1" /> | ||
<xsd:element name="languageisocode" type="xsd:string" maxOccurs="1" minOccurs="1" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="disclosureinformationType"> | ||
<xsd:sequence> | ||
<xsd:element name="companyname" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element | ||
name="street" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element | ||
name="countryisocode" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element | ||
name="city" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element name="postcode" | ||
type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="clientinformationType"> | ||
<xsd:sequence> | ||
<xsd:element name="fieldname" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
<xsd:element name="fieldvalue" type="xsd:string" maxOccurs="1" minOccurs="0" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="resultType"> | ||
<xsd:sequence> | ||
<xsd:element name="transactioncode" type="xsd:string" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
<xsd:complexType name="errorType"> | ||
<xsd:sequence> | ||
<xsd:element name="errorcode" type="xsd:string" /> | ||
<xsd:element name="errortext" type="xsd:string" /> | ||
</xsd:sequence> | ||
</xsd:complexType> | ||
</xsd:schema> | ||
</wsdl:types> | ||
<wsdl:message name="getRequest"> | ||
<wsdl:part name="getRequest" type="tns:getRequestType" /> | ||
</wsdl:message> | ||
<wsdl:message name="getResponse"> | ||
<wsdl:part name="getResponse" type="tns:getResultType" /> | ||
</wsdl:message> | ||
<wsdl:portType name="myServer"> | ||
<wsdl:operation name="get"> | ||
<wsdl:input message="tns:getRequest" /> | ||
<wsdl:output message="tns:getResponse" /> | ||
</wsdl:operation> | ||
</wsdl:portType> | ||
<wsdl:binding name="myServerSOAP" type="tns:myServer"> | ||
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> | ||
<wsdl:operation name="get"> | ||
<soap:operation soapAction="urn:ServerWsdl/get" /> | ||
<wsdl:input> | ||
<soap:body namespace="urn:ServerWsdl" use="literal" /> | ||
</wsdl:input> | ||
<wsdl:output> | ||
<soap:body namespace="urn:ServerWsdl" use="literal" /> | ||
</wsdl:output> | ||
</wsdl:operation> | ||
</wsdl:binding> | ||
<wsdl:service name="myServer"> | ||
<wsdl:port binding="tns:myServerSOAP" name="myServerSOAP"> | ||
<soap:address | ||
location="https://some.server.de/myServer.php" /> | ||
</wsdl:port> | ||
</wsdl:service> | ||
</wsdl:definitions> |