Package com.alibaba.druid.support.http.stat

Examples of com.alibaba.druid.support.http.stat.WebAppStat


        for (Object item : stats) {
            if (!(item instanceof WebAppStat)) {
                continue;
            }

            WebAppStat webAppStat = (WebAppStat) item;

            if (collectWebAppEanble) {
                WebAppStatValue webAppStatValue = webAppStat.getStatValue(true);
                webAppStatValueList.add(webAppStatValue);
            }

            if (collectWebURIEnable) {
                webURIValueList.addAll(webAppStat.getURIStatValueList(true));
            }
        }

        MonitorContext ctx = createContext();
View Full Code Here


        StatFilterContext.getInstance().addContextListener(statFilterContextListener);

        this.contextPath = DruidWebUtils.getContextPath(config.getServletContext());
        if (webAppStat == null) {
            webAppStat = new WebAppStat(contextPath, this.sessionStatMaxCount);
        }
        WebAppStatManager.getInstance().addWebAppStatSet(webAppStat);
    }
View Full Code Here

        }

        StatFilterContext.getInstance().addContextListener(statFilterContextListener);

        this.contextPath = DruidWebUtils.getContextPath(config.getServletContext());
        webAppStat = new WebAppStat(contextPath, this.sessionStatMaxCount);

        WebAppStatManager.getInstance().addWebAppStatSet(webAppStat);
    }
View Full Code Here

        StatFilterContext.getInstance().addContextListener(statFilterContextListener);

        this.contextPath = DruidWebUtils.getContextPath(config.getServletContext());
        if (webAppStat == null) {
            webAppStat = new WebAppStat(contextPath, this.sessionStatMaxCount);
        }
        WebAppStatManager.getInstance().addWebAppStatSet(webAppStat);
    }
View Full Code Here

        MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
        filterConfig.addInitParameter(WebStatFilter.PARAM_NAME_SESSION_STAT_ENABLE, "false");

        WebStatFilter filter = new WebStatFilter();
        WebAppStat appStat = new WebAppStat() {
            public WebURIStat getURIStat(String uri, boolean create) {
                return null;
            }
        };
        filter.setWebAppStat(appStat);
        filter.setProfileEnable(true);

        Assert.assertNotNull(filter.getWebAppStat());

        filter.init(filterConfig);
       
        Assert.assertSame(appStat, filter.getWebAppStat());

        Assert.assertFalse(filter.isSessionStatEnable());
        Assert.assertTrue(WebAppStatManager.getInstance().getWebAppStatSet().contains(appStat));
        Assert.assertTrue(StatFilterContext.getInstance().getListeners().contains(filter.getStatFilterContextListener()));

        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        MockFilterChain chain = new MockFilterChain();

        Assert.assertNull(filter.getSessionStat(request));

        filter.doFilter(request, response, chain);

        Assert.assertEquals(0, appStat.getSessionStatDataList().size());

        filter.destroy();
       
        Assert.assertFalse(WebAppStatManager.getInstance().getWebAppStatSet().contains(appStat));
        Assert.assertFalse(StatFilterContext.getInstance().getListeners().contains(filter.getStatFilterContextListener()));
       
        Map<String, Object> statData = appStat.getStatData();
        Assert.assertEquals(1L, statData.get("RequestCount"));
    }
View Full Code Here

import com.alibaba.druid.support.http.stat.WebAppStat;

public class UserAgentAndroid_4_0_4_Test extends TestCase {

    public void test_mac_firefox() throws Exception {
        WebAppStat stat = new WebAppStat("");
        stat.computeUserAgent("Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19");
        Assert.assertEquals(1, stat.getBrowserChromeCount());
        Assert.assertEquals(0, stat.getBrowserFirefoxCount());
        Assert.assertEquals(0, stat.getBrowserOperaCount());
        Assert.assertEquals(0, stat.getBrowserSafariCount());
        Assert.assertEquals(0, stat.getBrowserIECount());
        Assert.assertEquals(0, stat.getBrowserIE10Count());

        Assert.assertEquals(1, stat.getDeviceAndroidCount());
        Assert.assertEquals(0, stat.getDeviceIphoneCount());
        Assert.assertEquals(0, stat.getDeviceWindowsPhoneCount());

        Assert.assertEquals(1, stat.getOSLinuxCount());
        Assert.assertEquals(1, stat.getOSAndroidCount());
        Assert.assertEquals(1, stat.getOSAndroid40Count());
        Assert.assertEquals(0, stat.getOSLinuxUbuntuCount());
        Assert.assertEquals(0, stat.getOSMacOSXCount());
        Assert.assertEquals(0, stat.getOSWindowsCount());
        Assert.assertEquals(0, stat.getOSWindows8Count());
        Assert.assertEquals(0, stat.getOSSymbianCount());
        Assert.assertEquals(0, stat.getOSFreeBSDCount());
        Assert.assertEquals(0, stat.getOSOpenBSDCount());
    }
View Full Code Here

        WebStatFilter filter = new WebStatFilter();

        filter.init(filterConfig);

        WebAppStat appStat = filter.getWebAppStat();

