### Question:
ManifestMatcher implements VersionMatcher { public VersionMatchResult matches(DeploymentInfo info) { if(info.getManifest() == null || info.getManifest().size() == 0) { return VersionMatchResult.SKIPPED; } for (ManifestInfo manifest: info.getManifest()) { VersionMatchResult result = match(manifest); if(VersionMatchResult.MATCHED.equals(result)){ LOGGER.debug("Matched {} with {}", this, manifest); return VersionMatchResult.MATCHED; } if(VersionMatchResult.REJECTED.equals(result)){ LOGGER.debug("Rejected {} with {}", this, manifest); return VersionMatchResult.REJECTED; } } return VersionMatchResult.SKIPPED; } ManifestMatcher(Manifest cfg); VersionRange getIncludes(); VersionRange getExcludes(); Map<Name, String> getProperties(); VersionMatchResult matches(DeploymentInfo info); @Override String toString(); @Override boolean isApply();  }### Answer:
@Test public void testFails() throws IOException { Set<MavenInfo> maven = new HashSet<MavenInfo>(); ManifestInfo manifest = new ManifestInfo(new java.util.jar.Manifest(this.getClass().getResourceAsStream("/org/hotswap/agent/versions/matcher/TEST.MF"))); DeploymentInfo info = new DeploymentInfo(maven, Collections.singleton(manifest)); System.err.println(info); PluginMatcher p = new PluginMatcher(NotMatchingPlugin.class); assertEquals("Not Matching",VersionMatchResult.REJECTED, p.matches(info)); }
@Test public void testFailedEmptyArtifactInfo() throws IOException { Set<MavenInfo> maven = new HashSet<MavenInfo>(); ManifestInfo manifest = new ManifestInfo(null); DeploymentInfo info = new DeploymentInfo(maven, Collections.singleton(manifest)); System.err.println(info); PluginMatcher p = new PluginMatcher(NotMatchingPlugin.class); assertEquals("Failed Matching",VersionMatchResult.REJECTED, p.matches(info)); }
@Test public void testSkippedEmpty2() throws IOException { Set<MavenInfo> maven = new HashSet<MavenInfo>(); ManifestInfo manifest = new ManifestInfo(null); DeploymentInfo info = new DeploymentInfo(maven, Collections.singleton(manifest)); System.err.println(info); PluginMatcher p = new PluginMatcher(PluginMatcherTest.class); assertEquals("Skipped Matching",VersionMatchResult.SKIPPED, p.matches(info)); }
@Test public void testSkipped() throws IOException { Set<MavenInfo> maven = new HashSet<MavenInfo>(); ManifestInfo manifest = new ManifestInfo(new java.util.jar.Manifest(this.getClass().getResourceAsStream("/org/hotswap/agent/versions/matcher/TEST.MF"))); DeploymentInfo info = new DeploymentInfo(maven, Collections.singleton(manifest)); System.err.println(info); PluginMatcher p = new PluginMatcher(PluginMatcherTest.class); assertEquals("Skipped Matching",VersionMatchResult.SKIPPED, p.matches(info)); }
@Test public void testMatches() throws IOException { Set<MavenInfo> maven = new HashSet<MavenInfo>(); ManifestInfo manifest = new ManifestInfo(new java.util.jar.Manifest(this.getClass().getResourceAsStream("/org/hotswap/agent/versions/matcher/TEST.MF"))); DeploymentInfo info = new DeploymentInfo(maven, Collections.singleton(manifest)); System.err.println(info); PluginMatcher p = new PluginMatcher(MatchingPlugin.class); System.err.println(p); assertEquals("Matching",VersionMatchResult.MATCHED, p.matches(info)); }
@Test public void testMatchesManifestEmptyLine() throws IOException { Set<MavenInfo> maven = new HashSet<MavenInfo>(); ManifestInfo manifest = new ManifestInfo(new java.util.jar.Manifest(this.getClass().getResourceAsStream("/org/hotswap/agent/versions/matcher/TEST_EMPTYLINE.MF"))); DeploymentInfo info = new DeploymentInfo(maven, Collections.singleton(manifest)); System.err.println(info); PluginMatcher p = new PluginMatcher(MatchingPlugin2.class); System.err.println(p); assertEquals("Matching",VersionMatchResult.MATCHED, p.matches(info)); }