本文整理匯總了Java中com.squareup.okhttp.mockwebserver.MockWebServer.shutdown方法的典型用法代碼示例。如果您正苦於以下問題:Java MockWebServer.shutdown方法的具體用法?Java MockWebServer.shutdown怎麽用?Java MockWebServer.shutdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.squareup.okhttp.mockwebserver.MockWebServer
的用法示例。
在下文中一共展示了MockWebServer.shutdown方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testUpdateConditionOnError
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testUpdateConditionOnError() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/repository-not-exist.json")).setResponseCode(404));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final Long requiredApprover = 1L;
final Matcher matcherSrc = Matcher.create(Matcher.MatcherId.ANY, true);
final Matcher matcherDst = Matcher.create(Matcher.MatcherId.ANY, true);
final List<User> listUser = new ArrayList<>();
listUser.add(User.create(projectKey, testEmail, 1, projectKey, true, projectKey, normalKeyword));
final CreateCondition condition = CreateCondition.create(10L, matcherSrc, matcherDst, listUser, requiredApprover);
final Condition returnCondition = baseApi.defaultReviewersApi().updateCondition(projectKey, "123456", 10L, condition);
assertThat(returnCondition).isNotNull();
assertThat(returnCondition.errors()).isNotEmpty();
assertThat(returnCondition.errors().size()).isEqualTo(1);
assertSent(server, "PUT", defaultReviewersPath + BitbucketApiMetadata.API_VERSION
+ projectsPath + projectKey + "/repos/123456/condition/10");
} finally {
server.shutdown();
}
}
示例2: testGetListUserByGroup
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testGetListUserByGroup() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse()
.setBody(payloadFromResource("/admin-list-user-by-group.json"))
.setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final UserPage up = baseApi.adminApi().listUsersByGroup(localContext, null, 0, 2);
assertThat(up).isNotNull();
assertThat(up.errors()).isEmpty();
assertThat(up.size() == 2).isTrue();
assertThat(up.values().get(0).slug().equals("bob123")).isTrue();
final Map<String, ?> queryParams = ImmutableMap.of("context", localContext, limitKeyword, 2, startKeyword, 0);
assertSent(server, getMethod, restApiPath + BitbucketApiMetadata.API_VERSION
+ "/admin/groups/more-members", queryParams);
} finally {
server.shutdown();
}
}
示例3: testGetBranchModelConfigurationOnError
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testGetBranchModelConfigurationOnError() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/branch-model-configuration-error.json")).setResponseCode(404));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final BranchModelConfiguration configuration = baseApi.branchApi().getModelConfiguration(projectKey, repoKey);
assertThat(configuration).isNotNull();
assertThat(configuration.errors()).isNotEmpty();
assertThat(configuration.production()).isNull();
assertThat(configuration.development()).isNull();
assertSent(server, localGetMethod, localRestPath + BitbucketApiMetadata.API_VERSION
+ localProjectsPath + projectKey + localReposPath + repoKey + branchModelPath);
} finally {
server.shutdown();
}
}
示例4: testDeleteBranchesPermissions
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testDeleteBranchesPermissions() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setResponseCode(204));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final Long idToDelete = 839L;
final RequestStatus success = baseApi.branchApi().deleteBranchRestriction(projectKey, repoKey, idToDelete);
assertThat(success).isNotNull();
assertThat(success.value()).isTrue();
assertThat(success.errors()).isEmpty();
assertSent(server, localDeleteMethod, branchPermissionsPath
+ localProjectsPath + projectKey + localReposPath + repoKey + "/restrictions/" + idToDelete);
} finally {
server.shutdown();
}
}
示例5: testDeleteCondition
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testDeleteCondition() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final RequestStatus success = baseApi.defaultReviewersApi().deleteCondition(projectKey, repoKey, 10L);
assertThat(success).isNotNull();
assertThat(success.value()).isTrue();
assertThat(success.errors()).isEmpty();
assertSent(server, "DELETE", defaultReviewersPath + BitbucketApiMetadata.API_VERSION
+ projectsPath + projectKey + reposPath + repoKey + "/condition/10");
} finally {
server.shutdown();
}
}
示例6: testGetStatusOnError
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testGetStatusOnError() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/build-status-error.json")).setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final StatusPage statusPage = baseApi.buildStatusApi().status(commitHash, 0, 100);
assertThat(statusPage).isNotNull();
assertThat(statusPage.values()).isEmpty();
assertThat(statusPage.errors().size() == 1).isTrue();
final Map<String, ?> queryParams = ImmutableMap.of("limit", 100, "start", 0);
assertSent(server, "GET", restBuildStatusPath + BitbucketApiMetadata.API_VERSION
+ commitPath, queryParams);
} finally {
server.shutdown();
}
}
示例7: testGetSummary
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testGetSummary() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/build-summary.json")).setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final Summary summary = baseApi.buildStatusApi().summary(commitHash);
assertThat(summary).isNotNull();
assertThat(summary.failed() == 1).isTrue();
assertThat(summary.inProgress() == 2).isTrue();
assertThat(summary.successful() == 3).isTrue();
assertSent(server, "GET", restBuildStatusPath + BitbucketApiMetadata.API_VERSION
+ "/commits/stats/306bcf274566f2e89f75ae6f7faf10beff38382012");
} finally {
server.shutdown();
}
}
示例8: testAddBuildStatus
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testAddBuildStatus() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/build-status-post.json")).setResponseCode(204));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final CreateBuildStatus cbs = CreateBuildStatus.create(CreateBuildStatus.STATE.SUCCESSFUL,
"REPO-MASTER",
"REPO-MASTER-42",
"https://bamboo.example.com/browse/REPO-MASTER-42",
"Changes by John Doe");
final RequestStatus success = baseApi.buildStatusApi().add(commitHash, cbs);
assertThat(success).isNotNull();
assertThat(success.value()).isTrue();
assertThat(success.errors()).isEmpty();
assertSent(server, "POST", restBuildStatusPath + BitbucketApiMetadata.API_VERSION
+ commitPath);
} finally {
server.shutdown();
}
}
示例9: testAddBuildStatusOnError
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testAddBuildStatusOnError() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/errors.json")).setResponseCode(404));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final CreateBuildStatus cbs = CreateBuildStatus.create(CreateBuildStatus.STATE.SUCCESSFUL,
"REPO-MASTER",
"REPO-MASTER-42",
"https://bamboo.example.com/browse/REPO-MASTER-42",
"Changes by John Doe");
final RequestStatus success = baseApi.buildStatusApi().add(commitHash, cbs);
assertThat(success).isNotNull();
assertThat(success.value()).isFalse();
assertThat(success.errors()).isNotEmpty();
assertSent(server, "POST", restBuildStatusPath + BitbucketApiMetadata.API_VERSION
+ commitPath);
} finally {
server.shutdown();
}
}
示例10: testCreateCondition
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testCreateCondition() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/default-reviwers-create.json")).setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final Long requiredApprover = 1L;
final Matcher matcherSrc = Matcher.create(Matcher.MatcherId.ANY, true);
final Matcher matcherDst = Matcher.create(Matcher.MatcherId.ANY, true);
final List<User> listUser = new ArrayList<>();
listUser.add(User.create(projectKey, testEmail, 1, projectKey, true, projectKey, normalKeyword));
final CreateCondition condition = CreateCondition.create(null, matcherSrc, matcherDst, listUser, requiredApprover);
final Condition returnCondition = baseApi.defaultReviewersApi().createCondition(projectKey, repoKey, condition);
assertThat(returnCondition).isNotNull();
assertThat(returnCondition.errors()).isEmpty();
assertThat(returnCondition.id()).isEqualTo(3L);
assertSent(server, "POST", defaultReviewersPath + BitbucketApiMetadata.API_VERSION
+ projectsPath + projectKey + reposPath + repoKey + "/condition");
} finally {
server.shutdown();
}
}
示例11: testCreateBranch
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testCreateBranch() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/branch.json")).setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final String branchName = "dev-branch";
final String commitHash = "8d351a10fb428c0c1239530256e21cf24f136e73";
final CreateBranch createBranch = CreateBranch.create(branchName, commitHash, null);
final Branch branch = baseApi.branchApi().create(projectKey, repoKey, createBranch);
assertThat(branch).isNotNull();
assertThat(branch.errors().isEmpty()).isTrue();
assertThat(branch.id().endsWith(branchName)).isTrue();
assertThat(commitHash.equalsIgnoreCase(branch.latestChangeset())).isTrue();
assertSent(server, "POST", localRestPath + BitbucketApiMetadata.API_VERSION
+ localProjectsPath + projectKey + localReposPath + repoKey + localBranchesPath);
} finally {
server.shutdown();
}
}
示例12: testDeleteProjectNonExistent
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testDeleteProjectNonExistent() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse()
.setBody(payloadFromResource("/project-not-exist.json"))
.setResponseCode(404));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final String projectKey = "NOTEXIST";
final RequestStatus success = baseApi.projectApi().delete(projectKey);
assertThat(success).isNotNull();
assertThat(success.value()).isFalse();
assertThat(success.errors()).isNotEmpty();
assertSent(server, "DELETE", "/rest/api/" + BitbucketApiMetadata.API_VERSION + "/projects/" + projectKey);
} finally {
server.shutdown();
}
}
示例13: testGetBranchModelConfiguration
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testGetBranchModelConfiguration() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/branch-model-configuration.json")).setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final BranchModelConfiguration configuration = baseApi.branchApi().getModelConfiguration(projectKey, repoKey);
assertThat(configuration).isNotNull();
assertThat(configuration.errors().isEmpty()).isTrue();
assertThat(configuration.types().size() > 0).isTrue();
assertThat(configuration.development().refId().equals("refs/heads/master")).isTrue();
assertThat(configuration.production()).isNull();
assertSent(server, localGetMethod, localRestPath + BitbucketApiMetadata.API_VERSION
+ localProjectsPath + projectKey + localReposPath + repoKey + branchModelPath);
} finally {
server.shutdown();
}
}
示例14: testListCommits
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testListCommits() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/pull-request-commits.json"))
.setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final CommitPage pcr = baseApi.commitsApi().list(projectKey, repoKey, true, null, null, null, null, null, null, 1, null);
assertThat(pcr).isNotNull();
assertThat(pcr.errors()).isEmpty();
assertThat(pcr.values()).hasSize(1);
assertThat(pcr.totalCount()).isEqualTo(1);
final Map<String, ?> queryParams = ImmutableMap.of("withCounts", true, limitKeyword, 1);
assertSent(server, getMethod, restApiPath + BitbucketApiMetadata.API_VERSION
+ "/projects/PRJ/repos/myrepo/commits", queryParams);
} finally {
server.shutdown();
}
}
示例15: testGetBranchModel
import com.squareup.okhttp.mockwebserver.MockWebServer; //導入方法依賴的package包/類
public void testGetBranchModel() throws Exception {
final MockWebServer server = mockWebServer();
server.enqueue(new MockResponse().setBody(payloadFromResource("/branch-model.json")).setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {
final BranchModel branchModel = baseApi.branchApi().model(projectKey, repoKey);
assertThat(branchModel).isNotNull();
System.out.println(branchModel.errors());
assertThat(branchModel.errors().isEmpty()).isTrue();
assertThat(branchModel.types().size() > 0).isTrue();
assertSent(server, localGetMethod, localRestPath + BitbucketApiMetadata.API_VERSION
+ localProjectsPath + projectKey + localReposPath + repoKey + "/branchmodel");
} finally {
server.shutdown();
}
}