add testcase

This commit is contained in:
wenshao
2012-08-26 13:13:39 +08:00
parent e662f3f109
commit 58742c2a0e
2 changed files with 77 additions and 0 deletions
@@ -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();
}
}