Пример #1
0
 @Test
 public void testSetRevsLimit() {
   HttpResponse rsp = mock(HttpResponse.class);
   when(rsp.isSuccessful()).thenReturn(Boolean.TRUE);
   when(httpClient.put(anyString(), anyString())).thenReturn(rsp);
   dbCon.setRevisionLimit(500);
   verify(httpClient).put("/test_db/_revs_limit", "500");
   verify(rsp).releaseConnection();
 }
Пример #2
0
 public ContinuousChangesFeed(String dbName, HttpResponse httpResponse) {
   this.httpResponse = httpResponse;
   try {
     reader = new BufferedReader(new InputStreamReader(httpResponse.getContent(), "UTF-8"));
     thread.setName(
         String.format(
             "ektorp-%s-changes-listening-thread-%s", dbName, THREAD_COUNT.getAndIncrement()));
     thread.start();
   } catch (UnsupportedEncodingException e) {
     throw Exceptions.propagate(e);
   }
 }
Пример #3
0
 public void run() {
   try {
     String line = reader.readLine();
     while (shouldRun && line != null) {
       if (line.length() > 0) {
         handleChange(line);
       } else {
         handleHeartbeat();
       }
       line = reader.readLine();
     }
     String reason = !shouldRun ? "Cancelled" : "EOF";
     LOG.info("Changes feed stopped. Reason: " + reason);
   } catch (Exception e) {
     handleException(e);
   } finally {
     sendInterruptMarker();
     httpResponse.abort();
     try {
       reader.close();
     } catch (IOException e) {
     }
   }
 }
 @SuppressWarnings("unchecked")
 @Override
 public String success(HttpResponse hr) throws Exception {
   Map<String, ?> rsp = objectMapper.readValue(hr.getContent(), Map.class);
   return (String) rsp.get(REVISION_FIELD_NAME);
 }
Пример #5
0
 private HttpResponse setupResponseOnPost() {
   HttpResponse rsp = mock(HttpResponse.class);
   when(rsp.isSuccessful()).thenReturn(Boolean.TRUE);
   when(httpClient.post(anyString(), anyString())).thenReturn(rsp);
   return rsp;
 }
Пример #6
0
 @Override
 public DocumentOperationResult success(HttpResponse hr) throws Exception {
   return objectMapper.readValue(hr.getContent(), DocumentOperationResult.class);
 }