/** * Testing initial boot of Nexus with WL feature. Asserting that Central (and hence Public group, * that has Central and only one proxy member) has WL published, since Central discovery * succeeded. * * @throws Exception */ @Test public void whitelistLooksSane() throws Exception { // central Status centralStatus = whitelist().getWhitelistStatus("central"); assertThat(centralStatus.getPublishedStatus(), equalTo(Outcome.SUCCEEDED)); assertThat(centralStatus.getPublishedUrl(), is(notNullValue())); assertThat(centralStatus.getDiscoveryStatus(), is(notNullValue())); assertThat( centralStatus.getDiscoveryStatus().getDiscoveryLastStatus(), equalTo(Outcome.SUCCEEDED)); // let's check some sanity (just blindly check that some expected entries are present) final InputStream entityStream = getPrefixFileFrom(centralStatus.getPublishedUrl()); try { final LineNumberReader lnr = new LineNumberReader(new InputStreamReader(entityStream, "UTF-8")); boolean hasAbbot = false; boolean hasComApple = false; boolean hasOrgSonatype = false; String currentLine = lnr.readLine(); while (currentLine != null) { hasAbbot = hasAbbot || "/abbot".equals(currentLine); hasComApple = hasComApple || "/com/apple".equals(currentLine); hasOrgSonatype = hasOrgSonatype || "/org/sonatype".equals(currentLine); currentLine = lnr.readLine(); } // check is this what we think should be assertThat("Line /abbot is missing?", hasAbbot); assertThat("Line /com/apple is missing?", hasComApple); assertThat("Line /org/sonatype is missing?", hasOrgSonatype); // count lines lnr.skip(Long.MAX_VALUE); // 2013. 02. 08. Today, Nexus scraped prefix file with 5517 lines (depth=2) // So, safely assuming the prefix file MUST HAVE more than 5k lines // Naturally, if depth changes, making it lesser, this might fail. // 2012. 02. 14. Today the prefix file is deployed to Central, no more scraping // The prefix file has around 1600 entries. assertThat(lnr.getLineNumber() + 1, is(greaterThanOrEqualTo(1000))); } finally { Closeables.closeQuietly(entityStream); } }