• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ApacheRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.jcabi.http.request.ApacheRequest的典型用法代码示例。如果您正苦于以下问题:Java ApacheRequest类的具体用法?Java ApacheRequest怎么用?Java ApacheRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ApacheRequest类属于com.jcabi.http.request包,在下文中一共展示了ApacheRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: serverIsDown

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * Follow can stay silent if there's an exception.
 * @throws Exception If something goes wrong.
 */
@Test
public void serverIsDown() throws Exception {
    final Command com = this.mockMention();
    Mockito.when(com.issue().repo().github().entry())
        .thenReturn(
            new ApacheRequest("http://localhost:" + this.port() + "/")
        );
    final Log log = Mockito.mock(Log.class);
    final Logger slf4j = Mockito.mock(Logger.class);
    Mockito.when(log.logger()).thenReturn(slf4j);

    new FollowUser(new Step.Fake(true)).perform(com, log);
    
    Mockito.verify(slf4j).info(
        "Following Github user " + com.author() + " ..."
    );
    Mockito.verify(slf4j).warn(
        "IOException while trying to follow the user."
    );
}
 
开发者ID:amihaiemil,项目名称:comdor,代码行数:25,代码来源:FollowUserTestCase.java


示例2: hasGhPagesBranch

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * Returns true if the repository has a gh-pages branch, false otherwise.
 * The result is <b>cached</b> and so the http call to Github API is performed only at the first call.
 * @return true if there is a gh-pages branch, false otherwise.
 * @throws IOException If an error occurs
 *  while communicating with the Github API.
 */
public boolean hasGhPagesBranch() throws IOException {
    try {
        if(this.ghPagesBranch == null) {
            String branchesUrlPattern = this.json().getString("branches_url");
            String ghPagesUrl = branchesUrlPattern.substring(0, branchesUrlPattern.indexOf("{")) + "/gh-pages";
            Request req = new ApacheRequest(ghPagesUrl);
            this.ghPagesBranch = req.fetch().as(RestResponse.class)
                .assertStatus(
                    Matchers.isOneOf(
                        HttpURLConnection.HTTP_OK,
                        HttpURLConnection.HTTP_NOT_FOUND
                    )
                ).status() == HttpURLConnection.HTTP_OK;
            return this.ghPagesBranch;
        }
        return this.ghPagesBranch;
    } catch (AssertionError aerr) {
        throw new IOException ("Unexpected HTTP status response.", aerr);
    }
}
 
开发者ID:opencharles,项目名称:charles-rest,代码行数:28,代码来源:CachedRepo.java


示例3: retrievesKeys

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtPublicKeys should be able to iterate its keys.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void retrievesKeys() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            Json.createArrayBuilder()
                .add(key(1))
                .add(key(2))
                .build().toString()
        )
    ).start();
    final RtPublicKeys keys = new RtPublicKeys(
        new ApacheRequest(container.home()),
        Mockito.mock(User.class)
    );
    MatcherAssert.assertThat(
        keys.iterate(),
        Matchers.<PublicKey>iterableWithSize(2)
    );
    container.stop();
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:27,代码来源:RtPublicKeysTest.java


示例4: canFetchSingleKey

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtPublicKeys should be able to obtain a single key.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void canFetchSingleKey() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            ""
        )
    ).start();
    final RtPublicKeys keys = new RtPublicKeys(
        new ApacheRequest(container.home()),
        Mockito.mock(User.class)
    );
    try {
        MatcherAssert.assertThat(
            keys.get(1),
            Matchers.notNullValue()
        );
    } finally {
        container.stop();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:27,代码来源:RtPublicKeysTest.java


示例5: throwsIfNoMoreElement

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtPagination can throw if there is no more elements in pagination.
 *
 * @throws Exception if there is any problem
 */
@Test(expected = NoSuchElementException.class)
public void throwsIfNoMoreElement() throws Exception {
    final MkContainer container = new MkGrizzlyContainer()
        .next(simple("Hi there")).start();
    try {
        final Request request = new ApacheRequest(container.home());
        final RtPagination<JsonObject> page = new RtPagination<JsonObject>(
            request,
            new RtValuePagination.Mapping<JsonObject, JsonObject>() {
                @Override
                public JsonObject map(final JsonObject object) {
                    return object;
                }
            }
        );
        final Iterator<JsonObject> iterator = page.iterator();
        iterator.next();
        MatcherAssert.assertThat(
            iterator.next(),
            Matchers.notNullValue()
        );
    } finally {
        container.stop();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:31,代码来源:RtPaginationTest.java


示例6: checkIfRepoStarred

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtStars can check if repo is starred.
 *
 * @throws Exception If something goes wrong.
 */
@Test
public void checkIfRepoStarred() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT)
    ).next(new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_FOUND))
        .start();
    try {
        final Stars starred = new RtStars(
            new ApacheRequest(container.home()),
            RtStarsTest.repo("someuser", "starredrepo")
        );
        MatcherAssert.assertThat(
            starred.starred(), Matchers.is(true)
        );
        final Stars unstarred = new RtStars(
            new ApacheRequest(container.home()),
            RtStarsTest.repo("otheruser", "notstarredrepo")
        );
        MatcherAssert.assertThat(
            unstarred.starred(), Matchers.is(false)
        );
    } finally {
        container.stop();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:31,代码来源:RtStarsTest.java


示例7: givesToString

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * This tests that the toString() method is working fine.
 * @throws Exception - if anything goes wrong.
 */
@Test
public void givesToString() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "")
    ).start();
    final Repo repo = new MkGithub().randomRepo();
    final Issue issue = repo.issues().create("testing6", "issue6");
    final RtComment comment = new RtComment(
        new ApacheRequest(container.home()), issue, 10
    );
    try {
        final String stringComment = comment.toString();
        MatcherAssert.assertThat(
            stringComment, Matchers.not(Matchers.isEmptyOrNullString())
        );
        MatcherAssert.assertThat(stringComment, Matchers.endsWith("10"));
    } finally {
        container.stop();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:25,代码来源:RtCommentTest.java


示例8: iteratePulls

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtPulls can iterate pulls.
 * @throws Exception if there is any error
 */
@Test
public void iteratePulls() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            Json.createArrayBuilder()
                .add(pull("new-topic"))
                .add(pull("Amazing new feature"))
                .build().toString()
        )
    ).start();
    final RtPulls pulls = new RtPulls(
        new ApacheRequest(container.home()),
        repo()
    );
    MatcherAssert.assertThat(
        pulls.iterate(new ArrayMap<String, String>()),
        Matchers.<Pull>iterableWithSize(2)
    );
    container.stop();
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:26,代码来源:RtPullsTest.java


