org.apache.axiom.om.util.AXIOMUtil Java Examples
The following examples show how to use
org.apache.axiom.om.util.AXIOMUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpInboundDispatchTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@BeforeClass(alwaysRun = true) public void setEnvironment() throws Exception { super.init(); OMElement inbound1 = AXIOMUtil.stringToOM(FileUtils.readFileToString(new File(getESBResourceLocation() + File.separator + "http.inbound.transport" + File.separator + "inbound1.xml"))); Utils.deploySynapseConfiguration(inbound1, "inbound1", "inbound-endpoints", false); OMElement inbound2 = AXIOMUtil.stringToOM(FileUtils.readFileToString(new File(getESBResourceLocation() + File.separator + "http.inbound.transport" + File.separator + "inbound2.xml"))); Utils.deploySynapseConfiguration(inbound2, "inbound2", "inbound-endpoints", true); urlContext = "http://" + getHostname() + ":" + "9090" + "/"; carbonLogReader = new CarbonLogReader(); carbonLogReader.start(); }
Example #2
Source File: AggregateWithMaxMInLimitsTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "number of messages is equal to the minimum") public void testEqualtoMinimum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = 2; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched"); }
Example #3
Source File: TaskMediaTypeTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Test Schedule Task media type - text/xml", enabled = false) public void scheduleTaskMediaTypeTest() throws Exception { OMElement task = AXIOMUtil.stringToOM( "<task:task xmlns:task=\"http://www.wso2.org/products/wso2commons/tasks\" " + "name=\"" + TASK_NAME + "\" " + "class=\"org.apache.synapse.startup.tasks.MessageInjector\" " + "group=\"" + TASK_GROUP + "\">" + "<task:trigger count=\"5\" " + "interval=\"100000\" />" + "</task:task>"); taskAdminClient.addTask((DataHandler) task); isTaskExist = true; //addEndpoint is a a asynchronous call, it will take some time to write to a registry Thread.sleep(10000); MetadataBean metadata = resourceAdmin .getMetadata("/_system/config/repository/synapse/default/synapse-startups/" + TASK_NAME); Assert.assertEquals(metadata.getMediaType(), "text/xml", "Media Type mismatched for Schedule Task"); }
Example #4
Source File: SpecifyBothMinMaxByExpressionTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "more number of messages than maximum count") public void testMoreNumberThanMaximum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = 15; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertTrue(minMessageCount <= responseCount && responseCount <= maxMessageCount); }
Example #5
Source File: TransportBuilderUtils.java From micro-integrator with Apache License 2.0 | 6 votes |
public static Parameter toAxisParameter(TransportParameter parameter) throws XMLStreamException { Parameter p = new Parameter(); p.setName(parameter.getName()); OMElement paramElement = AXIOMUtil.stringToOM(parameter.getParamElement()); p.setParameterElement(paramElement); if (paramElement.getFirstElement() != null) { p.setValue(paramElement); p.setParameterType(Parameter.OM_PARAMETER); } else { p.setValue(paramElement.getText()); p.setParameterType(Parameter.TEXT_PARAMETER); } return p; }
Example #6
Source File: SapBapiTest.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Sends a BAPI request to a SAP system and asserts that a response of code '200' and with a successful return * type is received. * * @throws Exception if an error occurs while sending the BAPI request */ @Test(groups = { "wso2.esb" }, description = "Test ESB as an BAPI Sender") public void testSendBapiRequest() throws Exception { SimpleHttpClient soapClient = new SimpleHttpClient(); String payload = "<bapirfc name=\"BAPI_SALESORDER_GETLIST\">\n" + " \t<import>\n" + "\t\t<field name=\"CUSTOMER_NUMBER\">PCS-C301</field>\n" + "\t\t<field name=\"SALES_ORGANIZATION\">10000</field>\n" + "\t</import>\n" + "</bapirfc>\n"; HttpResponse response = soapClient .doPost(getProxyServiceURLHttp("sapBapiProxy"), null, payload, MEDIA_TYPE_TEXT_XML); Assert.assertEquals(response.getStatusLine().getStatusCode(), HTTP_SC_OK, "incorrect response code received"); String responseString = Util.getResponsePayload(response); OMElement responseElement = AXIOMUtil.stringToOM(responseString); assertNotNull(responseElement); OMElement outputElement = responseElement.getFirstChildWithName(new QName("OUTPUT")); assertNotNull(outputElement); OMElement returnElement = outputElement.getFirstChildWithName(new QName("RETURN")); assertNotNull(returnElement); OMElement returnTypeElement = returnElement.getFirstChildWithName(new QName("TYPE")); String returnTypeText = returnTypeElement.getText(); assertEquals(returnTypeText, "", "Incorrect response received. Received response: " + responseString); }
Example #7
Source File: SequenceTemplateMediaTypeTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Test defined Sequence Template media type - text/xml", enabled = false) public void definedSequenceTemplateMediaTypeTest() throws Exception { OMElement sequence = AXIOMUtil.stringToOM( "<template xmlns=\"http://ws.apache.org/ns/synapse\" name=\"" + DEFINED_SEQUENCE_TEMPLATE_NAME + "\">" + "<parameter name=\"message\"/>" + "<sequence> " + "<log level=\"custom\">" + "<property name=\"GREETING_MESSAGE\" expression=\"$func:message\" />" + "</log>" + "</sequence>" + "</template>"); sequenceTemplateAdminServiceClient.addSequenceTemplate(sequence); isDefinedSequenceTemplateExist = true; //addEndpoint is a a asynchronous call, it will take some time to write to a registry Thread.sleep(10000); MetadataBean metadata = resourceAdmin .getMetadata("/_system/config/repository/synapse/default/templates/" + DEFINED_SEQUENCE_TEMPLATE_NAME); Assert.assertEquals(metadata.getMediaType(), "text/xml", "Media Type mismatched for Defined Sequence Template"); }
Example #8
Source File: MessageStoreMessageStoringTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Test whether messages are stored from store mediator") public void messageStoreStoringTest() throws Exception { // The count should be 0 as soon as the message store is created Assert.assertTrue(messageStoreAdminClient.getMessageCount(MESSAGE_STORE_NAME) == 0, "Message store should be initially empty"); // refer within a sequence through a store mediator, mediate messages // and verify the messages are stored correctly in the store. loadESBConfigurationFromClasspath("/artifacts/ESB/synapseconfig/messageStore/sample_700.xml"); for (int i = 0; i < 5; i++) { client.sendSimpleQuoteRequest(getMainSequenceURL(), null, "WSO2"); } Assert.assertTrue(Utils.waitForMessageCount(messageStoreAdminClient, MESSAGE_STORE_NAME, 5, 30000), "Messsages are missing or repeated"); MessageInfo info[] = messageStoreAdminClient.getPaginatedMessages(MESSAGE_STORE_NAME, 0); ArrayList<String> list = new ArrayList<String>(); String sendEnvilope = "<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Body><ns:getSimpleQuote xmlns:ns=\"http://services.samples\"><ns:symbol>WSO2</ns:symbol></ns:getSimpleQuote></soapenv:Body></soapenv:Envelope>"; OMElement sendElement = AXIOMUtil.stringToOM(sendEnvilope); for (int i = 0; i < 5; i++) { OMElement stored = AXIOMUtil.stringToOM(info[i].getSoapXml()); // verify whether the SOAP message is equivalent to what was // mediated Assert.assertEquals(sendElement.toString(), stored.toString()); } }
Example #9
Source File: SmooksMediatorConfigFromLocalEntryTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
private void addSmooksProxy() throws Exception { Utils.deploySynapseConfiguration(AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"SmooksProxy\" transports=\"vfs\" " + "startOnLoad=\"true\">\n" + " <target>\n" + " <inSequence>\n" + " <log level=\"full\"/>\n" + " <smooks config-key=\"smooksKey\">\n" + " <input type=\"text\"/>\n" + " <output type=\"xml\"/>\n" + " </smooks>\n" + " <property name=\"OUT_ONLY\" value=\"true\"/>\n" + " <send>\n" + " <endpoint name=\"FileEpr\">\n" + " <address uri=\"vfs:file://" + getClass() .getResource("/artifacts/ESB/synapseconfig/smooks/").getPath() + "test/out/config-localentry-test-out" + ".xml\" format=\"soap11\"/>\n" + " </endpoint>\n" + " </send>\n" + " <log level=\"full\"/>\n" + " </inSequence>\n" + " </target>\n" + " <parameter name=\"transport.PollInterval\">1</parameter>\n" + " <parameter name=\"transport.vfs.FileURI\">file://" + getClass() .getResource("/artifacts/ESB/synapseconfig/smooks/").getPath() + "test/in/</parameter>\n" + " <parameter name=\"transport.vfs.FileNamePattern\">.*\\.txt</parameter>\n" + " <parameter name=\"transport.vfs.ContentType\">text/plain</parameter>\n" + "</proxy>"), "SmooksProxy", "proxy-services", true); }
Example #10
Source File: EndPointMediaTypeTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Test dynamic Endpoint media type - application/vnd.wso2.esb.endpoint") public void dynamicEndpointMediaTypeTest() throws Exception { final String name = "automationEndpoint"; OMElement endpoint = AXIOMUtil.stringToOM( "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\" name=\"" + name + "\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\">" + "<suspendOnFailure>" + "<progressionFactor>1.0</progressionFactor>" + "</suspendOnFailure>" + "<markForSuspension>" + "<retriesBeforeSuspension>0</retriesBeforeSuspension>" + "<retryDelay>0</retryDelay></markForSuspension>" + "</address>" + "</endpoint>"); isDynamicEndpointExist = endpointAdminClient.addDynamicEndPoint(KEY, endpoint); Assert.assertTrue(isDynamicEndpointExist, "Endpoint addition failed"); boolean isEndpointExist = false; for (String endpointName : endpointAdminClient.getDynamicEndpoints()) { if (KEY.equalsIgnoreCase(endpointName)) { isEndpointExist = true; break; } } Assert.assertTrue(isEndpointExist, "Endpoint not found in Dynamic Endpoint list"); MetadataBean metadata = resourceAdmin.getMetadata("/_system/config/endpoint/testAutomationEndpoint"); Assert.assertEquals(metadata.getMediaType(), "application/vnd.wso2.esb.endpoint", "Media Type mismatched for Dynamic Endpoint"); }
Example #11
Source File: EndPointMediaTypeTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Test defined Endpoint media type - text/xml", enabled = false) public void definedEndpointMediaTypeTest() throws Exception { OMElement endpoint = AXIOMUtil.stringToOM( "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\" " + "name=\"" + DEFINED_ENDPOINT_NAME + "\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" />" + "</endpoint>"); isDefinedEndpointExist = endpointAdminClient.addEndPoint(endpoint); Assert.assertTrue(isDefinedEndpointExist, "Endpoint addition failed"); boolean isEndpointExist = false; for (String endpointName : endpointAdminClient.getEndpointNames()) { if (DEFINED_ENDPOINT_NAME.equalsIgnoreCase(endpointName)) { isEndpointExist = true; break; } } Assert.assertTrue(isEndpointExist, "Endpoint not found in Defined Endpoint list"); //addEndpoint is a a asynchronous call, it will take some time to write to a registry Thread.sleep(10000); MetadataBean metadata = resourceAdmin .getMetadata("/_system/config/repository/synapse/default/endpoints/" + DEFINED_ENDPOINT_NAME); Assert.assertEquals(metadata.getMediaType(), "text/xml", "Media Type mismatched for Defined Endpoint"); }
Example #12
Source File: PropertyPersistenceDeletingAndAddingTstCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@BeforeClass(alwaysRun = true) public void setEnvironment() throws Exception { if (!(osname.contains("windows"))) { super.init(); serverConfigurationManager = new ServerConfigurationManager(context); serverConfigurationManager.copyToComponentLib(new File( getClass().getResource(JAR_LOCATION + File.separator + CLASS_JAR_FIVE_PROPERTIES).toURI())); OMElement class_five_properties = AXIOMUtil.stringToOM(FileUtils.readFileToString( new File(getESBResourceLocation() + File.separator + "mediatorconfig" + File.separator + "class" + File.separator + "class_property_persistence_five_properties.xml"))); Utils.deploySynapseConfiguration(class_five_properties, "class_property_persistence_five_properties", "proxy-services", true); super.init(); } else { log.info("Skip the test execution in Windows. [Unable to delete dropins in Winodws]"); } }
Example #13
Source File: MediationStatEnableTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Adds new endpoint * * @throws Exception */ private void addEndpoint() throws Exception { int beforeCount = endPointAdminClient.getEndpointCount(); addEndpoint(AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\" name=\"" + ENDPOINT_NAME + "\">\n" + " <address uri=\"" + getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE) + "\" />\n" + "</endpoint>")); int afterCount = endPointAdminClient.getEndpointCount(); assertEquals(1, afterCount - beforeCount); //Verify whether endpoint is added String[] endpoints = endPointAdminClient.getEndpointNames(); if (endpoints != null && endpoints.length > 0 && endpoints[0] != null) { List endpointList = Arrays.asList(endpoints); assertTrue(endpointList.contains(ENDPOINT_NAME)); } else { fail("Endpoint has not been added to the system properly"); } }
Example #14
Source File: SequenceTemplateMediaTypeTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Test dynamic Sequence Template media type - application/vnd.wso2.template") public void dynamicSequenceTemplateMediaTypeTest() throws Exception { final String name = "registrySequenceTemplate"; OMElement sequence = AXIOMUtil.stringToOM( "<template xmlns=\"http://ws.apache.org/ns/synapse\" name=\"" + name + "\">" + "<parameter name=\"message\"/>" + "<sequence> " + "<log level=\"custom\">" + "<property name=\"GREETING_MESSAGE\" expression=\"$func:message\"/>" + "</log>" + "</sequence>" + "</template>"); sequenceTemplateAdminServiceClient.addDynamicSequenceTemplate(KEY, sequence); isDynamicSequenceTemplateExist = true; MetadataBean metadata = resourceAdmin.getMetadata("/_system/config/template/registrySequenceTemplate"); Assert.assertEquals(metadata.getMediaType(), "application/vnd.wso2.template", "Media Type mismatched for Dynamic Sequence Template"); }
Example #15
Source File: SpecifyBothMinMaxByExpressionTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "number of messages is equal to the minimum") public void testEqualtoMinimum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = minMessageCount; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertEquals(no_of_requests, responseCount); }
Example #16
Source File: AggregateWithMaxMInLimitsTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "less number of messages than minimum count") public void testMoreNumberThanMaximum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = 10; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertTrue(2 <= responseCount && responseCount <= 5); }
Example #17
Source File: SoapToRestPeopleSampleTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, priority = 5, description = "Tests Delete method with application/jason content type") public void deletePeople() throws Exception { if (tomcatServerManager.isRunning()) { AxisServiceClient axisServiceClient = new AxisServiceClient(); OMElement getRequest = AXIOMUtil.stringToOM( "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:per=\"http://samples.esb.wso2.org\">\n" + " <soapenv:Header/>\n" + " <soapenv:Body>\n" + " <per:person>\n" + " <per:email>" + personEmail + "</per:email>\n" + " </per:person>\n" + " </soapenv:Body>\n" + "</soapenv:Envelope>"); OMElement response = axisServiceClient .sendReceive(getRequest, getProxyServiceURLHttp("peopleDeleteProxy"), "mediate"); Assert.assertTrue(response.toString().contains("Deleted")); Assert.assertTrue(response.toString().contains("200")); } else { Assert.fail("Jaxrs Service Startup failed"); } }
Example #18
Source File: NestedAggregatesTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Sending request for aggregation") public void test() throws IOException, XMLStreamException { int responseCount = 0; OMElement response = AXIOMUtil.stringToOM(aggregatedRequestClient.getResponse()); OMElement soapBody = response.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM Company")); } Assert.assertEquals(no_of_requests, responseCount, "Response Aggregation not as expected"); }
Example #19
Source File: MailToTransportRemoveHeaderTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@BeforeClass(alwaysRun = true) public void initialize() throws Exception { super.init(); OMElement mailToProxyOMElement = AXIOMUtil.stringToOM(FileUtils.readFileToString(new File( getESBResourceLocation() + File.separator + "mailTransport" + File.separator + "mailTransportReceiver" + File.separator + "mail_transport_remove_header.xml"))); Utils.deploySynapseConfiguration(mailToProxyOMElement, "MailTransportRemoveHeader","proxy-services", true); carbonLogReader = new CarbonLogReader(); greenMailUser = GreenMailServer.getPrimaryUser(); greenMailClient = new GreenMailClient(greenMailUser); carbonLogReader.start(); // Since ESB reads all unread emails one by one, we have to delete // the all unread emails before run the test GreenMailServer.deleteAllEmails("imap"); }
Example #20
Source File: MailToTransportActionAfterFailureMOVETestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@BeforeClass(alwaysRun = true) public void initialize() throws Exception { super.init(); OMElement mailToProxyOMElement = AXIOMUtil.stringToOM(FileUtils.readFileToString(new File( getESBResourceLocation() + File.separator + "mailTransport" + File.separator + "mailTransportReceiver" + File.separator + "mail_transport_actionafter_failure_move.xml"))); Utils.deploySynapseConfiguration(mailToProxyOMElement, "MailToTransportActionAfterFailureMoveTestCase","proxy-services", true); carbonLogReader = new CarbonLogReader(); carbonLogReader.start(); greenMailUser = GreenMailServer.getPrimaryUser(); greenMailClient = new GreenMailClient(greenMailUser); // Since ESB reads all unread emails one by one, we have to // delete the all unread emails before run the test GreenMailServer.deleteAllEmails("imap"); }
Example #21
Source File: MailToTransportFolderTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@BeforeClass(alwaysRun = true) public void initialize() throws Exception { super.init(); OMElement mailToProxyOMElement = AXIOMUtil.stringToOM(FileUtils.readFileToString(new File( getESBResourceLocation() + File.separator + "mailTransport" + File.separator + "mailTransportReceiver" + File.separator + "mail_transport_folder.xml"))); Utils.deploySynapseConfiguration(mailToProxyOMElement, "MailTransportFolder","proxy-services", true); carbonLogReader = new CarbonLogReader(); greenMailUser = GreenMailServer.getPrimaryUser(); greenMailClient = new GreenMailClient(greenMailUser); carbonLogReader.start(); // Since ESB reads all unread emails one by one, we have to delete // the all unread emails before run the test GreenMailServer.deleteAllEmails("imap"); }
Example #22
Source File: AggregateWithHighMaxAndLowMinTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "number of messages is equal to the maximum", enabled = false) public void testEqualtoMaximum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = 100; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched"); }
Example #23
Source File: RestEndpointSetter.java From micro-integrator with Apache License 2.0 | 6 votes |
public static OMElement setEndpoint(String relativePath) throws XMLStreamException, FileNotFoundException, XPathExpressionException { ESBTestCaseUtils util = new ESBTestCaseUtils(); relativePath = relativePath.replaceAll("[\\\\/]", File.separator); OMElement synapse = util.loadResource(relativePath); //if builder is enable, keep current configuration if (TestConfigurationProvider.isIntegration()) { return synapse; } String config = synapse.toString(); String secureStockQuoteService = EndpointGenerator.getBackEndServiceEndpointUrl(""); config = config.replace("http://localhost:9009/services/", secureStockQuoteService); config = config.replace("http://127.0.0.1:9009/services/", secureStockQuoteService); return AXIOMUtil.stringToOM(config); }
Example #24
Source File: AggregateOnCompleteConditionErrorTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Verify aggregate mediator return expected exception and expected error message * * @throws IOException * @throws XMLStreamException */ @Test(groups = { "wso2.esb" }, description = "verify proxy service return exception evaluating the on complete", expectedExceptions = org.apache.axis2.AxisFault.class, expectedExceptionsMessageRegExp = ".*Error evaluating expression.*") public void testAggregatorOnCompleteConditionError() throws IOException, XMLStreamException { OMElement payload = AXIOMUtil.stringToOM( "<soapenv:Envelope\n" + " xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" + " xmlns:ser=\"http://services.samples\"\n" + " xmlns:xsd=\"http://services.samples/xsd\">\n" + " <soapenv:Header/>\n" + " <soapenv:Body>\n" + " <ser:getQuotes>\n" + " <ser:getQuote>\n" + " <ser:request>\n" + " <xsd:symbol>IBM</xsd:symbol>\n" + " </ser:request>\n" + " </ser:getQuote>\n" + " <ser:getQuote>\n" + " <ser:request>\n" + " <xsd:symbol>WSO2</xsd:symbol>\n" + " </ser:request>\n" + " </ser:getQuote>\n" + " </ser:getQuotes>\n" + " </soapenv:Body>\n" + "</soapenv:Envelope>"); axis2Client.send(getProxyServiceURLHttp("aggregateMediatorOnCompleteErrorTestProxy"), null, "urn:getQuote", payload); }
Example #25
Source File: AggregateWithHighMaxAndLowMinTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "less number of messages than minimum count") public void testLessThanMinimum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = 1; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched"); }
Example #26
Source File: VFSTransportTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
private void addVFSProxy24() throws Exception { String proxyName = "VFSProxy24"; OMElement proxy = AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSProxy24\" transports=\"vfs\">\n" + " <parameter name=\"transport.vfs.FileURI\">file://" + pathToVfsDir + "test" + File.separator + proxyName + File.separator + "in" + File.separator + "</parameter> <!--CHANGE-->\n" + " <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n" + " <parameter name=\"transport.vfs.FileNamePattern\">.*\\.xml</parameter>\n" + " <parameter name=\"transport.PollInterval\">1</parameter>\n" + " <target>\n" + " <endpoint>\n" + " <address format=\"soap12\" uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>\n" + " </endpoint>\n" + " <outSequence>\n" + " <property name=\"transport.vfs.ReplyFileName\" value=\"out.xml\" scope=\"transport\"/>" + " <property action=\"set\" name=\"OUT_ONLY\" value=\"true\"/>\n" + " <send>\n" + " <endpoint>\n" + " <address uri=\"vfs:ftpd://" + pathToVfsDir + "test" + File.separator + proxyName + File.separator + "out" + File.separator + "\"/> <!--CHANGE-->\n" + " </endpoint>\n" + " </send>\n" + " </outSequence>\n" + " </target>\n" + " </proxy>"); addProxy(proxy, proxyName); }
Example #27
Source File: SpecifyMinMessageCountAsExpressionTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "number of messages is equal to the minimum") public void testEqualtoMinimum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = minMessageCount; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertEquals(responseCount, no_of_requests, "GetQuoteResponse Element count mismatched"); }
Example #28
Source File: VFSTransportTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
private void addVFSProxy21() throws Exception { String proxyName = "VFSProxy21"; OMElement proxy = AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSProxy21\" transports=\"vfs\">\n" + " <parameter name=\"transport.vfs.FileURI\">file://" + pathToVfsDir + "test" + File.separator + proxyName + File.separator + "in" + File.separator + "</parameter> <!--CHANGE-->\n" + " <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n" + " <parameter name=\"transport.vfs.FileNamePattern\">.*\\.xml</parameter>\n" + " <parameter name=\"transport.PollInterval\">1</parameter>\n" + " <parameter name=\"transport.vfs.ActionAfterProcess\">MOVE</parameter>\n" + " <parameter name=\"transport.vfs.MoveAfterProcess\">file://" + pathToVfsDir + "test" + File.separator + proxyName + File.separator + "processed" + File.separator + "</parameter>" + " <parameter name=\"transport.vfs.CreateFolder\">true</parameter>" + " <target>\n" + " <endpoint>\n" + " <address format=\"soap12\" uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>\n" + " </endpoint>\n" + " <outSequence>\n" + " <log level=\"full\"/>" + " <property action=\"set\" name=\"OUT_ONLY\" value=\"true\"/>\n" + " <send>\n" + " <endpoint>\n" + " <address uri=\"vfs:file://" + pathToVfsDir + "test" + File.separator + proxyName + File.separator + "out" + File.separator + "out.xml\"/> <!--CHANGE-->\n" + " </endpoint>\n" + " </send>\n" + " </outSequence>\n" + " </target>\n" + " </proxy>"); addProxy(proxy, proxyName); }
Example #29
Source File: VFSTransportTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
private void addVFSProxy20() throws Exception { String proxyName = "VFSProxy20"; OMElement proxy = AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSProxy20\" transports=\"vfs\">\n" + " <parameter name=\"transport.vfs.FileURI\">file://" + pathToVfsDir + "test" + File.separator + proxyName + File.separator + "in" + File.separator + "</parameter> <!--CHANGE-->\n" + " <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n" + " <parameter name=\"transport.vfs.FileNamePattern\">.*\\.xml</parameter>\n" + " <parameter name=\"transport.PollInterval\">1</parameter>\n" + " <parameter name=\"transport.vfs.MoveAfterFailure\">file://" + pathToVfsDir + "test" + File.separator + proxyName + File.separator + "failure" + File.separator + "</parameter>\n" + " <parameter name=\"transport.vfs.ActionAfterFailure\">MOVEDD</parameter>" + " <target>\n" + " <endpoint>\n" + " <address format=\"soap12\" uri=\"http://localhost:9000/services/SimpleStockQuoteService\"/>\n" + " </endpoint>\n" + " <outSequence>\n" + " <property action=\"set\" name=\"OUT_ONLY\" value=\"true\"/>\n" + " <send>\n" + " <endpoint>\n" + " <address uri=\"vfs:file://" + pathToVfsDir + "test" + File.separator + proxyName + File.separator + "out" + File.separator + "out.xml\"/> <!--CHANGE-->\n" + " </endpoint>\n" + " </send>\n" + " </outSequence>\n" + " </target>\n" + " </proxy>"); addProxy(proxy, proxyName); }
Example #30
Source File: AggregateWithHighMaxAndLowMinTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "more number of messages than maximum count") public void testMoreNumberThanMaximum() throws IOException, XMLStreamException { int responseCount = 0; no_of_requests = 110; aggregatedRequestClient.setNoOfIterations(no_of_requests); String Response = aggregatedRequestClient.getResponse(); Assert.assertNotNull(Response); OMElement Response2 = AXIOMUtil.stringToOM(Response); OMElement soapBody = Response2.getFirstElement(); Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples", "getQuoteResponse")); while (iterator.hasNext()) { responseCount++; OMElement getQuote = (OMElement) iterator.next(); Assert.assertTrue(getQuote.toString().contains("IBM")); } Assert.assertTrue(2 <= responseCount && responseCount <= 100); }