@Test public void testProtectFilename() throws Exception { ArrayList<SimpleImmutableEntry<String,String>> testmap = new ArrayList<>(); testmap.add(new SimpleImmutableEntry<>("Testfile 34", "Testfile 34")); testmap.add(new SimpleImmutableEntry<>("Test%52", "Test%2552")); testmap.add(new SimpleImmutableEntry<>("Test*4+2", "Test%2A4+2")); testmap.add(new SimpleImmutableEntry<>("Test@", "Test%40")); testmap.add(new SimpleImmutableEntry<>("@seventeen", "%40seventeen")); testmap.add(new SimpleImmutableEntry<>("upNdown(", "upNdown(")); testmap.add(new SimpleImmutableEntry<>("tst#99", "tst%2399")); testmap.add(new SimpleImmutableEntry<>("#File*Three%trig", "%23File%2AThree%25trig")); testmap.add(new SimpleImmutableEntry<>("Two%and5#3#4", "Two%25and5%233%234")); for (SimpleImmutableEntry<String,String> ent : testmap) { String prot = protectPerforceFilename(ent.getKey()); assertEquals("Improper protected filename, "+prot+" != "+ent.getValue(), ent.getValue(), prot); } }
static String protectPerforceFilename(String name) { String t = name.replace("%", "%25"); t = t.replace("#", "%23"); t = t.replace("*", "%2A"); t = t.replace("@", "%40"); if (LOGGER.isLoggable(Level.FINEST) && !name.equals(t)) { LOGGER.log(Level.FINEST, "protectPerforceFilename: replaced ''{0}'' with ''{1}''", new Object[]{name, t}); } return t; }
PerforceRepository extends Repository { static String protectPerforceFilename(String name) { String t = name.replace("%", "%25"); t = t.replace("#", "%23"); t = t.replace("*", "%2A"); t = t.replace("@", "%40"); if (LOGGER.isLoggable(Level.FINEST) && !name.equals(t)) { LOGGER.log(Level.FINEST, "protectPerforceFilename: replaced ''{0}'' with ''{1}''", new Object[]{name, t}); } return t; } }
PerforceRepository extends Repository { static String protectPerforceFilename(String name) { String t = name.replace("%", "%25"); t = t.replace("#", "%23"); t = t.replace("*", "%2A"); t = t.replace("@", "%40"); if (LOGGER.isLoggable(Level.FINEST) && !name.equals(t)) { LOGGER.log(Level.FINEST, "protectPerforceFilename: replaced ''{0}'' with ''{1}''", new Object[]{name, t}); } return t; } PerforceRepository(); }
PerforceRepository extends Repository { static String protectPerforceFilename(String name) { String t = name.replace("%", "%25"); t = t.replace("#", "%23"); t = t.replace("*", "%2A"); t = t.replace("@", "%40"); if (LOGGER.isLoggable(Level.FINEST) && !name.equals(t)) { LOGGER.log(Level.FINEST, "protectPerforceFilename: replaced ''{0}'' with ''{1}''", new Object[]{name, t}); } return t; } PerforceRepository(); @Override Annotation annotate(File file, String rev); @Override boolean fileHasAnnotation(File file); @Override boolean isWorking(); }
PerforceRepository extends Repository { static String protectPerforceFilename(String name) { String t = name.replace("%", "%25"); t = t.replace("#", "%23"); t = t.replace("*", "%2A"); t = t.replace("@", "%40"); if (LOGGER.isLoggable(Level.FINEST) && !name.equals(t)) { LOGGER.log(Level.FINEST, "protectPerforceFilename: replaced ''{0}'' with ''{1}''", new Object[]{name, t}); } return t; } PerforceRepository(); @Override Annotation annotate(File file, String rev); @Override boolean fileHasAnnotation(File file); @Override boolean isWorking(); static final String CMD_PROPERTY_KEY; static final String CMD_FALLBACK; }