CndImporter { public void importFrom( InputStream stream, Problems problems, String resourceName ) throws IOException { importFrom(IoUtil.read(stream), problems, resourceName); } CndImporter( ExecutionContext context ); void importFrom( InputStream stream,
                            Problems problems,
                            String resourceName ); void importFrom( File file,
                            Problems problems ); void importFrom( String content,
                            Problems problems,
                            String resourceName ); void importBuiltIns( Problems problems ); Set<NamespaceRegistry.Namespace> getNamespaces(); List<NodeTypeDefinition> getNodeTypeDefinitions(); static final boolean DEFAULT_USE_VENDOR_EXTENSIONS; static final boolean DEFAULT_COMPATIBLE_WITH_PREJCR2; }
@Test public void shouldImportCndForMp3Sequencer() throws Exception { importer.importFrom(openCndFile("mp3.cnd"), problems); if (problems.size() != 0) printProblems(); assertThat(problems.size(), is(0)); }
@Test public void shouldImportCndForTeiidSequencer() throws Exception { importer.importFrom(openCndFile("teiid.cnd"), problems); if (problems.size() != 0) printProblems(); registerImportedNamespaces(); assertThat(problems.size(), is(0)); assertNodeType("relational:catalog", new String[] {"nt:unstructured", "relational:relationalEntity"}, NO_PRIMARY_NAME, NodeOptions.Queryable, NodeOptions.Ordered); }
@Test public void shouldNotImportFileThatIsNotAValidCnd() throws Exception { importer.importFrom(openCndFile("invalid.cnd"), problems); assertThat(problems.size(), is(1)); }
@Test public void shouldImportCndForAircraft() throws Exception { importer.importFrom(openCndFile("aircraft.cnd"), problems); if (problems.size() != 0) printProblems(); assertThat(problems.size(), is(0)); }
@Test public void shouldImportCndForCars() throws Exception { importer.importFrom(openCndFile("cars.cnd"), problems); if (problems.size() != 0) printProblems(); assertThat(problems.size(), is(0)); }
@Test public void shouldImportCndForJavaSequencer() throws Exception { importer.importFrom(openCndFile("javaSource.cnd"), problems); if (problems.size() != 0) printProblems(); assertThat(problems.size(), is(0)); }
@Test public void shouldImportCndThatIsOnOneLine() { String cnd = "<ns = 'http: + "<ex = 'http: + "[ns:NodeType] > ns:ParentType1, ns:ParentType2 abstract orderable mixin noquery primaryitem ex:property " + "- ex:property (STRING) = 'default1', 'default2' mandatory autocreated protected multiple VERSION < 'constraint1', 'constraint2' " + " queryops '=, <>, <, <=, >, >=, LIKE' nofulltext noqueryorder " + "+ ns:node (ns:reqType1, ns:reqType2) = ns:defaultType mandatory autocreated protected sns version"; importer.importFrom(cnd, problems, "string"); }
@Test public void shouldImportCndThatHasNoChildren() { String cnd = "<ns = 'http: + "<ex = 'http: + "[ns:NodeType] > ns:ParentType1, ns:ParentType2 abstract orderable mixin noquery primaryitem ex:property\n" + "- ex:property (STRING) = 'default1', 'default2' mandatory autocreated protected multiple VERSION < 'constraint1', 'constraint2'\n" + " queryops '=, <>, <, <=, >, >=, LIKE' nofulltext noqueryorder"; importer.importFrom(cnd, problems, "string"); }
@Test @FixFor( "MODE-1696" ) public void shouldRaiseProblemsImportingJcrBuiltinNodeTypesForJSR170() throws Exception { importer.importFrom(openCndFile("jcr-builtins-170.cnd"), problems); if (problems.size() != 0) printProblems(); registerImportedNamespaces(); assertThat(problems.size(), is(1)); }
@Test public void shouldImportJcrBuiltinNodeTypesForJSR283() throws Exception { importer.importFrom(openCndFile("jcr-builtins-283-early-draft.cnd"), problems); if (problems.size() != 0) printProblems(); registerImportedNamespaces(); assertThat(problems.size(), is(0)); assertNodeType("nt:base", new String[] {"mode:defined"}, NO_PRIMARY_NAME, NodeOptions.Abstract, NodeOptions.Queryable); assertProperty("nt:base", "jcr:primaryType", "Name", NO_DEFAULTS, new PropertyOptions[] {PropertyOptions.Mandatory, PropertyOptions.Autocreated, PropertyOptions.Protected, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable}, OnParentVersion.Compute); assertProperty("nt:base", "jcr:mixinTypes", "Name", NO_DEFAULTS, new PropertyOptions[] {PropertyOptions.Multiple, PropertyOptions.Protected, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable}, OnParentVersion.Compute); assertNodeType("nt:unstructured", NO_SUPERTYPES, NO_PRIMARY_NAME, NodeOptions.Ordered, NodeOptions.Queryable); assertProperty("nt:unstructured", "*", "Undefined", NO_DEFAULTS, PropertyOptions.Multiple, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable); assertChild("nt:unstructured", "*", "nt:base", "nt:unstructured", OnParentVersion.Version, ChildOptions.Multiple, ChildOptions.Sns); assertNodeType("mix:referenceable", NO_SUPERTYPES, NO_PRIMARY_NAME, NodeOptions.Mixin, NodeOptions.Queryable); assertProperty("mix:referenceable", "jcr:uuid", "String", NO_DEFAULTS, OnParentVersion.Initialize, PropertyOptions.Mandatory, PropertyOptions.Autocreated, PropertyOptions.Protected, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable); assertNodeType("mix:lockable", NO_SUPERTYPES, NO_PRIMARY_NAME, NodeOptions.Mixin, NodeOptions.Queryable); assertProperty("mix:lockable", "jcr:lockOwner", "String", NO_DEFAULTS, OnParentVersion.Ignore, PropertyOptions.Protected, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable); assertProperty("mix:lockable", "jcr:lockIsDeep", "Boolean", NO_DEFAULTS, OnParentVersion.Ignore, PropertyOptions.Protected, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable); assertNodeType("nt:propertyDefinition", NO_SUPERTYPES, NO_PRIMARY_NAME, NodeOptions.Queryable); assertProperty("nt:propertyDefinition", "jcr:name", "Name", NO_DEFAULTS, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable); assertProperty("nt:propertyDefinition", "jcr:autoCreated", "Boolean", NO_DEFAULTS, PropertyOptions.Mandatory, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable); assertProperty("nt:propertyDefinition", "jcr:mandatory", "Boolean", NO_DEFAULTS, PropertyOptions.Mandatory, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable); assertProperty("nt:propertyDefinition", "jcr:onParentVersion", "String", NO_DEFAULTS, new PropertyOptions[] { PropertyOptions.Mandatory, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable}, null, new String[] { "COPY", "VERSION", "INITIALIZE", "COMPUTE", "IGNORE", "ABORT"}); assertProperty("nt:propertyDefinition", "jcr:protected", "Boolean", NO_DEFAULTS, PropertyOptions.Mandatory, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable); assertProperty("nt:propertyDefinition", "jcr:requiredType", "String", NO_DEFAULTS, new PropertyOptions[] { PropertyOptions.Mandatory, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable}, null, new String[] { "STRING", "BINARY", "LONG", "DOUBLE", "BOOLEAN", "DATE", "NAME", "PATH", "REFERENCE", "UNDEFINED"}); assertProperty("nt:propertyDefinition", "jcr:valueConstraints", "String", NO_DEFAULTS, PropertyOptions.Multiple, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable); assertProperty("nt:propertyDefinition", "jcr:defaultValues", "Undefined", NO_DEFAULTS, PropertyOptions.Multiple, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable); assertProperty("nt:propertyDefinition", "jcr:multiple", "Boolean", NO_DEFAULTS, PropertyOptions.Mandatory, PropertyOptions.FullTextSearchable, PropertyOptions.QueryOrderable); }
@Test public void shouldImportCndThatIsEmpty() throws Exception { importer.importFrom(openCndFile("empty.cnd"), problems); if (problems.size() != 0) printProblems(); assertThat(problems.size(), is(0)); }
@Test public void shouldImportCndForImageSequencer() throws Exception { importer.importFrom(openCndFile("images.cnd"), problems); if (problems.size() != 0) printProblems(); assertThat(problems.size(), is(0)); }