@@ -107,6 +107,14 @@ private Watch.Response createHttpGoneErrorResponse(int nextResourceVersion) {
107107 return WatchEvent .createErrorEvent (HTTP_GONE , nextResourceVersion ).toWatchResponse ();
108108 }
109109
110+ private Watch .Response createHttpGoneErrorWithoutResourceVersionResponse () {
111+ return WatchEvent .createErrorEvent (HTTP_GONE ).toWatchResponse ();
112+ }
113+
114+ private Watch .Response createErrorWithoutStatusResponse () {
115+ return WatchEvent .createErrorEventWithoutStatus ().toWatchResponse ();
116+ }
117+
110118 @ SuppressWarnings ({"unchecked" , "rawtypes" })
111119 @ Test
112120 public void receivedEvents_areSentToListeners () {
@@ -138,18 +146,36 @@ public void afterFirstSetOfEvents_nextRequestSendsLastResourceVersion() {
138146 @ SuppressWarnings ({"unchecked" , "rawtypes" })
139147 @ Test
140148 public void afterHttpGoneError_nextRequestSendsIncludedResourceVersion () {
141- try {
142- StubWatchFactory .addCallResponses (createHttpGoneErrorResponse (NEXT_RESOURCE_VERSION ));
143- scheduleDeleteResponse (createObjectWithMetaData ());
144-
145- createAndRunWatcher (NAMESPACE , stopping , INITIAL_RESOURCE_VERSION );
146-
147- assertThat (
148- StubWatchFactory .getRequestParameters ().get (1 ),
149- hasEntry ("resourceVersion" , Integer .toString (NEXT_RESOURCE_VERSION )));
150- } catch (Throwable t ) {
151- t .printStackTrace ();
152- }
149+ StubWatchFactory .addCallResponses (createHttpGoneErrorResponse (NEXT_RESOURCE_VERSION ));
150+ scheduleDeleteResponse (createObjectWithMetaData ());
151+
152+ createAndRunWatcher (NAMESPACE , stopping , INITIAL_RESOURCE_VERSION );
153+
154+ assertThat (
155+ StubWatchFactory .getRequestParameters ().get (1 ),
156+ hasEntry ("resourceVersion" , Integer .toString (NEXT_RESOURCE_VERSION )));
157+ }
158+
159+ @ SuppressWarnings ({"unchecked" , "rawtypes" })
160+ @ Test
161+ public void afterHttpGoneErrorWithoutResourceVersion_nextRequestSendsResourceVersionZero () {
162+ StubWatchFactory .addCallResponses (createHttpGoneErrorWithoutResourceVersionResponse ());
163+ scheduleDeleteResponse (createObjectWithMetaData ());
164+
165+ createAndRunWatcher (NAMESPACE , stopping , INITIAL_RESOURCE_VERSION );
166+
167+ assertThat (StubWatchFactory .getRequestParameters ().get (1 ), hasEntry ("resourceVersion" , "0" ));
168+ }
169+
170+ @ SuppressWarnings ({"unchecked" , "rawtypes" })
171+ @ Test
172+ public void afterErrorWithoutStatus_nextRequestSendsResourceVersionZero () {
173+ StubWatchFactory .addCallResponses (createErrorWithoutStatusResponse ());
174+ scheduleDeleteResponse (createObjectWithMetaData ());
175+
176+ createAndRunWatcher (NAMESPACE , stopping , INITIAL_RESOURCE_VERSION );
177+
178+ assertThat (StubWatchFactory .getRequestParameters ().get (1 ), hasEntry ("resourceVersion" , "0" ));
153179 }
154180
155181 @ SuppressWarnings ({"unchecked" , "rawtypes" })
0 commit comments