Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Yuta HIGUCHI
2014-09-25 01:41:15 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3f6d29bf74182961de1849a2068ac17f7d36449b
3f6d29bf
1 parent
4ee707ad
poll for events when validating.
Change-Id: Ia727a1c97f5d2d713281130997cee7fa3b1ba39d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
core/net/src/test/java/org/onlab/onos/net/device/impl/DistributedDeviceManagerTest.java
core/net/src/test/java/org/onlab/onos/net/device/impl/DistributedDeviceManagerTest.java
View file @
3f6d29b
...
...
@@ -43,8 +43,11 @@ import java.util.Iterator;
import
java.util.List
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
onlab
.
onos
.
net
.
Device
.
Type
.
SWITCH
;
...
...
@@ -182,7 +185,7 @@ public class DistributedDeviceManagerTest {
validateEvents
(
DEVICE_ADDED
,
DEVICE_ADDED
);
connectDevice
(
DID1
,
SW2
);
validateEvents
(
DEVICE_UPDATED
);
validateEvents
(
DEVICE_UPDATED
,
DEVICE_UPDATED
);
}
@Test
...
...
@@ -251,12 +254,16 @@ public class DistributedDeviceManagerTest {
}
protected
void
validateEvents
(
Enum
...
types
)
{
int
i
=
0
;
assertEquals
(
"wrong events received"
,
types
.
length
,
listener
.
events
.
size
());
for
(
Event
event
:
listener
.
events
)
{
assertEquals
(
"incorrect event type"
,
types
[
i
],
event
.
type
());
i
++;
for
(
Enum
type
:
types
)
{
try
{
Event
event
=
listener
.
events
.
poll
(
1
,
TimeUnit
.
SECONDS
);
assertNotNull
(
"Timed out waiting for "
+
event
,
event
);
assertEquals
(
"incorrect event type"
,
type
,
event
.
type
());
}
catch
(
InterruptedException
e
)
{
fail
(
"Unexpected interrupt"
);
}
}
assertTrue
(
"Unexpected events left"
,
listener
.
events
.
isEmpty
());
listener
.
events
.
clear
();
}
...
...
@@ -281,7 +288,7 @@ public class DistributedDeviceManagerTest {
}
private
static
class
TestListener
implements
DeviceListener
{
final
List
<
DeviceEvent
>
events
=
new
ArrayList
<>();
final
BlockingQueue
<
DeviceEvent
>
events
=
new
LinkedBlockingQueue
<>();
@Override
public
void
event
(
DeviceEvent
event
)
{
...
...
Please
register
or
login
to post a comment