/* * Copyright 2013, The Sporting Exchange Limited * Copyright 2014, Simon Matić Langford * * Licensed 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. */ // Originally from UpdatedComponentTests/StandardValidation/SOAP/Test-IDL/SOAP_RequestTypes_Floats_Incorrect_Mandatory_NotSet.xls; package com.betfair.cougar.tests.updatedcomponenttests.standardvalidation.soap.testidl; import com.betfair.testing.utils.cougar.misc.XMLHelpers; import com.betfair.testing.utils.cougar.assertions.AssertionUtils; import com.betfair.testing.utils.cougar.beans.HttpCallBean; import com.betfair.testing.utils.cougar.beans.HttpResponseBean; import com.betfair.testing.utils.cougar.helpers.CougarHelpers; import com.betfair.testing.utils.cougar.manager.AccessLogRequirement; import com.betfair.testing.utils.cougar.manager.CougarManager; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import org.w3c.dom.Document; import java.sql.Timestamp; import java.util.Map; /** * Ensure that when a SOAP request is received with a missing mandatory Float parameter, Cougar returns the correct fault */ public class SOAPRequestTypesFloatsIncorrectMandatoryNotSetTest { @Test(dataProvider = "SchemaValidationEnabled") public void doTest(boolean schemaValidationEnabled) throws Exception { CougarHelpers helpers = new CougarHelpers(); try { CougarManager cougarManager = CougarManager.getInstance(); helpers.setSOAPSchemaValidationEnabled(schemaValidationEnabled); // Create the HttpCallBean HttpCallBean httpCallBeanBaseline = cougarManager.getNewHttpCallBean(); // Get the cougar logging attribute for getting log entries later // Point the created HttpCallBean at the correct service httpCallBeanBaseline.setServiceName("baseline", "cougarBaseline"); httpCallBeanBaseline.setVersion("v2"); // Create the SOAP request as an XML Document (with a missing mandatory query parameter) XMLHelpers xMLHelpers2 = new XMLHelpers(); Document createAsDocument2 = xMLHelpers2.getXMLObjectFromString("<FloatOperationRequest><headerParam>78.4</headerParam><message><bodyParameter>0.0006</bodyParameter></message></FloatOperationRequest>"); // Set up the Http Call Bean to make the request CougarManager cougarManager3 = CougarManager.getInstance(); HttpCallBean getNewHttpCallBean3 = cougarManager3.getNewHttpCallBean("87.248.113.14"); cougarManager3 = cougarManager3; cougarManager3.setCougarFaultControllerJMXMBeanAttrbiute("DetailedFaults", "false"); getNewHttpCallBean3.setServiceName("Baseline"); getNewHttpCallBean3.setVersion("v2"); // Set the created SOAP request as the PostObject getNewHttpCallBean3.setPostObjectForRequestType(createAsDocument2, "SOAP"); // Get current time for getting log entries later Timestamp getTimeAsTimeStamp9 = new Timestamp(System.currentTimeMillis()); // Make the SOAP call to the operation cougarManager3.makeSoapCougarHTTPCalls(getNewHttpCallBean3); // Create the expected response object as an XML document (fault) XMLHelpers xMLHelpers5 = new XMLHelpers(); Document createAsDocument11 = xMLHelpers5.getXMLObjectFromString("<soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>DSC-0018</faultstring><detail/></soapenv:Fault>"); // Check the response is as expected HttpResponseBean response6 = getNewHttpCallBean3.getResponseObjectsByEnum(com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum.SOAP); AssertionUtils.multiAssertEquals(createAsDocument11, response6.getResponseObject()); // generalHelpers.pauseTest(500L); // Check the log entries are as expected CougarHelpers cougarHelpers10 = new CougarHelpers(); String JavaVersion = cougarHelpers10.getJavaVersion(); CougarManager cougarManager11 = CougarManager.getInstance(); cougarManager11.verifyAccessLogEntriesAfterDate(getTimeAsTimeStamp9, new AccessLogRequirement("87.248.113.14", "/BaselineService/v2", "BadRequest")); } finally { helpers.setSOAPSchemaValidationEnabled(true); } } @DataProvider(name = "SchemaValidationEnabled") public Object[][] versions () { return new Object[][]{ {true} , {false} }; } }