本文整理汇总了Java中net.floodlightcontroller.debugevent.Event类的典型用法代码示例。如果您正苦于以下问题:Java Event类的具体用法?Java Event怎么用?Java Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Event类属于net.floodlightcontroller.debugevent包,在下文中一共展示了Event类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testIncorrectAnnotation
import net.floodlightcontroller.debugevent.Event; //导入依赖的package包/类
@Test
public void testIncorrectAnnotation() {
Event e = new Event(1L, 32, "test",
new LakeEvent(199), 11L); // dpid cannot be int
assertTrue(e.getFormattedEvent(LakeEvent.class, "test").getDataFields()
.contains(new Metadata("Error",
"java.lang.Integer cannot be cast to org.projectfloodlight.openflow.types.DatapathId")));
Event e2 = new Event(1L, 32, "test",
new LakeEvent2(199), 12L); // mac cannot be int
assertTrue(e2.getFormattedEvent(LakeEvent2.class, "test").getDataFields()
.contains(new Metadata("Error",
"java.lang.Integer cannot be cast to java.lang.Long")));
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:15,代码来源:EventTest.java
示例2: testFormat
import net.floodlightcontroller.debugevent.Event; //导入依赖的package包/类
@Test
public void testFormat() {
River r = new River("ganges", 42);
Event e = new Event(1L, 32, "test",
new RiverEvent(DatapathId.of(1L), (short)10, true, "big river", 5, 4L, r), 10L);
EventResourceBuilder edb = new EventResourceBuilder();
edb.dataFields.add(new Metadata("dpid", "00:00:00:00:00:00:00:01"));
edb.dataFields.add(new Metadata("portId", "10"));
edb.dataFields.add(new Metadata("valid", "true"));
edb.dataFields.add(new Metadata("desc", "big river"));
edb.dataFields.add(new Metadata("ip", "0.0.0.5"));
edb.dataFields.add(new Metadata("mac", "00:00:00:00:00:04"));
edb.dataFields.add(new Metadata("obj", "ganges/42"));
edb.setThreadId(e.getThreadId());
edb.setThreadName(e.getThreadName());
edb.setTimeStamp(e.getTimeMs());
edb.setModuleEventName("test");
EventResource ed = edb.build();
// check Event.getFormattedEvent()
assertTrue(ed.equals(e.getFormattedEvent(RiverEvent.class, "test")));
/* Why does it matter? Java's built-in Date does not format in ISO8601...
// ensure timestamp comes in ISO8601 time
// e.g.: 1969-12-31T16:00:00.001-08:00
Pattern pat =
Pattern.compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}[+-]\\d{2}:\\d{2}");
Date t1 = e.getFormattedEvent(RiverEvent.class, "test2").getTimestamp();
Matcher m1 = pat.matcher(t1.toString());
assertTrue(m1.matches());
*/
// ensure that cached value is not returned for incorrect class
assertFalse(ed.equals(e.getFormattedEvent(River.class, "test")));
assertTrue(e.getFormattedEvent(River.class, "test").getDataFields().
contains(new Metadata("Error",
"null event data or event-class does not match event-data")));
assertTrue(e.getFormattedEvent(null, "test").getDataFields().contains(
new Metadata("Error",
"null event data or event-class does not match event-data")));
}
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:45,代码来源:EventTest.java
注:本文中的net.floodlightcontroller.debugevent.Event类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论