CloudTableClient tableClient = new CloudTableClient(baseUri, cred) tableClient.getDefaultRequestOptions().setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata);
/** * Initializes the values for this <code>TableRequestOptions</code> instance, if they are currently * <code>null</code>, using the values specified in the {@link CloudTableClient} parameter. * * @param options * A {@link TableRequestOptions} object which represents the input options to copy from when applying * defaults. * @param client * A {@link CloudTableClient} object from which to copy the timeout and retry policy. * * @return A {@link TableRequestOptions} object. * */ protected static final TableRequestOptions populateAndApplyDefaults(final TableRequestOptions options, final CloudTableClient client) { TableRequestOptions modifiedOptions = new TableRequestOptions(options); TableRequestOptions.populate(modifiedOptions, client.getDefaultRequestOptions()); TableRequestOptions.applyDefaults(modifiedOptions); return modifiedOptions; }
/** * Initializes the values for this <code>TableRequestOptions</code> instance, if they are currently * <code>null</code>, using the values specified in the {@link CloudTableClient} parameter. * * @param options * A {@link TableRequestOptions} object which represents the input options to copy from when applying * defaults. * @param client * A {@link CloudTableClient} object from which to copy the timeout and retry policy. * * @return A {@link TableRequestOptions} object. * */ protected static final TableRequestOptions populateAndApplyDefaults(final TableRequestOptions options, final CloudTableClient client) { TableRequestOptions modifiedOptions = new TableRequestOptions(options); TableRequestOptions.populate(modifiedOptions, client.getDefaultRequestOptions()); TableRequestOptions.applyDefaults(modifiedOptions); return modifiedOptions; }
@Test @Category( {CloudTests.class }) public void testGetServiceStats() throws StorageException { CloudTableClient tClient = TableTestHelper.createCloudTableClient(); tClient.getDefaultRequestOptions().setLocationMode(LocationMode.SECONDARY_ONLY); TableTestHelper.verifyServiceStats(tClient.getServiceStats()); } }
tableClient.getDefaultRequestOptions().setLocationMode(LocationMode.PRIMARY_THEN_SECONDARY); tableClient.getDefaultRequestOptions().setTimeoutIntervalInMs(1000); tableClient.getDefaultRequestOptions().setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata); tableClient.getDefaultRequestOptions().setRetryPolicyFactory(new RetryNoRetry()); .getCredentials().getClass().toString()); assertEquals(tableClient.getDefaultRequestOptions().getLocationMode(), tableFromUri.getServiceClient() .getDefaultRequestOptions().getLocationMode()); assertEquals(tableClient.getDefaultRequestOptions().getTimeoutIntervalInMs(), tableFromUri.getServiceClient() .getDefaultRequestOptions().getTimeoutIntervalInMs()); assertEquals(tableClient.getDefaultRequestOptions().getTablePayloadFormat(), tableFromUri.getServiceClient() .getDefaultRequestOptions().getTablePayloadFormat()); assertEquals(tableClient.getDefaultRequestOptions().getRetryPolicyFactory().getClass(), tableFromUri .getServiceClient().getDefaultRequestOptions().getRetryPolicyFactory().getClass());
tableClient.getDefaultRequestOptions().setTablePayloadFormat( TablePayloadFormat.JsonNoMetadata);
@Test public void testTableCreateAndAttemptCreateOnceExists() throws StorageException, URISyntaxException { CloudTableClient tClient = TableTestHelper.createCloudTableClient(); String tableName = TableTestHelper.generateRandomTableName(); CloudTable table = tClient.getTableReference(tableName); tClient.getDefaultRequestOptions().setTablePayloadFormat(TablePayloadFormat.Json); try { table.create(); assertTrue(table.exists()); // Should fail as it already exists try { table.create(); fail(); } catch (StorageException ex) { assertEquals(ex.getErrorCode(), "TableAlreadyExists"); } } finally { // cleanup table.deleteIfExists(); } }
private static void testTableDownloadPermissions(LocationMode optionsLocationMode, LocationMode clientLocationMode, StorageLocation initialLocation, List<RetryContext> retryContextList, List<RetryInfo> retryInfoList) throws URISyntaxException, StorageException { CloudTableClient client = TestHelper.createCloudTableClient(); CloudTable table = client.getTableReference(TableTestHelper.generateRandomTableName()); MultiLocationTestHelper helper = new MultiLocationTestHelper(table.getServiceClient().getStorageUri(), initialLocation, retryContextList, retryInfoList); table.getServiceClient().getDefaultRequestOptions().setLocationMode(clientLocationMode); TableRequestOptions options = new TableRequestOptions(); options.setLocationMode(optionsLocationMode); options.setRetryPolicyFactory(helper.retryPolicy); try { table.downloadPermissions(options, helper.operationContext); } catch (StorageException ex) { assertEquals(HttpURLConnection.HTTP_NOT_FOUND, ex.getHttpStatusCode()); } finally { helper.close(); } } }