Repository: jclouds-labs
Updated Branches:
  refs/heads/master e4cbe223b -> 88ef0a221


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/03f72d5e/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/util/DeploymentTemplateBuilder.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/util/DeploymentTemplateBuilder.java
 
b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/util/DeploymentTemplateBuilder.java
index ffa533e..ed5ec9e 100644
--- 
a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/util/DeploymentTemplateBuilder.java
+++ 
b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/util/DeploymentTemplateBuilder.java
@@ -19,6 +19,7 @@ package org.jclouds.azurecompute.arm.util;
 import com.google.common.collect.ImmutableMap;
 import com.google.inject.assistedinject.Assisted;
 
+import 
org.jclouds.azurecompute.arm.compute.config.AzureComputeServiceContextModule;
 import org.jclouds.azurecompute.arm.domain.DeploymentProperties;
 import org.jclouds.compute.options.TemplateOptions;
 import org.jclouds.azurecompute.arm.domain.DataDisk;
@@ -72,12 +73,11 @@ public class DeploymentTemplateBuilder {
    private TemplateOptions options;
    private List<ResourceDefinition> resources;
    private Map<String, String> variables;
-   private String loginUser;
-   private String loginPassword;
+   private static String loginUser;
+   private static String loginPassword;
    private String location;
+   private AzureComputeServiceContextModule.AzureComputeConstants 
azureComputeConstants;
 
-   public static final String DEFAULT_LOGIN_USER = "jclouds";
-   public static final String DEFAULT_LOGIN_PASSWORD = "Password1!";
    private static final String DEPLOYMENT_MODE = "Incremental";
    private static final String DEFAULT_DATA_DISK_SIZE = "1023";
 
@@ -85,24 +85,37 @@ public class DeploymentTemplateBuilder {
    private static final String DEFAULT_subnetAddressPrefix = "10.0.0.0/24";
 
    @Inject
-   DeploymentTemplateBuilder(Json json, @Assisted("group") String group, 
@Assisted("name") String name, @Assisted Template template) {
+   DeploymentTemplateBuilder(Json json, @Assisted("group") String group, 
@Assisted("name") String name, @Assisted Template template,
+                             final 
AzureComputeServiceContextModule.AzureComputeConstants azureComputeConstants) {
       this.name = name;
       this.group = group;
       this.template = template;
       this.options = template.getOptions().as(TemplateOptions.class);
       this.variables = new HashMap<String, String>();
       this.resources = new ArrayList<ResourceDefinition>();
-      this.loginUser = options.getLoginUser() == null ? DEFAULT_LOGIN_USER : 
options.getLoginUser();
-      this.loginPassword = options.getLoginPassword() == null ? 
DEFAULT_LOGIN_PASSWORD : options.getLoginPassword();
       this.location = template.getLocation().getId();
       this.json = json;
+
+      this.azureComputeConstants = azureComputeConstants;
+
+      String[] defaultLogin = 
this.azureComputeConstants.azureDefaultImageLogin().split(":");
+      String defaultUser = null;
+      String defaultPassword = null;
+
+      if (defaultLogin.length == 2) {
+         defaultUser = defaultLogin[0].trim();
+         defaultPassword = defaultLogin[1].trim();
+      }
+
+      loginUser = options.getLoginUser() == null ? defaultUser : 
options.getLoginUser();
+      loginPassword = options.getLoginPassword() == null ? defaultPassword : 
options.getLoginPassword();
    }
 
-   public String getLoginUserUsername() {
+   public static String getLoginUserUsername() {
       return loginUser;
    }
 
-   public String getLoginPassword() {
+   public static String getLoginPassword() {
       return loginPassword;
    }
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/03f72d5e/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceContextLiveTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceContextLiveTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceContextLiveTest.java
new file mode 100644
index 0000000..940f785
--- /dev/null
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceContextLiveTest.java
@@ -0,0 +1,284 @@
+/*
+ * 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.azurecompute.arm.compute;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.inject.Module;
+import org.jclouds.azurecompute.arm.AzureComputeProviderMetadata;
+import org.jclouds.azurecompute.arm.internal.AzureLiveTestUtils;
+import org.jclouds.compute.RunNodesException;
+import org.jclouds.compute.RunScriptOnNodesException;
+import org.jclouds.compute.domain.ComputeMetadata;
+import org.jclouds.compute.domain.ExecResponse;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.domain.Credentials;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.Test;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.assertj.core.api.Assertions.assertThat;
+import static 
org.jclouds.azurecompute.arm.config.AzureComputeProperties.RESOURCE_GROUP_NAME;
+import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
+import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_SCRIPT_COMPLETE;
+
+import static org.jclouds.compute.predicates.NodePredicates.inGroup;
+import static 
org.jclouds.compute.options.TemplateOptions.Builder.overrideLoginCredentials;
+import static org.jclouds.scriptbuilder.domain.Statements.exec;
+import static org.testng.Assert.assertTrue;
+
+@Test(groups = "live", testName = "AzureComputeServiceContextLiveTest")
+public class AzureComputeServiceContextLiveTest extends 
BaseComputeServiceContextLiveTest {
+
+   public String azureGroup;
+   protected static final int RAND = new Random().nextInt(999);
+
+   @Override
+   protected Module getSshModule() {
+      return new SshjSshClientModule();
+   }
+
+   @Override protected Properties setupProperties() {
+      azureGroup = "jc" + RAND;
+
+      Properties properties = super.setupProperties();
+      long scriptTimeout = TimeUnit.MILLISECONDS.convert(60, TimeUnit.MINUTES);
+      properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, scriptTimeout + "");
+      properties.setProperty(TIMEOUT_NODE_RUNNING, scriptTimeout + "");
+
+      AzureLiveTestUtils.defaultProperties(properties);
+      checkNotNull(setIfTestSystemPropertyPresent(properties, 
"oauth.endpoint"), "test.oauth.endpoint");
+
+      properties.put(RESOURCE_GROUP_NAME, azureGroup);
+      return properties;
+   }
+
+   public AzureComputeServiceContextLiveTest() {
+      provider = "azurecompute-arm";
+   }
+
+   @Test
+   public void testDefault() throws RunNodesException {
+
+      final String groupName = this.azureGroup;
+      final TemplateBuilder templateBuilder = 
view.getComputeService().templateBuilder();
+      templateBuilder.osFamily(OsFamily.UBUNTU);
+      templateBuilder.osVersionMatches("14.04");
+      templateBuilder.hardwareId("Standard_A0");
+      templateBuilder.locationId("westus");
+
+      final Template template = templateBuilder.build();
+
+      try {
+         Set<? extends NodeMetadata> nodes = 
view.getComputeService().createNodesInGroup(groupName, 1, template);
+         assertThat(nodes).hasSize(1);
+      } finally {
+// Do not destroy         
view.getComputeService().destroyNodesMatching(inGroup(groupName));
+      }
+   }
+
+   private LoginCredentials getLogin() {
+      Credentials credentials = new Credentials("jclouds", "Password1!");
+      LoginCredentials login = LoginCredentials.fromCredentials(credentials);
+      return login;
+   }
+
+   @Test(dependsOnMethods = "testDefault")
+   public void testExec() throws RunScriptOnNodesException {
+      final String groupName = this.azureGroup;
+      String command = "echo hello";
+
+      Map<? extends NodeMetadata, ExecResponse> responses = 
view.getComputeService().runScriptOnNodesMatching(//
+              inGroup(groupName), // predicate used to select nodes
+              exec(command), // what you actually intend to run
+              overrideLoginCredentials(getLogin()) // use my local user &
+                      // ssh key
+                      .runAsRoot(false) // don't attempt to run as root (sudo)
+                      .wrapInInitScript(false)); // run command directly
+
+      assertTrue(responses.size() > 0);
+   }
+
+   public static Predicate<ComputeMetadata> nameStartsWith(final String 
prefix) {
+      Preconditions.checkNotNull(prefix, "prefix must be defined");
+
+      return new Predicate<ComputeMetadata>() {
+         @Override
+         public boolean apply(ComputeMetadata computeMetadata) {
+            return computeMetadata.getName().startsWith(prefix);
+         }
+
+         @Override
+         public String toString() {
+            return "nameStartsWith(" + prefix + ")";
+         }
+      };
+   }
+
+   @Test(dependsOnMethods = "testExec")
+   public void testStop() throws RunScriptOnNodesException {
+      final String groupName = this.azureGroup;
+      Set<? extends NodeMetadata> nodes = 
view.getComputeService().suspendNodesMatching(inGroup(groupName));
+      assertTrue(nodes.size() > 0);
+
+      boolean allStopped = false;
+      while (!allStopped) {
+         nodes = 
view.getComputeService().listNodesDetailsMatching(nameStartsWith(groupName));
+         for (NodeMetadata node : nodes) {
+            if (node.getStatus() != NodeMetadata.Status.SUSPENDED)
+            {
+               // Not stopped yet
+               allStopped = false;
+               try {
+                  Thread.sleep(15 * 1000);
+               } catch (InterruptedException e) {
+               }
+               continue;
+            }
+            else
+            {
+               allStopped = true;
+            }
+         }
+      }
+      assertTrue(allStopped);
+   }
+
+   @Test(dependsOnMethods = "testStop")
+   public void testStart() throws RunScriptOnNodesException {
+      final String groupName = this.azureGroup;
+      Set<? extends NodeMetadata> nodes = 
view.getComputeService().resumeNodesMatching(inGroup(groupName));
+      assertTrue(nodes.size() > 0);
+
+      boolean allStarted = false;
+      while (!allStarted) {
+         nodes = 
view.getComputeService().listNodesDetailsMatching(nameStartsWith(groupName));
+         for (NodeMetadata node : nodes) {
+            if (node.getStatus() != NodeMetadata.Status.RUNNING)
+            {
+               // Not started yet
+               allStarted = false;
+               try {
+                  Thread.sleep(15 * 1000);
+               } catch (InterruptedException e) {
+               }
+               continue;
+            }
+            else
+            {
+               allStarted = true;
+            }
+         }
+      }
+      assertTrue(allStarted);
+   }
+
+   @Test(dependsOnMethods = "testStart")
+   public void testRestart() throws RunScriptOnNodesException {
+      final String groupName = this.azureGroup;
+      Set<? extends NodeMetadata> nodes = 
view.getComputeService().rebootNodesMatching(inGroup(groupName));
+      assertTrue(nodes.size() > 0);
+
+      boolean allRestarted = false;
+      while (!allRestarted) {
+         nodes = 
view.getComputeService().listNodesDetailsMatching(nameStartsWith(groupName));
+         for (NodeMetadata node : nodes) {
+            if (node.getStatus() != NodeMetadata.Status.RUNNING)
+            {
+               // Not started yet
+               allRestarted = false;
+               try {
+                  Thread.sleep(30 * 1000);
+               } catch (InterruptedException e) {
+               }
+               continue;
+            }
+            else
+            {
+               allRestarted = true;
+            }
+         }
+      }
+      assertTrue(allRestarted);
+
+      view.getComputeService().destroyNodesMatching(inGroup(groupName));
+   }
+
+   @Test(dependsOnMethods = "testRestart")
+   public void testLinuxNode() throws RunNodesException {
+      final String groupName = this.azureGroup;
+      final TemplateBuilder templateBuilder = 
view.getComputeService().templateBuilder();
+      templateBuilder.osFamily(OsFamily.UBUNTU);
+      templateBuilder.osVersionMatches("14.04");
+      templateBuilder.hardwareId("Standard_A0");
+      templateBuilder.locationId("westus");
+      final Template template = templateBuilder.build();
+
+      try {
+         Set<? extends NodeMetadata> nodes = 
view.getComputeService().createNodesInGroup(groupName, 1, template);
+         assertThat(nodes).hasSize(1);
+      } finally {
+         view.getComputeService().destroyNodesMatching(inGroup(groupName));
+      }
+   }
+
+   @Test(dependsOnMethods = "testLinuxNode")
+   public void testWindowsNode() throws RunNodesException {
+      final String groupName = this.azureGroup;
+      final TemplateBuilder templateBuilder = 
view.getComputeService().templateBuilder();
+      
templateBuilder.imageId("global/MicrosoftWindowsServer/WindowsServer/Windows-Server-Technical-Preview");
+      templateBuilder.hardwareId("Standard_A0");
+      templateBuilder.locationId("westus");
+      final Template template = templateBuilder.build();
+
+      try {
+         Set<? extends NodeMetadata> nodes = 
view.getComputeService().createNodesInGroup(groupName, 1, template);
+         assertThat(nodes).hasSize(1);
+      } finally {
+         view.getComputeService().destroyNodesMatching(inGroup(groupName));
+      }
+   }
+
+   @Override
+   protected ProviderMetadata createProviderMetadata() {
+      AzureComputeProviderMetadata pm = 
AzureComputeProviderMetadata.builder().build();
+      return pm;
+   }
+
+   protected String setIfTestSystemPropertyPresent(Properties overrides, 
String key) {
+      if (System.getProperties().containsKey("test." + key)) {
+         String val = System.getProperty("test." + key);
+         overrides.setProperty(key, val);
+         return val;
+      } else {
+         return null;
+      }
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/03f72d5e/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceLiveTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceLiveTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceLiveTest.java
new file mode 100644
index 0000000..ae43511
--- /dev/null
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureComputeServiceLiveTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.azurecompute.arm.compute;
+
+import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.Test;
+
+import org.jclouds.providers.ProviderMetadata;
+
+import org.jclouds.azurecompute.arm.AzureComputeProviderMetadata;
+
+import static 
org.jclouds.azurecompute.arm.config.AzureComputeProperties.RESOURCE_GROUP_NAME;
+import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
+import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_SCRIPT_COMPLETE;
+import org.jclouds.azurecompute.arm.internal.AzureLiveTestUtils;
+
+import com.google.inject.Module;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Live tests for the {@link org.jclouds.compute.ComputeService} integration.
+ */
+@Test(groups = "live", singleThreaded = true, testName = 
"AzureComputeServiceLiveTest")
+public class AzureComputeServiceLiveTest extends BaseComputeServiceLiveTest {
+   public String azureGroup;
+
+   public AzureComputeServiceLiveTest() {
+      provider = "azurecompute-arm";
+   }
+
+   @Override
+   protected Module getSshModule() {
+      return new SshjSshClientModule();
+   }
+
+   @Override
+   protected ProviderMetadata createProviderMetadata() {
+      AzureComputeProviderMetadata pm = 
AzureComputeProviderMetadata.builder().build();
+      return pm;
+   }
+
+   @Override protected Properties setupProperties() {
+      azureGroup = "jc" + System.getProperty("user.name").substring(0, 3);
+      Properties properties = super.setupProperties();
+      long scriptTimeout = TimeUnit.MILLISECONDS.convert(20, TimeUnit.MINUTES);
+      properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, scriptTimeout + "");
+      properties.setProperty(TIMEOUT_NODE_RUNNING, scriptTimeout + "");
+      properties.put(RESOURCE_GROUP_NAME, azureGroup);
+
+      AzureLiveTestUtils.defaultProperties(properties);
+      checkNotNull(setIfTestSystemPropertyPresent(properties, 
"oauth.endpoint"), "test.oauth.endpoint");
+
+      return properties;
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/03f72d5e/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureTemplateBuilderLiveTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureTemplateBuilderLiveTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureTemplateBuilderLiveTest.java
new file mode 100644
index 0000000..652c12a
--- /dev/null
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/AzureTemplateBuilderLiveTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.azurecompute.arm.compute;
+
+import com.google.inject.Module;
+import org.jclouds.azurecompute.arm.AzureComputeProviderMetadata;
+import org.jclouds.azurecompute.arm.internal.AzureLiveTestUtils;
+import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.Test;
+
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import com.google.common.collect.ImmutableSet;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static 
org.jclouds.azurecompute.arm.config.AzureComputeProperties.RESOURCE_GROUP_NAME;
+import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
+import static 
org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_SCRIPT_COMPLETE;
+
+@Test(groups = "live", testName = "AzureTemplateBuilderLiveTest")
+public class AzureTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
+   public String azureGroup;
+
+   @Override
+   protected Set<String> getIso3166Codes() {
+      return ImmutableSet.of("US-IA", "US-VA", "US-IL", "US-TX", "US-CA", 
"IE", "NL", "HK", "SG", "JP-11", "JP-27", "BR", "AU-NSW", "AU-VIC");
+   }
+
+   public AzureTemplateBuilderLiveTest() {
+      provider = "azurecompute-arm";
+   }
+
+   @Override
+   protected Module getSshModule() {
+      return new SshjSshClientModule();
+   }
+
+   @Override
+   protected ProviderMetadata createProviderMetadata() {
+      AzureComputeProviderMetadata pm = 
AzureComputeProviderMetadata.builder().build();
+      return pm;
+   }
+
+   @Override
+   protected Properties setupProperties() {
+      azureGroup = "jc" + System.getProperty("user.name").substring(0, 3);
+      Properties properties = super.setupProperties();
+      long scriptTimeout = TimeUnit.MILLISECONDS.convert(20, TimeUnit.MINUTES);
+      properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, scriptTimeout + "");
+      properties.setProperty(TIMEOUT_NODE_RUNNING, scriptTimeout + "");
+      properties.put(RESOURCE_GROUP_NAME, azureGroup);
+
+      AzureLiveTestUtils.defaultProperties(properties);
+      checkNotNull(setIfTestSystemPropertyPresent(properties, 
"oauth.endpoint"), "test.oauth.endpoint");
+
+      return properties;
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/03f72d5e/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
new file mode 100644
index 0000000..70f2ad6
--- /dev/null
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.azurecompute.arm.features;
+
+import org.jclouds.azurecompute.arm.domain.ResourceProviderMetaData;
+import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+@Test(groups = "unit", testName = "NetworkInterfaceCardApiMockTest", 
singleThreaded = true)
+public class ResourceProviderAPIMockTest extends BaseAzureComputeApiMockTest {
+
+   final String apiVersion = "2015-01-01";
+   final String resource = "Microsoft.Compute";
+   private final String vm_resource = "virtualMachines";
+
+   public void getPublicIPAddressInfo() throws InterruptedException {
+      server.enqueue(jsonResponse("/getresourceprovidermetadata.json"));
+
+      final ResourceProviderApi resourceProviderApi = 
api.getResourceProviderApi();
+
+      List<ResourceProviderMetaData> metaDatas = 
resourceProviderApi.get(resource);
+
+      String path = 
String.format("/subscriptions/SUBSCRIPTIONID/providers/%s?api-version=%s", 
resource, apiVersion);
+
+      assertSent(server, "GET", path);
+      assertTrue(metaDatas.size() > 0);
+      ResourceProviderMetaData md = metaDatas.get(0);
+
+      assertEquals(md.resourceType(), "availabilitySets");
+      assertEquals(md.locations().get(0), "East US");
+      assertEquals(md.apiVersions().get(0), "2016-03-30");
+   }
+
+   public void getPublicIPAddressInfoEmpty() throws InterruptedException {
+      server.enqueue(response404());
+
+      final ResourceProviderApi resourceProviderApi = 
api.getResourceProviderApi();
+
+      List<ResourceProviderMetaData> metaDatas = 
resourceProviderApi.get(resource);
+
+      String path = 
String.format("/subscriptions/SUBSCRIPTIONID/providers/%s?api-version=%s", 
resource, apiVersion);
+
+      assertSent(server, "GET", path);
+      assertNull(metaDatas);
+   }
+}
+

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/03f72d5e/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderApiLiveTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderApiLiveTest.java
new file mode 100644
index 0000000..5ebf996
--- /dev/null
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderApiLiveTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.azurecompute.arm.features;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import org.jclouds.azurecompute.arm.domain.ResourceProviderMetaData;
+import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+
+@Test(groups = "live", testName = "ResourceProviderApiLiveTest")
+public class ResourceProviderApiLiveTest extends BaseAzureComputeApiLiveTest {
+
+   private final String PROVIDER = "Microsoft.Compute";
+   private final String VM_RESOURCE_TYPE = "virtualMachines";
+
+   private ResourceProviderApi api() {
+      return api.getResourceProviderApi();
+   }
+
+   @Test
+   public void testGetComputeProviderMetadata() {
+
+      List<ResourceProviderMetaData> resourceProviderMetaDatas = 
api().get(PROVIDER);
+
+      assertNotNull(resourceProviderMetaDatas);
+
+      assertTrue(Iterables.any(resourceProviderMetaDatas, new 
Predicate<ResourceProviderMetaData>() {
+         @Override
+         public boolean apply(final ResourceProviderMetaData providerMetaData) 
{
+            return providerMetaData.resourceType().equals(VM_RESOURCE_TYPE);
+         }
+      }));
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/03f72d5e/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AbstractAzureComputeApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AbstractAzureComputeApiLiveTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AbstractAzureComputeApiLiveTest.java
index bd55694..337812b 100644
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AbstractAzureComputeApiLiveTest.java
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/AbstractAzureComputeApiLiveTest.java
@@ -17,20 +17,19 @@
 package org.jclouds.azurecompute.arm.internal;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static 
org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_POLL_INITIAL_PERIOD;
-import static 
org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_POLL_MAX_PERIOD;
-import static 
org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_TIMEOUT;
-import static 
org.jclouds.azurecompute.arm.config.AzureComputeProperties.TCP_RULE_FORMAT;
-import static 
org.jclouds.azurecompute.arm.config.AzureComputeProperties.TCP_RULE_REGEXP;
 
 import java.util.Properties;
 import java.util.Random;
+import com.google.inject.Module;
+import com.google.inject.Injector;
+
+
 import org.jclouds.apis.BaseApiLiveTest;
 import org.jclouds.azurecompute.arm.AzureComputeApi;
 import org.jclouds.azurecompute.arm.AzureComputeProviderMetadata;
-import org.jclouds.compute.config.ComputeServiceProperties;
 import org.jclouds.providers.ProviderMetadata;
 
+
 public abstract class AbstractAzureComputeApiLiveTest extends 
BaseApiLiveTest<AzureComputeApi> {
 
    protected static final int RAND = new Random().nextInt(999);
@@ -39,19 +38,16 @@ public abstract class AbstractAzureComputeApiLiveTest 
extends BaseApiLiveTest<Az
       provider = "azurecompute-arm";
    }
 
+   @Override protected AzureComputeApi create(Properties props, 
Iterable<Module> modules) {
+      Injector injector = 
newBuilder().modules(modules).overrides(props).buildInjector();
+      return injector.getInstance(AzureComputeApi.class);
+   }
+
    @Override protected Properties setupProperties() {
       Properties properties = super.setupProperties();
-      properties.put(ComputeServiceProperties.POLL_INITIAL_PERIOD, 1000);
-      properties.put(ComputeServiceProperties.POLL_MAX_PERIOD, 10000);
-      properties.setProperty(OPERATION_TIMEOUT, "60000");
-      properties.setProperty(OPERATION_POLL_INITIAL_PERIOD, "5");
-      properties.setProperty(OPERATION_POLL_MAX_PERIOD, "15");
-      properties.setProperty(TCP_RULE_FORMAT, "tcp_%s-%s");
-      properties.setProperty(TCP_RULE_REGEXP, "tcp_\\d{1,5}-\\d{1,5}");
 
       // for oauth
       AzureLiveTestUtils.defaultProperties(properties);
-      checkNotNull(setIfTestSystemPropertyPresent(properties, 
"jclouds.oauth.resource"), "test.jclouds.oauth.resource");
       checkNotNull(setIfTestSystemPropertyPresent(properties, 
"oauth.endpoint"), "test.oauth.endpoint");
       return properties;
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/03f72d5e/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java
index 900d3e0..bd9adfc 100644
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java
@@ -65,25 +65,6 @@ public class BaseAzureComputeApiLiveTest extends 
AbstractAzureComputeApiLiveTest
 
    private String storageServiceName = null;
 
-
-   protected String getCredential() {
-      String credential = null;
-      if (System.getProperty("test.azurecompute-arm.credential") != null) {
-         credential = System.getProperty("test.azurecompute-arm.credential");
-      }
-      assertNotNull(credential);
-      return credential;
-   }
-
-   protected String getIdentity() {
-      String identity = null;
-      if (System.getProperty("test.azurecompute-arm.identity") != null) {
-         identity = System.getProperty("test.azurecompute-arm.identity");
-      }
-      assertNotNull(identity);
-      return identity;
-   }
-
    protected String getStorageServiceName() {
       if (storageServiceName == null) {
          storageServiceName = String.format("%3.24s",

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/03f72d5e/azurecompute-arm/src/test/resources/getresourceprovidermetadata.json
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/resources/getresourceprovidermetadata.json 
b/azurecompute-arm/src/test/resources/getresourceprovidermetadata.json
new file mode 100644
index 0000000..b7693d7
--- /dev/null
+++ b/azurecompute-arm/src/test/resources/getresourceprovidermetadata.json
@@ -0,0 +1,366 @@
+{
+  "id": "/subscriptions/SUBSCRIPTIONID/providers/Microsoft.Compute",
+  "namespace": "Microsoft.Compute",
+  "authorization": {
+    "applicationId": "12312312-1212-1212-1212-121212121212",
+    "roleDefinitionId": "34534534-272e-4238-8723-123423452224"
+  },
+  "resourceTypes": [
+    {
+      "resourceType": "availabilitySets",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ],
+      "capabilities": "CrossResourceGroupResourceMove, 
CrossSubscriptionResourceMove"
+    },
+    {
+      "resourceType": "virtualMachines",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ],
+      "capabilities": "CrossResourceGroupResourceMove, 
CrossSubscriptionResourceMove"
+    },
+    {
+      "resourceType": "virtualMachines/extensions",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ],
+      "capabilities": "CrossResourceGroupResourceMove, 
CrossSubscriptionResourceMove"
+    },
+    {
+      "resourceType": "virtualMachines/diagnosticSettings",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2014-04-01"
+      ]
+    },
+    {
+      "resourceType": "virtualMachines/metricDefinitions",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2014-04-01"
+      ]
+    },
+    {
+      "resourceType": "virtualMachineScaleSets",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ],
+      "capabilities": "None"
+    },
+    {
+      "resourceType": "virtualMachineScaleSets/extensions",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ],
+      "capabilities": "CrossResourceGroupResourceMove, 
CrossSubscriptionResourceMove"
+    },
+    {
+      "resourceType": "virtualMachineScaleSets/virtualMachines",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ]
+    },
+    {
+      "resourceType": "virtualMachineScaleSets/networkInterfaces",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ]
+    },
+    {
+      "resourceType": 
"virtualMachineScaleSets/virtualMachines/networkInterfaces",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ]
+    },
+    {
+      "resourceType": "locations",
+      "locations": [],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ]
+    },
+    {
+      "resourceType": "locations/operations",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ]
+    },
+    {
+      "resourceType": "locations/vmSizes",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ]
+    },
+    {
+      "resourceType": "locations/usages",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ]
+    },
+    {
+      "resourceType": "locations/publishers",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ]
+    },
+    {
+      "resourceType": "operations",
+      "locations": [
+        "East US",
+        "East US 2",
+        "West US",
+        "Central US",
+        "North Central US",
+        "South Central US",
+        "North Europe",
+        "West Europe",
+        "East Asia",
+        "Southeast Asia",
+        "Japan East",
+        "Japan West",
+        "Brazil South"
+      ],
+      "apiVersions": [
+        "2016-03-30",
+        "2015-06-15",
+        "2015-05-01-preview"
+      ]
+    }
+  ],
+  "registrationState": "Registered"
+}
\ No newline at end of file

Reply via email to