OtaPlistGenerator extends VelocityBase<Parameters> { public static URL generatePlistRequestUrl(URL plistServiceUrl, Map<String, String> params) throws IOException { if (plistServiceUrl == null) { throw new NullPointerException("serviceUrl null"); } String urlString = String.format("%s/%s/%s/%s/%s%s%s", plistServiceUrl, LibUtils.encode(KEY_REFERER + "=" + params.get(KEY_REFERER)), LibUtils.encode(KEY_TITLE + "=" + params.get(KEY_TITLE)), LibUtils.encode(KEY_BUNDLE_IDENTIFIER + "=" + params.get(KEY_BUNDLE_IDENTIFIER)), LibUtils.encode(KEY_BUNDLE_VERSION + "=" + params.get(KEY_BUNDLE_VERSION)), (isEmpty(params.get(KEY_IPA_CLASSIFIER)) ? "" : "/" + encode(KEY_IPA_CLASSIFIER + "=" + params.get(KEY_IPA_CLASSIFIER))), (isEmpty(params.get(KEY_OTA_CLASSIFIER)) ? "" : "/" + encode(KEY_OTA_CLASSIFIER + "=" + params.get(KEY_OTA_CLASSIFIER))) ); return new URL(urlString); } private  OtaPlistGenerator(String template); static synchronized OtaPlistGenerator getInstance(); static synchronized OtaPlistGenerator getInstance(String template); static synchronized OtaPlistGenerator getInstance(String template, boolean forceNewInstance); @Override synchronized String generate(Parameters parameters); @Override synchronized void generate(PrintWriter writer, Parameters parameters); static URL generatePlistRequestUrl(URL plistServiceUrl, Map<String, String> params);  }
@Test public void testGenerateURL() throws IOException { URL url = OtaPlistGenerator.generatePlistRequestUrl(new URL(long_service), buildMap(KEY_REFERER, long_referer, KEY_TITLE, long_title, KEY_BUNDLE_IDENTIFIER, long_identifier, KEY_BUNDLE_VERSION, long_version, KEY_IPA_CLASSIFIER, ipaClassifier, KEY_OTA_CLASSIFIER, otaClassifier)); assertEquals(10, StringUtils.countMatches(url.toExternalForm(), "/")); System.out.println("Length: " + url.toExternalForm().length() + " - " + url.toExternalForm()); assertTrue(url.toExternalForm().startsWith(long_service)); assertContains("/" + LibUtils.encode("Referer=" + long_referer) + "/", url.toExternalForm()); assertContains("/" + LibUtils.encode("title=" + long_title) + "/", url.toExternalForm()); assertContains("/" + LibUtils.encode("bundleIdentifier=" + long_identifier) + "/", url.toExternalForm()); assertContains("/" + LibUtils.encode("bundleVersion=" + long_version), url.toExternalForm()); assertContains("/" + LibUtils.encode("ipaClassifier=" + ipaClassifier), url.toExternalForm()); assertContains("/" + LibUtils.encode("otaClassifier=" + otaClassifier), url.toExternalForm()); url = OtaPlistGenerator.generatePlistRequestUrl(new URL(long_service), buildMap(KEY_REFERER, long_referer, KEY_TITLE, long_title, KEY_BUNDLE_IDENTIFIER, long_identifier, KEY_BUNDLE_VERSION, long_version)); assertEquals(8, StringUtils.countMatches(url.toExternalForm(), "/")); url = OtaPlistGenerator.generatePlistRequestUrl(new URL(long_service), buildMap(KEY_REFERER, long_referer, KEY_TITLE, long_title, KEY_BUNDLE_IDENTIFIER, long_identifier, KEY_BUNDLE_VERSION, long_version, KEY_OTA_CLASSIFIER, otaClassifier)); assertEquals(9, StringUtils.countMatches(url.toExternalForm(), "/")); }