Java Code Examples for org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.QueryStats

The following examples show how to use org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport.QueryStats. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Tomcat8-Source-Read   Source File: TestSlowQueryComparator.java    License: MIT License 7 votes vote down vote up
@Test
public void testBug58489() throws Exception {

    long[] testData = { 0, 0, 0, 1444225382010l, 0, 1444225382011l, 0,
            1444225382012l, 0, 1444225382056l, 0, 1444225382014l, 0,
            1444225382015l, 0, 1444225382016l, 0, 0, 1444225382017l, 0,
            1444225678350l, 0, 1444225680397l, 0, 1444225382018l,
            1444225382019l, 1444225382020l, 0, 1444225382021l, 0,
            1444225382022l, 1444225382023l

    };

    List<QueryStats> stats = new ArrayList<>();

    for (int i = 0; i < testData.length; i++) {
        QueryStats qs = new QueryStats(String.valueOf(i));
        qs.add(0, testData[i]);
        stats.add(qs);
    }

    try {
        Collections.sort(stats, createComparator());
    } catch (IllegalArgumentException e) {
        Assert.fail(e.getMessage());
    }
}
 
Example 2
Source Project: Tomcat7.0.67   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testBug58489() throws Exception {

    long[] testData = { 0, 0, 0, 1444225382010l, 0, 1444225382011l, 0,
            1444225382012l, 0, 1444225382056l, 0, 1444225382014l, 0,
            1444225382015l, 0, 1444225382016l, 0, 0, 1444225382017l, 0,
            1444225678350l, 0, 1444225680397l, 0, 1444225382018l,
            1444225382019l, 1444225382020l, 0, 1444225382021l, 0,
            1444225382022l, 1444225382023l

    };

    List<QueryStats> stats = new ArrayList<QueryStats>();

    for (int i = 0; i < testData.length; i++) {
        QueryStats qs = new QueryStats(String.valueOf(i));
        qs.add(0, testData[i]);
        stats.add(qs);
    }

    try {
        Collections.sort(stats, createComparator());
    } catch (IllegalArgumentException e) {
        Assert.fail(e.getMessage());
    }
}
 
Example 3
Source Project: tomcatsrc   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testBug58489() throws Exception {

    long[] testData = { 0, 0, 0, 1444225382010l, 0, 1444225382011l, 0,
            1444225382012l, 0, 1444225382056l, 0, 1444225382014l, 0,
            1444225382015l, 0, 1444225382016l, 0, 0, 1444225382017l, 0,
            1444225678350l, 0, 1444225680397l, 0, 1444225382018l,
            1444225382019l, 1444225382020l, 0, 1444225382021l, 0,
            1444225382022l, 1444225382023l

    };

    List<QueryStats> stats = new ArrayList<QueryStats>();

    for (int i = 0; i < testData.length; i++) {
        QueryStats qs = new QueryStats(String.valueOf(i));
        qs.add(0, testData[i]);
        stats.add(qs);
    }

    try {
        Collections.sort(stats, createComparator());
    } catch (IllegalArgumentException e) {
        Assert.fail(e.getMessage());
    }
}
 
Example 4
Source Project: Tomcat8-Source-Read   Source File: TestSlowQueryComparator.java    License: MIT License 5 votes vote down vote up
@Test
public void testEqualQueryStatsWithLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    q1.add(0, 100);
    Assert.assertEquals(0, queryStatsComparator.compare(q1, q1));
}
 
Example 5
Source Project: Tomcat8-Source-Read   Source File: TestSlowQueryComparator.java    License: MIT License 5 votes vote down vote up
@Test
public void testQueryStatsOneWithLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    QueryStats q2 = new QueryStats("def");
    q2.add(0, 100);
    Assert.assertEquals(1, queryStatsComparator.compare(q1, q2));
    Assert.assertEquals(-1, queryStatsComparator.compare(q2, q1));
}
 
Example 6
Source Project: Tomcat8-Source-Read   Source File: TestSlowQueryComparator.java    License: MIT License 5 votes vote down vote up
@Test
public void testQueryStatsBothWithSameLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    QueryStats q2 = new QueryStats("def");
    q1.add(0, 100);
    q2.add(0, 100);
    Assert.assertEquals(0, queryStatsComparator.compare(q1, q2));
    Assert.assertEquals(0, queryStatsComparator.compare(q2, q1));
}
 
Example 7
Source Project: Tomcat8-Source-Read   Source File: TestSlowQueryComparator.java    License: MIT License 5 votes vote down vote up
@Test
public void testQueryStatsBothWithSomeLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    QueryStats q2 = new QueryStats("abc");
    q1.add(0, 100);
    q2.add(0, 150);
    Assert.assertEquals(-1, queryStatsComparator.compare(q1, q2));
    Assert.assertEquals(1, queryStatsComparator.compare(q2, q1));
}
 
