List of usage examples for org.apache.commons.httpclient HttpStatus SC_BAD_REQUEST
int SC_BAD_REQUEST
To view the source code for org.apache.commons.httpclient HttpStatus SC_BAD_REQUEST.
Click Source Link
From source file:org.apache.falcon.regression.lineage.LineageApiTest.java
@Test public void testVerticesFilterBlankKey() throws Exception { Map<String, String> params = new TreeMap<>(); params.put("key", ""); params.put("value", "someValue"); HttpResponse response = lineageHelper .runGetRequest(lineageHelper.getUrl(LineageHelper.URL.VERTICES, params)); String responseString = lineageHelper.getResponseString(response); LOGGER.info(responseString);/* w w w .j a va 2 s. c om*/ Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_BAD_REQUEST, "The get request was a bad request"); Assert.assertTrue(responseString.contains(INVALID_ARGUMENT_STR), "Result should contain string Invalid argument"); }
From source file:org.apache.falcon.regression.lineage.LineageApiTest.java
@Test public void testVertexBadDirection() throws Exception { final int clusterVertexId = lineageHelper.getVertex(clusterMerlin.getName()).getId(); HttpResponse response = lineageHelper.runGetRequest(lineageHelper.getUrl(LineageHelper.URL.VERTICES, lineageHelper.getUrlPath(clusterVertexId, "badDirection"))); final String responseString = lineageHelper.getResponseString(response); LOGGER.info("response: " + response); LOGGER.info("responseString: " + responseString); Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_BAD_REQUEST, "We should not get internal server error"); }
From source file:org.apache.falcon.regression.security.AclValidationTest.java
/** * Test a cluster's acl validations for different aclOwner and aclGroup. * @param aclOwner owner for the acl/*from w w w. j a v a 2 s .c o m*/ * @param aclGroup group for the acl * @throws Exception */ @Test(dataProvider = "generateUserAndGroup") public void submitClusterBadAcl(String aclOwner, String aclGroup) throws Exception { clusterMerlin.setACL(aclOwner, aclGroup, "*"); final ServiceResponse serviceResponse = prism.getClusterHelper().submitEntity(clusterMerlin.toString()); AssertUtil.assertFailedWithStatus(serviceResponse, HttpStatus.SC_BAD_REQUEST, "Cluster's ACL owner should be same as submitting user"); }
From source file:org.apache.falcon.regression.security.AclValidationTest.java
/** * Test a feed's acl validations for different aclOwner and aclGroup. * @param aclOwner owner for the acl// www. java 2 s . c o m * @param aclGroup group for the acl * @throws Exception */ @Test(dataProvider = "generateUserAndGroup") public void submitFeedBadAcl(String aclOwner, String aclGroup) throws Exception { bundles[0].submitClusters(prism); feedMerlin.setACL(aclOwner, aclGroup, "*"); final ServiceResponse serviceResponse = prism.getFeedHelper().submitEntity(feedMerlin.toString()); AssertUtil.assertFailedWithStatus(serviceResponse, HttpStatus.SC_BAD_REQUEST, "Feed's ACL owner should be same as submitting user"); }
From source file:org.apache.falcon.regression.security.AclValidationTest.java
/** * Test a process's acl validations for different aclOwner and aclGroup. * @param aclOwner owner for the acl// w ww . ja va 2 s . c o m * @param aclGroup group for the acl * @throws Exception */ @Test(dataProvider = "generateUserAndGroup") public void submitProcessBadAcl(String aclOwner, String aclGroup) throws Exception { bundles[0].submitAndScheduleAllFeeds(); processMerlin.setACL(aclOwner, aclGroup, "*"); final ServiceResponse serviceResponse = prism.getProcessHelper().submitEntity(processMerlin.toString()); AssertUtil.assertFailedWithStatus(serviceResponse, HttpStatus.SC_BAD_REQUEST, "Process's ACL owner should be same as submitting user"); }
From source file:org.apache.falcon.regression.ValidateAPIPrismAndServerTest.java
/** *Validate a valid process but without workflow present via prism. * Should fail.// w w w. j a v a2s. co m * * @throws Exception */ @Test(groups = "distributed") public void validateValidProcessNoWorkflowOnPrism() throws Exception { prism.getClusterHelper().submitEntity(bundles[0].getClusters().get(0)); prism.getFeedHelper().submitEntity(feed); ServiceResponse response = prism.getProcessHelper().validateEntity(bundles[0].getProcessData()); AssertUtil.assertFailedWithStatus(response, HttpStatus.SC_BAD_REQUEST, "Workflow does not exist"); }
From source file:org.apache.falcon.regression.ValidateAPIPrismAndServerTest.java
/** *Validate a valid process but without workflow present via server. * Should fail./*from ww w . jav a 2 s . c o m*/ * * @throws Exception */ @Test(groups = "embedded") public void validateValidProcessNoWorkflowOnServer() throws Exception { prism.getClusterHelper().submitEntity(bundles[0].getClusters().get(0)); prism.getFeedHelper().submitEntity(feed); ServiceResponse response = cluster.getProcessHelper().validateEntity(bundles[0].getProcessData()); AssertUtil.assertFailedWithStatus(response, HttpStatus.SC_BAD_REQUEST, "Workflow does not exist"); }
From source file:org.artifactory.repo.webdav.WebdavServiceImpl.java
@Override public void handleMove(ArtifactoryRequest request, ArtifactoryResponse response) throws IOException { RepoPath repoPath = request.getRepoPath(); if (StringUtils.isEmpty(repoPath.getPath())) { response.sendError(HttpStatus.SC_BAD_REQUEST, "Cannot perform MOVE action on a repository. " + "Please specify a valid path", log); return;/*w ww . j a v a 2 s. c o m*/ } String destination = URLDecoder.decode(request.getHeader("Destination"), "UTF-8"); if (StringUtils.isEmpty(destination)) { response.sendError(HttpStatus.SC_BAD_REQUEST, "Header 'Destination' is required.", log); return; } String targetPathWithoutContextUrl = StringUtils.remove(destination, request.getServletContextUrl()); String targetPathParent = PathUtils.getParent(targetPathWithoutContextUrl); RepoPath targetPath = InternalRepoPathFactory.create(targetPathParent); if (!authService.canDelete(repoPath) || !authService.canDeploy(targetPath)) { response.sendError(HttpStatus.SC_FORBIDDEN, "Insufficient permissions.", log); return; } MoveMultiStatusHolder status = repoService.move(repoPath, targetPath, false, true, true); if (!status.hasWarnings() && !status.hasErrors()) { response.sendSuccess(); } else { response.sendError(status); } }
From source file:org.artifactory.request.ResponseStatusCodesMapper.java
public int getStatusCode(Throwable e) { if (e instanceof BadPomException) { return HttpStatus.SC_CONFLICT; } else if (e instanceof DoesNotExistException) { return HttpStatus.SC_NOT_FOUND; } else if (e instanceof ItemNotFoundRuntimeException) { return HttpStatus.SC_BAD_REQUEST; } else if (e instanceof RepoRejectException) { return ((RepoRejectException) e).getErrorCode(); } else if (e instanceof IllegalArgumentException) { return HttpStatus.SC_BAD_REQUEST; }// ww w . ja v a 2 s.co m return HttpStatus.SC_INTERNAL_SERVER_ERROR; }
From source file:org.artifactory.rest.resource.search.types.DependencySearchResource.java
@GET @Produces({ SearchRestConstants.MT_DEPENDENCY_BUILDS, MediaType.APPLICATION_JSON }) public Response get(@QueryParam(SearchRestConstants.PARAM_SHA1_CHECKSUM) String sha1) throws IOException { try {/*from www . j a v a 2 s. co m*/ return restAddon.searchDependencyBuilds(request, sha1); } catch (IllegalArgumentException iae) { response.sendError(HttpStatus.SC_BAD_REQUEST, iae.getMessage()); } return null; }