protected JCRSiteNode site;
@Before
public void setUp() throws Exception {
try {
JahiaSite site = TestHelper.createSite("test");
paramBean = (ParamBean) Jahia.getThreadParamBean();
paramBean.getSession(true).setAttribute(ParamBean.SESSION_SITE, site);
session = JCRSessionFactory.getInstance().getCurrentUserSession(Constants.EDIT_WORKSPACE, Locale.ENGLISH);
this.site = (JCRSiteNode) session.getNode("/sites/"+site.getSiteKey());
String templatesFolder = "/sites/"+site.getSiteKey() + "/templates";
InputStream importStream = IndexOptionsTest.class.getClassLoader()
.getResourceAsStream("imports/importTemplatesForCacheTest.xml");
session.importXML(templatesFolder + "/base", importStream,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
importStream.close();
session.save();
JCRNodeWrapper shared = this.site.getNode("home");
if (shared.hasNode("testContent")) {
shared.getNode("testContent").remove();
}
if(shared.isVersioned()) session.checkout(shared);
node = shared.addNode("testContent", "jnt:page");
node.setProperty("jcr:title", "English test page");
node.setProperty("j:templateNode", session.getNode(
templatesFolder + "/base/pagetemplate/subpagetemplate"));
node.addNode("testType2", "jnt:mainContent");
session.save();
final JCRPublicationService service = JCRPublicationService.getInstance();
List<PublicationInfo> infoList = service.getPublicationInfo(
session.getNode(
templatesFolder + "/base/pagetemplate").getIdentifier(), new LinkedHashSet<String>(Arrays.asList(Locale.ENGLISH.toString())),
true, true, true, Constants.EDIT_WORKSPACE, Constants.LIVE_WORKSPACE);
service.publishByInfoList(infoList, Constants.EDIT_WORKSPACE, Constants.LIVE_WORKSPACE,Collections.<String>emptyList());
infoList = service.getPublicationInfo(
shared.getIdentifier(), new LinkedHashSet<String>(Arrays.asList(Locale.ENGLISH.toString())),
true, true, true, Constants.EDIT_WORKSPACE, Constants.LIVE_WORKSPACE);
service.publishByInfoList(infoList, Constants.EDIT_WORKSPACE, Constants.LIVE_WORKSPACE,Collections.<String>emptyList());
session = JCRSessionFactory.getInstance().getCurrentUserSession(Constants.LIVE_WORKSPACE, Locale.ENGLISH);
node = session.getNode("/sites/"+site.getSiteKey()+"/home/testContent");
} catch (Exception e) {
logger.warn("Exception during test setUp", e);
}
}