CassandraConfig { @GET @Path("/double_ring") public Response doubleRing() throws IOException, ClassNotFoundException { try { metrics.incDoubleRing(); doubleRing.backup(); doubleRing.doubleSlots(); } catch (Throwable th) { logger.error("Error in doubling the ring...", th); doubleRing.restore(); throw new RuntimeException(th); } return Response.status(200).build(); } @Inject  CassandraConfig(PriamServer server, DoubleRing doubleRing, CassMonitorMetrics metrics); @GET @Path("/get_seeds") Response getSeeds(); @GET @Path("/get_token") Response getToken(); @GET @Path("/is_replace_token") Response isReplaceToken(); @GET @Path("/get_replaced_ip") Response getReplacedIp(); @POST @Path("/set_replaced_ip") Response setReplacedIp(@QueryParam("ip") String ip); @GET @Path("/get_extra_env_params") Response getExtraEnvParams(); @GET @Path("/double_ring") Response doubleRing();  }
@Test public void doubleRing() throws Exception { new Expectations() { { doubleRing.backup(); doubleRing.doubleSlots(); } }; Response response = resource.doubleRing(); assertEquals(200, response.getStatus()); }
@Test public void doubleRing_ioExceptionInBackup() throws Exception { final IOException exception = new IOException(); new Expectations() { { doubleRing.backup(); result = exception; doubleRing.restore(); } }; try { resource.doubleRing(); fail("Excepted RuntimeException"); } catch (RuntimeException e) { assertEquals(exception, e.getCause()); } }
@Test(expected = IOException.class) public void doubleRing_ioExceptionInRestore() throws Exception { new Expectations() { { doubleRing.backup(); result = new IOException(); doubleRing.restore(); result = new IOException(); } }; resource.doubleRing(); }
@Test(expected = ClassNotFoundException.class) public void doubleRing_classNotFoundExceptionInRestore() throws Exception { new Expectations() { { doubleRing.backup(); result = new IOException(); doubleRing.restore(); result = new ClassNotFoundException(); } }; resource.doubleRing(); }