Bundles { public static Artifact unresolvedArtifactFromURI(URI bundleIdentifier) { @Nullable String coordinates = bundleIdentifier.getSchemeSpecificPart(); if (URI_SCHEME.equals(bundleIdentifier.getScheme()) && coordinates != null && !coordinates.isEmpty()) { DefaultArtifact artifact = new DefaultArtifact(coordinates); if (ARTIFACT_TYPE.equals(artifact.getExtension())) { return artifact; } } throw new IllegalArgumentException(String.format( "Expected URI of form '%s:<groupId>:<artifactId>:%s[:<classifier>]:<version>', but got '%s'.", URI_SCHEME, ARTIFACT_TYPE, bundleIdentifier )); } private  Bundles(); static URI bundleIdentifierFromMaven(String groupId, String artifactId, Version version); static Artifact unresolvedArtifactFromURI(URI bundleIdentifier); static MutableBundle loadBundle(JAXBContext jaxbContext, XMLInputFactory xmlInputFactory,
            Artifact bundleArtifact); static final String URI_SCHEME; static final String ARTIFACT_TYPE; }
@Test public void testUnresolvedArtifactFromURI() { URI uri = Bundles.bundleIdentifierFromMaven("foo", "bar", Version.valueOf("1.0")); Artifact artifact = Bundles.unresolvedArtifactFromURI(uri); Assert.assertEquals(artifact.getGroupId(), "foo"); Assert.assertEquals(artifact.getArtifactId(), "bar"); Assert.assertEquals(artifact.getVersion(), "1.0"); Assert.assertNull(artifact.getFile()); try { Bundles.unresolvedArtifactFromURI(URI.create("http: Assert.fail(); } catch (IllegalArgumentException exception) { Assert.assertTrue(exception.getMessage().contains(Bundles.URI_SCHEME) && exception.getMessage().contains(Bundles.ARTIFACT_TYPE)); } }