map1.put("prop3", "v3");
map1.put("prop4", "v4");
selectionInformation = new SelectionInformation("perm2", 0, map1);
artifactSet.add(selectionInformation);
// put in some files
SyntheticArtifact a1 =
new SyntheticArtifact(PermutationMapLinker.class, "1.test", "bla".getBytes("UTF-8"));
artifactSet.add(a1);
SyntheticArtifact a2 =
new SyntheticArtifact(PermutationMapLinker.class, "2.test", "bla1".getBytes("UTF-8"));
artifactSet.add(a2);
ConfigurationProperty standardConfigurationProperty =
mock(MyConfigurationProperty.class);
when(standardConfigurationProperty.getValues()).thenReturn(Arrays.asList("index.html"));
when(standardConfigurationProperty.getName()).thenReturn(
PermutationMapLinker.EXTERNAL_FILES_CONFIGURATION_PROPERTY_NAME);
TreeSet<ConfigurationProperty> set = new TreeSet<ConfigurationProperty>();
set.add(standardConfigurationProperty);
when(linkerContext.getConfigurationProperties()).thenReturn(set);
// lets put in two permutationartifacts
HashSet<String> files = new HashSet<String>();
files.add("perm1_file1");
files.add("perm1_file2");
HashSet<BindingProperty> bpSet = new HashSet<BindingProperty>();
bpSet.add(new BindingProperty("sel1", "1"));
artifactSet.add(new PermutationArtifact(PermutationMapLinker.class, "perm1", files, bpSet));
files = new HashSet<String>();
files.add("perm2_file1");
files.add("perm2_file2");
bpSet = new HashSet<BindingProperty>();
bpSet.add(new BindingProperty("sel1", "2"));
artifactSet.add(new PermutationArtifact(PermutationMapLinker.class, "perm2", files, bpSet));
ArtifactSet linkedSet = permutationMapLinker.link(null, linkerContext, artifactSet, false);
SortedSet<SyntheticArtifact> pas = linkedSet.find(SyntheticArtifact.class);
Assert.assertEquals(7, pas.size());
// manifest for first permutation
SyntheticArtifact artifact =
getArtifact("perm1" + PermutationMapLinker.PERMUTATION_MANIFEST_FILE_ENDING, pas);
Assert.assertNotNull(artifact);
InputStream contents = artifact.getContents(null);
// test some things on artifact...
StringWriter writer = new StringWriter();
IOUtils.copy(contents, writer, "UTF-8");
String theString = writer.toString();
Assert.assertTrue(theString.startsWith("CACHE MANIFEST"));
Assert.assertTrue(theString.contains("perm1_file2"));
Assert.assertTrue(theString.contains("strong/1.test"));
Assert.assertTrue(theString.contains("perm1_file1"));
Assert.assertTrue(theString.contains("strong/2.test"));
Assert.assertTrue(theString.contains("index.html"));
Assert.assertTrue(!theString.contains("perm2_file2"));
Assert.assertTrue(!theString.contains("perm2_file1"));
// manifest for second permutation
artifact = getArtifact("perm2" + PermutationMapLinker.PERMUTATION_MANIFEST_FILE_ENDING, pas);
Assert.assertNotNull(artifact);
contents = artifact.getContents(null);
// test some things on artifact...
writer = new StringWriter();
IOUtils.copy(contents, writer, "UTF-8");
theString = writer.toString();
Assert.assertTrue(theString.startsWith("CACHE MANIFEST"));
Assert.assertTrue(theString.contains("perm2_file2"));
Assert.assertTrue(theString.contains("strong/1.test"));
Assert.assertTrue(theString.contains("perm2_file1"));
Assert.assertTrue(theString.contains("strong/2.test"));
Assert.assertTrue(theString.contains("index.html"));
Assert.assertTrue(!theString.contains("perm1_file2"));
Assert.assertTrue(!theString.contains("perm1_file1"));
// manifest map file
artifact = getArtifact(PermutationMapLinker.MANIFEST_MAP_FILE_NAME, pas);
Assert.assertNotNull(artifact);
contents = artifact.getContents(null);
// test some things on artifact...
writer = new StringWriter();
IOUtils.copy(contents, writer, "UTF-8");
theString = writer.toString();
Assert.assertTrue(theString.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));