-
Notifications
You must be signed in to change notification settings - Fork 7
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
8c938d2
commit bb5618b
Showing
5 changed files
with
163 additions
and
86 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
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,27 @@ | ||
import org.junit.jupiter.api.Test; | ||
import javax.wsdl.*; | ||
import javax.wsdl.factory.WSDLFactory; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class FaultTest { | ||
|
||
@Test | ||
public void testFaultElement() throws Exception { | ||
WSDLFactory factory = WSDLFactory.newInstance(); | ||
Definition definition = factory.newDefinition(); | ||
|
||
// Create a new operation with a fault | ||
Operation operation = definition.createOperation(); | ||
operation.setName("testOperation"); | ||
|
||
Fault fault = definition.createFault(); | ||
fault.setName("TestFault"); | ||
fault.setDocumentationElement(definition.getDocumentationElement()); | ||
|
||
operation.addFault(fault); | ||
|
||
// Check the fault name and linkage | ||
assertEquals("TestFault", operation.getFault("TestFault").getName()); | ||
} | ||
} |
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,31 @@ | ||
import com.ibm.wsdl.extensions.soap.SOAPBindingImpl; | ||
import org.junit.jupiter.api.Test; | ||
import javax.wsdl.*; | ||
import javax.wsdl.extensions.*; | ||
import javax.wsdl.extensions.soap.SOAPBinding; | ||
import javax.wsdl.factory.WSDLFactory; | ||
import javax.xml.namespace.QName; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class SOAPBindingTest { | ||
|
||
@Test | ||
public void testSOAPBindingAttributes() throws Exception { | ||
WSDLFactory factory = WSDLFactory.newInstance(); | ||
Definition definition = factory.newDefinition(); | ||
|
||
// Create and add a SOAP binding to the definition | ||
SOAPBinding soapBinding = new SOAPBindingImpl(); | ||
soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http"); | ||
soapBinding.setStyle("document"); | ||
|
||
Binding binding = definition.createBinding(); | ||
binding.setQName(new QName("http://www.example.com/sample", "SampleBinding")); | ||
binding.addExtensibilityElement(soapBinding); | ||
|
||
// Validate SOAP binding properties | ||
assertEquals("http://schemas.xmlsoap.org/soap/http", soapBinding.getTransportURI()); | ||
assertEquals("document", soapBinding.getStyle()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,85 @@ | ||
import org.junit.jupiter.api.Test; | ||
import org.xml.sax.InputSource; | ||
|
||
import javax.wsdl.*; | ||
import javax.wsdl.factory.WSDLFactory; | ||
import javax.wsdl.xml.WSDLReader; | ||
import javax.wsdl.xml.WSDLWriter; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.StringWriter; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import javax.xml.namespace.QName; | ||
import javax.xml.transform.stream.StreamSource; | ||
|
||
public class WSDLReaderWriterTest { | ||
|
||
@Test | ||
public void testReadAndWriteWSDL() throws Exception { | ||
// Create WSDLFactory and WSDLReader/Writer instances | ||
WSDLFactory factory = WSDLFactory.newInstance(); | ||
WSDLReader reader = factory.newWSDLReader(); | ||
WSDLWriter writer = factory.newWSDLWriter(); | ||
|
||
// Load a sample WSDL file | ||
String wsdlPath = "src/test/resources/sample.wsdl"; | ||
Definition definition = reader.readWSDL(wsdlPath); | ||
|
||
// Ensure the WSDL Definition is correctly read | ||
assertNotNull(definition, "WSDL Definition should not be null"); | ||
|
||
// Verify basic WSDL properties | ||
assertEquals("http://www.example.com/sample", definition.getTargetNamespace(), | ||
"The target namespace should match the expected value"); | ||
|
||
// Check Services in the WSDL | ||
Map<?, ?> services = definition.getServices(); | ||
assertNotNull(services, "Services should not be null"); | ||
assertEquals(1, services.size(), "There should be exactly one service defined"); | ||
|
||
// Retrieve and validate the service | ||
Service service = (Service) services.get(new QName("http://www.example.com/sample", "SampleService")); | ||
assertNotNull(service, "SampleService should be present in the WSDL"); | ||
|
||
// Write the WSDL back to a string | ||
StringWriter stringWriter = new StringWriter(); | ||
writer.writeWSDL(definition, stringWriter); | ||
|
||
// Validate the Written WSDL Content | ||
String writtenWsdlContent = stringWriter.toString(); | ||
assertNotNull(writtenWsdlContent, "The written WSDL content should not be null"); | ||
assertTrue(writtenWsdlContent.contains("SampleService"), "The written WSDL should contain the service name 'SampleService'"); | ||
assertTrue(writtenWsdlContent.contains("SampleSoapBinding"), "The written WSDL should contain the binding name 'SampleSoapBinding'"); | ||
assertTrue(writtenWsdlContent.contains("getSampleRequest"), "The written WSDL should contain the input message name 'getSampleRequest'"); | ||
assertTrue(writtenWsdlContent.contains("getSampleResponse"), "The written WSDL should contain the output message name 'getSampleResponse'"); | ||
|
||
// Re-read the written WSDL content using a StreamSource instead of passing null | ||
ByteArrayInputStream inputStream = new ByteArrayInputStream(writtenWsdlContent.getBytes(StandardCharsets.UTF_8)); | ||
InputSource streamSource = new InputSource(inputStream); | ||
|
||
// Use readWSDL with StreamSource | ||
Definition reReadDefinition = reader.readWSDL(null, streamSource); | ||
assertNotNull(reReadDefinition, "The re-read WSDL definition should not be null"); | ||
|
||
// Compare basic properties between the original and re-read definitions | ||
assertEquals(definition.getTargetNamespace(), reReadDefinition.getTargetNamespace(), | ||
"The target namespace should match between the original and re-read definitions"); | ||
|
||
// Validate Services in the Re-read Definition | ||
Map<?, ?> reReadServices = reReadDefinition.getServices(); | ||
assertNotNull(reReadServices, "Re-read services map should not be null"); | ||
assertEquals(1, reReadServices.size(), "Re-read definition should have exactly one service defined"); | ||
|
||
// Verify the re-read service name | ||
Service reReadService = (Service) reReadServices.get(new QName("http://www.example.com/sample", "SampleService")); | ||
assertNotNull(reReadService, "The re-read SampleService should be present in the re-read WSDL"); | ||
|
||
// Additional validation to ensure the re-read WSDL matches the original definition | ||
assertEquals(service.getQName(), reReadService.getQName(), "Service QName should match between original and re-read WSDL"); | ||
assertEquals(service.getPorts().size(), reReadService.getPorts().size(), | ||
"The number of ports should match between original and re-read WSDL"); | ||
} | ||
} |