OtaBuildHtmlGenerator extends VelocityBase<Parameters> { public static OtaBuildHtmlGenerator getInstance() { return getInstance(null); } private  OtaBuildHtmlGenerator(String template); static OtaBuildHtmlGenerator getInstance(); static synchronized OtaBuildHtmlGenerator getInstance(String template);  }
@Test public void testCorrectValues() throws IOException { URL htmlServiceUrl = new URL(HTML_SERVICE); String generated = OtaBuildHtmlGenerator.getInstance().generate( new Parameters(htmlServiceUrl, title, bundleIdentifier, bundleVersion, ipaClassifier, otaClassifier, null)); assertContains(KEY_TITLE + "=" + title, generated); assertContains(KEY_BUNDLE_IDENTIFIER + "=" + bundleIdentifier, generated); assertContains(KEY_BUNDLE_VERSION + "=" + bundleVersion, generated); assertContains(KEY_IPA_CLASSIFIER + "=" + ipaClassifier, generated); assertContains(KEY_OTA_CLASSIFIER + "=" + otaClassifier, generated); assertContains( "<iframe id=\"iframe\" src=\"" + HTML_SERVICE + "?title=MyApp&bundleIdentifier=com.sap.xyz.MyApp&bundleVersion=1.0.2&ipaClassifier=ipaClassifier&otaClassifier=otaClassifier", generated); }
@Test public void testAlternativeTemplateByResource() throws IOException { URL htmlServiceUrl = new URL(HTML_SERVICE); String generated = OtaBuildHtmlGenerator.getInstance("alternativeBuildTemplate.html").generate( new Parameters(htmlServiceUrl, title, bundleIdentifier, bundleVersion, ipaClassifier, otaClassifier, null)); checkAlternativeResult(generated); }
@Test public void testAlternativeTemplateByFile() throws IOException { URL htmlServiceUrl = new URL(HTML_SERVICE); String generated = OtaBuildHtmlGenerator.getInstance("./src/test/resources/alternativeBuildTemplate.html") .generate( new Parameters(htmlServiceUrl, title, bundleIdentifier, bundleVersion, ipaClassifier, otaClassifier, null)); checkAlternativeResult(generated); }
@Test public void testProject() throws MalformedURLException, IOException { URL htmlServiceUrl = new URL(HTML_SERVICE); OtaBuildHtmlGenerator.getInstance().generate( new Parameters(htmlServiceUrl, "MyApp", "com.sap.tip.production.ios.ota.test", "1.0", "Production-iphoneos", "OTA-Installer", null)); }
@Test public void getNewInstanceNull() throws FileNotFoundException { assertEquals(OtaBuildHtmlGenerator.DEFAULT_TEMPLATE, OtaBuildHtmlGenerator.getInstance(null).template.getName()); }
@Test public void getNewInstanceEmpty() throws FileNotFoundException { assertEquals(OtaBuildHtmlGenerator.DEFAULT_TEMPLATE, OtaBuildHtmlGenerator.getInstance("").template.getName()); }
@Test(expected = ResourceNotFoundException.class) public void getNewInstanceWrongResource() throws FileNotFoundException { assertEquals(OtaBuildHtmlGenerator.DEFAULT_TEMPLATE, OtaBuildHtmlGenerator.getInstance("doesnotexist.htm").template.getName()); }
@Test public void getNewInstanceCorrectFile() throws FileNotFoundException { assertEquals("alternativeBuildTemplate.html", OtaBuildHtmlGenerator.getInstance(new File("./src/test/resources/alternativeBuildTemplate.html") .getAbsolutePath()).template.getName()); }
@Test(expected = ResourceNotFoundException.class) public void getNewInstanceWrongFile() throws FileNotFoundException { assertEquals(OtaBuildHtmlGenerator.DEFAULT_TEMPLATE, OtaBuildHtmlGenerator.getInstance(new File("./doesnotexist.htm").getAbsolutePath()).template.getName()); }