BucketPath { public static String escapeString(String in, Map<String, String> headers){ return escapeString(in, headers, false, 0, 0); }  static boolean containsTag(String in); static String expandShorthand(char c); static String replaceShorthand(char c, Map<String, String> headers); static String replaceShorthand(char c, Map<String, String> headers,
      boolean needRounding, int unit, int roundDown); static String escapeString(String in, Map<String, String> headers); static String escapeString(String in, Map<String, String> headers,
      boolean needRounding, int unit, int roundDown); static Map<String, String> getEscapeMapping(String in,
      Map<String, String> headers); static Map<String, String> getEscapeMapping(String in,
      Map<String, String> headers, boolean needRounding,
      int unit, int roundDown); final static String TAG_REGEX; final static Pattern tagPattern; }
@Test public void testDateFormatHours() { String test = "%c"; String escapedString = BucketPath.escapeString( test, headers, true, Calendar.HOUR_OF_DAY, 12); System.out.println("Escaped String: " + escapedString); Calendar cal2 = Calendar.getInstance(); cal2.set(2012, 5, 23, 12, 0, 0); cal2.set(Calendar.MILLISECOND, 0); SimpleDateFormat format = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy"); Date d = new Date(cal2.getTimeInMillis()); String expectedString = format.format(d); System.out.println("Expected String: "+ expectedString); Assert.assertEquals(expectedString, escapedString); }
@Test public void testDateFormatMinutes() { String test = "%s"; String escapedString = BucketPath.escapeString( test, headers, true, Calendar.MINUTE, 5); System.out.println("Escaped String: " + escapedString); Calendar cal2 = Calendar.getInstance(); cal2.set(2012, 5, 23, 13, 45, 0); cal2.set(Calendar.MILLISECOND, 0); String expectedString = String.valueOf(cal2.getTimeInMillis()/1000); System.out.println("Expected String: "+ expectedString); Assert.assertEquals(expectedString, escapedString); }
@Test public void testDateFormatSeconds() { String test = "%s"; String escapedString = BucketPath.escapeString( test, headers, true, Calendar.SECOND, 5); System.out.println("Escaped String: " + escapedString); Calendar cal2 = Calendar.getInstance(); cal2.set(2012, 5, 23, 13, 46, 30); cal2.set(Calendar.MILLISECOND, 0); String expectedString = String.valueOf(cal2.getTimeInMillis()/1000); System.out.println("Expected String: "+ expectedString); Assert.assertEquals(expectedString, escapedString); }
@Test public void testNoRounding(){ String test = "%c"; String escapedString = BucketPath.escapeString( test, headers, false, Calendar.HOUR_OF_DAY, 12); System.out.println("Escaped String: " + escapedString); SimpleDateFormat format = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy"); Date d = new Date(cal.getTimeInMillis()); String expectedString = format.format(d); System.out.println("Expected String: "+ expectedString); Assert.assertEquals(expectedString, escapedString); }