@Ignore("Can cause flakiness - only run manually") public void put202Retry200Async() throws Exception { final CountDownLatch lock = new CountDownLatch(1); long startTime = System.currentTimeMillis(); final long[] callbackTime = new long[1]; Product product = new Product(); product.setLocation("West US"); client.getAzureClient().setLongRunningOperationRetryTimeout(1); client .getLROsOperations() .put202Retry200Async( product, new ServiceCallback<Product>() { @Override public void failure(Throwable t) { fail(); } @Override public void success(ServiceResponse<Product> result) { Assert.assertEquals(200, result.getResponse().code()); Assert.assertEquals("100", result.getBody().getId()); callbackTime[0] = System.currentTimeMillis(); lock.countDown(); } }); long endTime = System.currentTimeMillis(); Assert.assertTrue(500 > endTime - startTime); Assert.assertTrue(lock.await(3000, TimeUnit.MILLISECONDS)); client.getAzureClient().setLongRunningOperationRetryTimeout(0); Assert.assertTrue(1000 < callbackTime[0] - startTime); }
@Test public void postAsyncRetrySucceeded() throws Exception { Product product = new Product(); product.setLocation("West US"); ServiceResponse<Product> response = client.getLROsOperations().postAsyncRetrySucceeded(product); Assert.assertEquals(200, response.getResponse().code()); }
@Test public void put202Retry200() throws Exception { Product product = new Product(); product.setLocation("West US"); ServiceResponse<Product> response = client.getLROsOperations().put202Retry200(product); Assert.assertEquals(200, response.getResponse().code()); Assert.assertEquals("100", response.getBody().getId()); }
@Test public void put200Succeeded() throws Exception { Product product = new Product(); product.setLocation("West US"); ServiceResponse<Product> response = client.getLROsOperations().put200Succeeded(product); Assert.assertEquals(200, response.getResponse().code()); Assert.assertEquals("Succeeded", response.getBody().getProvisioningState()); }
@Test public void postAsyncRetrycanceled() throws Exception { try { Product product = new Product(); product.setLocation("West US"); ServiceResponse<Void> response = client.getLROsOperations().postAsyncRetrycanceled(product); fail(); } catch (CloudException e) { Assert.assertEquals("Async operation failed", e.getMessage()); } }
@Test public void put200Acceptedcanceled200() throws Exception { Product product = new Product(); product.setLocation("West US"); try { ServiceResponse<Product> response = client.getLROsOperations().put200Acceptedcanceled200(product); fail(); } catch (CloudException e) { Assert.assertEquals("Async operation failed", e.getMessage()); } }