@@ -144,9 +144,8 @@ public void setUp() {
144144 frameReader = new MockFrameReader ();
145145 }
146146
147- private void initTransport () throws Exception {
147+ private void initTransport () {
148148 initTransport (3 , new ConnectedCallback (false ));
149- connectedCallback .waitUntilConnected ();
150149 }
151150
152151 private void initTransport (int startId , ConnectedCallback connectedCallback ) {
@@ -1092,7 +1091,17 @@ public void cancelBeforeConnected() throws Exception {
10921091 verifyNoMoreInteractions (frameWriter );
10931092
10941093 connectedCallback .allowConnected ();
1095- verifyNoMoreInteractions (frameWriter );
1094+
1095+ // There should be 4 pending operations
1096+ verify (frameWriter , timeout (TIME_OUT_MS )).synStream (
1097+ eq (false ), eq (false ), eq (3 ), eq (0 ), Matchers .<List <Header >>any ());
1098+ verify (frameWriter , timeout (TIME_OUT_MS )).flush ();
1099+ verify (frameWriter , timeout (TIME_OUT_MS )).rstStream (eq (3 ), eq (ErrorCode .CANCEL ));
1100+
1101+ // TODO(madongfly): Is this really what we want, we may just throw away the messages of
1102+ // a cancelled stream.
1103+ verify (frameWriter , timeout (TIME_OUT_MS ))
1104+ .data (eq (false ), eq (3 ), any (Buffer .class ), eq (12 + HEADER_LENGTH ));
10961105 }
10971106
10981107 @ Test
@@ -1105,10 +1114,17 @@ public void shutdownDuringConnecting() throws Exception {
11051114 clientTransport .shutdown ();
11061115 connectedCallback .allowConnected ();
11071116
1108- // The new stream should be failed, as well as the pending stream.
1117+ // The new stream should be failed, but the started stream should not be affected .
11091118 assertNewStreamFail ();
1110- listener .waitUntilStreamClosed ();
1111- assertEquals (Status .UNAVAILABLE .getCode (), listener .status .getCode ());
1119+ InputStream input = new ByteArrayInputStream (message .getBytes (UTF_8 ));
1120+ stream .writeMessage (input );
1121+ stream .flush ();
1122+ ArgumentCaptor <Buffer > captor = ArgumentCaptor .forClass (Buffer .class );
1123+ verify (frameWriter , timeout (TIME_OUT_MS ))
1124+ .data (eq (false ), eq (3 ), captor .capture (), eq (12 + HEADER_LENGTH ));
1125+ Buffer sentFrame = captor .getValue ();
1126+ assertEquals (createMessageFrame (message ), sentFrame );
1127+ stream .cancel (Status .CANCELLED );
11121128 }
11131129
11141130 private int activeStreamCount () {
0 commit comments