@Test public void parseMetadata() { MavenMetadataParser parser = new MavenMetadataParser(); assertNull(parser.parseMetadata(null, null)); MavenMetadataParser.Metadata metadata = parser.parseMetadata("classpath:mock-mvn-repo/log4j/log4j", null); assertEquals("1.2.16", metadata.latest); assertEquals(1, metadata.versions.size()); assertEquals("1.2.16", metadata.versions.get(0)); metadata = parser.parseMetadata("classpath:mock-mvn-repo/log4j/log4j/", null); assertEquals("1.2.16", metadata.latest); assertEquals(1, metadata.versions.size()); assertEquals("1.2.16", metadata.versions.get(0)); metadata = parser.parseMetadata("classpath:mock-mvn-repo/javax/mail/mail", null); assertEquals("1.4.4", metadata.latest); assertEquals(5, metadata.versions.size()); assertEquals("1.4.2", metadata.versions.get(0)); assertEquals("1.4.3-rc1", metadata.versions.get(1)); assertEquals("1.4.3", metadata.versions.get(2)); assertEquals("1.4.4-rc1", metadata.versions.get(3)); assertEquals("1.4.4", metadata.versions.get(4)); }
public Metadata parseMetadata(String baseUrl, Map<String, String> headers) { if (baseUrl == null) { return null; } if (!baseUrl.endsWith("/")) { baseUrl = baseUrl + "/"; } try { return parse(baseUrl + "maven-metadata.xml", headers); } catch (IOException ioe) { try { return parse(baseUrl + "metadata.xml", headers); } catch (Exception e) { throw new RuntimeException(e); } } catch (Exception e) { throw new RuntimeException(e); } }
MavenMetadataParser { public Metadata parseMetadata(String baseUrl, Map<String, String> headers) { if (baseUrl == null) { return null; } if (!baseUrl.endsWith("/")) { baseUrl = baseUrl + "/"; } try { return parse(baseUrl + "maven-metadata.xml", headers); } catch (IOException ioe) { try { return parse(baseUrl + "metadata.xml", headers); } catch (Exception e) { throw new RuntimeException(e); } } catch (Exception e) { throw new RuntimeException(e); } } }
MavenMetadataParser { public Metadata parseMetadata(String baseUrl, Map<String, String> headers) { if (baseUrl == null) { return null; } if (!baseUrl.endsWith("/")) { baseUrl = baseUrl + "/"; } try { return parse(baseUrl + "maven-metadata.xml", headers); } catch (IOException ioe) { try { return parse(baseUrl + "metadata.xml", headers); } catch (Exception e) { throw new RuntimeException(e); } } catch (Exception e) { throw new RuntimeException(e); } }  }
MavenMetadataParser { public Metadata parseMetadata(String baseUrl, Map<String, String> headers) { if (baseUrl == null) { return null; } if (!baseUrl.endsWith("/")) { baseUrl = baseUrl + "/"; } try { return parse(baseUrl + "maven-metadata.xml", headers); } catch (IOException ioe) { try { return parse(baseUrl + "metadata.xml", headers); } catch (Exception e) { throw new RuntimeException(e); } } catch (Exception e) { throw new RuntimeException(e); } }  Metadata parseMetadata(String baseUrl, Map<String, String> headers); }
MavenMetadataParser { public Metadata parseMetadata(String baseUrl, Map<String, String> headers) { if (baseUrl == null) { return null; } if (!baseUrl.endsWith("/")) { baseUrl = baseUrl + "/"; } try { return parse(baseUrl + "maven-metadata.xml", headers); } catch (IOException ioe) { try { return parse(baseUrl + "metadata.xml", headers); } catch (Exception e) { throw new RuntimeException(e); } } catch (Exception e) { throw new RuntimeException(e); } }  Metadata parseMetadata(String baseUrl, Map<String, String> headers);  }