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
tom
2014-09-08 00:41:32 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c0ccfb21c127e05ac7c200042f60c7f0031005f6
c0ccfb21
1 parent
d176fc45
Added more unit tests.
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
121 additions
and
0 deletions
net/api/src/test/java/org/onlab/onos/net/DefaultLinkTest.java
net/api/src/test/java/org/onlab/onos/net/link/DefaultLinkDescriptionTest.java
net/api/src/test/java/org/onlab/onos/net/link/LinkEventTest.java
net/api/src/test/java/org/onlab/onos/net/DefaultLinkTest.java
0 → 100644
View file @
c0ccfb2
package
org
.
onlab
.
onos
.
net
;
import
com.google.common.testing.EqualsTester
;
import
org.junit.Test
;
import
org.onlab.onos.net.provider.ProviderId
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
Link
.
Type
.
DIRECT
;
import
static
org
.
onlab
.
onos
.
net
.
Link
.
Type
.
INDIRECT
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
/**
* Test of the default link model entity.
*/
public
class
DefaultLinkTest
{
private
static
final
ProviderId
PID
=
new
ProviderId
(
"foo"
);
private
static
final
DeviceId
DID1
=
deviceId
(
"of:foo"
);
private
static
final
DeviceId
DID2
=
deviceId
(
"of:bar"
);
private
static
final
PortNumber
P1
=
portNumber
(
1
);
private
static
final
PortNumber
P2
=
portNumber
(
2
);
public
static
ConnectPoint
cp
(
DeviceId
id
,
PortNumber
pn
)
{
return
new
ConnectPoint
(
id
,
pn
);
}
@Test
public
void
testEquality
()
{
Link
l1
=
new
DefaultLink
(
PID
,
cp
(
DID1
,
P1
),
cp
(
DID2
,
P2
),
DIRECT
);
Link
l2
=
new
DefaultLink
(
PID
,
cp
(
DID1
,
P1
),
cp
(
DID2
,
P2
),
DIRECT
);
Link
l3
=
new
DefaultLink
(
PID
,
cp
(
DID1
,
P2
),
cp
(
DID2
,
P2
),
DIRECT
);
Link
l4
=
new
DefaultLink
(
PID
,
cp
(
DID1
,
P2
),
cp
(
DID2
,
P2
),
DIRECT
);
Link
l5
=
new
DefaultLink
(
PID
,
cp
(
DID1
,
P2
),
cp
(
DID2
,
P2
),
INDIRECT
);
new
EqualsTester
().
addEqualityGroup
(
l1
,
l2
)
.
addEqualityGroup
(
l3
,
l4
)
.
addEqualityGroup
(
l5
)
.
testEquals
();
}
@Test
public
void
basics
()
{
Link
link
=
new
DefaultLink
(
PID
,
cp
(
DID1
,
P1
),
cp
(
DID2
,
P2
),
DIRECT
);
assertEquals
(
"incorrect src"
,
cp
(
DID1
,
P1
),
link
.
src
());
assertEquals
(
"incorrect dst"
,
cp
(
DID2
,
P2
),
link
.
dst
());
assertEquals
(
"incorrect type"
,
DIRECT
,
link
.
type
());
}
}
net/api/src/test/java/org/onlab/onos/net/link/DefaultLinkDescriptionTest.java
0 → 100644
View file @
c0ccfb2
package
org
.
onlab
.
onos
.
net
.
link
;
import
org.junit.Test
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.PortNumber
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
onlab
.
onos
.
net
.
DefaultLinkTest
.
cp
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
Link
.
Type
.
DIRECT
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
/**
* Test of the default link description.
*/
public
class
DefaultLinkDescriptionTest
{
private
static
final
DeviceId
DID1
=
deviceId
(
"of:foo"
);
private
static
final
DeviceId
DID2
=
deviceId
(
"of:bar"
);
private
static
final
PortNumber
P1
=
portNumber
(
1
);
@Test
public
void
basics
()
{
LinkDescription
desc
=
new
DefaultLinkDescription
(
cp
(
DID1
,
P1
),
cp
(
DID2
,
P1
),
DIRECT
);
assertEquals
(
"incorrect src"
,
cp
(
DID1
,
P1
),
desc
.
src
());
assertEquals
(
"incorrect dst"
,
cp
(
DID2
,
P1
),
desc
.
dst
());
assertEquals
(
"incorrect type"
,
DIRECT
,
desc
.
type
());
}
}
net/api/src/test/java/org/onlab/onos/net/link/LinkEventTest.java
0 → 100644
View file @
c0ccfb2
package
org
.
onlab
.
onos
.
net
.
link
;
import
org.junit.Test
;
import
org.onlab.onos.event.AbstractEventTest
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DefaultLink
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.provider.ProviderId
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
/**
* Tests of the device event.
*/
public
class
LinkEventTest
extends
AbstractEventTest
{
private
Link
createLink
()
{
return
new
DefaultLink
(
new
ProviderId
(
"foo"
),
new
ConnectPoint
(
deviceId
(
"of:foo"
),
portNumber
(
1
)),
new
ConnectPoint
(
deviceId
(
"of:bar"
),
portNumber
(
2
)),
Link
.
Type
.
INDIRECT
);
}
@Test
public
void
withTime
()
{
Link
link
=
createLink
();
LinkEvent
event
=
new
LinkEvent
(
LinkEvent
.
Type
.
LINK_ADDED
,
link
,
123L
);
validateEvent
(
event
,
LinkEvent
.
Type
.
LINK_ADDED
,
link
,
123L
);
}
@Test
public
void
withoutTime
()
{
Link
link
=
createLink
();
long
before
=
System
.
currentTimeMillis
();
LinkEvent
event
=
new
LinkEvent
(
LinkEvent
.
Type
.
LINK_ADDED
,
link
);
long
after
=
System
.
currentTimeMillis
();
validateEvent
(
event
,
LinkEvent
.
Type
.
LINK_ADDED
,
link
,
before
,
after
);
}
}
Please
register
or
login
to post a comment