S3StorageDriver implements BackupStorageDriver { String getEndpoint(BackupRestoreContext ctx) throws URISyntaxException { URI uri = new URI(ctx.getExternalLocation()); String scheme = uri.getScheme(); if (scheme.equals(AmazonS3Client.S3_SERVICE_NAME)) { return Constants.S3_HOSTNAME; } else { String endpoint = scheme + ": int port = uri.getPort(); if (port != -1) { endpoint += ":" + Integer.toString(port); } return endpoint; } }  @Override void upload(BackupRestoreContext ctx); @Override void uploadSchema(BackupRestoreContext ctx, String schema); @Override void download(BackupRestoreContext ctx); @Override String downloadSchema(BackupRestoreContext ctx);  }
@Test public void testGetEndpointHTTPProtocolHost() throws URISyntaxException { String endpoint = "http: BackupRestoreContext backupRestoreContext = BackupRestoreContext.create( "node-id", "name", endpoint + "/cassandrabackup", "local-location", "account-id", "secret-key", false, "existing"); Assert.assertEquals(endpoint, s3StorageDriver.getEndpoint(backupRestoreContext)); }
@Test public void testGetEndpointS3Protocol() throws URISyntaxException { BackupRestoreContext backupRestoreContext = BackupRestoreContext.create( "node-id", "name", "s3: "local-location", "account-id", "secret-key", false, "existing"); Assert.assertEquals(Constants.S3_HOSTNAME, s3StorageDriver.getEndpoint(backupRestoreContext)); }
@Test public void testGetEndpointHTTPSProtocol() throws URISyntaxException { String endpoint = "https: BackupRestoreContext backupRestoreContext = BackupRestoreContext.create( "node-id", "name", endpoint + "/cassandrabackup", "local-location", "account-id", "secret-key", false, "existing"); Assert.assertEquals(endpoint, s3StorageDriver.getEndpoint(backupRestoreContext)); }
@Test public void testGetEndpointHTTPProtocolHostPort() throws URISyntaxException { String endpoint = "http: BackupRestoreContext backupRestoreContext = BackupRestoreContext.create( "node-id", "name", endpoint + "/cassandrabackup", "local-location", "account-id", "secret-key", false, "existing"); Assert.assertEquals(endpoint, s3StorageDriver.getEndpoint(backupRestoreContext)); }