}
private void inPkg(AddPartBehaviour mode, int partsAdded, int relsAdded, boolean expectReplace) throws Exception {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
HeaderPart part = new HeaderPart();
wordMLPackage.getMainDocumentPart().addTargetPart(part, mode);
// int mdpRelsCountBefore = wordMLPackage.getMainDocumentPart().getRelationshipsPart().size();
int rootRelsCountBefore = wordMLPackage.getRelationshipsPart().size();
int partsCountBefore = wordMLPackage.getParts().getParts().size();
// Add it again
// Note that we're adding this ELSEWHERE in the pkg for the purposes of this test only
HeaderPart part2 = new HeaderPart();
Relationship rel = wordMLPackage.addTargetPart(part2, mode);
if (mode==AddPartBehaviour.REUSE_EXISTING) {
// In the REUSE_EXISTING case, we won't be adding this part, so
// we can't add content to it (since its pkg isn't set)
part2 = (HeaderPart)wordMLPackage.getRelationshipsPart().getPart(rel);
}
part2.getContent().add(Context.getWmlObjectFactory().createP() );
// Just added a part
//Assert.assertTrue("hmm", wordMLPackage.getMainDocumentPart().getRelationshipsPart().size()==mdpRelsCountBefore+expectedIncrement);
Assert.assertTrue("hmm", wordMLPackage.getRelationshipsPart().size()==rootRelsCountBefore+relsAdded);
Assert.assertTrue("hmm", wordMLPackage.getParts().getParts().size()==partsCountBefore+partsAdded);
// Check this part is the one we added - differentiated by its content
HeaderPart result = (HeaderPart)wordMLPackage.getRelationshipsPart().getPart(rel);
if (expectReplace) {
Assert.assertTrue("hmm", result.getContent().size()==1);
} else {
Assert.assertTrue("hmm", result.getContent().size()==0);
}