示例9: canFetchNonEmptyListOfDeployKeys

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtDeployKeys can fetch non empty list of deploy keys.
 *
 * @throws IOException If some problem inside.
 */
@Test
public void canFetchNonEmptyListOfDeployKeys() throws IOException {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            Json.createArrayBuilder()
                .add(key(1))
                .add(key(2))
                .build().toString()
        )
    );
    container.start();
    try {
        MatcherAssert.assertThat(
            new RtDeployKeys(
                new ApacheRequest(container.home()),
                RtDeployKeysTest.repo()
            ).iterate(),
            Matchers.<DeployKey>iterableWithSize(2)
        );
    } finally {
        container.stop();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:30,代码来源:RtDeployKeysTest.java


示例10: canCreateDeployKey

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtDeployKeys can create a key.
 * @throws IOException If some problem inside.
 */
@Test
public void canCreateDeployKey() throws IOException {
    final int number = 2;
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_CREATED,
            String.format("{\"id\":%d}", number)
        )
    );
    container.start();
    try {
        final DeployKeys keys = new RtDeployKeys(
            new ApacheRequest(container.home()), RtDeployKeysTest.repo()
        );
        MatcherAssert.assertThat(
            keys.create("Title", "Key").number(),
            Matchers.equalTo(number)
        );
    } finally {
        container.stop();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:27,代码来源:RtDeployKeysTest.java


示例11: executePatchRequest

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtUser can execute PATCH request.
 *
 * @throws Exception if there is any problem
 */
@Test
public void executePatchRequest() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_OK,
            "{\"login\":\"octocate\"}"
        )
    ).start();
    final RtUser json = new RtUser(
        Mockito.mock(Github.class),
        new ApacheRequest(container.home())
    );
    json.patch(
        Json.createObjectBuilder()
            .add("location", "San Francisco")
            .build()
    );
    MatcherAssert.assertThat(
        container.take().method(),
        Matchers.equalTo(Request.PATCH)
    );
    container.stop();
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:29,代码来源:RtUserTest.java


示例12: canDeleteDeployKey

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtDeployKey can delete a deploy key.
 *
 * @throws Exception If some problem inside.
 */
@Test
public void canDeleteDeployKey() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_NO_CONTENT,
            ""
        )
    ).start();
    final DeployKey key = new RtDeployKey(
        new ApacheRequest(container.home()),
        3,
        RtDeployKeyTest.repo()
    );
    key.remove();
    final MkQuery query = container.take();
    MatcherAssert.assertThat(
        query.method(),
        Matchers.equalTo(Request.DELETE)
    );
    container.stop();
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:27,代码来源:RtDeployKeyTest.java


示例13: removesAsset

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtReleaseAsset can remove itself.
 * @throws Exception If a problem occurs.
 */
