Examples of ThrottleAdminServiceStub


Examples of org.wso2.carbon.throttle.stub.ThrottleAdminServiceStub

                          String backendServerURL,
                          ConfigurationContext configCtx, Locale locale) throws AxisFault {
        String serviceURL = backendServerURL + "ThrottleAdminService";
        bundle = ResourceBundle.getBundle(BUNDLE, locale);

        stub = new ThrottleAdminServiceStub(configCtx, serviceURL);
        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
View Full Code Here

Examples of org.wso2.carbon.throttle.stub.ThrottleAdminServiceStub

            AuthenticateStub authenticateStub = new AuthenticateStub();
            ProxyServiceAdminStub proxyServiceAdminStub = new ProxyServiceAdminStub("https://" + FrameworkSettings.HOST_NAME + ":" + FrameworkSettings.HTTPS_PORT + "/services/ProxyServiceAdmin");
            authenticateStub.authenticateAdminStub(proxyServiceAdminStub, sessionCookie);

            ThrottleAdminServiceStub throttleAdminServiceStub = new ThrottleAdminServiceStub("https://" + FrameworkSettings.HOST_NAME + ":" + FrameworkSettings.HTTPS_PORT + "/services/ThrottleAdminService");
            authenticateStub.authenticateAdminStub(throttleAdminServiceStub, sessionCookie);

            proxyData = handler.getProxy(ThrottlleTest.class.getResource("/testdata/StockQuoteProxyTest.xml").getPath());

            //Add proxy Service test
            proxyServiceAdminStub.addProxy(proxyData);

            log.info("Proxy service added");


            ThrottlePolicy throttlePolicy = new ThrottlePolicy();

            InternalData[] internalDatas = new InternalData[1];

            InternalData data = new InternalData();

            data.setMaxRequestCount(6);
            data.setProhibitTimePeriod(10000);
            data.setRange("other");
            data.setAccessLevel(0);
            data.setRangeType("IP");
            data.setUnitTime(10000);

            internalDatas[0] = data;

            throttlePolicy.setInternalConfigs(internalDatas);
            throttleAdminServiceStub.enableThrottling("StockQuoteProxyTest", throttlePolicy);


            for (int i = 0; i <= 7; i++) {

                StockQuoteClient stockQuoteClient = new StockQuoteClient();
                if (FrameworkSettings.STRATOS.equalsIgnoreCase("false")) {
                    result = stockQuoteClient.stockQuoteClientforProxy("http://" + FrameworkSettings.HOST_NAME + ":" + FrameworkSettings.HTTP_PORT + "/services/StockQuoteProxyTest", null, "IBM");
                }
                else if (FrameworkSettings.STRATOS.equalsIgnoreCase("true")) {
                    System.out.println("http://" + FrameworkSettings.HOST_NAME + ":" + FrameworkSettings.HTTP_PORT + "/services/" + FrameworkSettings.TENANT_NAME + "/StockQuoteProxyTest");
                    result = stockQuoteClient.stockQuoteClientforProxy("http://" + FrameworkSettings.HOST_NAME + ":" + FrameworkSettings.HTTP_PORT + "/services/" + FrameworkSettings.TENANT_NAME + "/StockQuoteProxyTest", null, "IBM");
                }
                boolean isFound = result.getChildren().next().toString().contains("IBM");
                System.out.println(result.toString());
                if (!isFound) {
                    log.error("Required response not found");
                    Assert.fail("Required response not found");
                }

                Iterator iterator = result.getFirstElement().getChildrenWithName(new QName("http://services.samples/xsd", "name"));
                while (iterator.hasNext()) {
                    OMElement element = (OMElement) iterator.next();
                    System.out.println("The response is received : " + element.getText());
                    Assert.assertEquals("IBM Company", element.getText());

                }
                throttleCounter++;
            }
            throttleAdminServiceStub.disableThrottling("StockQuoteProxyTest");
        }
        catch (Exception
                e) {
            log.fatal(e.toString());
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.