Program: 6225
Project: 6225
Buggy source:
@Test public void testPluginNamespaceIsolation() throws Exception {
  Id.Artifact systemId=Id.Artifact.from(Id.Namespace.SYSTEM,"String_Node_Str","String_Node_Str");
  File systemArtifact=buildAppArtifact(WordCountApp.class,"String_Node_Str");
  artifactRepository.addArtifact(systemId,systemArtifact,Sets.<ArtifactRange>newHashSet());
  Set<ArtifactRange> parents=Sets.newHashSet(new ArtifactRange(systemId.getNamespace(),systemId.getName(),systemId.getVersion(),true,systemId.getVersion(),true));
  Id.Namespace namespace1=Id.Namespace.from("String_Node_Str");
  Id.Namespace namespace2=Id.Namespace.from("String_Node_Str");
  createNamespace(namespace1.getId());
  createNamespace(namespace2.getId());
  try {
    Manifest manifest=new Manifest();
    manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,Plugin1.class.getPackage().getName());
    Id.Artifact pluginsId1=Id.Artifact.from(namespace1,"String_Node_Str","String_Node_Str");
    Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(pluginsId1,Plugin1.class,manifest,parents).getStatusLine().getStatusCode());
    manifest=new Manifest();
    manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,Plugin1.class.getPackage().getName());
    Id.Artifact pluginsId2=Id.Artifact.from(namespace2,"String_Node_Str","String_Node_Str");
    Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(pluginsId2,Plugin1.class,manifest,parents).getStatusLine().getStatusCode());
    ArtifactSummary artifact1=new ArtifactSummary(pluginsId1.getName(),pluginsId1.getVersion().getVersion(),ArtifactScope.USER);
    ArtifactSummary artifact2=new ArtifactSummary(pluginsId2.getName(),pluginsId2.getVersion().getVersion(),ArtifactScope.USER);
    PluginSummary summary1Namespace1=new PluginSummary("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),artifact1);
    PluginSummary summary2Namespace1=new PluginSummary("String_Node_Str","String_Node_Str","String_Node_Str",Plugin2.class.getName(),artifact1);
    PluginSummary summary1Namespace2=new PluginSummary("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),artifact2);
    PluginSummary summary2Namespace2=new PluginSummary("String_Node_Str","String_Node_Str","String_Node_Str",Plugin2.class.getName(),artifact2);
    PluginInfo info1Namespace1=new PluginInfo("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),artifact1,ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true),"String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true)));
    PluginInfo info2Namespace1=new PluginInfo("String_Node_Str","String_Node_Str","String_Node_Str",Plugin2.class.getName(),artifact1,ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true)));
    PluginInfo info1Namespace2=new PluginInfo("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),artifact2,ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true),"String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true)));
    PluginInfo info2Namespace2=new PluginInfo("String_Node_Str","String_Node_Str","String_Node_Str",Plugin2.class.getName(),artifact2,ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true)));
    Id.Artifact namespace1Artifact=Id.Artifact.from(namespace1,systemId.getName(),systemId.getVersion());
    Id.Artifact namespace2Artifact=Id.Artifact.from(namespace2,systemId.getName(),systemId.getVersion());
    Assert.assertEquals(ImmutableSet.of("String_Node_Str","String_Node_Str"),getPluginTypes(namespace1Artifact,ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of("String_Node_Str","String_Node_Str"),getPluginTypes(namespace2Artifact,ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(summary1Namespace1),getPluginSummaries(namespace1Artifact,"String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(summary2Namespace1),getPluginSummaries(namespace1Artifact,"String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(info1Namespace1),getPluginInfos(namespace1Artifact,"String_Node_Str","String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(info2Namespace1),getPluginInfos(namespace1Artifact,"String_Node_Str","String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(summary1Namespace2),getPluginSummaries(namespace2Artifact,"String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(summary2Namespace2),getPluginSummaries(namespace2Artifact,"String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(info1Namespace2),getPluginInfos(namespace2Artifact,"String_Node_Str","String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(info2Namespace2),getPluginInfos(namespace2Artifact,"String_Node_Str","String_Node_Str",ArtifactScope.SYSTEM));
  }
  finally {
    deleteNamespace("String_Node_Str");
    deleteNamespace("String_Node_Str");
  }
}

Fixed version (ground truth):
@Test public void testPluginNamespaceIsolation() throws Exception {
  Id.Artifact systemId=Id.Artifact.from(Id.Namespace.SYSTEM,"String_Node_Str","String_Node_Str");
  File systemArtifact=buildAppArtifact(WordCountApp.class,"String_Node_Str");
  artifactRepository.addArtifact(systemId,systemArtifact,Sets.<ArtifactRange>newHashSet());
  Set<ArtifactRange> parents=Sets.newHashSet(new ArtifactRange(systemId.getNamespace(),systemId.getName(),systemId.getVersion(),true,systemId.getVersion(),true));
  Id.Namespace namespace1=Id.Namespace.from("String_Node_Str");
  Id.Namespace namespace2=Id.Namespace.from("String_Node_Str");
  createNamespace(namespace1.getId());
  createNamespace(namespace2.getId());
  try {
    Manifest manifest=new Manifest();
    manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,Plugin1.class.getPackage().getName());
    Id.Artifact pluginsId1=Id.Artifact.from(namespace1,"String_Node_Str","String_Node_Str");
    Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(pluginsId1,Plugin1.class,manifest,parents).getStatusLine().getStatusCode());
    manifest=new Manifest();
    manifest.getMainAttributes().put(ManifestFields.EXPORT_PACKAGE,Plugin1.class.getPackage().getName());
    Id.Artifact pluginsId2=Id.Artifact.from(namespace2,"String_Node_Str","String_Node_Str");
    Assert.assertEquals(HttpResponseStatus.OK.getCode(),addPluginArtifact(pluginsId2,Plugin1.class,manifest,parents).getStatusLine().getStatusCode());
    ArtifactSummary artifact1=new ArtifactSummary(pluginsId1.getName(),pluginsId1.getVersion().getVersion(),ArtifactScope.USER);
    ArtifactSummary artifact2=new ArtifactSummary(pluginsId2.getName(),pluginsId2.getVersion().getVersion(),ArtifactScope.USER);
    PluginSummary summary1Namespace1=new PluginSummary("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),artifact1);
    PluginSummary summary2Namespace1=new PluginSummary("String_Node_Str","String_Node_Str","String_Node_Str",Plugin2.class.getName(),artifact1);
    PluginSummary summary1Namespace2=new PluginSummary("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),artifact2);
    PluginSummary summary2Namespace2=new PluginSummary("String_Node_Str","String_Node_Str","String_Node_Str",Plugin2.class.getName(),artifact2);
    PluginInfo info1Namespace1=new PluginInfo("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),artifact1,ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true),"String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true)),new HashSet<String>());
    PluginInfo info2Namespace1=new PluginInfo("String_Node_Str","String_Node_Str","String_Node_Str",Plugin2.class.getName(),artifact1,ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true)),new HashSet<String>());
    PluginInfo info1Namespace2=new PluginInfo("String_Node_Str","String_Node_Str","String_Node_Str",Plugin1.class.getName(),artifact2,ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true),"String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true)),new HashSet<String>());
    PluginInfo info2Namespace2=new PluginInfo("String_Node_Str","String_Node_Str","String_Node_Str",Plugin2.class.getName(),artifact2,ImmutableMap.of("String_Node_Str",new PluginPropertyField("String_Node_Str","String_Node_Str","String_Node_Str",true)),new HashSet<String>());
    Id.Artifact namespace1Artifact=Id.Artifact.from(namespace1,systemId.getName(),systemId.getVersion());
    Id.Artifact namespace2Artifact=Id.Artifact.from(namespace2,systemId.getName(),systemId.getVersion());
    Assert.assertEquals(ImmutableSet.of("String_Node_Str","String_Node_Str"),getPluginTypes(namespace1Artifact,ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of("String_Node_Str","String_Node_Str"),getPluginTypes(namespace2Artifact,ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(summary1Namespace1),getPluginSummaries(namespace1Artifact,"String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(summary2Namespace1),getPluginSummaries(namespace1Artifact,"String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(info1Namespace1),getPluginInfos(namespace1Artifact,"String_Node_Str","String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(info2Namespace1),getPluginInfos(namespace1Artifact,"String_Node_Str","String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(summary1Namespace2),getPluginSummaries(namespace2Artifact,"String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(summary2Namespace2),getPluginSummaries(namespace2Artifact,"String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(info1Namespace2),getPluginInfos(namespace2Artifact,"String_Node_Str","String_Node_Str",ArtifactScope.SYSTEM));
    Assert.assertEquals(ImmutableSet.of(info2Namespace2),getPluginInfos(namespace2Artifact,"String_Node_Str","String_Node_Str",ArtifactScope.SYSTEM));
  }
  finally {
    deleteNamespace("String_Node_Str");
    deleteNamespace("String_Node_Str");
  }
}