mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
@@ -15,12 +15,8 @@
|
||||
*/
|
||||
package com.alibaba.druid.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.alibaba.druid.support.logging.Log;
|
||||
import com.alibaba.druid.support.logging.LogFactory;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.alibaba.druid.bvt.utils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
|
||||
import com.alibaba.druid.util.DruidWebUtils;
|
||||
|
||||
public class DruidWebUtilsTest extends TestCase {
|
||||
|
||||
public void test_getContextPath_2_5() throws Exception {
|
||||
new DruidWebUtils(); //
|
||||
|
||||
MockServletContext context = new MockServletContext() {
|
||||
|
||||
public int getMajorVersion() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public int getMinorVersion() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public String getContextPath() {
|
||||
throw new NoSuchMethodError();
|
||||
}
|
||||
};
|
||||
|
||||
Assert.assertNull(DruidWebUtils.getContextPath(context));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.alibaba.druid.bvt.utils;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.util.Histogram;
|
||||
|
||||
public class HistogramTest extends TestCase {
|
||||
|
||||
public void test_histo() throws Exception {
|
||||
Histogram histo = Histogram.makeHistogram(4);
|
||||
|
||||
Assert.assertEquals(4, histo.getRanges().length);
|
||||
|
||||
histo.record(0);
|
||||
|
||||
histo.record(1);
|
||||
histo.record(2);
|
||||
|
||||
histo.record(11);
|
||||
histo.record(12);
|
||||
histo.record(13);
|
||||
|
||||
histo.record(101);
|
||||
histo.record(102);
|
||||
histo.record(103);
|
||||
histo.record(104);
|
||||
|
||||
histo.record(1001);
|
||||
histo.record(1002);
|
||||
histo.record(1003);
|
||||
histo.record(1004);
|
||||
histo.record(1005);
|
||||
|
||||
histo.record(10001);
|
||||
|
||||
Assert.assertEquals(1, histo.get(0));
|
||||
Assert.assertEquals(2, histo.get(1));
|
||||
Assert.assertEquals(3, histo.get(2));
|
||||
Assert.assertEquals(4, histo.get(3));
|
||||
Assert.assertEquals(6, histo.get(4));
|
||||
|
||||
histo.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user