提交 6877b149 编写于 作者: F Frankie Wu

add number format

上级 2dd6dfc5
<?xml version="1.0" encoding="UTF-8"?>
<model model-package="com.dianping.cat.consumer.transaction.model"
enable-merger="true" enable-json-builder="true" enable-xml-parser="true"
enable-base-visitor="true">
<model model-package="com.dianping.cat.consumer.transaction.model" enable-merger="true" enable-json-builder="true"
enable-xml-parser="true" enable-base-visitor="true">
<entity name="transaction-report" root="true">
<attribute name="domain" key="true" />
<attribute name="startTime" value-type="Date" format="yyyy-MM-dd HH:mm:ss" />
......@@ -10,34 +9,30 @@
</entity>
<entity name="type" class-name="TransactionType">
<attribute name="id" key="true" />
<entity-ref name="name" type="map" />
<attribute name="totalCount" value-type="long" primitive="true" />
<attribute name="failCount" value-type="long" primitive="true" />
<attribute name="failPercent" value-type="double" primitive="true" />
<attribute name="min" value-type="double" primitive="true"
default-value="Double.MAX_VALUE" />
<attribute name="max" value-type="double" primitive="true"
default-value="Double.MIN_VALUE" />
<attribute name="avg" value-type="double" primitive="true" />
<attribute name="failPercent" value-type="double" primitive="true" format="0.#%" />
<attribute name="min" value-type="double" primitive="true" default-value="Double.MAX_VALUE" />
<attribute name="max" value-type="double" primitive="true" default-value="Double.MIN_VALUE" />
<attribute name="avg" value-type="double" primitive="true" format="0.#" />
<attribute name="sum" value-type="double" primitive="true" />
<attribute name="sum2" value-type="double" primitive="true" />
<attribute name="std" value-type="double" primitive="true" />
<attribute name="std" value-type="double" primitive="true" format="0.#" />
<element name="success-message-id" value-type="String" />
<element name="fail-message-id" value-type="String" />
<entity-ref name="name" type="map" />
</entity>
<entity name="name" class-name="TransactionName">
<attribute name="id" key="true" />
<attribute name="totalCount" value-type="long" primitive="true" />
<attribute name="failCount" value-type="long" primitive="true" />
<attribute name="failPercent" value-type="double" primitive="true" />
<attribute name="min" value-type="double" primitive="true"
default-value="Double.MAX_VALUE" />
<attribute name="max" value-type="double" primitive="true"
default-value="Double.MIN_VALUE" />
<attribute name="avg" value-type="double" primitive="true" />
<attribute name="failPercent" value-type="double" primitive="true" format="0.#%" />
<attribute name="min" value-type="double" primitive="true" default-value="Double.MAX_VALUE" />
<attribute name="max" value-type="double" primitive="true" default-value="Double.MIN_VALUE" />
<attribute name="avg" value-type="double" primitive="true" format="0.#" />
<attribute name="sum" value-type="double" primitive="true" />
<attribute name="sum2" value-type="double" primitive="true" />
<attribute name="std" value-type="double" primitive="true" />
<attribute name="std" value-type="double" primitive="true" format="0.#" />
<element name="success-message-id" value-type="String" />
<element name="fail-message-id" value-type="String" />
</entity>
......
......@@ -6,6 +6,7 @@ import org.junit.runners.Suite.SuiteClasses;
import com.dianping.cat.consumer.failure.FailureAnalyzerStoreTest;
import com.dianping.cat.consumer.failure.FailureAnalyzerTest;
import com.dianping.cat.consumer.transaction.NumberFormatTest;
import com.dianping.cat.consumer.transaction.TransactionReportMessageAnalyzerTest;
@RunWith(Suite.class)
......@@ -17,10 +18,11 @@ ManyAnalyzerTest.class,
OneAnalyzerTwoDurationTest.class,
/* .model.failure */
FailureAnalyzerTest.class,
FailureAnalyzerStoreTest.class,
FailureAnalyzerTest.class, FailureAnalyzerStoreTest.class,
/* .transaction */
NumberFormatTest.class,
TransactionReportMessageAnalyzerTest.class
})
......
package com.dianping.cat.consumer.transaction;
import junit.framework.Assert;
import org.junit.Test;
public class NumberFormatTest {
@Test
public void test() {
check(12, "0", "12");
check(12.34, "0", "12");
check(12, "0.#", "12");
check(12.34, "0.#", "12.3");
check(12.35, "0.#", "12.4");
check(12.34, "0.##", "12.34");
check(12.346, "0.##", "12.35");
check(0.3467, "0.#%", "34.7%");
}
private void check(Number number, String format, String expected) {
String actual = new java.text.DecimalFormat(format).format(number);
Assert.assertEquals(expected, actual);
}
}
......@@ -23,7 +23,7 @@ public class SimpleServer extends SimpleServerSupport {
private static ComponentAdaptor s_adaptor = new ComponentAdaptor();
private static MVC s_mvc = new MVC();
private static CatServlet s_cat = new CatServlet();
@AfterClass
......@@ -72,7 +72,7 @@ public class SimpleServer extends SimpleServerSupport {
@Override
protected void postConfigure(Context ctx) {
ServletHolder holder = new ServletHolder(s_mvc);
ctx.addServlet(new ServletHolder(s_cat), "/s/*");
ctx.addServlet(holder, "/");
ctx.addServlet(holder, "/r/*");
......@@ -92,7 +92,9 @@ public class SimpleServer extends SimpleServerSupport {
@Test
public void startServer() throws Exception {
// s_adaptor.display("/cat/r");
// open the page in the default browser
s_adaptor.display("/cat/r");
System.out.println(String.format("[%s] Press any key to stop server ... ", getTimestamp()));
System.in.read();
}
......
......@@ -43,7 +43,7 @@
<dependency>
<groupId>com.site.common</groupId>
<artifactId>test-framework</artifactId>
<version>1.0.0</version>
<version>1.0.0-a1</version>
</dependency>
<dependency>
<groupId>com.site.common</groupId>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册