本文整理汇总了Java中javax.ws.rs.RedirectionException类的典型用法代码示例。如果您正苦于以下问题:Java RedirectionException类的具体用法?Java RedirectionException怎么用?Java RedirectionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RedirectionException类属于javax.ws.rs包,在下文中一共展示了RedirectionException类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: downloadLatestVersion
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
@Test( expected = RedirectionException.class )
public void downloadLatestVersion()
throws Exception
{
String id = createAndScanRepo();
try
{
Response response =
getSearchService().redirectToArtifactFile( null, "org.apache.archiva", "archiva-test", "LATEST", null,
null );
}
catch ( RedirectionException e )
{
Assertions.assertThat( e.getLocation().compareTo( new URI( "http://localhost:" + port + "/repository/" + id
+ "/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar" ) ) ).isEqualTo(
0 );
throw e;
}
finally
{
getManagedRepositoriesService().deleteManagedRepository( id, false );
}
}
开发者ID:ruikom,项目名称:apache-archiva,代码行数:27,代码来源:DownloadArtifactFromQueryTest.java
示例2: getWebApplicationExceptionClass
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
public static Class<? extends WebApplicationException> getWebApplicationExceptionClass(Response response) {
int status = response.getStatus();
final Class<? extends WebApplicationException> exceptionType = EXCEPTIONS_MAP.get(status);
if (exceptionType == null) {
final int family = status / 100;
switch (family) {
case 3:
return RedirectionException.class;
case 4:
return ClientErrorException.class;
case 5:
return ServerErrorException.class;
default:
return WebApplicationException.class;
}
}
return exceptionType;
}
开发者ID:Microbule,项目名称:microbule,代码行数:19,代码来源:WebApplicationExceptions.java
示例3: testCreateException
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
@Test
public void testCreateException() {
assertExceptionType(Response.Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class);
assertExceptionType(Response.Status.NOT_FOUND, NotFoundException.class);
assertExceptionType(Response.Status.FORBIDDEN, ForbiddenException.class);
assertExceptionType(Response.Status.BAD_REQUEST, BadRequestException.class);
assertExceptionType(Response.Status.METHOD_NOT_ALLOWED, NotAllowedException.class);
assertExceptionType(Response.Status.UNAUTHORIZED, NotAuthorizedException.class);
assertExceptionType(Response.Status.NOT_ACCEPTABLE, NotAcceptableException.class);
assertExceptionType(Response.Status.UNSUPPORTED_MEDIA_TYPE, NotSupportedException.class);
assertExceptionType(Response.Status.SERVICE_UNAVAILABLE, ServiceUnavailableException.class);
assertExceptionType(Response.Status.TEMPORARY_REDIRECT, RedirectionException.class);
assertExceptionType(Response.Status.LENGTH_REQUIRED, ClientErrorException.class);
assertExceptionType(Response.Status.BAD_GATEWAY, ServerErrorException.class);
assertExceptionType(Response.Status.NO_CONTENT, WebApplicationException.class);
}
开发者ID:Microbule,项目名称:microbule,代码行数:17,代码来源:AbstractErrorResponseStrategyTest.java
示例4: redirect
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
@GET
@Path("redirect/{status}")
public Response redirect(@PathParam("status") int status) {
if (status == 307) {
throw new RedirectionException(status, URI.create("hello"));
}
return Response.status(status).header("Location", "/hello").build();
}
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:9,代码来源:TestResource.java
示例5: downloadFixedVersion
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
@Test( expected = RedirectionException.class )
public void downloadFixedVersion()
throws Exception
{
String id = createAndScanRepo();
try
{
Response response =
getSearchService().redirectToArtifactFile( null, "org.apache.archiva", "archiva-test", "1.0", null,
null );
}
catch ( RedirectionException e )
{
Assertions.assertThat( e.getLocation().compareTo( new URI( "http://localhost:" + port + "/repository/" + id
+ "/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar" ) ) ).isEqualTo(
0 );
throw e;
}
finally
{
getManagedRepositoriesService().deleteManagedRepository( id, false );
}
}
开发者ID:ruikom,项目名称:apache-archiva,代码行数:28,代码来源:DownloadArtifactFromQueryTest.java
示例6: getStoriesById
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
/**
* Given (up to MAX_ITEMS_PER_LISTING_PAGE) story ids,
* fetch the latest information about those stories in bulk and return a hashmap of (story id -> story)
*
* @param storyShortIds list of SHORT reddit story ids to fetch (can be max MAX_ITEMS_PER_LISTING_PAGE) size
* @return map of story id -> story pairs, not guaranteed though to exist
* @throws RedditClientException
*/
@Nonnull
public Map<String, RedditStory> getStoriesById(@Nonnull final Set<String> storyShortIds) throws RedditClientException {
Preconditions.checkArgument(storyShortIds.size() <= MAX_ITEMS_PER_LISTING_PAGE,
"Cannot request more than " + MAX_ITEMS_PER_LISTING_PAGE + " stories by id at a given time");
Preconditions.checkArgument(storyShortIds.size() > 0, "Empty list of ids passed to getStoriesById");
final Set<String> storyLongIds = new HashSet<>(storyShortIds.size());
for (final String storyId : storyShortIds) storyLongIds.add(RedditKind.STORY.getKey() + "_" + storyId);
final RedditListing<RedditStory> stories;
try {
//fetch listing of all stories
final JsonNode jsonNodeResponse = redditEndpoint.path("/by_id/" + Joiner.on(",").join(storyLongIds) + ".json")
.queryParam("limit", MAX_ITEMS_PER_LISTING_PAGE)
.request(MediaType.APPLICATION_JSON)
.get(JsonNode.class);
stories = new RedditListing<>(jsonNodeResponse, RedditStory.class);
} catch (@Nonnull RedirectionException | ProcessingException | ClientErrorException | JsonProcessingException e) {
this.clientExceptionMeter.mark();
throw new RedditClientException(e);
}
//convert to a map
final Map<String, RedditStory> storyMap = new LinkedHashMap<>(storyShortIds.size());
for (final RedditStory story : stories) {
storyMap.put(story.getId(), story);
}
return storyMap;
}
开发者ID:andrewortman,项目名称:reddcrawl,代码行数:39,代码来源:RedditClient.java
示例7: getSubredditByName
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
/**
* Gets the details about a specific subreddit
*
* @param subredditName the subreddit name (eg 'news' or 'gaybros')
* @return RedditSubreddit object
* @throws RedditClientException
*/
public RedditSubreddit getSubredditByName(@Nonnull final String subredditName) throws RedditClientException {
try {
final JsonNode jsonNodeResponse = redditEndpoint.path("/r/" + subredditName + "/about.json")
.request(MediaType.APPLICATION_JSON)
.get(JsonNode.class);
return RedditThing.parseThing(jsonNodeResponse, RedditSubreddit.class);
} catch (@Nonnull RedirectionException | ProcessingException | ClientErrorException e) {
this.clientExceptionMeter.mark();
throw new RedditClientException(e);
}
}
开发者ID:andrewortman,项目名称:reddcrawl,代码行数:19,代码来源:RedditClient.java
示例8: autnum_redirect
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
@Test
public void autnum_redirect() throws Exception {
try {
RestTest.target(getPort(), String.format("rdap/%s", "autnum/100"))
.request(MediaType.APPLICATION_JSON_TYPE)
.get(String.class);
fail();
} catch (final RedirectionException e) {
assertThat(e.getResponse().getHeaders().getFirst("Location").toString(), is("https://rdap.one.net/autnum/100"));
}
}
开发者ID:RIPE-NCC,项目名称:whois,代码行数:12,代码来源:RdapRedirectTestIntegration.java
示例9: inetnum_exact_match_redirect
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
@Test
public void inetnum_exact_match_redirect() {
try {
RestTest.target(getPort(), String.format("rdap/%s", "ip/193.0.0.0/21"))
.request(MediaType.APPLICATION_JSON_TYPE)
.get(String.class);
fail();
} catch (final RedirectionException e) {
assertThat(e.getResponse().getHeaders().getFirst("Location").toString(), is("https://rdap.one.net/ip/193.0.0.0/21"));
}
}
开发者ID:RIPE-NCC,项目名称:whois,代码行数:12,代码来源:RdapRedirectTestIntegration.java
示例10: inetnum_child_redirect
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
@Test
public void inetnum_child_redirect() {
try {
RestTest.target(getPort(), String.format("rdap/%s", "ip/193.0.0.1"))
.request(MediaType.APPLICATION_JSON_TYPE)
.get(String.class);
fail();
} catch (final RedirectionException e) {
assertThat(e.getResponse().getHeaders().getFirst("Location").toString(), is("https://rdap.one.net/ip/193.0.0.1"));
}
}
开发者ID:RIPE-NCC,项目名称:whois,代码行数:12,代码来源:RdapRedirectTestIntegration.java
示例11: inet6num_exact_match_redirect
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
@Test
public void inet6num_exact_match_redirect() {
try {
RestTest.target(getPort(), String.format("rdap/%s", "ip/2001:67c:370::/48"))
.request(MediaType.APPLICATION_JSON_TYPE)
.get(String.class);
fail();
} catch (final RedirectionException e) {
assertThat(e.getResponse().getHeaders().getFirst("Location").toString(), is("https://rdap.one.net/ip/2001:67c:370::/48"));
}
}
开发者ID:RIPE-NCC,项目名称:whois,代码行数:12,代码来源:RdapRedirectTestIntegration.java
示例12: inet6num_child_redirect
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
@Test
public void inet6num_child_redirect() {
try {
RestTest.target(getPort(), String.format("rdap/%s", "ip/2001:67c:370::1234"))
.request(MediaType.APPLICATION_JSON_TYPE)
.get(String.class);
fail();
} catch (final RedirectionException e) {
assertThat(e.getResponse().getHeaders().getFirst("Location").toString(), is("https://rdap.one.net/ip/2001:67c:370::1234"));
}
}
开发者ID:RIPE-NCC,项目名称:whois,代码行数:12,代码来源:RdapRedirectTestIntegration.java
示例13: getStoryListingForSubreddits
import javax.ws.rs.RedirectionException; //导入依赖的package包/类
/**
* Get a story listing for a given set of subreddits
*
* @param subreddits the subreddits to look at
* @param sort the sort style
* @param timeRange the time range to filter on
* @param limit the max number of stories
* @return set of reddit stories found in the search
* @throws RedditClientException
*/
@Nonnull
public Set<RedditStory> getStoryListingForSubreddits(@Nonnull final Set<String> subreddits,
@Nonnull final SortStyle sort,
@Nonnull final TimeRange timeRange,
final int limit) throws RedditClientException {
final Set<RedditStory> stories = new LinkedHashSet<>();
String currentAfter = "";
int lastCount = 0;
while (stories.size() < limit) {
final RedditListing<RedditStory> subListing;
try {
final JsonNode jsonNodeResponse =
redditEndpoint.path("/r/" + Joiner.on("+").join(subreddits) + "/" + sort.toString() + ".json")
.queryParam("limit", MAX_ITEMS_PER_LISTING_PAGE)
.queryParam("after", currentAfter)
.queryParam("t", timeRange.toString())
.request(MediaType.APPLICATION_JSON)
.get(JsonNode.class);
subListing = new RedditListing<>(jsonNodeResponse, RedditStory.class);
} catch (@Nonnull RedirectionException | ProcessingException | ClientErrorException | JsonProcessingException e) {
this.clientExceptionMeter.mark();
throw new RedditClientException(e);
}
if (subListing.getChildren().size() == 0) {
break; //no more listing!
}
for (int i = 0; i < subListing.getChildren().size() && stories.size() < limit; i++) {
stories.add(subListing.getChildren().get(i));
}
if (stories.size() == lastCount) {
break; //no more stories added, fail early
}
lastCount = stories.size();
currentAfter = subListing.getAfter();
}
return stories;
}
开发者ID:andrewortman,项目名称:reddcrawl,代码行数:53,代码来源:RedditClient.java
注:本文中的javax.ws.rs.RedirectionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论