Example 8
Source Project: Tomcat8-Source-Read   Source File: TestSlowQueryComparator.java    License: MIT License 5 votes vote down vote up
private Comparator<QueryStats> createComparator()
        throws ClassNotFoundException, InstantiationException,
        IllegalAccessException, InvocationTargetException,
        SecurityException, NoSuchMethodException {
    Class<?> comparatorClass = Class
            .forName("org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport$QueryStatsComparator");
    Constructor<?> comparatorConstructor = comparatorClass.getConstructor();
    comparatorConstructor.setAccessible(true);
    @SuppressWarnings("unchecked")
    Comparator<QueryStats> queryStatsComparator = (Comparator<QueryStats>) comparatorConstructor
            .newInstance();
    return queryStatsComparator;
}
 
Example 9
Source Project: Tomcat7.0.67   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testEqualQueryStatsWithLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    q1.add(0, 100);
    Assert.assertEquals(0, queryStatsComparator.compare(q1, q1));
}
 
Example 10
Source Project: Tomcat7.0.67   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryStatsOneWithLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    QueryStats q2 = new QueryStats("def");
    q2.add(0, 100);
    Assert.assertEquals(1, queryStatsComparator.compare(q1, q2));
    Assert.assertEquals(-1, queryStatsComparator.compare(q2, q1));
}
 
Example 11
Source Project: Tomcat7.0.67   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryStatsBothWithSameLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    QueryStats q2 = new QueryStats("def");
    q1.add(0, 100);
    q2.add(0, 100);
    Assert.assertEquals(0, queryStatsComparator.compare(q1, q2));
    Assert.assertEquals(0, queryStatsComparator.compare(q2, q1));
}
 
Example 12
Source Project: Tomcat7.0.67   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryStatsBothWithSomeLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    QueryStats q2 = new QueryStats("abc");
    q1.add(0, 100);
    q2.add(0, 150);
    Assert.assertEquals(-1, queryStatsComparator.compare(q1, q2));
    Assert.assertEquals(1, queryStatsComparator.compare(q2, q1));
}
 
Example 13
Source Project: Tomcat7.0.67   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 5 votes vote down vote up
private Comparator<QueryStats> createComparator()
        throws ClassNotFoundException, InstantiationException,
        IllegalAccessException, InvocationTargetException,
        SecurityException, NoSuchMethodException {
    Class<?> comparatorClass = Class
            .forName("org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport$QueryStatsComparator");
    Constructor<?> comparatorConstructor = comparatorClass
            .getDeclaredConstructor();
    comparatorConstructor.setAccessible(true);
    @SuppressWarnings("unchecked")
    Comparator<QueryStats> queryStatsComparator = (Comparator<QueryStats>) comparatorConstructor
            .newInstance();
    return queryStatsComparator;
}
 
Example 14
Source Project: tomcatsrc   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testEqualQueryStatsWithLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    q1.add(0, 100);
    Assert.assertEquals(0, queryStatsComparator.compare(q1, q1));
}
 
Example 15
Source Project: tomcatsrc   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryStatsOneWithLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    QueryStats q2 = new QueryStats("def");
    q2.add(0, 100);
    Assert.assertEquals(1, queryStatsComparator.compare(q1, q2));
    Assert.assertEquals(-1, queryStatsComparator.compare(q2, q1));
}
 
Example 16
Source Project: tomcatsrc   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryStatsBothWithSameLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    QueryStats q2 = new QueryStats("def");
    q1.add(0, 100);
    q2.add(0, 100);
    Assert.assertEquals(0, queryStatsComparator.compare(q1, q2));
    Assert.assertEquals(0, queryStatsComparator.compare(q2, q1));
}
 
Example 17
Source Project: tomcatsrc   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryStatsBothWithSomeLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    QueryStats q2 = new QueryStats("abc");
    q1.add(0, 100);
    q2.add(0, 150);
    Assert.assertEquals(-1, queryStatsComparator.compare(q1, q2));
    Assert.assertEquals(1, queryStatsComparator.compare(q2, q1));
}
 
Example 18
Source Project: tomcatsrc   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 5 votes vote down vote up
private Comparator<QueryStats> createComparator()
        throws ClassNotFoundException, InstantiationException,
        IllegalAccessException, InvocationTargetException,
        SecurityException, NoSuchMethodException {
    Class<?> comparatorClass = Class
            .forName("org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport$QueryStatsComparator");
    Constructor<?> comparatorConstructor = comparatorClass
            .getDeclaredConstructor();
    comparatorConstructor.setAccessible(true);
    @SuppressWarnings("unchecked")
    Comparator<QueryStats> queryStatsComparator = (Comparator<QueryStats>) comparatorConstructor
            .newInstance();
    return queryStatsComparator;
}
 
Example 19
Source Project: Tomcat8-Source-Read   Source File: TestSlowQueryComparator.java    License: MIT License 4 votes vote down vote up
@Test
public void testEqualQueryStatsWithNoLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    Assert.assertEquals(0, queryStatsComparator.compare(q1, q1));
}
 
Example 20
Source Project: Tomcat7.0.67   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testEqualQueryStatsWithNoLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    Assert.assertEquals(0, queryStatsComparator.compare(q1, q1));
}
 
Example 21
Source Project: tomcatsrc   Source File: TestSlowQueryComparator.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testEqualQueryStatsWithNoLastInvocation() throws Exception {
    Comparator<QueryStats> queryStatsComparator = createComparator();
    QueryStats q1 = new QueryStats("abc");
    Assert.assertEquals(0, queryStatsComparator.compare(q1, q1));
}