use of org.apache.jackrabbit.api.JackrabbitNodeTypeManager in project jackrabbit by apache.
the class DocumentViewTest method setUp.
/**
* Sets up the test fixture.
*
* @throws Exception if an unexpected error occurs
*/
@Override
protected void setUp() throws Exception {
super.setUp();
JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager) superuser.getWorkspace().getNodeTypeManager();
try {
manager.getNodeType("DocViewMultiValueTest");
} catch (NoSuchNodeTypeException e) {
String cnd = "[DocViewMultiValueTest] - test (boolean) multiple";
Reader cndReader = new InputStreamReader(new ByteArrayInputStream(cnd.getBytes("UTF-8")));
CndImporter.registerNodeTypes(cndReader, superuser);
}
}
use of org.apache.jackrabbit.api.JackrabbitNodeTypeManager in project jackrabbit by apache.
the class AbstractRepositoryTest method createTestData.
protected void createTestData(Session session) throws Exception {
JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager) session.getWorkspace().getNodeTypeManager();
String cnd = "<nt='http://www.jcp.org/jcr/nt/1.0'>\n" + "<mix='http://www.jcp.org/jcr/mix/1.0'>\n" + "[nt:myversionable] > nt:unstructured, mix:versionable\n";
manager.registerNodeTypes(new ByteArrayInputStream(cnd.getBytes("UTF-8")), JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
Node root = session.getRootNode();
Node test = root.addNode("test", "nt:unstructured");
root.save();
Node versionable = createVersionable(test);
createProperties(test, versionable);
createLock(test);
createUsers(session);
}
use of org.apache.jackrabbit.api.JackrabbitNodeTypeManager in project jackrabbit by apache.
the class TestAll method testInvalidCNDNodeTypes.
/**
* Test for same node type name on node type import.
*/
public void testInvalidCNDNodeTypes() throws Exception {
JackrabbitNodeTypeManager ntm = (JackrabbitNodeTypeManager) superuser.getWorkspace().getNodeTypeManager();
try {
ntm.registerNodeTypes(TestAll.class.getResourceAsStream(TEST_SAME_NT_NAME_CND_NODETYPES), JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
fail("Importing multiple node types with the same name must fail");
} catch (RepositoryException e) {
if (e.getCause() instanceof InvalidNodeTypeDefException) {
// Expected
} else {
throw e;
}
}
}
use of org.apache.jackrabbit.api.JackrabbitNodeTypeManager in project jackrabbit by apache.
the class TestAll method testInvalidXMLNodeTypes.
/**
* Test for same node type name on node type import.
*/
public void testInvalidXMLNodeTypes() throws Exception {
JackrabbitNodeTypeManager ntm = (JackrabbitNodeTypeManager) superuser.getWorkspace().getNodeTypeManager();
try {
ntm.registerNodeTypes(TestAll.class.getResourceAsStream(TEST_SAME_NT_NAME_XML_NODETYPES), JackrabbitNodeTypeManager.TEXT_XML);
fail("Importing multiple node types with the same name must fail");
} catch (RepositoryException e) {
if (e.getCause() instanceof InvalidNodeTypeDefException) {
// Expected
} else {
throw e;
}
}
}
use of org.apache.jackrabbit.api.JackrabbitNodeTypeManager in project jackrabbit by apache.
the class TestContentLoader method loadTestContent.
public void loadTestContent(Session session) throws RepositoryException, IOException {
JackrabbitWorkspace workspace = (JackrabbitWorkspace) session.getWorkspace();
Collection<String> workspaces = Arrays.asList(workspace.getAccessibleWorkspaceNames());
if (!workspaces.contains("test")) {
workspace.createWorkspace("test");
}
JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager) workspace.getNodeTypeManager();
if (!manager.hasNodeType("test:versionable")) {
InputStream xml = TestContentLoader.class.getResourceAsStream("test-nodetypes.xml");
try {
manager.registerNodeTypes(xml, JackrabbitNodeTypeManager.TEXT_XML);
} finally {
xml.close();
}
}
Node data = getOrAddNode(session.getRootNode(), "testdata");
addPropertyTestData(getOrAddNode(data, "property"));
addQueryTestData(getOrAddNode(data, "query"));
addNodeTestData(getOrAddNode(data, "node"));
addLifecycleTestData(getOrAddNode(data, "lifecycle"));
addExportTestData(getOrAddNode(data, "docViewTest"));
Node conf = getOrAddNode(session.getRootNode(), "testconf");
addRetentionTestData(getOrAddNode(conf, "retentionTest"));
session.save();
}
Aggregations