コード例 #1
0
  @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"));
  }
コード例 #2
0
  @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 {
    // 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 getNewHttpCallBean2 = cougarManager2.getNewHttpCallBean("87.248.113.14");
    cougarManager2 = cougarManager2;

    cougarManager2.setCougarFaultControllerJMXMBeanAttrbiute("DetailedFaults", "false");

    getNewHttpCallBean2.setOperationName("simpleMapOperation");

    getNewHttpCallBean2.setServiceName("baseline", "cougarBaseline");

    getNewHttpCallBean2.setVersion("v2");
    // Set the body parameter to a map that contains a value with no corresponding key
    Map map3 = new HashMap();
    map3.put(
        "RESTJSON",
        "{\n    \"simpleMap\": {\n        \"bbb\": \"Value for bbb\",\n        \"aaa\": \"Value for aaa\",\n        \"ccc\": \"Value for ccc\",\n        \"value for not passed key\"\n    }\n}");
    getNewHttpCallBean2.setPostQueryObjects(map3);
    // Get current time for getting log entries later

    Timestamp getTimeAsTimeStamp9 = new Timestamp(System.currentTimeMillis());
    // Make REST JSON call to the operation requesting an XML response
    cougarManager2.makeRestCougarHTTPCall(
        getNewHttpCallBean2,
        com.betfair.testing.utils.cougar.enums.CougarMessageProtocolRequestTypeEnum.RESTJSON,
        com.betfair.testing.utils.cougar.enums.CougarMessageContentTypeEnum.XML);
    // Make REST JSON call to the operation requesting a JSON response
    cougarManager2.makeRestCougarHTTPCall(
        getNewHttpCallBean2,
        com.betfair.testing.utils.cougar.enums.CougarMessageProtocolRequestTypeEnum.RESTJSON,
        com.betfair.testing.utils.cougar.enums.CougarMessageContentTypeEnum.JSON);
    // Create the expected response as an XML document (Fault)
    XMLHelpers xMLHelpers5 = new XMLHelpers();
    Document createAsDocument12 =
        xMLHelpers5.getXMLObjectFromString(
            "<fault><faultcode>Client</faultcode><faultstring>DSC-0008</faultstring><detail/></fault>");
    // Convert expected response to a JSON object for comparison with JSON actual response
    JSONHelpers jSONHelpers6 = new JSONHelpers();
    JSONObject convertXMLDocumentToJSONObjectRemoveRootElement13 =
        jSONHelpers6.convertXMLDocumentToJSONObjectRemoveRootElement(createAsDocument12);
    // Check the 2 responses are as expected (Bad Request)
    HttpResponseBean response7 =
        getNewHttpCallBean2.getResponseObjectsByEnum(
            com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum
                .RESTJSONXML);
    AssertionUtils.multiAssertEquals(createAsDocument12, response7.getResponseObject());
    AssertionUtils.multiAssertEquals((int) 400, response7.getHttpStatusCode());
    AssertionUtils.multiAssertEquals("Bad Request", response7.getHttpStatusText());

    HttpResponseBean response8 =
        getNewHttpCallBean2.getResponseObjectsByEnum(
            com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum
                .RESTJSONJSON);
    AssertionUtils.multiAssertEquals(
        convertXMLDocumentToJSONObjectRemoveRootElement13, response8.getResponseObject());
    AssertionUtils.multiAssertEquals((int) 400, response8.getHttpStatusCode());
    AssertionUtils.multiAssertEquals("Bad Request", response8.getHttpStatusText());

    // generalHelpers.pauseTest(500L);
    // Check the log entries are as expected

    CougarManager cougarManager11 = CougarManager.getInstance();
    cougarManager11.verifyAccessLogEntriesAfterDate(
        getTimeAsTimeStamp9,
        new AccessLogRequirement(
            "87.248.113.14", "/cougarBaseline/v2/simpleMapOperation", "BadRequest"),
        new AccessLogRequirement(
            "87.248.113.14", "/cougarBaseline/v2/simpleMapOperation", "BadRequest"));
  }
  @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 getNewHttpCallBean2 = cougarManager2.getNewHttpCallBean("87.248.113.14");
    cougarManager2 = cougarManager2;

    cougarManager2.setCougarFaultControllerJMXMBeanAttrbiute("DetailedFaults", "false");

    getNewHttpCallBean2.setOperationName("floatOperation");

    getNewHttpCallBean2.setServiceName("baseline", "cougarBaseline");

    getNewHttpCallBean2.setVersion("v2");

    Map map3 = new HashMap();
    map3.put("HeaderParam", "5.43");
    getNewHttpCallBean2.setHeaderParams(map3);

    Map map4 = new HashMap();
    map4.put("queryParam", "3455.54");
    getNewHttpCallBean2.setQueryParams(map4);
    // Set the Float body parameter as a non Float
    getNewHttpCallBean2.setRestPostQueryObjects(
        DocumentBuilderFactory.newInstance()
            .newDocumentBuilder()
            .parse(
                new ByteArrayInputStream(
                    "<message><bodyParameter>dfdsfsf</bodyParameter></message>".getBytes())));
    // Get current time for getting log entries later

    Timestamp getTimeAsTimeStamp11 = new Timestamp(System.currentTimeMillis());
    // Make the 4 REST calls to the operation
    cougarManager2.makeRestCougarHTTPCalls(getNewHttpCallBean2);
    // Create the expected response to XML requests as an XML document (XML Fault)
    XMLHelpers xMLHelpers6 = new XMLHelpers();
    Document createAsDocument13 =
        xMLHelpers6.getXMLObjectFromString(
            "<fault><faultcode>Client</faultcode><faultstring>DSC-0044</faultstring><detail/></fault>");
    // Create the expected response to JSON requests as an XML document (JSON Fault)
    XMLHelpers xMLHelpers7 = new XMLHelpers();
    Document createAsDocument14 =
        xMLHelpers7.getXMLObjectFromString(
            "<fault><faultcode>Client</faultcode><faultstring>DSC-0044</faultstring><detail/></fault>");
    // Convert expected response to XML requests to JSON object
    JSONHelpers jSONHelpers8 = new JSONHelpers();
    JSONObject convertXMLDocumentToJSONObjectRemoveRootElement15 =
        jSONHelpers8.convertXMLDocumentToJSONObjectRemoveRootElement(createAsDocument13);
    // Convert expected response to JSON requests to JSON object
    JSONHelpers jSONHelpers9 = new JSONHelpers();
    JSONObject convertXMLDocumentToJSONObjectRemoveRootElement16 =
        jSONHelpers9.convertXMLDocumentToJSONObjectRemoveRootElement(createAsDocument14);
    // Check the 4 responses are as expected (Bad Request)
    HttpResponseBean response10 =
        getNewHttpCallBean2.getResponseObjectsByEnum(
            com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum
                .RESTXMLXML);
    AssertionUtils.multiAssertEquals(createAsDocument13, response10.getResponseObject());
    AssertionUtils.multiAssertEquals((int) 400, response10.getHttpStatusCode());
    AssertionUtils.multiAssertEquals("Bad Request", response10.getHttpStatusText());

    HttpResponseBean response11 =
        getNewHttpCallBean2.getResponseObjectsByEnum(
            com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum
                .RESTJSONJSON);
    AssertionUtils.multiAssertEquals(
        convertXMLDocumentToJSONObjectRemoveRootElement16, response11.getResponseObject());
    AssertionUtils.multiAssertEquals((int) 400, response11.getHttpStatusCode());
    AssertionUtils.multiAssertEquals("Bad Request", response11.getHttpStatusText());

    HttpResponseBean response12 =
        getNewHttpCallBean2.getResponseObjectsByEnum(
            com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum
                .RESTXMLJSON);
    AssertionUtils.multiAssertEquals(
        convertXMLDocumentToJSONObjectRemoveRootElement15, response12.getResponseObject());
    AssertionUtils.multiAssertEquals((int) 400, response12.getHttpStatusCode());
    AssertionUtils.multiAssertEquals("Bad Request", response12.getHttpStatusText());

    HttpResponseBean response13 =
        getNewHttpCallBean2.getResponseObjectsByEnum(
            com.betfair.testing.utils.cougar.enums.CougarMessageProtocolResponseTypeEnum
                .RESTJSONXML);
    AssertionUtils.multiAssertEquals(createAsDocument14, response13.getResponseObject());
    AssertionUtils.multiAssertEquals((int) 400, response13.getHttpStatusCode());
    AssertionUtils.multiAssertEquals("Bad Request", response13.getHttpStatusText());
    // Check the log entries are as expected

    CougarManager cougarManager15 = CougarManager.getInstance();
    cougarManager15.verifyAccessLogEntriesAfterDate(
        getTimeAsTimeStamp11,
        new AccessLogRequirement(
            "87.248.113.14", "/cougarBaseline/v2/floatOperation", "BadRequest"),
        new AccessLogRequirement(
            "87.248.113.14", "/cougarBaseline/v2/floatOperation", "BadRequest"),
        new AccessLogRequirement(
            "87.248.113.14", "/cougarBaseline/v2/floatOperation", "BadRequest"),
        new AccessLogRequirement(
            "87.248.113.14", "/cougarBaseline/v2/floatOperation", "BadRequest"));
  }
コード例 #5
0
  @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"));
  }