24
24
25
25
import static com .github .odiszapc .nginxparser .TestUtils .assertBlock ;
26
26
import static com .github .odiszapc .nginxparser .TestUtils .assertParam ;
27
+ import static org .junit .Assert .assertEquals ;
28
+ import static org .junit .Assert .assertFalse ;
29
+ import static org .junit .Assert .assertNotEquals ;
30
+ import static org .junit .Assert .assertTrue ;
27
31
28
32
public class NestedTest extends ParseTestBase {
29
33
@@ -47,17 +51,17 @@ public class NestedTest extends ParseTestBase {
47
51
appIt = application .iterator ();
48
52
assertParam (appIt .next (), "live" , "off" );
49
53
50
- Assert . assertFalse (it .hasNext ());
54
+ assertFalse (it .hasNext ());
51
55
}
52
56
53
57
@ Test
54
58
public void testC1find () throws Exception {
55
59
NgxConfig conf = parse ("nested/c1.conf" );
56
60
List <NgxEntry > result = conf .findAll (NgxConfig .PARAM , "rtmp" , "server" , "application" , "live" );
57
- Assert . assertEquals (result .size (), 2 );
61
+ assertEquals (result .size (), 2 );
58
62
assertParam (result .get (0 ), "live" , "on" );
59
63
assertParam (result .get (1 ), "live" , "off" );
60
- Assert . assertNotEquals (result .get (0 ), result .get (1 ));
64
+ assertNotEquals (result .get (0 ), result .get (1 ));
61
65
}
62
66
63
67
@ Test
@@ -72,23 +76,23 @@ public void testC1findEvery() throws Exception {
72
76
assertBlock (s1 , "server" );
73
77
NgxParam param = s1 .findParam ("application" , "live" );
74
78
assertParam (param , "live" );
75
- Assert . assertEquals (param .getValue (), "on" );
79
+ assertEquals (param .getValue (), "on" );
76
80
77
81
NgxBlock s2 = (NgxBlock ) it .next ();
78
82
assertBlock (s2 , "server" );
79
83
NgxParam param2 = s2 .findParam ("application" , "live" );
80
84
assertParam (param2 , "live" );
81
- Assert . assertEquals (param2 .getValue (), "off" );
85
+ assertEquals (param2 .getValue (), "off" );
82
86
}
83
87
84
88
@ Test
85
89
public void testC1findBlock () throws Exception {
86
90
NgxConfig conf = parse ("nested/c1.conf" );
87
91
List <NgxEntry > result = conf .findAll (NgxConfig .BLOCK , "rtmp" , "server" , "application" );
88
- Assert . assertEquals (result .size (), 2 );
92
+ assertEquals (result .size (), 2 );
89
93
assertBlock (result .get (0 ), "application" , "myapp" );
90
94
assertBlock (result .get (1 ), "application" , "myapp2" );
91
- Assert . assertNotEquals (result .get (0 ), result .get (1 ));
95
+ assertNotEquals (result .get (0 ), result .get (1 ));
92
96
}
93
97
94
98
@ Test
@@ -101,4 +105,16 @@ public void testC1findBlock() throws Exception {
101
105
assertParam (it .next (), "set_if_empty" , "$name" , "\" Anonymous\" " );
102
106
assertParam (it .next (), "memc_pass" , "127.0.0.1:11211" );
103
107
}
108
+
109
+ @ Test
110
+ public void testС5 () throws Exception {
111
+ NgxConfig conf = parse ("nested/c5.conf" );
112
+ NgxBlock loc = assertBlock (conf .findBlock ("http" , "server" , "location" ), "location" , "/foo" );
113
+ Iterator <NgxEntry > it = loc .iterator ();
114
+ NgxEntry entry = it .next ();
115
+ assertTrue (entry instanceof NgxParam );
116
+ assertEquals (((NgxParam ) entry ).getName (), "stub_status" );
117
+ assertEquals (0 , ((NgxParam ) entry ).getValues ().size ());
118
+ assertEquals ("" , ((NgxParam ) entry ).getValue ());
119
+ }
104
120
}
0 commit comments