@@ -140,38 +140,13 @@ public void getCacheFails() throws Exception {
140
140
fetcher .close ();
141
141
}
142
142
143
- @ Test
144
- public void cacheWriteFails () throws Exception {
145
- this .server .enqueue (new MockResponse ().setResponseCode (200 ).setBody (TEST_JSON2 ));
146
- ConfigCache cache = mock (ConfigCache .class );
147
-
148
- Gson gson = new GsonBuilder ().create ();
149
- Config config = gson .fromJson (TEST_JSON , Config .class );
150
- config .timeStamp = Instant .now ().getEpochSecond ();
151
-
152
- when (cache .read (anyString ())).thenReturn (gson .toJson (config ));
153
- doThrow (new Exception ()).when (cache ).write (anyString (), anyString ());
154
-
155
- ConfigJsonCache configJsonCache = new ConfigJsonCache (logger , cache , "" );
156
- ConfigFetcher fetcher = new ConfigFetcher (new OkHttpClient .Builder ().build (), logger , configJsonCache ,
157
- "" , this .server .url ("/" ).toString (), false , PollingModes .manualPoll ().getPollingIdentifier ());
158
-
159
- FetchResponse result = fetcher .fetchAsync ().get ();
160
- configJsonCache .writeToCache (result .config ());
161
-
162
- assertEquals ("fakeValue2" , configJsonCache .readFromCache ().entries .get ("fakeKey" ).value .getAsString ());
163
-
164
- fetcher .close ();
165
- }
166
-
167
143
@ Test
168
144
public void cacheWriteFailsCachedTakesPrecedence () throws Exception {
169
145
this .server .enqueue (new MockResponse ().setResponseCode (200 ).setBody (TEST_JSON2 ));
170
146
ConfigCache cache = mock (ConfigCache .class );
171
147
172
148
Gson gson = new GsonBuilder ().create ();
173
149
Config config = gson .fromJson (TEST_JSON , Config .class );
174
- config .timeStamp = Instant .now ().getEpochSecond () + 50 ;
175
150
176
151
when (cache .read (anyString ())).thenReturn (gson .toJson (config ));
177
152
doThrow (new Exception ()).when (cache ).write (anyString (), anyString ());
0 commit comments