@@ -107,6 +107,14 @@ private Watch.Response createHttpGoneErrorResponse(int nextResourceVersion) {
107
107
return WatchEvent .createErrorEvent (HTTP_GONE , nextResourceVersion ).toWatchResponse ();
108
108
}
109
109
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
+
110
118
@ SuppressWarnings ({"unchecked" , "rawtypes" })
111
119
@ Test
112
120
public void receivedEvents_areSentToListeners () {
@@ -138,18 +146,36 @@ public void afterFirstSetOfEvents_nextRequestSendsLastResourceVersion() {
138
146
@ SuppressWarnings ({"unchecked" , "rawtypes" })
139
147
@ Test
140
148
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" ));
153
179
}
154
180
155
181
@ SuppressWarnings ({"unchecked" , "rawtypes" })
0 commit comments