MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / snapshot

Method snapshot

src/test/java/org/htmlunit/ExternalTest.java:188–217  ·  view source on GitHub ↗

Tests that the deployed snapshot is not more than two weeks old. @throws Exception if an error occurs

()

Source from the content-addressed store, hash-verified

186 * @throws Exception if an error occurs
187 */
188 @Test
189 public void snapshot() throws Exception {
190 final File pomFile = new File("pom.xml");
191 if (!pomFile.exists()) {
192 throw new IOException("POM file not found: " + pomFile.getAbsolutePath());
193 }
194
195 MavenXpp3Reader reader = new MavenXpp3Reader();
196 try (FileReader fileReader = new FileReader(pomFile)) {
197 final Model model = reader.read(fileReader);
198
199 final String version = model.getVersion();
200 Assertions.assertNotNull(version);
201 if (version.contains("SNAPSHOT")) {
202 try (WebClient webClient = new WebClient(BrowserVersion.FIREFOX, false, null, -1)) {
203 final String url = SONATYPE_SNAPSHOT_REPO_URL_
204 + "org/htmlunit/htmlunit/" + version + "/maven-metadata.xml";
205
206 final XmlPage page = webClient.getPage(url);
207 final String timestamp = page.getElementsByTagName("timestamp").get(0).getTextContent();
208 final DateFormat format = new SimpleDateFormat("yyyyMMdd.HHmmss", Locale.ROOT);
209 final long snapshotMillis = format.parse(timestamp).getTime();
210 final long nowMillis = System.currentTimeMillis();
211 final long days = TimeUnit.MILLISECONDS.toDays(nowMillis - snapshotMillis);
212
213 Assertions.assertTrue(days < 14, "Snapshot not deployed for " + days + " days");
214 }
215 }
216 }
217 }
218
219 private static void assertVersion(final String groupId, final String artifactId,
220 final String pomVersion, final Pattern ignorePattern)

Callers

nothing calls this directly

Calls 10

assertNotNullMethod · 0.80
assertTrueMethod · 0.80
containsMethod · 0.65
getPageMethod · 0.65
parseMethod · 0.65
readMethod · 0.45
getVersionMethod · 0.45
getTextContentMethod · 0.45
getMethod · 0.45
getElementsByTagNameMethod · 0.45

Tested by

no test coverage detected