// ERROR: 'org.xml.sax.SAXParseException; cvc-complex-type.2.4.b: The content of element // 'bas:objects' is not complete. One of // '{"http://www.betfair.com/servicetypes/v2/Baseline/":ComplexObject}' is expected.' @Test public void doTest() throws Exception { // Create the SOAP request as an XML Document XMLHelpers xMLHelpers1 = new XMLHelpers(); Document createAsDocument1 = xMLHelpers1.getXMLObjectFromString( "<TestLargePostRequest><largeRequest><size>2</size><objects><ComplexObject><value1>34</value1></ComplexObject></objects><oddOrEven>ODD</oddOrEven></largeRequest></TestLargePostRequest>"); // Set up the Http Call Bean to make the request CougarManager cougarManager2 = CougarManager.getInstance(); HttpCallBean getNewHttpCallBean2 = cougarManager2.getNewHttpCallBean("87.248.113.14"); cougarManager2 = cougarManager2; cougarManager2.setCougarFaultControllerJMXMBeanAttrbiute("DetailedFaults", "false"); getNewHttpCallBean2.setServiceName("Baseline"); getNewHttpCallBean2.setVersion("v2"); // Set the created SOAP request as the PostObject getNewHttpCallBean2.setPostObjectForRequestType(createAsDocument1, "SOAP"); // Get current time for getting log entries later Timestamp getTimeAsTimeStamp8 = new Timestamp(System.currentTimeMillis()); // Make the SOAP call to the operation cougarManager2.makeSoapCougarHTTPCalls(getNewHttpCallBean2); // Create the expected response object as an XML document (A message stating if the number of // items in the list was correct) XMLHelpers xMLHelpers4 = new XMLHelpers(); Document createAsDocument10 = xMLHelpers4.getXMLObjectFromString( "<response><message>There were 2 items specified in the list, 1 actually</message></response>"); // Convert the expected response to SOAP for comparison with actual response Map<String, Object> convertResponseToSOAP11 = cougarManager2.convertResponseToSOAP(createAsDocument10, getNewHttpCallBean2); // Check the response is as expected HttpResponseBean response5 = getNewHttpCallBean2.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum.SOAP); AssertionUtils.multiAssertEquals( convertResponseToSOAP11.get("SOAP"), response5.getResponseObject()); // generalHelpers.pauseTest(500L); // Check the log entries are as expected cougarManager2.verifyRequestLogEntriesAfterDate( getTimeAsTimeStamp8, new RequestLogRequirement("2.8", "testLargePost")); }
@Test public void doTest() throws Exception { // Create a soap request structure as a Document object XMLHelpers xMLHelpers1 = new XMLHelpers(); Document requestDocument = xMLHelpers1.getXMLObjectFromString( "<I64SimpleTypeEchoRequest><msg>200</msg></I64SimpleTypeEchoRequest>"); // Get an HTTPCallBean CougarManager cougarManager2 = CougarManager.getInstance(); HttpCallBean HTTPCallBean = cougarManager2.getNewHttpCallBean("87.248.113.14"); CougarManager CougarManager = cougarManager2; // Get LogManager JMX Attribute // Set Cougar Fault Controller attributes CougarManager.setCougarFaultControllerJMXMBeanAttrbiute("DetailedFaults", "false"); // Set service name to call HTTPCallBean.setServiceName("Baseline"); // Set service version to call HTTPCallBean.setVersion("v2"); // Set post object and request type HTTPCallBean.setPostObjectForRequestType(requestDocument, "SOAP"); // Get current time Timestamp timestamp = new Timestamp(System.currentTimeMillis()); // Make Cougar SOAP call CougarManager.makeSoapCougarHTTPCalls(HTTPCallBean); // Create a soap response structure as a Document object XMLHelpers xMLHelpers4 = new XMLHelpers(); Document responseDocument = xMLHelpers4.getXMLObjectFromString("<response>200</response>"); // Convert the Document to SOAP Map<String, Object> response5 = CougarManager.convertResponseToSOAP(responseDocument, HTTPCallBean); Object responseSoap = response5.get("SOAP"); // Get the actual SOAP response and compare it to the expected response HttpResponseBean response6 = HTTPCallBean.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum.SOAP); AssertionUtils.multiAssertEquals(responseSoap, response6.getResponseObject()); // Pause test // generalHelpers.pauseTest(500L); // Get Service log entries after the time recorded earlier in the test // Get request log entries after the time recorded earlier in the test CougarManager.verifyRequestLogEntriesAfterDate( timestamp, new RequestLogRequirement("2.8", "i64SimpleTypeEcho")); }
@Test public void doTest() throws Exception { // Create the SOAP request as an XML Document (with byte parameters) XMLHelpers xMLHelpers1 = new XMLHelpers(); Document createAsDocument1 = xMLHelpers1.getXMLObjectFromString( "<ByteOperationRequest><headerParam>0</headerParam><queryParam>0</queryParam><message><bodyParameter>AAAA</bodyParameter></message></ByteOperationRequest>"); // Set up the Http Call Bean to make the request CougarManager cougarManager2 = CougarManager.getInstance(); HttpCallBean hbean = cougarManager2.getNewHttpCallBean("87.248.113.14"); CougarManager hinstance = cougarManager2; hbean.setServiceName("Baseline"); hbean.setVersion("v2"); // Set the created SOAP request as the PostObject hbean.setPostObjectForRequestType(createAsDocument1, "SOAP"); // Get current time for getting log entries later Timestamp getTimeAsTimeStamp7 = new Timestamp(System.currentTimeMillis()); // Make the SOAP call to the operation hinstance.makeSoapCougarHTTPCalls(hbean); // Create the expected response object as an XML document XMLHelpers xMLHelpers4 = new XMLHelpers(); Document createAsDocument9 = xMLHelpers4.getXMLObjectFromString( "<response><queryParameter>0</queryParameter><headerParameter>0</headerParameter><bodyParameter>AAAA</bodyParameter></response>"); // Convert the expected response to SOAP for comparison with actual response Map<String, Object> convertResponseToSOAP10 = hinstance.convertResponseToSOAP(createAsDocument9, hbean); // Check the response is as expected HttpResponseBean response5 = hbean.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum.SOAP); AssertionUtils.multiAssertEquals( convertResponseToSOAP10.get("SOAP"), response5.getResponseObject()); // generalHelpers.pauseTest(500L); // Check the log entries are as expected hinstance.verifyRequestLogEntriesAfterDate( getTimeAsTimeStamp7, new RequestLogRequirement("2.8", "byteOperation")); }
@Test public void doTest() throws Exception { CougarManager cougarManager1 = CougarManager.getInstance(); HttpCallBean getNewHttpCallBean1 = cougarManager1.getNewHttpCallBean("87.248.113.14"); cougarManager1 = cougarManager1; getNewHttpCallBean1.setOperationName("i32MapSimpleTypeEcho", "i32MapEcho"); getNewHttpCallBean1.setServiceName("baseline", "cougarBaseline"); getNewHttpCallBean1.setVersion("v2"); Map map2 = new HashMap(); map2.put("RESTJSON", " {\"msg\": \n {\"1\": 11, \n \"2\": 22}}"); getNewHttpCallBean1.setPostQueryObjects(map2); Timestamp getTimeAsTimeStamp7 = new Timestamp(System.currentTimeMillis()); cougarManager1.makeRestCougarHTTPCall( getNewHttpCallBean1, com.betfair.testing.utils.cougar.enums.CougarMessageProtocolRequestTypeEnum.RESTJSON, com.betfair.testing.utils.cougar.enums.CougarMessageContentTypeEnum.XML); cougarManager1.makeRestCougarHTTPCall( getNewHttpCallBean1, com.betfair.testing.utils.cougar.enums.CougarMessageProtocolRequestTypeEnum.RESTJSON, com.betfair.testing.utils.cougar.enums.CougarMessageContentTypeEnum.JSON); XMLHelpers xMLHelpers4 = new XMLHelpers(); Document createAsDocument10 = xMLHelpers4.getXMLObjectFromString( "<I32MapSimpleTypeEchoResponse><entry key=\"1\"><Integer>11</Integer></entry><entry key=\"2\"><Integer>22</Integer></entry></I32MapSimpleTypeEchoResponse>"); JSONHelpers jSONHelpers5 = new JSONHelpers(); JSONObject createAsJSONObject11 = jSONHelpers5.createAsJSONObject(new JSONObject("{\"1\": 11,\"2\": 22}")); HttpResponseBean response6 = getNewHttpCallBean1.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTJSONXML); AssertionUtils.multiAssertEquals(createAsDocument10, response6.getResponseObject()); AssertionUtils.multiAssertEquals((int) 200, response6.getHttpStatusCode()); AssertionUtils.multiAssertEquals("OK", response6.getHttpStatusText()); HttpResponseBean response7 = getNewHttpCallBean1.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTJSONJSON); AssertionUtils.multiAssertEquals(createAsJSONObject11, response7.getResponseObject()); AssertionUtils.multiAssertEquals((int) 200, response7.getHttpStatusCode()); AssertionUtils.multiAssertEquals("OK", response7.getHttpStatusText()); // generalHelpers.pauseTest(500L); cougarManager1.verifyRequestLogEntriesAfterDate( getTimeAsTimeStamp7, new RequestLogRequirement("2.8", "i32MapSimpleTypeEcho"), new RequestLogRequirement("2.8", "i32MapSimpleTypeEcho")); }
@Test public void doTest() throws Exception { // Set up the Http Call Bean to make the request CougarManager cougarManager1 = CougarManager.getInstance(); HttpCallBean callBean = cougarManager1.getNewHttpCallBean("87.248.113.14"); CougarManager cougarManager = cougarManager1; cougarManager.setCougarFaultControllerJMXMBeanAttrbiute("DetailedFaults", "false"); // Set the call bean to use JSON batching callBean.setJSONRPC(true); // Set the list of requests to make a batched call to Map[] mapArray2 = new Map[3]; mapArray2[0] = new HashMap(); mapArray2[0].put("method", "dateTimeOperation"); mapArray2[0].put("params", "[{\"dateTimeParameter\":\"2009-06-01T11:50:00.435\"}]"); mapArray2[0].put("id", "\"DateTimeNoOff\""); mapArray2[1] = new HashMap(); mapArray2[1].put("method", "dateTimeOperation"); mapArray2[1].put("params", "[{\"dateTimeParameter\":\"2009-02-01T11:50:00.435\"}]"); mapArray2[1].put("id", "\"DateTimeNoOff2\""); mapArray2[2] = new HashMap(); mapArray2[2].put("method", "dateTimeOperation"); mapArray2[2].put("params", "[{\"dateTimeParameter\":\"2009-02-01T00:00:00.000\"}]"); mapArray2[2].put("id", "\"DateTimeNoOffMidNight\""); callBean.setBatchedRequests(mapArray2); // Get current time for getting log entries later Timestamp timeStamp = new Timestamp(System.currentTimeMillis()); // Make JSON call to the operation requesting a JSON response cougarManager.makeRestCougarHTTPCall( callBean, com.betfair.testing.utils.cougar.enums.CougarMessageProtocolRequestTypeEnum.RESTJSON, com.betfair.testing.utils.cougar.enums.CougarMessageContentTypeEnum.JSON); // Get the response to the batched query (store the response for further comparison as order of // batched responses cannot be relied on) HttpResponseBean actualResponseJSON = callBean.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTJSONJSON); // Convert the returned json object to a map for comparison CougarHelpers cougarHelpers4 = new CougarHelpers(); Map<String, Object> map5 = cougarHelpers4.convertBatchedResponseToMap(actualResponseJSON); AssertionUtils.multiAssertEquals( "{\"id\":\"DateTimeNoOff\",\"result\":{\"localTime\":\"2009-06-01T11:50:00.435Z\",\"localTime2\":\"2009-06-01T11:50:00.435Z\"},\"jsonrpc\":\"2.0\"}", map5.get("responseDateTimeNoOff")); AssertionUtils.multiAssertEquals( "{\"id\":\"DateTimeNoOff2\",\"result\":{\"localTime\":\"2009-02-01T11:50:00.435Z\",\"localTime2\":\"2009-02-01T11:50:00.435Z\"},\"jsonrpc\":\"2.0\"}", map5.get("responseDateTimeNoOff2")); AssertionUtils.multiAssertEquals( "{\"id\":\"DateTimeNoOffMidNight\",\"result\":{\"localTime\":\"2009-02-01T00:00:00.000Z\",\"localTime2\":\"2009-02-01T00:00:00.000Z\"},\"jsonrpc\":\"2.0\"}", map5.get("responseDateTimeNoOffMidNight")); AssertionUtils.multiAssertEquals("OK", map5.get("httpStatusText")); AssertionUtils.multiAssertEquals(200, map5.get("httpStatusCode")); // Pause the test to allow the logs to be filled // generalHelpers.pauseTest(500L); // Check the log entries are as expected cougarManager.verifyRequestLogEntriesAfterDate( timeStamp, new RequestLogRequirement("2.8", "dateTimeOperation"), new RequestLogRequirement("2.8", "dateTimeOperation"), new RequestLogRequirement("2.8", "dateTimeOperation")); CougarManager cougarManager9 = CougarManager.getInstance(); cougarManager9.verifyAccessLogEntriesAfterDate( timeStamp, new AccessLogRequirement("87.248.113.14", "/json-rpc", "Ok")); }
@Test public void doTest() throws Exception { // Create the HttpCallBean CougarManager cougarManager1 = CougarManager.getInstance(); HttpCallBean httpCallBeanBaseline = cougarManager1.getNewHttpCallBean(); CougarManager cougarManagerBaseline = cougarManager1; // 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"); // Set up the Http Call Bean to make the request CougarManager cougarManager2 = CougarManager.getInstance(); HttpCallBean callBean = cougarManager2.getNewHttpCallBean("87.248.113.14"); CougarManager cougarManager = cougarManager2; cougarManager.setCougarFaultControllerJMXMBeanAttrbiute("DetailedFaults", "false"); // Set the call bean to use JSON batching callBean.setJSONRPC(true); // Set the list of requests to make a batched call to Map[] mapArray3 = new Map[7]; mapArray3[0] = new HashMap(); mapArray3[0].put("method", "dateTimeOperation"); mapArray3[0].put("params", "[{\"dateTimeParameter\":\"2009-12-01T23:00:00.000Z\"}]"); mapArray3[0].put("id", "\"Call with correct params\""); mapArray3[1] = new HashMap(); mapArray3[1].put("method", "dateTimeOperation"); mapArray3[1].put("params", "[{\"dateTimeParameter\":\"true\"}]"); mapArray3[1].put("id", "\"Invalid parameter type\""); mapArray3[2] = new HashMap(); mapArray3[2].put("method", "dateTimeOperation"); mapArray3[2].put("params", "[{\"dateTimeParameter\":\"2009-12-01T25:00:00.000Z\"}]"); mapArray3[2].put("id", "\"Invalid Hour\""); mapArray3[3] = new HashMap(); mapArray3[3].put("method", "dateTimeOperation"); mapArray3[3].put("params", "[{\"dateTimeParameter\":\"2009-02-29T13:50:00.435Z\"}]"); mapArray3[3].put("id", "\"Invalid Leap Year\""); mapArray3[4] = new HashMap(); mapArray3[4].put("method", "dateTimeOperation"); mapArray3[4].put("params", "[{\"dateTimeParameter\":\"2009-12-01T23:60:00.000Z\"}]"); mapArray3[4].put("id", "\"Invalid Minute\""); mapArray3[5] = new HashMap(); mapArray3[5].put("method", "dateTimeOperation"); mapArray3[5].put("params", "[{\"dateTimeParameter\":\"2009-13-01T23:60:00.000Z\"}]"); mapArray3[5].put("id", "\"Invalid Month\""); mapArray3[6] = new HashMap(); mapArray3[6].put("method", "dateTimeOperation"); mapArray3[6].put("params", "[{\"dateTimeParameter\":\"2009-00-01T23:60:00.000Z\"}]"); mapArray3[6].put("id", "\"Invalid Month2\""); callBean.setBatchedRequests(mapArray3); // Get current time for getting log entries later Timestamp timeStamp = new Timestamp(System.currentTimeMillis()); // Make JSON call to the operation requesting a JSON response cougarManager.makeRestCougarHTTPCall( callBean, com.betfair.testing.utils.cougar.enums.CougarMessageProtocolRequestTypeEnum.RESTJSON, com.betfair.testing.utils.cougar.enums.CougarMessageContentTypeEnum.JSON); // Get the response to the batched query (store the response for further comparison as order of // batched responses cannot be relied on) HttpResponseBean actualResponseJSON = callBean.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTJSONJSON); // Convert the returned json object to a map for comparison CougarHelpers cougarHelpers5 = new CougarHelpers(); Map<String, Object> map6 = cougarHelpers5.convertBatchedResponseToMap(actualResponseJSON); AssertionUtils.multiAssertEquals( "{\"id\":\"Call with correct params\",\"result\":{\"localTime\":\"2009-12-01T23:00:00.000Z\",\"localTime2\":\"2009-12-01T23:00:00.000Z\"},\"jsonrpc\":\"2.0\"}", map6.get("responseCall with correct params")); AssertionUtils.multiAssertEquals( "{\"id\":\"Invalid parameter type\",\"error\":{\"message\":\"DSC-0044\",\"code\":-32602},\"jsonrpc\":\"2.0\"}", map6.get("responseInvalid parameter type")); AssertionUtils.multiAssertEquals( "{\"id\":\"Invalid Hour\",\"error\":{\"message\":\"DSC-0044\",\"code\":-32602},\"jsonrpc\":\"2.0\"}", map6.get("responseInvalid Hour")); AssertionUtils.multiAssertEquals( "{\"id\":\"Invalid Minute\",\"error\":{\"message\":\"DSC-0044\",\"code\":-32602},\"jsonrpc\":\"2.0\"}", map6.get("responseInvalid Minute")); AssertionUtils.multiAssertEquals( "{\"id\":\"Invalid Leap Year\",\"error\":{\"message\":\"DSC-0044\",\"code\":-32602},\"jsonrpc\":\"2.0\"}", map6.get("responseInvalid Leap Year")); AssertionUtils.multiAssertEquals( "{\"id\":\"Invalid Month\",\"error\":{\"message\":\"DSC-0044\",\"code\":-32602},\"jsonrpc\":\"2.0\"}", map6.get("responseInvalid Month")); AssertionUtils.multiAssertEquals( "{\"id\":\"Invalid Month2\",\"error\":{\"message\":\"DSC-0044\",\"code\":-32602},\"jsonrpc\":\"2.0\"}", map6.get("responseInvalid Month2")); AssertionUtils.multiAssertEquals(200, map6.get("httpStatusCode")); AssertionUtils.multiAssertEquals("OK", map6.get("httpStatusText")); // Pause the test to allow the logs to be filled // generalHelpers.pauseTest(500L); // Check the log entries are as expected cougarManager.verifyRequestLogEntriesAfterDate( timeStamp, new RequestLogRequirement("2.8", "dateTimeOperation")); CougarManager cougarManager10 = CougarManager.getInstance(); cougarManager10.verifyAccessLogEntriesAfterDate( timeStamp, new AccessLogRequirement("87.248.113.14", "/json-rpc", "Ok")); }
@Test public void doTest() throws Exception { // Set up the Http Call Bean to make the request CougarManager cougarManager1 = CougarManager.getInstance(); HttpCallBean getNewHttpCallBean1 = cougarManager1.getNewHttpCallBean("87.248.113.14"); cougarManager1 = cougarManager1; getNewHttpCallBean1.setOperationName("testParameterStylesQA"); getNewHttpCallBean1.setServiceName("baseline", "cougarBaseline"); getNewHttpCallBean1.setVersion("v2"); Map map2 = new HashMap(); map2.put("HeaderParam", "Foo"); getNewHttpCallBean1.setHeaderParams(map2); // Set the query parameter to a string containing encoded : Map map3 = new HashMap(); map3.put("queryParam", "colon%3A"); map3.put("dateQueryParam", "2009-06-01T13:50:00.0Z"); getNewHttpCallBean1.setQueryParams(map3); CougarHelpers cougarHelpers4 = new CougarHelpers(); Date convertedDate1 = cougarHelpers4.convertToSystemTimeZone("2009-06-01T13:50:00.0Z"); // Get current time for getting log entries later Timestamp getTimeAsTimeStamp8 = new Timestamp(System.currentTimeMillis()); // Make the 4 REST calls to the operation cougarManager1.makeRestCougarHTTPCalls(getNewHttpCallBean1); // Create the expected response as an XML document XMLHelpers xMLHelpers6 = new XMLHelpers(); Document createAsDocument10 = xMLHelpers6.createAsDocument( DocumentBuilderFactory.newInstance() .newDocumentBuilder() .parse( new ByteArrayInputStream( ("<SimpleResponse><message>headerParam=Foo,queryParam=colon:,dateQueryParam=" + cougarHelpers4.dateInUTC(convertedDate1) + "</message></SimpleResponse>") .getBytes()))); // Convert the expected response to REST types for comparison with actual responses Map<CougarMessageProtocolRequestTypeEnum, Object> convertResponseToRestTypes11 = cougarManager1.convertResponseToRestTypes(createAsDocument10, getNewHttpCallBean1); // Check the 4 responses are as expected HttpResponseBean response7 = getNewHttpCallBean1.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTXMLXML); AssertionUtils.multiAssertEquals( convertResponseToRestTypes11.get(CougarMessageProtocolRequestTypeEnum.RESTXML), response7.getResponseObject()); AssertionUtils.multiAssertEquals((int) 200, response7.getHttpStatusCode()); AssertionUtils.multiAssertEquals("OK", response7.getHttpStatusText()); HttpResponseBean response8 = getNewHttpCallBean1.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTJSONJSON); AssertionUtils.multiAssertEquals( convertResponseToRestTypes11.get(CougarMessageProtocolRequestTypeEnum.RESTJSON), response8.getResponseObject()); AssertionUtils.multiAssertEquals((int) 200, response8.getHttpStatusCode()); AssertionUtils.multiAssertEquals("OK", response8.getHttpStatusText()); HttpResponseBean response9 = getNewHttpCallBean1.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTXMLJSON); AssertionUtils.multiAssertEquals( convertResponseToRestTypes11.get(CougarMessageProtocolRequestTypeEnum.RESTJSON), response9.getResponseObject()); AssertionUtils.multiAssertEquals((int) 200, response9.getHttpStatusCode()); AssertionUtils.multiAssertEquals("OK", response9.getHttpStatusText()); HttpResponseBean response10 = getNewHttpCallBean1.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTJSONXML); AssertionUtils.multiAssertEquals( convertResponseToRestTypes11.get(CougarMessageProtocolRequestTypeEnum.RESTXML), response10.getResponseObject()); AssertionUtils.multiAssertEquals((int) 200, response10.getHttpStatusCode()); AssertionUtils.multiAssertEquals("OK", response10.getHttpStatusText()); // generalHelpers.pauseTest(500L); // Check the log entries are as expected cougarManager1.verifyRequestLogEntriesAfterDate( getTimeAsTimeStamp8, new RequestLogRequirement("2.8", "testParameterStylesQA"), new RequestLogRequirement("2.8", "testParameterStylesQA"), new RequestLogRequirement("2.8", "testParameterStylesQA"), new RequestLogRequirement("2.8", "testParameterStylesQA")); }
@Test public void doTest() throws Exception { CougarManager cougarManager1 = CougarManager.getInstance(); HttpCallBean getNewHttpCallBean1 = cougarManager1.getNewHttpCallBean("87.248.113.14"); cougarManager1 = cougarManager1; getNewHttpCallBean1.setOperationName("TestSimpleMapGet", "simpleMapGet"); getNewHttpCallBean1.setServiceName("baseline", "cougarBaseline"); getNewHttpCallBean1.setVersion("v2"); getNewHttpCallBean1.setRestPostQueryObjects( DocumentBuilderFactory.newInstance() .newDocumentBuilder() .parse( new ByteArrayInputStream( "<inputMap><entry key=\"bbb\"><String>Value for bbb</String></entry><entry key=\"aaa\"><String>Value for aaa</String></entry><entry key=\"ddd\"></entry><entry key=\"ccc\"><String>Value for ccc</String></entry></inputMap>" .getBytes()))); Timestamp getTimeAsTimeStamp7 = new Timestamp(System.currentTimeMillis()); cougarManager1.makeRestCougarHTTPCall( getNewHttpCallBean1, com.betfair.testing.utils.cougar.enums.CougarMessageProtocolRequestTypeEnum.RESTXML, com.betfair.testing.utils.cougar.enums.CougarMessageContentTypeEnum.XML); cougarManager1.makeRestCougarHTTPCall( getNewHttpCallBean1, com.betfair.testing.utils.cougar.enums.CougarMessageProtocolRequestTypeEnum.RESTXML, com.betfair.testing.utils.cougar.enums.CougarMessageContentTypeEnum.JSON); XMLHelpers xMLHelpers3 = new XMLHelpers(); Document createAsDocument10 = xMLHelpers3.getXMLObjectFromString( "<TestSimpleMapGetResponse><entry key=\"aaa\"><String>Value for aaa</String></entry><entry key=\"ddd\"></entry><entry key=\"ccc\"><String>Value for ccc</String></entry><entry key=\"bbb\"><String>Value for bbb</String></entry></TestSimpleMapGetResponse>"); JSONHelpers jSONHelpers4 = new JSONHelpers(); JSONObject createAsJSONObject11 = jSONHelpers4.createAsJSONObject( new JSONObject( "{\"aaa\": \"Value for aaa\",\"bbb\": \"Value for bbb\",\"ccc\": \"Value for ccc\",\"ddd\": null}")); HttpResponseBean response5 = getNewHttpCallBean1.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTXMLXML); AssertionUtils.multiAssertEquals(createAsDocument10, response5.getResponseObject()); AssertionUtils.multiAssertEquals((int) 200, response5.getHttpStatusCode()); AssertionUtils.multiAssertEquals("OK", response5.getHttpStatusText()); HttpResponseBean response6 = getNewHttpCallBean1.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTXMLJSON); AssertionUtils.multiAssertEquals(createAsJSONObject11, response6.getResponseObject()); AssertionUtils.multiAssertEquals((int) 200, response6.getHttpStatusCode()); AssertionUtils.multiAssertEquals("OK", response6.getHttpStatusText()); // generalHelpers.pauseTest(500L); cougarManager1.verifyRequestLogEntriesAfterDate( getTimeAsTimeStamp7, new RequestLogRequirement("2.8", "testSimpleMapGet"), new RequestLogRequirement("2.8", "testSimpleMapGet")); }
@Test public void doTest() throws Exception { // Set up the Http Call Bean to make the request CougarManager cougarManager1 = CougarManager.getInstance(); HttpCallBean getNewHttpCallBean1 = cougarManager1.getNewHttpCallBean("87.248.113.14"); cougarManager1 = cougarManager1; getNewHttpCallBean1.setOperationName("complexMapOperation"); getNewHttpCallBean1.setServiceName("baseline", "cougarBaseline"); getNewHttpCallBean1.setVersion("v2"); // Instruct cougar to use a delegate to populate the complex response object getNewHttpCallBean1.setRestPostQueryObjects( DocumentBuilderFactory.newInstance() .newDocumentBuilder() .parse( new ByteArrayInputStream( "<message><complexMap><entry key=\"DELEGATE\"><SomeComplexObject/></entry></complexMap></message>" .getBytes()))); // Get current time for getting log entries later Timestamp getTimeAsTimeStamp7 = new Timestamp(System.currentTimeMillis()); // Make the XML call to the operation with XML response type cougarManager1.makeRestCougarHTTPCall( getNewHttpCallBean1, com.betfair.testing.utils.cougar.enums.CougarMessageProtocolRequestTypeEnum.RESTXML, com.betfair.testing.utils.cougar.enums.CougarMessageContentTypeEnum.XML); // Make the XML call to the operation with JSON response type cougarManager1.makeRestCougarHTTPCall( getNewHttpCallBean1, com.betfair.testing.utils.cougar.enums.CougarMessageProtocolRequestTypeEnum.RESTXML, com.betfair.testing.utils.cougar.enums.CougarMessageContentTypeEnum.JSON); // Create date object expected to be received in response object String date = TimingHelpers.convertUTCDateTimeToCougarFormat( (int) 1970, (int) 1, (int) 1, (int) 0, (int) 1, (int) 52, (int) 233); // Create the expected response as an XML document (using date just created) XMLHelpers xMLHelpers4 = new XMLHelpers(); Document expectedResponseXML = xMLHelpers4.createAsDocument( DocumentBuilderFactory.newInstance() .newDocumentBuilder() .parse( new ByteArrayInputStream( ("<ComplexMapOperationResponse><ComplexMapOperationResponseObject><responseMap><entry key=\"object1\"><SomeComplexObject><dateTimeParameter>" + date + "</dateTimeParameter><listParameter><String>item1</String><String>item2</String></listParameter><enumParameter>BAR</enumParameter><stringParameter>delegate1</stringParameter></SomeComplexObject></entry><entry key=\"object2\"><SomeComplexObject><dateTimeParameter>" + date + "</dateTimeParameter><listParameter><String>item1</String><String>item2</String></listParameter><enumParameter>BAR</enumParameter><stringParameter>delegate2</stringParameter></SomeComplexObject></entry><entry key=\"object3\"><SomeComplexObject><dateTimeParameter>" + date + "</dateTimeParameter><listParameter><String>item1</String><String>item2</String></listParameter><enumParameter>BAR</enumParameter><stringParameter>delegate3</stringParameter></SomeComplexObject></entry></responseMap></ComplexMapOperationResponseObject></ComplexMapOperationResponse>") .getBytes()))); // Create the expected response as an JSON document (using date just created) JSONHelpers jSONHelpers5 = new JSONHelpers(); JSONObject expectedResponseJSON = jSONHelpers5.createAsJSONObject( new JSONObject( "{responseMap:{object1:{dateTimeParameter:\"" + date + "\",listParameter:[item1,item2],enumParameter:\"BAR\",stringParameter:\"delegate1\"},object2:{dateTimeParameter:\"" + date + "\",listParameter:[item1,item2],enumParameter:\"BAR\",stringParameter:\"delegate2\"},object3:{dateTimeParameter:\"" + date + "\",listParameter:[item1,item2],enumParameter:\"BAR\",stringParameter:\"delegate3\"}}}")); // Check the XML response is as expected HttpResponseBean response6 = getNewHttpCallBean1.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTXMLXML); AssertionUtils.multiAssertEquals(expectedResponseXML, response6.getResponseObject()); AssertionUtils.multiAssertEquals((int) 200, response6.getHttpStatusCode()); AssertionUtils.multiAssertEquals("OK", response6.getHttpStatusText()); // Check the JSON response is as expected HttpResponseBean response7 = getNewHttpCallBean1.getResponseObjectsByEnum( com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum .RESTXMLJSON); AssertionUtils.multiAssertEquals(expectedResponseJSON, response7.getResponseObject()); AssertionUtils.multiAssertEquals((int) 200, response7.getHttpStatusCode()); AssertionUtils.multiAssertEquals("OK", response7.getHttpStatusText()); // generalHelpers.pauseTest(500L); // Check the log entries are as expected cougarManager1.verifyRequestLogEntriesAfterDate( getTimeAsTimeStamp7, new RequestLogRequirement("2.8", "complexMapOperation"), new RequestLogRequirement("2.8", "complexMapOperation")); }