org.apache.commons.httpclient.methods.GetMethod Java Examples
The following examples show how to use
org.apache.commons.httpclient.methods.GetMethod.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NetworkUtil.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
public static byte[] loadUrlData(String url) throws Exception { HttpClient httpClient = new HttpClient(); setHttpClientProxyFromSystem(httpClient, url); GetMethod get = new GetMethod(url); get.setFollowRedirects(true); try { httpClient.getParams().setParameter("http.connection.timeout", 5000); int httpReturnCode = httpClient.executeMethod(get); if (httpReturnCode == 200) { // Don't use get.getResponseBody, it causes a warning in log try (InputStream inputStream = get.getResponseBodyAsStream()) { return IOUtils.toByteArray(inputStream); } } else { throw new Exception("ERROR: Received httpreturncode " + httpReturnCode); } } finally { get.releaseConnection(); } }
Example #2
Source File: PortFactory.java From development with Apache License 2.0 | 6 votes |
/** * Retrieves the content under the given URL with username and passwort * authentication. * * @param url * @param username * @param password * @return * @throws IOException */ private static byte[] getUrlContent(URL url, String username, String password) throws IOException { final HttpClient client = new HttpClient(); // Set credentials: client.getParams().setAuthenticationPreemptive(true); final Credentials credentials = new UsernamePasswordCredentials( username, password); client.getState() .setCredentials( new AuthScope(url.getHost(), url.getPort(), AuthScope.ANY_REALM), credentials); // Retrieve content: final GetMethod method = new GetMethod(url.toString()); final int status = client.executeMethod(method); if (status != HttpStatus.SC_OK) { throw new IOException("Error " + status + " while retrieving " + url); } return method.getResponseBody(); }
Example #3
Source File: JumpToCodeClient.java From otroslogviewer with Apache License 2.0 | 6 votes |
private HttpMethod buildMethod(String url, LocationInfo locationInfo, HttpOperation httpOperation) { HttpMethod method = new GetMethod(url); ArrayList<NameValuePair> list = new ArrayList<>(5); list.add(new NameValuePair("o", httpOperation.getOperation())); locationInfo.getPackageName().ifPresent(p -> list.add(new NameValuePair("p", p))); locationInfo.getClassName().ifPresent(p -> list.add(new NameValuePair("c", p))); locationInfo.getFileName().ifPresent(p -> list.add(new NameValuePair("f", p))); locationInfo.getMessage().ifPresent(m -> list.add(new NameValuePair("m", m))); locationInfo.getLineNumber().map(i -> Integer.toString(i)).ifPresent(l -> list.add(new NameValuePair("l", l))); NameValuePair[] pair = list.toArray(new NameValuePair[0]); method.setQueryString(pair); return method; }
Example #4
Source File: MailUtils.java From document-management-system with GNU General Public License v2.0 | 6 votes |
/** * User tinyurl service as url shorter Depends on commons-httpclient:commons-httpclient:jar:3.0 because of * org.apache.jackrabbit:jackrabbit-webdav:jar:1.6.4 */ public static String getTinyUrl(String fullUrl) throws HttpException, IOException { HttpClient httpclient = new HttpClient(); // Prepare a request object HttpMethod method = new GetMethod("http://tinyurl.com/api-create.php"); method.setQueryString(new NameValuePair[]{new NameValuePair("url", fullUrl)}); httpclient.executeMethod(method); InputStreamReader isr = new InputStreamReader(method.getResponseBodyAsStream(), "UTF-8"); StringWriter sw = new StringWriter(); int c; while ((c = isr.read()) != -1) sw.write(c); isr.close(); method.releaseConnection(); return sw.toString(); }
Example #5
Source File: SubmarineServerTest.java From submarine with Apache License 2.0 | 6 votes |
@Test // SUBMARINE-422. Fix refreshing page returns 404 error public void testRefreshingURL() throws IOException { ArrayList<String> arrUrls = new ArrayList(); arrUrls.add("/user/login"); arrUrls.add("/workbench/manager/user"); for (int i = 0; i < arrUrls.size(); i++) { GetMethod response = httpGet(arrUrls.get(i)); LOG.info(response.toString()); String requestBody = response.getResponseBodyAsString(); LOG.info(requestBody); assertFalse(requestBody.contains("Error 404 Not Found")); } }
Example #6
Source File: HttpUtil.java From OfficeAutomatic-System with Apache License 2.0 | 6 votes |
public static String sendGet(String urlParam) throws HttpException, IOException { // 创建httpClient实例对象 HttpClient httpClient = new HttpClient(); // 设置httpClient连接主机服务器超时时间:15000毫秒 httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(15000); // 创建GET请求方法实例对象 GetMethod getMethod = new GetMethod(urlParam); // 设置post请求超时时间 getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 60000); getMethod.addRequestHeader("Content-Type", "application/json"); httpClient.executeMethod(getMethod); String result = getMethod.getResponseBodyAsString(); getMethod.releaseConnection(); return result; }
Example #7
Source File: StressTestDirectAttach.java From cloudstack with Apache License 2.0 | 6 votes |
private static String executeRegistration(String server, String username, String password) throws HttpException, IOException { String url = server + "?command=registerUserKeys&id=" + s_userId.get().toString(); s_logger.info("registering: " + username); String returnValue = null; HttpClient client = new HttpClient(); HttpMethod method = new GetMethod(url); int responseCode = client.executeMethod(method); if (responseCode == 200) { InputStream is = method.getResponseBodyAsStream(); Map<String, String> requestKeyValues = getSingleValueFromXML(is, new String[] {"apikey", "secretkey"}); s_apiKey.set(requestKeyValues.get("apikey")); returnValue = requestKeyValues.get("secretkey"); } else { s_logger.error("registration failed with error code: " + responseCode); } return returnValue; }
Example #8
Source File: DirAccessTest.java From zeppelin with Apache License 2.0 | 6 votes |
@Test public void testDirAccessOk() throws Exception { synchronized (this) { try { System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED .getVarName(), "true"); AbstractTestRestApi.startUp(DirAccessTest.class.getSimpleName()); HttpClient httpClient = new HttpClient(); GetMethod getMethod = new GetMethod(getUrlToTest() + "/app/"); LOG.info("Invoke getMethod"); httpClient.executeMethod(getMethod); assertEquals(getMethod.getResponseBodyAsString(), HttpStatus.SC_OK, getMethod.getStatusCode()); } finally { AbstractTestRestApi.shutDown(); } } }
Example #9
Source File: GetRouteByGuidCommand.java From orion.server with Eclipse Public License 1.0 | 6 votes |
public ServerStatus _doIt() { try { URI targetURI = URIUtil.toURI(getCloud().getUrl()); // Get the app URI appsURI = targetURI.resolve("/v2/routes/" + routeGuid); GetMethod getRoutesMethod = new GetMethod(appsURI.toString()); ServerStatus confStatus = HttpUtil.configureHttpMethod(getRoutesMethod, getCloud()); if (!confStatus.isOK()) return confStatus; ServerStatus getStatus = HttpUtil.executeMethod(getRoutesMethod); if (!getStatus.isOK()) return getStatus; JSONObject routeJSON = getStatus.getJsonData(); this.route = new Route().setCFJSON(routeJSON); return new ServerStatus(Status.OK_STATUS, HttpServletResponse.SC_OK, this.route.toJSON()); } catch (Exception e) { String msg = NLS.bind("An error occured when performing operation {0}", commandName); //$NON-NLS-1$ logger.error(msg, e); return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e); } }
Example #10
Source File: HeliumRestApiTest.java From zeppelin with Apache License 2.0 | 6 votes |
@Test public void testEnableDisablePackage() throws IOException { String packageName = "name1"; PostMethod post1 = httpPost("/helium/enable/" + packageName, ""); assertThat(post1, isAllowed()); post1.releaseConnection(); GetMethod get1 = httpGet("/helium/package/" + packageName); Map<String, Object> resp1 = gson.fromJson(get1.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); List<StringMap<Object>> body1 = (List<StringMap<Object>>) resp1.get("body"); assertEquals(body1.get(0).get("enabled"), true); PostMethod post2 = httpPost("/helium/disable/" + packageName, ""); assertThat(post2, isAllowed()); post2.releaseConnection(); GetMethod get2 = httpGet("/helium/package/" + packageName); Map<String, Object> resp2 = gson.fromJson(get2.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); List<StringMap<Object>> body2 = (List<StringMap<Object>>) resp2.get("body"); assertEquals(body2.get(0).get("enabled"), false); }
Example #11
Source File: UserMgmtITCase.java From olat with Apache License 2.0 | 6 votes |
@Test public void testFindUsersByLogin() throws IOException { final HttpClient c = loginWithCookie("administrator", "olat"); final GetMethod method = createGet("/users", MediaType.APPLICATION_JSON, true); method.setQueryString(new NameValuePair[] { new NameValuePair("login", "administrator"), new NameValuePair("authProvider", "OLAT") }); final int code = c.executeMethod(method); assertEquals(code, 200); final String body = method.getResponseBodyAsString(); method.releaseConnection(); final List<UserVO> vos = parseUserArray(body); final String[] authProviders = new String[] { "OLAT" }; final List<Identity> identities = securityManager.getIdentitiesByPowerSearch("administrator", null, true, null, null, authProviders, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT); assertNotNull(vos); assertFalse(vos.isEmpty()); assertEquals(vos.size(), identities.size()); boolean onlyLikeAdmin = true; for (final UserVO vo : vos) { if (!vo.getLogin().startsWith("administrator")) { onlyLikeAdmin = false; } } assertTrue(onlyLikeAdmin); }
Example #12
Source File: YarnRestJobStatusProvider.java From samza with Apache License 2.0 | 6 votes |
/** * Issues a HTTP Get request to the provided url and returns the response * @param requestUrl the request url * @return the response * @throws IOException if there are problems with the http get request. */ byte[] httpGet(String requestUrl) throws IOException { GetMethod getMethod = new GetMethod(requestUrl); try { int responseCode = this.httpClient.executeMethod(getMethod); LOGGER.debug("Received response code: {} for the get request on the url: {}", responseCode, requestUrl); byte[] response = getMethod.getResponseBody(); if (responseCode != HttpStatus.SC_OK) { throw new SamzaException( String.format("Received response code: %s for get request on: %s, with message: %s.", responseCode, requestUrl, StringUtils.newStringUtf8(response))); } return response; } finally { getMethod.releaseConnection(); } }
Example #13
Source File: WebAPI.java From h2o-2 with Apache License 2.0 | 6 votes |
/** * Exports a model to a JSON file. */ static void exportModel() throws Exception { HttpClient client = new HttpClient(); GetMethod get = new GetMethod(URL + "/2/ExportModel.json?model=MyInitialNeuralNet"); int status = client.executeMethod(get); if( status != 200 ) throw new Exception(get.getStatusText()); JsonObject response = (JsonObject) new JsonParser().parse(new InputStreamReader(get.getResponseBodyAsStream())); JsonElement model = response.get("model"); JsonWriter writer = new JsonWriter(new FileWriter(JSON_FILE)); writer.setLenient(true); writer.setIndent(" "); Streams.write(model, writer); writer.close(); get.releaseConnection(); }
Example #14
Source File: CourseGroupMgmtITCase.java From olat with Apache License 2.0 | 6 votes |
@Test public void testGetCourseGroups() throws IOException { final HttpClient c = loginWithCookie("administrator", "olat"); final String request = "/repo/courses/" + course.getResourceableId() + "/groups"; final GetMethod method = createGet(request, MediaType.APPLICATION_JSON, true); final int code = c.executeMethod(method); assertEquals(200, code); final String body = method.getResponseBodyAsString(); method.releaseConnection(); final List<GroupVO> vos = parseGroupArray(body); assertNotNull(vos); assertEquals(2, vos.size());// g1 and g2 assertTrue(vos.get(0).getKey().equals(g1.getKey()) || vos.get(0).getKey().equals(g2.getKey())); assertTrue(vos.get(1).getKey().equals(g1.getKey()) || vos.get(1).getKey().equals(g2.getKey())); }
Example #15
Source File: SolrSearchProviderImpl.java From swellrt with Apache License 2.0 | 6 votes |
private JsonArray sendSearchRequest(String solrQuery, Function<InputStreamReader, JsonArray> function) throws IOException { JsonArray docsJson; GetMethod getMethod = new GetMethod(); HttpClient httpClient = new HttpClient(); try { getMethod.setURI(new URI(solrQuery, false)); int statusCode = httpClient.executeMethod(getMethod); docsJson = function.apply(new InputStreamReader(getMethod.getResponseBodyAsStream())); if (statusCode != HttpStatus.SC_OK) { LOG.warning("Failed to execute query: " + solrQuery); throw new IOException("Search request status is not OK: " + statusCode); } } finally { getMethod.releaseConnection(); } return docsJson; }
Example #16
Source File: NetworkTools.java From yeti with MIT License | 6 votes |
public static String getHTMLFromUrl(String url) { HttpClient client = new HttpClient(); HttpMethod method = new GetMethod(url); String response = ""; try { client.executeMethod(method); if (method.getStatusCode() == HttpStatus.SC_OK) { response = method.getResponseBodyAsString(); } } catch (IOException e) { Logger.getLogger("networkTools.getHTMLFromUrl").log(Level.SEVERE, null, e); } finally { method.releaseConnection(); } return response; }
Example #17
Source File: GetSSLCert.java From MyVirtualDirectory with Apache License 2.0 | 6 votes |
public static javax.security.cert.X509Certificate getCert(String host, int port) { GetCertSSLProtocolSocketFactory certFactory = new GetCertSSLProtocolSocketFactory(); Protocol myhttps = new Protocol("https", certFactory, port); HttpClient httpclient = new HttpClient(); httpclient.getHostConfiguration().setHost(host, port, myhttps); GetMethod httpget = new GetMethod("/"); try { httpclient.executeMethod(httpget); //System.out.println(httpget.getStatusLine()); } catch (Throwable t) { //do nothing } finally { httpget.releaseConnection(); } return certFactory.getCertificate(); }
Example #18
Source File: User.java From cloudstack with Apache License 2.0 | 6 votes |
public void launchUser() throws IOException { String encodedUsername = URLEncoder.encode(this.getUserName(), "UTF-8"); this.encryptedPassword = TestClientWithAPI.createMD5Password(this.getPassword()); String encodedPassword = URLEncoder.encode(this.encryptedPassword, "UTF-8"); String url = this.server + "?command=createUser&username=" + encodedUsername + "&password=" + encodedPassword + "&firstname=Test&lastname=Test&[email protected]&domainId=1"; String userIdStr = null; HttpClient client = new HttpClient(); HttpMethod method = new GetMethod(url); int responseCode = client.executeMethod(method); if (responseCode == 200) { InputStream is = method.getResponseBodyAsStream(); Map<String, String> userIdValues = TestClientWithAPI.getSingleValueFromXML(is, new String[] {"id"}); userIdStr = userIdValues.get("id"); if ((userIdStr != null) && (Long.parseLong(userIdStr) != -1)) { this.setUserId(userIdStr); } } }
Example #19
Source File: EndpointIT.java From boost with Eclipse Public License 1.0 | 6 votes |
@Test public void testServlet() throws Exception { HttpClient client = new HttpClient(); GetMethod method = new GetMethod(URL + "/hello"); try { int statusCode = client.executeMethod(method); assertEquals("HTTP GET failed", HttpStatus.SC_OK, statusCode); String response = method.getResponseBodyAsString(10000); assertTrue("Unexpected response body", response.contains("Hello World From Your Friends at Liberty Boost EE!")); } finally { method.releaseConnection(); } }
Example #20
Source File: AbstractTestRestApi.java From zeppelin with Apache License 2.0 | 6 votes |
protected static boolean checkIfServerIsRunning() { GetMethod request = null; boolean isRunning; try { request = httpGet("/version"); isRunning = request.getStatusCode() == 200; } catch (IOException e) { LOG.error("AbstractTestRestApi.checkIfServerIsRunning() fails .. ZeppelinServer is not " + "running"); isRunning = false; } finally { if (request != null) { request.releaseConnection(); } } return isRunning; }
Example #21
Source File: HdHttpClient.java From neoscada with Eclipse Public License 1.0 | 6 votes |
public List<DataPoint> getData ( final String item, final String type, final Date from, final Date to, final Integer number ) throws Exception { final HttpClient client = new HttpClient (); final HttpMethod method = new GetMethod ( this.baseUrl + "/" + URLEncoder.encode ( item, "UTF-8" ) + "/" + URLEncoder.encode ( type, "UTF-8" ) + "?from=" + URLEncoder.encode ( Utils.isoDateFormat.format ( from ), "UTF-8" ) + "&to=" + URLEncoder.encode ( Utils.isoDateFormat.format ( to ), "UTF-8" ) + "&no=" + number ); client.getParams ().setSoTimeout ( (int)this.timeout ); try { final int status = client.executeMethod ( method ); if ( status != HttpStatus.SC_OK ) { throw new RuntimeException ( "Method failed with error " + status + " " + method.getStatusLine () ); } return Utils.fromJson ( method.getResponseBodyAsString () ); } finally { method.releaseConnection (); } }
Example #22
Source File: UriUtils.java From cloudstack with Apache License 2.0 | 6 votes |
public static InputStream getInputStreamFromUrl(String url, String user, String password) { try { Pair<String, Integer> hostAndPort = validateUrl(url); HttpClient httpclient = new HttpClient(new MultiThreadedHttpConnectionManager()); if ((user != null) && (password != null)) { httpclient.getParams().setAuthenticationPreemptive(true); Credentials defaultcreds = new UsernamePasswordCredentials(user, password); httpclient.getState().setCredentials(new AuthScope(hostAndPort.first(), hostAndPort.second(), AuthScope.ANY_REALM), defaultcreds); s_logger.info("Added username=" + user + ", password=" + password + "for host " + hostAndPort.first() + ":" + hostAndPort.second()); } // Execute the method. GetMethod method = new GetMethod(url); int statusCode = httpclient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { s_logger.error("Failed to read from URL: " + url); return null; } return method.getResponseBodyAsStream(); } catch (Exception ex) { s_logger.error("Failed to read from URL: " + url); return null; } }
Example #23
Source File: GroupMgmtITCase.java From olat with Apache License 2.0 | 6 votes |
@Test public void testGetGroupInfos() throws IOException { final HttpClient c = loginWithCookie("administrator", "olat"); final String request = "/groups/" + g1.getKey() + "/infos"; final GetMethod method = createGet(request, MediaType.APPLICATION_JSON, true); final int code = c.executeMethod(method); assertEquals(code, 200); final String body = method.getResponseBodyAsString(); method.releaseConnection(); final GroupInfoVO vo = parse(body, GroupInfoVO.class); assertNotNull(vo); assertEquals(Boolean.TRUE, vo.getHasWiki()); assertEquals("<p>Hello world</p>", vo.getNews()); assertNotNull(vo.getForumKey()); }
Example #24
Source File: HeliumRestApiTest.java From zeppelin with Apache License 2.0 | 6 votes |
@Test public void testVisualizationPackageOrder() throws IOException { GetMethod get1 = httpGet("/helium/order/visualization"); assertThat(get1, isAllowed()); Map<String, Object> resp1 = gson.fromJson(get1.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); List<Object> body1 = (List<Object>) resp1.get("body"); assertEquals(body1.size(), 0); //We assume allPackages list has been refreshed before sorting helium.getAllPackageInfo(); String postRequestJson = "[name2, name1]"; PostMethod post = httpPost("/helium/order/visualization", postRequestJson); assertThat(post, isAllowed()); post.releaseConnection(); GetMethod get2 = httpGet("/helium/order/visualization"); assertThat(get2, isAllowed()); Map<String, Object> resp2 = gson.fromJson(get2.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); List<Object> body2 = (List<Object>) resp2.get("body"); assertEquals(body2.size(), 2); assertEquals(body2.get(0), "name2"); assertEquals(body2.get(1), "name1"); }
Example #25
Source File: VmRuntimeJettyAuthTest.java From appengine-java-vm-runtime with Apache License 2.0 | 5 votes |
public void testAuth_UntrustedInboundIp() throws Exception { HttpClient httpClient = new HttpClient(); httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000); GetMethod get = new GetMethod(createUrlForHostIP("/admin/test-auth").toString()); get.addRequestHeader(VmApiProxyEnvironment.REAL_IP_HEADER, "127.0.0.2"); // Force untrusted dev IP get.setFollowRedirects(false); int httpCode = httpClient.executeMethod(get); assertEquals(307, httpCode); assertEquals("https://testversion-dot-testbackend-dot-testhostname/admin/test-auth", get.getResponseHeader("Location").getValue()); }
Example #26
Source File: NotebookRepoRestApiTest.java From zeppelin with Apache License 2.0 | 5 votes |
private List<Map<String, Object>> getListOfReposotiry() throws IOException { GetMethod get = httpGet("/notebook-repositories"); Map<String, Object> responce = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {}.getType()); get.releaseConnection(); return (List<Map<String, Object>>) responce.get("body"); }
Example #27
Source File: TestCaldav.java From davmail with GNU General Public License v2.0 | 5 votes |
public void testCreateCalendar() throws IOException { String folderName = "test & accentué"; String encodedFolderpath = URIUtil.encodePath("/users/" + session.getEmail() + "/calendar/" + folderName + '/'); // first delete calendar session.deleteFolder("calendar/" + folderName); String body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + " <C:mkcalendar xmlns:D=\"DAV:\"\n" + " xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n" + " <D:set>\n" + " <D:prop>\n" + " <D:displayname>" + StringUtil.xmlEncode(folderName) + "</D:displayname>\n" + " <C:calendar-description xml:lang=\"en\">Calendar description</C:calendar-description>\n" + " <C:supported-calendar-component-set>\n" + " <C:comp name=\"VEVENT\"/>\n" + " </C:supported-calendar-component-set>\n" + " </D:prop>\n" + " </D:set>\n" + " </C:mkcalendar>"; SearchReportMethod method = new SearchReportMethod(encodedFolderpath, body) { @Override public String getName() { return "MKCALENDAR"; } }; httpClient.executeMethod(method); assertEquals(HttpStatus.SC_CREATED, method.getStatusCode()); GetMethod getMethod = new GetMethod(encodedFolderpath); httpClient.executeMethod(getMethod); assertEquals(HttpStatus.SC_OK, getMethod.getStatusCode()); }
Example #28
Source File: HarvestQaManagerImpl.java From webcurator with Apache License 2.0 | 5 votes |
@Override public void triggerAutoQA(ArcHarvestResult ahr) { TargetInstance ti = ahr.getTargetInstance(); if (autoQAUrl != null && autoQAUrl.length() > 0 && ti.isUseAQA()) { GetMethod getMethod = new GetMethod(autoQAUrl); String primarySeed = ""; // Might be nice to use the SeedHistory here, but as this won't // necessarily be turned on, we can't use it reliably Set<Seed> seeds = ti.getTarget().getSeeds(); Iterator<Seed> it = seeds.iterator(); while (it.hasNext()) { Seed seed = it.next(); if (seed.isPrimary()) { primarySeed = seed.getSeed(); break; } } NameValuePair[] params = { new NameValuePair("targetInstanceId", ti.getOid().toString()), new NameValuePair("harvestNumber", Integer.toString(ahr.getHarvestNumber())), new NameValuePair("primarySeed", primarySeed) }; getMethod.setQueryString(params); HttpClient client = new HttpClient(); try { int result = client.executeMethod(getMethod); if (result != HttpURLConnection.HTTP_OK) { log.error("Unable to initiate Auto QA. Response at " + autoQAUrl + " is " + result); } } catch (Exception e) { log.error("Unable to initiate Auto QA.", e); } } }
Example #29
Source File: CoursesResourcesFoldersITCase.java From olat with Apache License 2.0 | 5 votes |
@Test public void testGetFilesDeeper() throws IOException { final HttpClient c = loginWithCookie("administrator", "olat"); final URI uri = UriBuilder.fromUri(getCourseFolderURI()).path("SubDir").path("SubSubDir").path("SubSubSubDir").build(); final GetMethod method = createGet(uri, MediaType.APPLICATION_JSON, true); final int code = c.executeMethod(method); assertEquals(code, 200); final String body = method.getResponseBodyAsString(); final List<LinkVO> links = parseLinkArray(body); assertNotNull(links); assertEquals(1, links.size()); assertEquals("3_singlepage.html", links.get(0).getTitle()); }
Example #30
Source File: RepositoryEntriesITCase.java From olat with Apache License 2.0 | 5 votes |
@Test public void testGetEntry() throws HttpException, IOException { final RepositoryEntry re = createRepository("Test GET repo entry", 83911l); final HttpClient c = loginWithCookie("administrator", "olat"); final GetMethod method = createGet("repo/entries/" + re.getKey(), MediaType.APPLICATION_JSON, true); final int code = c.executeMethod(method); assertEquals(200, code); final String body = method.getResponseBodyAsString(); method.releaseConnection(); final RepositoryEntryVO entryVo = parse(body, RepositoryEntryVO.class); assertNotNull(entryVo); }