Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
croft1
floodlight
Commits
22ed4878
Commit
22ed4878
authored
9 years ago
by
Jacob Chappell
Browse files
Options
Downloads
Patches
Plain Diff
Add unit tests for SPUD class.
parent
fb5f2553
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/net/floodlightcontroller/packet/SPUDTest.java
+114
-0
114 additions, 0 deletions
src/test/java/net/floodlightcontroller/packet/SPUDTest.java
with
114 additions
and
0 deletions
src/test/java/net/floodlightcontroller/packet/SPUDTest.java
0 → 100644
+
114
−
0
View file @
22ed4878
package
net.floodlightcontroller.packet
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.util.Arrays
;
import
org.junit.Test
;
/**
* @author Jacob Chappell (jacob.chappell@uky.edu)
*/
public
class
SPUDTest
{
@Test
public
void
testSerializeCommandOpen
()
{
byte
[]
expected
=
new
byte
[]
{
(
byte
)
0xd8
,
0x00
,
0x00
,
(
byte
)
0xd8
,
(
byte
)
0xb6
,
0x40
,
0x17
,
(
byte
)
0x88
,
0x0a
,
0x51
,
0x01
,
0x07
,
0x40
};
SPUD
packet
=
(
new
SPUD
())
.
setTubeID
(
0xb64017880a510107
L
)
.
setCommand
(
SPUD
.
COMMAND_OPEN
)
.
setADEC
(
false
)
.
setPDEC
(
false
)
.
setReserved
((
byte
)
0
);
byte
[]
actual
=
packet
.
serialize
();
assertTrue
(
Arrays
.
equals
(
expected
,
actual
));
}
@Test
public
void
testSerializeCommandDataEmpty
()
{
byte
[]
expected
=
new
byte
[]
{
(
byte
)
0xd8
,
0x00
,
0x00
,
(
byte
)
0xd8
,
(
byte
)
0xb6
,
0x40
,
0x17
,
(
byte
)
0x88
,
0x0a
,
0x51
,
0x01
,
0x07
,
0x00
};
SPUD
packet
=
(
new
SPUD
())
.
setTubeID
(
0xb64017880a510107
L
)
.
setCommand
(
SPUD
.
COMMAND_DATA
)
.
setADEC
(
false
)
.
setPDEC
(
false
)
.
setReserved
((
byte
)
0
);
byte
[]
actual
=
packet
.
serialize
();
assertTrue
(
Arrays
.
equals
(
expected
,
actual
));
}
@Test
public
void
testSerializeCommandDataEmptyWithADEC
()
{
byte
[]
expected
=
new
byte
[]
{
(
byte
)
0xd8
,
0x00
,
0x00
,
(
byte
)
0xd8
,
(
byte
)
0xb6
,
0x40
,
0x17
,
(
byte
)
0x88
,
0x0a
,
0x51
,
0x01
,
0x07
,
0x20
};
SPUD
packet
=
(
new
SPUD
())
.
setTubeID
(
0xb64017880a510107
L
)
.
setCommand
(
SPUD
.
COMMAND_DATA
)
.
setADEC
(
true
)
.
setPDEC
(
false
)
.
setReserved
((
byte
)
0
);
byte
[]
actual
=
packet
.
serialize
();
assertTrue
(
Arrays
.
equals
(
expected
,
actual
));
}
@Test
public
void
testSerializeCommandDataEmptyWithPDEC
()
{
byte
[]
expected
=
new
byte
[]
{
(
byte
)
0xd8
,
0x00
,
0x00
,
(
byte
)
0xd8
,
(
byte
)
0xb6
,
0x40
,
0x17
,
(
byte
)
0x88
,
0x0a
,
0x51
,
0x01
,
0x07
,
0x10
};
SPUD
packet
=
(
new
SPUD
())
.
setTubeID
(
0xb64017880a510107
L
)
.
setCommand
(
SPUD
.
COMMAND_DATA
)
.
setADEC
(
false
)
.
setPDEC
(
true
)
.
setReserved
((
byte
)
0
);
byte
[]
actual
=
packet
.
serialize
();
assertTrue
(
Arrays
.
equals
(
expected
,
actual
));
}
@Test
public
void
testSerializeCommandDataEmptyWithBoth
()
{
byte
[]
expected
=
new
byte
[]
{
(
byte
)
0xd8
,
0x00
,
0x00
,
(
byte
)
0xd8
,
(
byte
)
0xb6
,
0x40
,
0x17
,
(
byte
)
0x88
,
0x0a
,
0x51
,
0x01
,
0x07
,
0x30
};
SPUD
packet
=
(
new
SPUD
())
.
setTubeID
(
0xb64017880a510107
L
)
.
setCommand
(
SPUD
.
COMMAND_DATA
)
.
setADEC
(
true
)
.
setPDEC
(
true
)
.
setReserved
((
byte
)
0
);
byte
[]
actual
=
packet
.
serialize
();
assertTrue
(
Arrays
.
equals
(
expected
,
actual
));
}
@Test
public
void
testDeserialize
()
throws
PacketParsingException
{
byte
[]
spudPacket
=
{
(
byte
)
0xd8
,
0x00
,
0x00
,
(
byte
)
0xd8
,
(
byte
)
0xb6
,
0x40
,
0x17
,
(
byte
)
0x88
,
0x0a
,
0x51
,
0x01
,
0x07
,
0x00
,
(
byte
)
0xa1
,
0x00
,
(
byte
)
0xa2
,
0x68
,
0x75
,
0x73
,
0x65
,
0x72
,
0x6e
,
0x61
,
0x6d
,
0x65
,
0x65
,
0x4a
,
0x61
,
0x63
,
0x6f
,
0x62
,
0x67
,
0x6d
,
0x65
,
0x73
,
0x73
,
0x61
,
0x67
,
0x65
,
0x73
,
0x68
,
0x61
,
0x73
,
0x20
,
0x6a
,
0x6f
,
0x69
,
0x6e
,
0x65
,
0x64
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x72
,
0x6f
,
0x6f
,
0x6d
};
SPUD
packet
=
new
SPUD
();
packet
.
deserialize
(
spudPacket
,
0
,
spudPacket
.
length
);
byte
[]
packetSerialized
=
packet
.
serialize
();
assertTrue
(
Arrays
.
equals
(
spudPacket
,
packetSerialized
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment