List of usage examples for java.net MalformedURLException getLocalizedMessage
public String getLocalizedMessage()
From source file:TimestreamsTests.java
/** * Tests calling /metadata?tsid=[id] with correct parameters for the URL * being tested against.//from ww w.j ava 2 s .c o m */ @Test public void testGetMetadataIdLegit() { try { long time = new Date().getTime(); String now = Long.toString(time).substring(0, 10); String id = "1"; List<String> params = new ArrayList<String>(); params.add(PUBKEY); params.add(now); params.add(id); String urlStr = getSecurityString(BASEURL + "/metadata", params, now); URL url = new URL(urlStr + "&tsid=" + id); getTest(url); } catch (MalformedURLException e) { fail(e.getLocalizedMessage()); } }
From source file:TimestreamsTests.java
/** * Tests calling /measurement_container/[id]?action=first with valid * parameters for the URL being tested against. Note that id should be a * valid measurement container table name *//*from w w w . ja v a 2 s . com*/ @Test public void testGetMCIdFirstLegit() { try { long time = new Date().getTime(); String now = Long.toString(time).substring(0, 10); String id = "wp_1_ts_Pressure_25"; String action = "first"; List<String> params = new ArrayList<String>(); params.add(PUBKEY); params.add(now); params.add(action); String urlStr = getSecurityString(BASEURL + "/measurement_container/" + id, params, now); URL url = new URL(urlStr + "&action=" + action); getTest(url); } catch (MalformedURLException e) { fail(e.getLocalizedMessage()); } }
From source file:TimestreamsTests.java
/** * Tests calling /measurement_container/[id]?action=latest with valid * parameters for the URL being tested against. Note that id should be a * valid measurement container table name *//*from ww w . ja va 2 s .c o m*/ @Test public void testGetMCIdLatestLegit() { try { long time = new Date().getTime(); String now = Long.toString(time).substring(0, 10); String id = "wp_1_ts_Pressure_25"; String action = "latest"; List<String> params = new ArrayList<String>(); params.add(PUBKEY); params.add(now); params.add(action); String urlStr = getSecurityString(BASEURL + "/measurement_container/" + id, params, now); URL url = new URL(urlStr + "&action=" + action); getTest(url); } catch (MalformedURLException e) { fail(e.getLocalizedMessage()); } }
From source file:TimestreamsTests.java
/** * Tests calling /measurement_container/[id]?action=count with valid * parameters for the URL being tested against. Note that id should be a * valid measurement container table name */// w w w .j ava 2 s . c o m @Test public void testGetMCIdCountLegit() { try { long time = new Date().getTime(); String now = Long.toString(time).substring(0, 10); String id = "wp_1_ts_Pressure_25"; String action = "count"; List<String> params = new ArrayList<String>(); params.add(PUBKEY); params.add(now); params.add(action); String urlStr = getSecurityString(BASEURL + "/measurement_container/" + id, params, now); URL url = new URL(urlStr + "&action=" + action); getTest(url); } catch (MalformedURLException e) { fail(e.getLocalizedMessage()); } }
From source file:TimestreamsTests.java
/** * Tests posting to /metadata/heartbeat/:name with valid parameters * Note that the name should be a table in the database *//*from w ww . j a va2 s. c o m*/ @Test public void testPutHeartbeatLegit() { try { long time = new Date().getTime(); String now = Long.toString(time).substring(0, 10); String ip = "192.168.56.101"; List<String> params = new ArrayList<String>(); params.add(PUBKEY); params.add(now); params.add(ip); String hmac = getSecurityString(params); String paramsstr = "&ip=" + URLEncoder.encode(ip, "UTF-8") + "&pubkey=" + URLEncoder.encode(PUBKEY, "UTF-8") + "&now=" + URLEncoder.encode(now, "UTF-8") + "&hmac=" + URLEncoder.encode(hmac, "UTF-8"); //System.out.println("paramsstr: " + paramsstr); URL url = new URL(BASEURL + "/metadata/heartbeat/wp_1_ts_testPostMCLegit_60"); putTest(url, paramsstr); } catch (MalformedURLException e) { fail(e.getLocalizedMessage()); } catch (UnsupportedEncodingException e) { fail(e.getLocalizedMessage()); } }
From source file:TimestreamsTests.java
/** * Tests posting to /measurement/:name with valid parameters * Note that :name should exist in the database being tested *//* w ww . java 2s.c om*/ @Test public void testPostMeasurementLegit() { try { long time = new Date().getTime(); String now = Long.toString(time).substring(0, 10); String name = "wp_1_ts_testPostMCLegit_60"; String value = "1.0"; List<String> params = new ArrayList<String>(); params.add(PUBKEY); params.add(now); params.add(value); String hmac = getSecurityString(params); String paramsstr = "value=" + URLEncoder.encode(value, "UTF-8") + "&pubkey=" + URLEncoder.encode(PUBKEY, "UTF-8") + "&now=" + URLEncoder.encode(now, "UTF-8") + "&hmac=" + URLEncoder.encode(hmac, "UTF-8"); ; // System.out.println("paramsstr: " + paramsstr); URL url = new URL(BASEURL + "/measurement/" + name); postTest(url, paramsstr); } catch (MalformedURLException e) { fail(e.getLocalizedMessage()); } catch (UnsupportedEncodingException e) { fail(e.getLocalizedMessage()); } }
From source file:TimestreamsTests.java
/** * Tests posting to /context with valid parameters *///from w w w . j ava 2s. co m @Test public void testPutContextLegit() { try { long time = new Date().getTime(); String now = Long.toString(time).substring(0, 10); String value = "Nottingham"; String end = "2011-11-12 10:20:21"; List<String> params = new ArrayList<String>(); params.add(PUBKEY); params.add(now); params.add(value); params.add(end); String hmac = getSecurityString(params); String paramsstr = "&value=" + URLEncoder.encode(value, "UTF-8") + "&end=" + URLEncoder.encode(end, "UTF-8") + "&pubkey=" + URLEncoder.encode(PUBKEY, "UTF-8") + "&now=" + URLEncoder.encode(now, "UTF-8") + "&hmac=" + URLEncoder.encode(hmac, "UTF-8"); ; //System.out.println("paramsstr: " + paramsstr); URL url = new URL(BASEURL + "/context"); putTest(url, paramsstr); } catch (MalformedURLException e) { fail(e.getLocalizedMessage()); } catch (UnsupportedEncodingException e) { fail(e.getLocalizedMessage()); } }
From source file:TimestreamsTests.java
/** * Tests posting to /measurements/:name with valid parameters * Note that :name should exist in the database being tested *//*ww w. j a v a 2s .c om*/ @Test public void testPostMeasurementsLegit() { try { long time = new Date().getTime(); String now = Long.toString(time).substring(0, 10); String name = "wp_1_ts_testPostMCLegit_60"; String measurements = "{\"measurements\":[{\"v\":1,\"t\":" + "\"2012-11-09 12:10:23\"}," + "{\"v\":2,\"t\":\"2012-07-21 17:10:23\"}]}"; List<String> params = new ArrayList<String>(); params.add(PUBKEY); params.add(now); params.add(name); params.add(measurements); String hmac = getSecurityString(params); String paramsstr = "name=" + URLEncoder.encode(name, "UTF-8") + "&measurements=" + URLEncoder.encode(measurements, "UTF-8") + "&pubkey=" + URLEncoder.encode(PUBKEY, "UTF-8") + "&now=" + URLEncoder.encode(now, "UTF-8") + "&hmac=" + URLEncoder.encode(hmac, "UTF-8"); ; // System.out.println("paramsstr: " + paramsstr); URL url = new URL(BASEURL + "/measurements/" + name); postTest(url, paramsstr); } catch (MalformedURLException e) { fail(e.getLocalizedMessage()); } catch (UnsupportedEncodingException e) { fail(e.getLocalizedMessage()); } }
From source file:org.archive.wayback.replay.swf.SWFReplayRenderer.java
@Override public void renderResource(HttpServletRequest httpRequest, HttpServletResponse httpResponse, WaybackRequest wbRequest, CaptureSearchResult result, Resource httpHeadersResource, Resource payloadResource, ResultURIConverter uriConverter, CaptureSearchResults results) throws ServletException, IOException, WaybackException { try {/* w w w . j a v a2 s . c om*/ // copy HTTP response code: HttpHeaderOperation.copyHTTPMessageHeader(httpHeadersResource, httpResponse); // load and process original headers: Map<String, String> headers = HttpHeaderOperation.processHeaders(httpHeadersResource, result, uriConverter, httpHeaderProcessor); // The URL of the resource, for resolving embedded relative URLs: URL url = null; try { url = new URL(result.getOriginalUrl()); } catch (MalformedURLException e1) { e1.printStackTrace(); throw new IOException(e1.getMessage()); } // the date to associate with the embedded, rewritten URLs: String datespec = result.getCaptureTimestamp(); SWFUrlRewriter rw = new SWFUrlRewriter(uriConverter, url, datespec); // OK, try to read the input movie: Movie movie = getRobustMovie(RobustMovieDecoder.DECODE_RULE_NULLS); try { movie.decodeFromStream(payloadResource); } catch (DataFormatException e1) { throw new BadContentException(e1.getLocalizedMessage()); } Movie outMovie = new Movie(movie); List<MovieTag> inTags = movie.getObjects(); ArrayList<MovieTag> outTags = new ArrayList<MovieTag>(); for (MovieTag tag : inTags) { outTags.add(rewriteTag(rw, tag)); } outMovie.setObjects(outTags); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { outMovie.encodeToStream(baos); } catch (DataFormatException e) { throw new BadContentException(e.getLocalizedMessage()); } // put the new corrected length: headers.put(HttpHeaderOperation.HTTP_LENGTH_HEADER, String.valueOf(baos.size())); // send the new headers: HttpHeaderOperation.sendHeaders(headers, httpResponse); // and copy the stored up byte-stream: baos.writeTo(httpResponse.getOutputStream()); } catch (Exception e) { // Redirect to identity if there are any issues throw new BetterRequestException(UrlOperations.computeIdentityUrl(wbRequest)); } }
From source file:TimestreamsTests.java
/** * Tests posting to /timestream/head/:id with valid parameters * Note that the id should be an existing playhead *//*from w w w.java2 s .c o m*/ @Test public void testPutPlayheadLegit() { try { long time = new Date().getTime(); String now = Long.toString(time).substring(0, 10); String curtime = "1352315402"; String start = "1352315400"; String end = "1352315403"; String rate = "3"; List<String> params = new ArrayList<String>(); params.add(PUBKEY); params.add(now); params.add(curtime); params.add(start); params.add(end); params.add(rate); String hmac = getSecurityString(params); String paramsstr = "&curtime=" + URLEncoder.encode(curtime, "UTF-8") + "&start=" + URLEncoder.encode(start, "UTF-8") + "&end=" + URLEncoder.encode(end, "UTF-8") + "&rate=" + URLEncoder.encode(rate, "UTF-8") + "&pubkey=" + URLEncoder.encode(PUBKEY, "UTF-8") + "&now=" + URLEncoder.encode(now, "UTF-8") + "&hmac=" + URLEncoder.encode(hmac, "UTF-8"); ; //System.out.println("paramsstr: " + paramsstr); URL url = new URL(BASEURL + "/timestream/head/1"); putTest(url, paramsstr); } catch (MalformedURLException e) { fail(e.getLocalizedMessage()); } catch (UnsupportedEncodingException e) { fail(e.getLocalizedMessage()); } }