List of usage examples for java.net URL getQuery
public String getQuery()
From source file:com.mashape.unirest.request.HttpRequest.java
private URL parseUrl(String s) throws Exception { URL u = new URL(s); return new URI(u.getProtocol(), u.getAuthority(), u.getPath(), u.getQuery(), u.getRef()).toURL(); }
From source file:org.atricore.idbus.capabilities.josso.test.JOSSO11WebSelfservicesTest.java
private void initLostPasswordProcess(HttpClient client) throws Exception { log.debug("******************************************************************************"); log.debug("initLostPasswordProcess"); log.debug("******************************************************************************"); GetMethod get = new GetMethod(lostPasswordEndpoint + "?josso_cmd=lostPwd"); get.setFollowRedirects(false);/*from w w w .j a v a2 s . c om*/ int status = client.executeMethod(get); get.getResponseBodyAsString(); assert status == HttpStatus.SC_MOVED_TEMPORARILY : "status code spected " + HttpStatus.SC_MOVED_TEMPORARILY + " found [" + status + "]"; Header h = get.getResponseHeader("Location"); assert h != null : "No Location found"; URL url = new URL(h.getValue()); assert url.getQuery() != null && url.getQuery().contains("artifactId") : "No artifactId found"; }
From source file:org.geotools.data.wfs.internal.v1_1.MapServerTest.java
@Test public void testGetFeatures() throws Exception { WFSDataStore wfs = getWFSDataStore(new TestHttpClient() { @Override/*from w w w . ja va 2 s . co m*/ public HTTPResponse get(URL url) throws IOException { if (url.getQuery().contains("REQUEST=GetCapabilities")) { return new TestHttpResponse(TestData.getResource(this, "MapServer/GetCapabilities_1_1_0.xml"), "text/xml"); } else { return new TestHttpResponse( TestData.getResource(this, "MapServer/GetFeature_GovernmentalUnitCE.xml"), "text/xml"); } } @Override public HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException { String request = new String(IOUtils.toByteArray(postContent), "UTF-8"); if (request.contains("<wfs:DescribeFeatureType")) { return new TestHttpResponse( TestData.getResource(this, "MapServer/DescribeFeatureType_GovernmentalUnitCE.xsd"), "text/xml"); } else { return new TestHttpResponse( TestData.getResource(this, "MapServer/GetFeature_GovernmentalUnitCE.xml"), "text/xml"); } } }); SimpleFeatureSource source = wfs .getFeatureSource(new NameImpl("http://mapserver.gis.umn.edu/mapserver", "ms_GovernmentalUnitCE")); SimpleFeatureCollection features = source.getFeatures(); SimpleFeatureIterator reader = features.features(); SimpleFeature sf = null; try { if (reader.hasNext()) { sf = reader.next(); assertNotNull(sf); assertTrue(sf.getAttribute("typeAbbreviation") instanceof String); assertTrue(sf.getAttribute("number") instanceof BigInteger); assertTrue(sf.getAttribute("doubleNumber") instanceof Double); } assertNotNull(sf); } finally { reader.close(); } }
From source file:org.geotools.data.wfs.v1_1_0.MapServerTest.java
@Test public void testGetFeatures() throws Exception { WFSDataStore wfs = getWFSDataStore(new MockHttpClient() { @Override/* w w w . j av a2 s. c o m*/ public HTTPResponse get(URL url) throws IOException { if (url.getQuery().contains("REQUEST=GetCapabilities")) { return new MockHttpResponse(TestData.getResource(this, "MapServer/GetCapabilities_1_1_0.xml"), "text/xml"); } else { return new MockHttpResponse( TestData.getResource(this, "MapServer/GetFeature_GovernmentalUnitCE.xml"), "text/xml"); } } @Override public HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException { return new MockHttpResponse( TestData.getResource(this, "MapServer/GetFeature_GovernmentalUnitCE.xml"), "text/xml"); } }); ((WFS_1_1_0_DataStore) wfs).setMappedURIs(new MapServerStrategy().getNamespaceURIMappings()); SimpleFeatureSource source = wfs.getFeatureSource(MAPSRV_GOVUNITCE.FEATURETYPENAME); SimpleFeatureCollection features = source.getFeatures(); SimpleFeatureIterator reader = features.features(); SimpleFeature sf = null; try { if (reader.hasNext()) { sf = reader.next(); assertNotNull(sf); assertTrue(sf.getAttribute("typeAbbreviation") instanceof String); assertTrue(sf.getAttribute("number") instanceof BigInteger); assertTrue(sf.getAttribute("doubleNumber") instanceof Double); } assertNotNull(sf); } finally { reader.close(); } }
From source file:com.brightcove.com.zartan.verifier.video.VideoStillVerifier.java
@ZartanCheck(value = "VideoStill has billing params") public ResultEnum assertVideoStillBillingCorrect(UploadData upData) throws Throwable { URL u = getStillUrl(upData); assertTrue("Images should have pud Id billing params", u.getQuery().contains("pubId=" + upData.getmAccount().getId())); return ResultEnum.PASS; }
From source file:com.brightcove.com.zartan.verifier.video.ThumbnailVerifier.java
@ZartanCheck(value = "Thumbnail has billing params") public ResultEnum assertVideoStillBillingCorrect(UploadData upData) throws Throwable { URL u = getThumbnailUrl(upData); assertTrue("Images should have pud Id billing params", u.getQuery().contains("pubId=" + upData.getmAccount().getId())); return ResultEnum.PASS; }
From source file:org.echocat.nodoodle.server.BaseUrlsDiscovery.java
public void init(ServletContext servletContext) throws Exception { if (servletContext == null) { throw new NullPointerException("No servletContext provided."); }// w ww .j a v a 2 s . c om if (CollectionUtils.isEmpty(_baseUrls)) { throw new IllegalArgumentException("No baseUrls property set."); } for (URL baseUrl : _baseUrls) { if (!StringUtils.isEmpty(baseUrl.getQuery())) { throw new IllegalArgumentException("The given baseUrl (" + baseUrl + ") does contain a query."); } } _servletContext = servletContext; }
From source file:com.entertailion.android.shapeways.api.Request.java
/** * Normalize the URL parameters/*from w w w . j a v a 2 s . com*/ * * @param urlValue * @return * @throws Exception */ private final String normalize(String urlValue) throws Exception { Log.d(LOG_TAG, "normalize: " + urlValue); URL url = new URL(urlValue); if (url.getQuery() != null) { String[] parameters = url.getQuery().split(ShapewaysClient.AMPERSAND); for (String parameter : parameters) { if (parameter != null) { String[] keyValue = parameter.split(ShapewaysClient.EQUALS); if (keyValue != null) { addParameter(keyValue[0], keyValue[1]); } } } } return urlValue; }
From source file:com.esri.gpt.framework.http.crawl.HttpCrawlRequest.java
private String getRelativePath() throws MalformedURLException { URL u = new URL(getUrl()); return String.format("%s%s%s", u.getPath() != null ? u.getPath() : "/", u.getQuery() != null ? "?" + u.getQuery() : "", u.getRef() != null ? "#" + u.getRef() : ""); }
From source file:org.infoscoop.request.SignedAuthenticator.java
private String analyzeUrl(String url, Map<String, String> optionParams) throws MalformedURLException { URL u = new URL(url); String query = u.getQuery(); if (query != null) { String[] params = query.split("&"); for (int i = 0; i < params.length; i++) { try { String[] param = splitParameter(params[i].split("=")); String name = URLDecoder.decode(param[0], "UTF-8"); if (name.startsWith("oauth") || name.startsWith("xoauth") || name.startsWith("opensocial")) continue; optionParams.put(name, URLDecoder.decode(param[1], "UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace();//from ww w.jav a 2s .co m } } } return getRequestUrl(u); }