nacx commented on a change in pull request #88:
URL: https://github.com/apache/jclouds/pull/88#discussion_r522217861



##########
File path: 
providers/azureblob/src/test/java/org/jclouds/azure/storage/util/StorageUrlDelegateTest.java
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azure.storage.util;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Properties;
+
+import org.jclouds.ContextBuilder;
+import org.jclouds.azure.storage.reference.AzureConstants;
+import org.jclouds.logging.config.NullLoggingModule;
+import org.jclouds.rest.internal.BaseRestApiTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+
+@Test(groups = "unit")
+public class StorageUrlDelegateTest {
+
+   private static final String ACCOUNT = "foo";
+   private static final ImmutableSet<Module> MODULES = ImmutableSet.<Module> 
of(new BaseRestApiTest.MockModule(),
+         new NullLoggingModule());
+
+   @Test
+   void testDefaultEndpoint() {
+
+      StorageUrlDelegate target = ContextBuilder
+            .newBuilder("azureblob")
+            .credentials(ACCOUNT, "?token")
+            .modules(MODULES)
+            .buildInjector().getInstance(StorageUrlDelegate.class);
+
+      assertEquals(target.configureStorageUrl(), 
"https://foo.blob.core.windows.net/";);
+   }
+
+   @Test
+   void testCustomEndpointWithoutStorageAccountPath() {
+
+      StorageUrlDelegate target = ContextBuilder
+            .newBuilder("azureblob").endpoint("http://localhost:10000";)
+            .credentials(ACCOUNT, "?token")
+            .modules(MODULES)
+            .buildInjector()
+            .getInstance(StorageUrlDelegate.class);
+
+      assertEquals(target.configureStorageUrl(), "http://localhost:10000/";);

Review comment:
       Why are we only setting the account name if 
`PROPERTY_AZURE_VIRTUAL_HOST_STORAGE_ACCOUNT == false` is false? I mean, what 
is the point in not adding the account name anywhere in the URI? Either if we 
have a custom endpoint or not, I guess we want the account name to be present 
_somewhere_?

##########
File path: 
providers/azureblob/src/main/java/org/jclouds/azure/storage/util/StorageUrlDelegate.java
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.azure.storage.util;
+
+import static 
org.jclouds.azure.storage.reference.AzureConstants.PROPERTY_AZURE_VIRTUAL_HOST_STORAGE_ACCOUNT;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.domain.Credentials;
+import org.jclouds.providers.ProviderMetadata;
+
+import com.google.common.base.Supplier;
+
+@Singleton
+public class StorageUrlDelegate {
+
+   private ProviderMetadata providerMetadata;
+   private Supplier<Credentials> credentialsSupplier;
+   private boolean storageAccountInsideVirtualHost;
+
+   @Inject
+   public StorageUrlDelegate(ProviderMetadata providerMetadata,

Review comment:
       Instead of manually getting the endpoint from the provider metadata, you 
should inject the following endpoint supplier and get it from there, when 
needed.
   ```suggestion
      public StorageUrlDelegate(@Provider Supplier<URI> endpointSupplier,
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to