        Assert.assertEquals(3, filter.getSessionStatMaxCount());
        Assert.assertEquals(0, appStat.getSessionStatDataList().size());

        final MockHttpSession session_0 = new MockHttpSession(servletContext);
        final MockHttpSession session_1 = new MockHttpSession(servletContext);
        final MockHttpSession session_2 = new MockHttpSession(servletContext);
        final MockHttpSession session_3 = new MockHttpSession(servletContext);
        final MockHttpSession session_4 = new MockHttpSession(servletContext);

        // 第一个session请求2次
        {
            Assert.assertNull(appStat.getSessionStat(session_0.getId()));
           
            MockHttpServletRequest request = new MockHttpServletRequest();
            MockHttpServletResponse response = new MockHttpServletResponse();
            MockFilterChain chain = new MockFilterChain() {

                public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) {
                    ((MockHttpServletRequest) request).setSession(session_0);
                };
            };

            filter.doFilter(request, response, chain);

            Assert.assertEquals(1, appStat.getSessionStatDataList().size());
            Assert.assertEquals(1, appStat.getSessionStat(session_0.getId()).getRequestCount());
           
            Assert.assertTrue(appStat.getSessionStat(session_0.getId()).getLastAccessTimeMillis() > 0);
        }
        {
            MockHttpServletRequest request = new MockHttpServletRequest();
            MockHttpServletResponse response = new MockHttpServletResponse();
            MockFilterChain chain = new MockFilterChain() {
               
                public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) {
                    ((MockHttpServletRequest) request).setSession(session_0);
                };
            };
           
            filter.doFilter(request, response, chain);
           
            Assert.assertEquals(1, appStat.getSessionStatDataList().size());
            Assert.assertEquals(2, appStat.getSessionStat(session_0.getId()).getRequestCount());
        }
       
       
        // 第2个sesion请求1次
        {
            MockHttpServletRequest request = new MockHttpServletRequest();
            MockHttpServletResponse response = new MockHttpServletResponse();
            MockFilterChain chain = new MockFilterChain() {

                public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) {
                    ((MockHttpServletRequest) request).setSession(session_1);
                };
            };

            filter.doFilter(request, response, chain);

            Assert.assertEquals(2, appStat.getSessionStatDataList().size());
            Assert.assertEquals(2, appStat.getSessionStat(session_0.getId()).getRequestCount());
            Assert.assertEquals(1, appStat.getSessionStat(session_1.getId()).getRequestCount());
        }
       
        // 第3个sesion请求1次
        {
            MockHttpServletRequest request = new MockHttpServletRequest();
            MockHttpServletResponse response = new MockHttpServletResponse();
            MockFilterChain chain = new MockFilterChain() {
               
                public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) {
                    ((MockHttpServletRequest) request).setSession(session_2);
                };
            };
           
            filter.doFilter(request, response, chain);
           
            Assert.assertEquals(3, appStat.getSessionStatDataList().size());
            Assert.assertEquals(2, appStat.getSessionStat(session_0.getId()).getRequestCount());
            Assert.assertEquals(1, appStat.getSessionStat(session_1.getId()).getRequestCount());
            Assert.assertEquals(1, appStat.getSessionStat(session_2.getId()).getRequestCount());
        }
       
        // 第4个sesion请求1次
        {
            MockHttpServletRequest request = new MockHttpServletRequest();
            MockHttpServletResponse response = new MockHttpServletResponse();
            MockFilterChain chain = new MockFilterChain() {
               
                public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) {
                    ((MockHttpServletRequest) request).setSession(session_3);
                };
            };
           
            filter.doFilter(request, response, chain);
           
            Assert.assertEquals(3, appStat.getSessionStatDataList().size());
            Assert.assertNull(appStat.getSessionStat(session_0.getId()));
            Assert.assertEquals(1, appStat.getSessionStat(session_1.getId()).getRequestCount());
            Assert.assertEquals(1, appStat.getSessionStat(session_2.getId()).getRequestCount());
            Assert.assertEquals(1, appStat.getSessionStat(session_3.getId()).getRequestCount());
        }
       
        // 第5个sesion请求1次
        {
            MockHttpServletRequest request = new MockHttpServletRequest();
            MockHttpServletResponse response = new MockHttpServletResponse();
            MockFilterChain chain = new MockFilterChain() {
               
                public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) {
                    ((MockHttpServletRequest) request).setSession(session_4);
                };
            };
           
            filter.doFilter(request, response, chain);
           
            Assert.assertEquals(3, appStat.getSessionStatDataList().size());
            Assert.assertNull(appStat.getSessionStat(session_0.getId()));
            Assert.assertNull(appStat.getSessionStat(session_1.getId()));
            Assert.assertEquals(1, appStat.getSessionStat(session_2.getId()).getRequestCount());
            Assert.assertEquals(1, appStat.getSessionStat(session_3.getId()).getRequestCount());
            Assert.assertEquals(1, appStat.getSessionStat(session_4.getId()).getRequestCount());
        }
    }
View Full Code Here

import com.alibaba.druid.support.http.stat.WebAppStat;

public class UserAgentAndroid_4_3_Test_2 extends TestCase {

