@Test
  public void testReplicateBlobFailureDueToNotEnoughQuorum() throws Exception {
    try {
      MockServerLayout layout = new MockServerLayout(mockClusterMap);
      String serviceId = "replicate-blob-service";
      setRouter(getNonBlockingRouterProperties(localDcName), layout, new LoggingNotificationSystem());
      setOperationParams();
      // PutBlob to the three local replicas
      String blobIdStr =
          router.putBlob(putBlobProperties, putUserMetadata, putChannel, new PutBlobOptionsBuilder().build())
              .get(AWAIT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
      router.getBlob(blobIdStr, new GetBlobOptionsBuilder().build(), null, null).get();

      // Except for source host, all other replicas are down.
      layout.getMockServers()
          .forEach(mockServer -> mockServer.setServerErrorForAllRequests(ServerErrorCode.ReplicaUnavailable));
      DataNodeId sourceDataNode = null;
      for (MockServer server : layout.getMockServers()) {
        if (server.getDataCenter().equals(localDcName)) {
          sourceDataNode = mockClusterMap.getDataNodeId(server.getHostName(), server.getHostPort());
          server.setServerErrorForAllRequests(null);
          break;
        }
      }
      router.replicateBlob(blobIdStr, serviceId, sourceDataNode).get();
      Assert.fail("Shouldn't come here. ");
    } catch (Exception e) {
      Assert.assertTrue(e.getCause() instanceof RouterException);
      RouterException routerException = (RouterException) e.getCause();
      Assert.assertEquals(routerException.getErrorCode(), RouterErrorCode.AmbryUnavailable);
    } finally {
      // Since we are using same blob ID for all tests, clear cache which stores blobs that are not found in router.
      router.getNotFoundCache().invalidateAll();
      if (router != null) {
        router.close();
      }
    }
  }
Test for ReplicateBlob failure when there is no available target node.
@throws Exception
ambry-router/src/test/java/com/github/ambry/router/NonBlockingRouterTest.java