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-10-02 08:18:41 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
747a2130c3a12d5ca2647a6727fb3ae2c01d63ed
747a2130
1 parent
bf474388
Adding more unit tests.
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
139 additions
and
19 deletions
core/api/src/main/java/org/onlab/onos/net/topology/DefaultGraphDescription.java
core/api/src/test/java/org/onlab/onos/net/ConnectPointTest.java
core/api/src/test/java/org/onlab/onos/net/DefaultDeviceTest.java
core/api/src/test/java/org/onlab/onos/net/topology/DefaultGraphDescriptionTest.java
core/api/src/test/java/org/onlab/onos/net/topology/DefaultTopologyEdgeTest.java
core/api/src/test/java/org/onlab/onos/net/topology/DefaultTopologyVertexTest.java
core/api/src/main/java/org/onlab/onos/net/topology/DefaultGraphDescription.java
View file @
747a213
...
...
@@ -23,7 +23,6 @@ public class DefaultGraphDescription extends AbstractDescription
private
final
Map
<
DeviceId
,
TopologyVertex
>
vertexesById
=
Maps
.
newHashMap
();
/**
* Creates a minimal topology graph description to allow core to construct
* and process the topology graph.
...
...
@@ -84,9 +83,7 @@ public class DefaultGraphDescription extends AbstractDescription
DeviceId
id
=
connectPoint
.
deviceId
();
TopologyVertex
vertex
=
vertexesById
.
get
(
id
);
if
(
vertex
==
null
)
{
// If vertex does not exist, create one and register it.
vertex
=
new
DefaultTopologyVertex
(
id
);
vertexesById
.
put
(
id
,
vertex
);
throw
new
IllegalArgumentException
(
"Vertex missing for "
+
id
);
}
return
vertex
;
}
...
...
core/api/src/test/java/org/onlab/onos/net/ConnectPointTest.java
View file @
747a213
...
...
@@ -3,8 +3,7 @@ package org.onlab.onos.net;
import
com.google.common.testing.EqualsTester
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
onlab
.
onos
.
net
.
Device
.
Type
.
SWITCH
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
...
...
@@ -13,10 +12,10 @@ import static org.onlab.onos.net.PortNumber.portNumber;
*/
public
class
ConnectPointTest
{
p
ublic
static
final
DeviceId
DID1
=
deviceId
(
"1"
);
p
ublic
static
final
DeviceId
DID2
=
deviceId
(
"2"
);
p
ublic
static
final
PortNumber
P1
=
portNumber
(
1
);
p
ublic
static
final
PortNumber
P2
=
portNumber
(
2
);
p
rivate
static
final
DeviceId
DID1
=
deviceId
(
"1"
);
p
rivate
static
final
DeviceId
DID2
=
deviceId
(
"2"
);
p
rivate
static
final
PortNumber
P1
=
portNumber
(
1
);
p
rivate
static
final
PortNumber
P2
=
portNumber
(
2
);
@Test
public
void
basics
()
{
...
...
core/api/src/test/java/org/onlab/onos/net/DefaultDeviceTest.java
View file @
747a213
...
...
@@ -13,15 +13,14 @@ import static org.onlab.onos.net.DeviceId.deviceId;
*/
public
class
DefaultDeviceTest
{
private
static
final
ProviderId
PID
=
new
ProviderId
(
"of"
,
"foo"
);
private
static
final
DeviceId
DID1
=
deviceId
(
"of:foo"
);
private
static
final
DeviceId
DID2
=
deviceId
(
"of:bar"
);
private
static
final
String
MFR
=
"whitebox"
;
private
static
final
String
HW
=
"1.1.x"
;
private
static
final
String
SW
=
"3.9.1"
;
private
static
final
String
SN1
=
"43311-12345"
;
private
static
final
String
SN2
=
"42346-43512"
;
static
final
ProviderId
PID
=
new
ProviderId
(
"of"
,
"foo"
);
static
final
DeviceId
DID1
=
deviceId
(
"of:foo"
);
static
final
DeviceId
DID2
=
deviceId
(
"of:bar"
);
static
final
String
MFR
=
"whitebox"
;
static
final
String
HW
=
"1.1.x"
;
static
final
String
SW
=
"3.9.1"
;
static
final
String
SN1
=
"43311-12345"
;
static
final
String
SN2
=
"42346-43512"
;
@Test
public
void
testEquality
()
{
...
...
core/api/src/test/java/org/onlab/onos/net/topology/DefaultGraphDescriptionTest.java
0 → 100644
View file @
747a213
package
org
.
onlab
.
onos
.
net
.
topology
;
import
com.google.common.collect.ImmutableSet
;
import
org.junit.Test
;
import
org.onlab.onos.net.DefaultDevice
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.DeviceId
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
onlab
.
onos
.
net
.
Device
.
Type
.
SWITCH
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
topology
.
DefaultTopologyEdgeTest
.*;
public
class
DefaultGraphDescriptionTest
{
static
final
DefaultTopologyEdge
E1
=
new
DefaultTopologyEdge
(
V1
,
V2
,
L1
);
static
final
DefaultTopologyEdge
E2
=
new
DefaultTopologyEdge
(
V1
,
V2
,
L1
);
private
static
final
DeviceId
D3
=
deviceId
(
"3"
);
static
final
Device
DEV1
=
new
DefaultDevice
(
PID
,
D1
,
SWITCH
,
""
,
""
,
""
,
""
);
static
final
Device
DEV2
=
new
DefaultDevice
(
PID
,
D2
,
SWITCH
,
""
,
""
,
""
,
""
);
static
final
Device
DEV3
=
new
DefaultDevice
(
PID
,
D3
,
SWITCH
,
""
,
""
,
""
,
""
);
@Test
public
void
basics
()
{
DefaultGraphDescription
desc
=
new
DefaultGraphDescription
(
4321L
,
ImmutableSet
.
of
(
DEV1
,
DEV2
,
DEV3
),
ImmutableSet
.
of
(
L1
,
L2
));
assertEquals
(
"incorrect time"
,
4321L
,
desc
.
timestamp
());
assertEquals
(
"incorrect vertex count"
,
3
,
desc
.
vertexes
().
size
());
assertEquals
(
"incorrect edge count"
,
2
,
desc
.
edges
().
size
());
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
missingVertex
()
{
new
DefaultGraphDescription
(
4321L
,
ImmutableSet
.
of
(
DEV1
,
DEV3
),
ImmutableSet
.
of
(
L1
,
L2
));
}
}
\ No newline at end of file
core/api/src/test/java/org/onlab/onos/net/topology/DefaultTopologyEdgeTest.java
0 → 100644
View file @
747a213
package
org
.
onlab
.
onos
.
net
.
topology
;
import
com.google.common.testing.EqualsTester
;
import
org.junit.Test
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DefaultLink
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.Link
;
import
org.onlab.onos.net.PortNumber
;
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
.
PortNumber
.
portNumber
;
/**
* Tests of the topology graph edge.
*/
public
class
DefaultTopologyEdgeTest
{
static
final
DeviceId
D1
=
deviceId
(
"1"
);
static
final
DeviceId
D2
=
deviceId
(
"2"
);
static
final
PortNumber
P1
=
portNumber
(
1
);
static
final
PortNumber
P2
=
portNumber
(
2
);
static
final
ConnectPoint
CP1
=
new
ConnectPoint
(
D1
,
P1
);
static
final
ConnectPoint
CP2
=
new
ConnectPoint
(
D2
,
P1
);
static
final
ConnectPoint
CP3
=
new
ConnectPoint
(
D2
,
P1
);
static
final
ConnectPoint
CP4
=
new
ConnectPoint
(
D1
,
P2
);
static
final
DefaultTopologyVertex
V1
=
new
DefaultTopologyVertex
(
D1
);
static
final
DefaultTopologyVertex
V2
=
new
DefaultTopologyVertex
(
D2
);
static
final
ProviderId
PID
=
new
ProviderId
(
"foo"
,
"bar"
);
static
final
Link
L1
=
new
DefaultLink
(
PID
,
CP1
,
CP2
,
Link
.
Type
.
INDIRECT
);
static
final
Link
L2
=
new
DefaultLink
(
PID
,
CP3
,
CP4
,
Link
.
Type
.
INDIRECT
);
@Test
public
void
basics
()
{
DefaultTopologyEdge
e
=
new
DefaultTopologyEdge
(
V1
,
V2
,
L1
);
assertEquals
(
"incorrect src"
,
V1
,
e
.
src
());
assertEquals
(
"incorrect dst"
,
V2
,
e
.
dst
());
assertEquals
(
"incorrect link"
,
L1
,
e
.
link
());
new
EqualsTester
()
.
addEqualityGroup
(
new
DefaultTopologyEdge
(
V1
,
V2
,
L1
),
new
DefaultTopologyEdge
(
V1
,
V2
,
L1
))
.
addEqualityGroup
(
new
DefaultTopologyEdge
(
V2
,
V1
,
L2
),
new
DefaultTopologyEdge
(
V2
,
V1
,
L2
))
.
testEquals
();
}
}
\ No newline at end of file
core/api/src/test/java/org/onlab/onos/net/topology/DefaultTopologyVertexTest.java
0 → 100644
View file @
747a213
package
org
.
onlab
.
onos
.
net
.
topology
;
import
com.google.common.testing.EqualsTester
;
import
org.junit.Test
;
import
org.onlab.onos.net.DeviceId
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
/**
* Tests of the topology graph vertex.
*/
public
class
DefaultTopologyVertexTest
{
private
static
final
DeviceId
D1
=
deviceId
(
"1"
);
private
static
final
DeviceId
D2
=
deviceId
(
"2"
);
@Test
public
void
basics
()
{
DefaultTopologyVertex
v
=
new
DefaultTopologyVertex
(
D1
);
assertEquals
(
"incorrect device id"
,
D1
,
v
.
deviceId
());
new
EqualsTester
()
.
addEqualityGroup
(
new
DefaultTopologyVertex
(
D1
),
new
DefaultTopologyVertex
(
D1
))
.
addEqualityGroup
(
new
DefaultTopologyVertex
(
D2
),
new
DefaultTopologyVertex
(
D2
)).
testEquals
();
}
}
\ No newline at end of file
Please
register
or
login
to post a comment