@Test
public void removesAsset() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")
    ).start();
    final RtReleaseAsset asset = new RtReleaseAsset(
        new ApacheRequest(container.home()),
        release(),
        3
    );
    try {
        asset.remove();
        final MkQuery query = container.take();
        MatcherAssert.assertThat(
            query.method(),
            Matchers.equalTo(Request.DELETE)
        );
    } finally {
        container.stop();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:26,代码来源:RtReleaseAssetTest.java


示例14: rawAsset

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtReleaseAsset can stream raw content.
 * @throws Exception If a problem occurs.
 */
@Test
public void rawAsset() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "")
    ).start();
    final RtReleaseAsset asset = new RtReleaseAsset(
        new ApacheRequest(container.home()),
        release(),
        4
    );
    try {
        final InputStream stream = asset.raw();
        final MkQuery query = container.take();
        MatcherAssert.assertThat(
            query.method(), Matchers.equalTo(Request.GET)
        );
        MatcherAssert.assertThat(
            IOUtils.toString(stream),
            Matchers.notNullValue()
        );
    } finally {
        container.stop();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:29,代码来源:RtReleaseAssetTest.java


示例15: addsEmails

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtUserEmails can add emails.
 * @throws Exception If some problem inside
 */
@Test
public void addsEmails() throws Exception {
    final String email = "[email protected]";
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(
            HttpURLConnection.HTTP_CREATED,
            String.format("[{\"email\":\"%s\"}]", email)
        )
    );
    container.start();
    try {
        final UserEmails emails = new RtUserEmails(
            new ApacheRequest(container.home())
        );
        MatcherAssert.assertThat(
            emails.add(Collections.singletonList(email)).iterator().next(),
            Matchers.equalTo(email)
        );
    } finally {
        container.stop();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:27,代码来源:RtUserEmailsTest.java


示例16: sendHttpRequestAndWriteResponseAsJson

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtLabel can  can fetch HTTP request and describe response as a JSON.
 *
 * @throws Exception if there is any problem
 */
@Test
public void sendHttpRequestAndWriteResponseAsJson() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"msg\": \"hi\"}")
    ).start();
    final RtLabel label = new RtLabel(
        new ApacheRequest(container.home()),
        RtLabelTest.repo(),
        "bug"
    );
    MatcherAssert.assertThat(
        label.json().getString("msg"),
        Matchers.equalTo("hi")
    );
    container.stop();
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:22,代码来源:RtLabelTest.java


示例17: executePatchRequest

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * GhLabel can execute PATCH request.
 *
 * @throws Exception if there is any problem
 */
@Test
public void executePatchRequest() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_OK, "{\"msg\":\"hi\"}")
    ).start();
    final RtLabel label = new RtLabel(
        new ApacheRequest(container.home()),
        RtLabelTest.repo(),
        "enhance"
    );
    label.patch(
        Json.createObjectBuilder()
            .add("content", "hi you!")
            .build()
    );
    MatcherAssert.assertThat(
        container.take().method(),
        Matchers.equalTo(Request.PATCH)
    );
    container.stop();
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:27,代码来源:RtLabelTest.java


示例18: deleteMilestone

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtMilestones can remove a milestone.
 * @throws Exception if some problem inside
 */
@Test
public void deleteMilestone() throws Exception {
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_NO_CONTENT, "")
    ).start();
    try {
        final RtMilestones milestones = new RtMilestones(
            new ApacheRequest(container.home()),
            repo()
        );
        milestones.remove(1);
        MatcherAssert.assertThat(
            container.take().method(),
            Matchers.equalTo(Request.DELETE)
        );
    } finally {
        container.stop();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:24,代码来源:RtMilestonesTest.java


示例19: fetchesRawContent

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtContent should be able to fetch raw content.
 *
 * @throws Exception if a problem occurs.
 */
@Test
public void fetchesRawContent() throws Exception {
    final String raw = "the raw \u20ac";
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_OK, raw)
    ).start();
    final InputStream stream = new RtContent(
        new ApacheRequest(container.home()),
        this.repo(),
        "raw"
    ).raw();
    try {
        MatcherAssert.assertThat(
            IOUtils.toString(stream, Charsets.UTF_8),
            Matchers.is(raw)
        );
        MatcherAssert.assertThat(
            container.take().headers().get(HttpHeaders.ACCEPT).get(0),
            Matchers.is("application/vnd.github.v3.raw")
        );
    } finally {
        stream.close();
        container.stop();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:31,代码来源:RtContentTest.java


示例20: createRepo

import com.jcabi.http.request.ApacheRequest; //导入依赖的package包/类
/**
 * RtRepos can create a repo.
 * @throws Exception if some problem inside
 */
@Test
public void createRepo() throws Exception {
    final String owner = "test-owner";
    final String name = "test-repo";
    final String response = response(owner, name).toString();
    final MkContainer container = new MkGrizzlyContainer().next(
        new MkAnswer.Simple(HttpURLConnection.HTTP_CREATED, response)
    ).next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK, response))
        .start();
    final RtRepos repos = new RtRepos(
        Mockito.mock(Github.class),
        new ApacheRequest(container.home())
    );
    final Repo repo = this.rule.repo(repos);
    MatcherAssert.assertThat(
        container.take().method(),
        Matchers.equalTo(Request.POST)
    );
    MatcherAssert.assertThat(
        repo.coordinates(),
        Matchers.equalTo((Coordinates) new Coordinates.Simple(owner, name))
    );
    container.stop();
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:29,代码来源:RtReposTest.java



注:本文中的com.jcabi.http.request.ApacheRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SelectionHandleController类代码示例发布时间:2022-05-22
下一篇:
Java SherlockExpandableListActivity类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap