提交 8a9e8d15 编写于 作者: Y yong.you

modify the test xml

上级 b574f3cf
......@@ -44,7 +44,6 @@ public class MockReportManager<T> implements ReportManager<T> {
if (m_report == null) {
m_report = m_delegate.makeReport(domain, startTime, Constants.HOUR);
}
return m_report;
}
......
package com.dianping.cat.consumer.event;
import java.text.SimpleDateFormat;
import java.util.Date;
import junit.framework.Assert;
import org.junit.Before;
......@@ -7,6 +10,7 @@ import org.junit.Test;
import org.unidal.helper.Files;
import org.unidal.lookup.ComponentTestCase;
import com.dianping.cat.Constants;
import com.dianping.cat.analysis.MessageAnalyzer;
import com.dianping.cat.consumer.event.model.entity.EventReport;
import com.dianping.cat.message.Message;
......@@ -31,6 +35,10 @@ public class EventAnalyzerTest extends ComponentTestCase {
m_timestamp = currentTimeMillis - currentTimeMillis % (3600 * 1000);
m_analyzer = (EventAnalyzer) lookup(MessageAnalyzer.class, EventAnalyzer.ID);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd HH:mm");
Date date = sdf.parse("20120101 00:00");
m_analyzer.initialize(date.getTime(), Constants.HOUR, Constants.MINUTE * 5);
}
@Test
......
package com.dianping.cat.consumer.transaction;
import java.text.SimpleDateFormat;
import java.util.Date;
import junit.framework.Assert;
import org.junit.Before;
......@@ -7,6 +10,7 @@ import org.junit.Test;
import org.unidal.helper.Files;
import org.unidal.lookup.ComponentTestCase;
import com.dianping.cat.Constants;
import com.dianping.cat.analysis.MessageAnalyzer;
import com.dianping.cat.consumer.transaction.model.entity.TransactionReport;
import com.dianping.cat.message.Message;
......@@ -29,6 +33,10 @@ public class TransactionAnalyzerTest extends ComponentTestCase {
try {
m_analyzer = (TransactionAnalyzer) lookup(MessageAnalyzer.class, TransactionAnalyzer.ID);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd HH:mm");
Date date = sdf.parse("20120101 00:00");
m_analyzer.initialize(date.getTime(), Constants.HOUR, Constants.MINUTE * 5);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -46,8 +54,7 @@ public class TransactionAnalyzerTest extends ComponentTestCase {
report.accept(new TransactionStatisticsComputer());
String expected = Files.forIO().readFrom(getClass().getResourceAsStream("transaction_analyzer.xml"),
"utf-8");
String expected = Files.forIO().readFrom(getClass().getResourceAsStream("transaction_analyzer.xml"), "utf-8");
Assert.assertEquals(expected.replaceAll("\r", ""), report.toString().replaceAll("\r", ""));
}
......
<?xml version="1.0" encoding="utf-8"?>
<event-report domain="group" startTime="1970-01-01 08:00:00" endTime="1970-01-01 08:59:59">
<event-report domain="group" startTime="2012-01-01 00:00:00" endTime="2012-01-01 00:59:59">
<domain>group</domain>
<ip>192.168.1.1</ip>
<machine ip="192.168.1.1">
......
<?xml version="1.0" encoding="utf-8"?>
<transaction-report domain="group" startTime="1970-01-01 08:00:00" endTime="1970-01-01 08:59:59">
<transaction-report domain="group" startTime="2012-01-01 00:00:00" endTime="2012-01-01 00:59:59">
<domain>group</domain>
<ip>192.168.1.1</ip>
<machine ip="192.168.1.1">
......
......@@ -5,6 +5,8 @@ public class Constants {
public static final String CAT = "Cat";
public static final long MINUTE = 60 * 1000L;
public static final long HOUR = 60 * 60 * 1000L;
public static final long DAY = 24 * HOUR;
......@@ -20,6 +22,6 @@ public class Constants {
public static final String REPORT_UTILIZATION = "utilization";
public static final String REPORT_HEAVY = "heavy";
public static final String REPORT_ABTEST = "abtest";
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册