/** * A simple check, if a missing node type is found */ public void testRegisterSimpleMissingNodeTypes() { /** * Constructs node types with the following structure: * [foo] * + myNTInFoo (I_am_an_invalid_required_primary_type) * */ final QNodeTypeDefinitionBuilder foo = new QNodeTypeDefinitionBuilder(); foo.setName(nameFactory.create("", "foo")); foo.setSupertypes(new Name[]{NameConstants.NT_BASE}); QNodeDefinitionBuilder myBarInFoo = new QNodeDefinitionBuilder(); myBarInFoo.setRequiredPrimaryTypes(new Name[]{nameFactory.create("", "I_am_an_invalid_required_primary_type")}); myBarInFoo.setName(nameFactory.create("", "myNTInFoo")); myBarInFoo.setDeclaringNodeType(foo.getName()); foo.setChildNodeDefs(new QNodeDefinition[]{myBarInFoo.build()}); ntDefCollection = new LinkedList<QNodeTypeDefinition>(); ntDefCollection.add(foo.build()); try { ntreg.registerNodeTypes(ntDefCollection); assertFalse("Missing node type not found", true); } catch (InvalidNodeTypeDefException e) { assertTrue(true); } catch (RepositoryException e) { assertFalse("Wrong Exception thrown on missing node type.", true); e.printStackTrace(); } }
/** * Sets up the fixture for the test cases. */ protected void setUp() throws Exception { //isReadOnly = true; super.setUp(); session = getHelper().getReadOnlySession(); manager = session.getWorkspace().getNodeTypeManager(); nameFactory = NameFactoryImpl.getInstance(); // Get the NodeTypeManager from the Workspace. // Note that it must be cast from the generic JCR NodeTypeManager to the // Jackrabbit-specific implementation. NodeTypeManagerImpl ntmgr = (NodeTypeManagerImpl) session.getWorkspace().getNodeTypeManager(); // Acquire the NodeTypeRegistry ntreg = ntmgr.getNodeTypeRegistry(); }
ntreg.registerNodeTypes(ntDefCollection); } catch (InvalidNodeTypeDefException e) { assertFalse(e.getMessage(), true); e.printStackTrace(); } catch (RepositoryException e) { assertFalse(e.getMessage(), true); e.printStackTrace(); assertTrue(allNTsAreRegistered);
ntreg.registerNodeTypes(ntDefCollection); } catch (InvalidNodeTypeDefException e) { assertFalse(e.getMessage(), true); e.printStackTrace(); } catch (RepositoryException e) { assertFalse(e.getMessage(), true); e.printStackTrace(); assertTrue(allNTsAreRegistered);