/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
package com.microsoft.azure.management.appservice;
import com.microsoft.azure.management.resources.fluentcore.arm.Region;
import com.microsoft.rest.RestClient;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
public class SourceControlTests extends AppServiceTest {
private static String WEBAPP_NAME = "";
private static OkHttpClient httpClient = new OkHttpClient.Builder().readTimeout(1, TimeUnit.MINUTES).build();
@Override
protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) {
WEBAPP_NAME = generateRandomResourceName("java-webapp-", 20);
super.initializeClients(restClient, defaultSubscription, domain);
}
@Test
public void canDeploySourceControl() throws Exception {
// Create web app
WebApp webApp = appServiceManager.webApps().define(WEBAPP_NAME)
.withRegion(Region.US_WEST)
.withNewResourceGroup(RG_NAME)
.withNewWindowsPlan(PricingTier.STANDARD_S1)
.defineSourceControl()
.withPublicGitRepository("https://github.com/jianghaolu/azure-site-test")
.withBranch("master")
.attach()
.create();
Assert.assertNotNull(webApp);
if (!IS_MOCKED) {
Response response = curl("http://" + WEBAPP_NAME + "." + "azurewebsites.net");
Assert.assertEquals(200, response.code());
String body = response.body().string();
Assert.assertNotNull(body);
Assert.assertTrue(body.contains("Hello world from linux 4"));
}
}
private static Response curl(String url) throws IOException {
Request request = new Request.Builder().url(url).get().build();
return httpClient.newCall(request).execute();
}
}