55import java .util .EnumSet ;
66import java .util .concurrent .CountDownLatch ;
77import java .util .concurrent .TimeUnit ;
8+ import javax .servlet .DispatcherType ;
89import javax .servlet .Filter ;
910import javax .servlet .FilterChain ;
1011import javax .servlet .FilterConfig ;
1516
1617import org .cometd .bayeux .server .BayeuxServer ;
1718import org .cometd .bayeux .server .ServerSession ;
18- import org .eclipse .jetty .client .ContentExchange ;
19- import org .eclipse .jetty .client .HttpExchange ;
20- import org .eclipse .jetty .server .DispatcherType ;
19+ import org .eclipse .jetty .client .api .ContentResponse ;
20+ import org .eclipse .jetty .client .api .Request ;
2121import org .eclipse .jetty .servlet .FilterHolder ;
2222import org .junit .Assert ;
2323import org .junit .Test ;
@@ -42,15 +42,14 @@ public void sessionRemoved(ServerSession session, boolean timedout)
4242 }
4343 });
4444
45- ContentExchange handshake = newBayeuxExchange ("[{" +
45+ Request handshake = newBayeuxRequest ("[{" +
4646 "\" channel\" : \" /meta/handshake\" ," +
4747 "\" version\" : \" 1.0\" ," +
4848 "\" minimumVersion\" : \" 1.0\" ," +
4949 "\" supportedConnectionTypes\" : [\" long-polling\" ]" +
5050 "}]" );
51- httpClient .send (handshake );
52- Assert .assertEquals (HttpExchange .STATUS_COMPLETED , handshake .waitForDone ());
53- Assert .assertEquals (200 , handshake .getResponseStatus ());
51+ ContentResponse response = handshake .send ();
52+ Assert .assertEquals (200 , response .getStatus ());
5453
5554 Assert .assertTrue (latch .await (5 , TimeUnit .SECONDS ));
5655 }
@@ -76,17 +75,16 @@ public void sessionRemoved(ServerSession session, boolean timedout)
7675 }
7776 });
7877
79- ContentExchange handshake = newBayeuxExchange ("[{" +
78+ Request handshake = newBayeuxRequest ("[{" +
8079 "\" channel\" : \" /meta/handshake\" ," +
8180 "\" version\" : \" 1.0\" ," +
8281 "\" minimumVersion\" : \" 1.0\" ," +
8382 "\" supportedConnectionTypes\" : [\" long-polling\" ]" +
8483 "}]" );
85- handshake .addRequestHeader (name , value1 );
86- handshake .addRequestHeader (name , value2 );
87- httpClient .send (handshake );
88- Assert .assertEquals (HttpExchange .STATUS_COMPLETED , handshake .waitForDone ());
89- Assert .assertEquals (200 , handshake .getResponseStatus ());
84+ handshake .header (name , value1 );
85+ handshake .header (name , value2 );
86+ ContentResponse response = handshake .send ();
87+ Assert .assertEquals (200 , response .getStatus ());
9088
9189 Assert .assertTrue (latch .await (5 , TimeUnit .SECONDS ));
9290 }
@@ -131,15 +129,14 @@ public void sessionRemoved(ServerSession session, boolean timedout)
131129 }
132130 });
133131
134- ContentExchange handshake = newBayeuxExchange ("[{" +
132+ Request handshake = newBayeuxRequest ("[{" +
135133 "\" channel\" : \" /meta/handshake\" ," +
136134 "\" version\" : \" 1.0\" ," +
137135 "\" minimumVersion\" : \" 1.0\" ," +
138136 "\" supportedConnectionTypes\" : [\" long-polling\" ]" +
139137 "}]" );
140- httpClient .send (handshake );
141- Assert .assertEquals (HttpExchange .STATUS_COMPLETED , handshake .waitForDone ());
142- Assert .assertEquals (200 , handshake .getResponseStatus ());
138+ ContentResponse response = handshake .send ();
139+ Assert .assertEquals (200 , response .getStatus ());
143140
144141 Assert .assertTrue (latch .await (5 , TimeUnit .SECONDS ));
145142 }
@@ -186,15 +183,14 @@ public void sessionRemoved(ServerSession session, boolean timedout)
186183 }
187184 });
188185
189- ContentExchange handshake = newBayeuxExchange ("[{" +
186+ Request handshake = newBayeuxRequest ("[{" +
190187 "\" channel\" : \" /meta/handshake\" ," +
191188 "\" version\" : \" 1.0\" ," +
192189 "\" minimumVersion\" : \" 1.0\" ," +
193190 "\" supportedConnectionTypes\" : [\" long-polling\" ]" +
194191 "}]" );
195- httpClient .send (handshake );
196- Assert .assertEquals (HttpExchange .STATUS_COMPLETED , handshake .waitForDone ());
197- Assert .assertEquals (200 , handshake .getResponseStatus ());
192+ ContentResponse response = handshake .send ();
193+ Assert .assertEquals (200 , response .getStatus ());
198194
199195 Assert .assertTrue (latch .await (5 , TimeUnit .SECONDS ));
200196 }
@@ -216,15 +212,14 @@ public void sessionRemoved(ServerSession session, boolean timedout)
216212 }
217213 });
218214
219- ContentExchange handshake = newBayeuxExchange ("[{" +
215+ Request handshake = newBayeuxRequest ("[{" +
220216 "\" channel\" : \" /meta/handshake\" ," +
221217 "\" version\" : \" 1.0\" ," +
222218 "\" minimumVersion\" : \" 1.0\" ," +
223219 "\" supportedConnectionTypes\" : [\" long-polling\" ]" +
224220 "}]" );
225- httpClient .send (handshake );
226- Assert .assertEquals (HttpExchange .STATUS_COMPLETED , handshake .waitForDone ());
227- Assert .assertEquals (200 , handshake .getResponseStatus ());
221+ ContentResponse response = handshake .send ();
222+ Assert .assertEquals (200 , response .getStatus ());
228223
229224 Assert .assertTrue (latch .await (5 , TimeUnit .SECONDS ));
230225 }
0 commit comments