3 import static org
.junit
.Assert
.*;
7 import reader
.DACPRequestParser
;
10 public class ServerParserTest
{
13 public void testParsePlay() {
14 assertEquals(DACPRequestParser
.parse("GET ctrl-int/1/playpause HTTP/1.1").getClass(), util
.command
.ctrlint
.PlayPause
.class);
18 public void testParsePause() {
19 assertEquals(DACPRequestParser
.parse("GET ctrl-int/1/pause HTTP/1.1").getClass(), util
.command
.ctrlint
.Pause
.class);
22 @Test (expected
= IllegalArgumentException
.class)
23 public void testInvalidCommand() {
24 DACPRequestParser
.parse("GET ctrl-int/1/puase HTTP/1.1");
27 @Test (expected
= IllegalArgumentException
.class)
28 public void testInvalidControl() {
29 DACPRequestParser
.parse("GET ctrl-itn/1/pause HTTP/1.1");
32 @Test (expected
= IllegalArgumentException
.class)
33 public void testInvalidRequestFormat() {
34 DACPRequestParser
.parse("GET ctrl-int/1/pause");
38 public void testVolume(){
39 assertEquals(DACPRequestParser
.parse("GET ctrl-int/1/setproperty?dmcp.volume=0&felix=cool HTTP/1.1").getClass(), util
.command
.ctrlint
.SetProperty
.class);
42 @Test (expected
= IllegalArgumentException
.class)
43 public void testInvalidNumberVolume1() {
44 DACPRequestParser
.parse("GET ctrl-int/1/setproperty?dmcp.volume=-1&felix=cool HTTP/1.1");
47 @Test (expected
= IllegalArgumentException
.class)
48 public void testInvalidNumberVolume2() {
49 DACPRequestParser
.parse("GET ctrl-int/1/setproperty?dmcp.volume=-100&felix=cool HTTP/1.1");
52 @Test (expected
= IllegalArgumentException
.class)
53 public void testInvalidNumberVolume3() {
54 DACPRequestParser
.parse("GET ctrl-int/1/setproperty?dmcp.volume=256&felix=cool HTTP/1.1");
57 @Test (expected
= IllegalArgumentException
.class)
58 public void testInvalidNumberVolume4() {
59 DACPRequestParser
.parse("GET ctrl-int/1/setproperty?dmcp.volume=10000&felix=cool HTTP/1.1");
62 @Test (expected
= IllegalArgumentException
.class)
63 public void testInvalidVolume() {
64 DACPRequestParser
.parse("GET ctrl-int/1/setproperty?dmcp.volume=abc&felix=cool HTTP/1.1");
67 @Test (expected
= IllegalArgumentException
.class)
68 public void testInvalidParameters() {
69 DACPRequestParser
.parse("GET ctrl-int/1/setproperty?dmcpvolume=abc&felix=cool HTTP/1.1");