    public void test_mac_firefox() throws Exception {
        WebAppStat stat = new WebAppStat("");
        stat.computeUserAgent("Mozilla/5.0 (Linux; U; Android 4.3; en-us; Nexus 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36");
        Assert.assertEquals(1, stat.getBrowserChromeCount());
        Assert.assertEquals(0, stat.getBrowserFirefoxCount());
        Assert.assertEquals(0, stat.getBrowserOperaCount());
        Assert.assertEquals(0, stat.getBrowserSafariCount());
        Assert.assertEquals(0, stat.getBrowserIECount());
        Assert.assertEquals(0, stat.getBrowserIE10Count());

        Assert.assertEquals(1, stat.getDeviceAndroidCount());
        Assert.assertEquals(0, stat.getDeviceIphoneCount());
        Assert.assertEquals(0, stat.getDeviceWindowsPhoneCount());

        Assert.assertEquals(1, stat.getOSLinuxCount());
        Assert.assertEquals(1, stat.getOSAndroidCount());
        Assert.assertEquals(1, stat.getOSAndroid43Count());
        Assert.assertEquals(0, stat.getOSLinuxUbuntuCount());
        Assert.assertEquals(0, stat.getOSMacOSXCount());
        Assert.assertEquals(0, stat.getOSWindowsCount());
        Assert.assertEquals(0, stat.getOSWindows8Count());
        Assert.assertEquals(0, stat.getOSSymbianCount());
        Assert.assertEquals(0, stat.getOSFreeBSDCount());
        Assert.assertEquals(0, stat.getOSOpenBSDCount());
    }
View Full Code Here


public class UserAgentWin8IETest extends TestCase {
   
    public void test_mac_firefox() throws Exception {
        WebAppStat stat = new WebAppStat("");
        stat.computeUserAgent("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
        Assert.assertEquals(0, stat.getBrowserChromeCount());
        Assert.assertEquals(0, stat.getBrowserFirefoxCount());
        Assert.assertEquals(0, stat.getBrowserOperaCount());
        Assert.assertEquals(0, stat.getBrowserSafariCount());
        Assert.assertEquals(1, stat.getBrowserIECount());
        Assert.assertEquals(1, stat.getBrowserIE10Count());

        Assert.assertEquals(0, stat.getDeviceAndroidCount());
        Assert.assertEquals(0, stat.getDeviceIpadCount());
        Assert.assertEquals(0, stat.getDeviceIphoneCount());
        Assert.assertEquals(0, stat.getDeviceWindowsPhoneCount());

        Assert.assertEquals(0, stat.getOSLinuxCount());
        Assert.assertEquals(0, stat.getOSLinuxUbuntuCount());
        Assert.assertEquals(0, stat.getOSMacOSXCount());
        Assert.assertEquals(1, stat.getOSWindowsCount());
        Assert.assertEquals(1, stat.getOSWindows8Count());
        Assert.assertEquals(0, stat.getOSSymbianCount());
        Assert.assertEquals(0, stat.getOSFreeBSDCount());
        Assert.assertEquals(0, stat.getOSOpenBSDCount());
    }
View Full Code Here

        Assert.assertEquals(0, stat.getOSAndroidCount());
        Assert.assertEquals(0, stat.getOSAndroid21Count());
    }
   
    public void test_opera_1() throws Exception {
        WebAppStat stat = new WebAppStat("");
        stat.computeUserAgent("Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.00");
        Assert.assertEquals(0, stat.getBrowserIECount());
        Assert.assertEquals(0, stat.getBrowserChromeCount());
        Assert.assertEquals(0, stat.getBrowserFirefoxCount());
        Assert.assertEquals(0, stat.getBrowserIE10Count());
        Assert.assertEquals(0, stat.getBrowserIE6Count());
        Assert.assertEquals(0, stat.getBrowserIE7Count());
        Assert.assertEquals(0, stat.getBrowserIE8Count());
        Assert.assertEquals(0, stat.getBrowserIE9Count());
        Assert.assertEquals(1, stat.getBrowserOperaCount());
        Assert.assertEquals(0, stat.getBrowserSafariCount());
       
        Assert.assertEquals(0, stat.getDeviceAndroidCount());
        Assert.assertEquals(0, stat.getDeviceIpadCount());
        Assert.assertEquals(0, stat.getDeviceIphoneCount());
        Assert.assertEquals(0, stat.getDeviceWindowsPhoneCount());
       
        Assert.assertEquals(0, stat.getOSLinuxCount());
        Assert.assertEquals(0, stat.getOSLinuxUbuntuCount());
        Assert.assertEquals(1, stat.getOSMacOSXCount());
        Assert.assertEquals(0, stat.getOSWindowsCount());
        Assert.assertEquals(0, stat.getOSSymbianCount());
        Assert.assertEquals(0, stat.getOSFreeBSDCount());
        Assert.assertEquals(0, stat.getOSOpenBSDCount());
        Assert.assertEquals(0, stat.getOSAndroidCount());
        Assert.assertEquals(0, stat.getOSAndroid21Count());
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.support.http.stat.WebAppStat

Copyright © 2018 www.massapicom. 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.