blob: b74a2439a1989fe4ec42626e5d6c4ff0def65e78 [file] [log] [blame]
/*
* 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.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.MockWebServer;
import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
import org.jclouds.azurecompute.xml.ListRoleSizesHandlerTest;
import org.testng.annotations.Test;
@Test(groups = "unit", testName = "SubscriptionApiMockTest")
public class SubscriptionApiMockTest extends BaseAzureComputeApiMockTest {
public void testList() throws Exception {
final MockWebServer server = mockAzureManagementServer();
server.enqueue(xmlResponse("/rolesizes.xml"));
try {
final SubscriptionApi api = api(server.getUrl("/")).getSubscriptionApi();
assertEquals(api.listRoleSizes(), ListRoleSizesHandlerTest.expected());
assertSent(server, "GET", "/rolesizes");
} finally {
server.shutdown();
}
}
public void testEmptyList() throws Exception {
final MockWebServer server = mockAzureManagementServer();
server.enqueue(new MockResponse().setResponseCode(404));
try {
final SubscriptionApi api = api(server.getUrl("/")).getSubscriptionApi();
assertTrue(api.listRoleSizes().isEmpty());
assertSent(server, "GET", "/rolesizes");
} finally {
server.shutdown();
}
}
}