Re: svn commit: r1834852 - /jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/
The task was so trivial I haven't checked for other implementations. I will for sure turn to Felix in case my requirements become more complicated than that. On Mon, 2 Jul 2018 at 19:57, Julian Sedding wrote: > Hi Francesco > > Have you considered using the MetaTypeReader from Felix' MetyType > implementation[0]? I've used it before and found it easy enough to > use. > > It's only a test dependency, and you don't need to worry about your > implementation being in sync with the spec/Felix' implementation. > > Regards > Julian > > [0] > https://github.com/apache/felix/blob/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java > > On Mon, Jul 2, 2018 at 4:57 PM, wrote: > > Author: frm > > Date: Mon Jul 2 14:57:25 2018 > > New Revision: 1834852 > > > > URL: http://svn.apache.org/viewvc?rev=1834852&view=rev > > Log: > > OAK-6770 - Test the metatype information descriptors > > > > Added: > > > > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/MetatypeInformation.java > (with props) > > Modified: > > > > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/SegmentNodeStoreFactoryTest.java > > > > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/SegmentNodeStoreMonitorServiceTest.java > > > > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/SegmentNodeStoreServiceTest.java > > > > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/StandbyStoreServiceTest.java > > > > Added: > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/MetatypeInformation.java > > URL: > http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/MetatypeInformation.java?rev=1834852&view=auto > > > == > > --- > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/MetatypeInformation.java > (added) > > +++ > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/MetatypeInformation.java > Mon Jul 2 14:57:25 2018 > > @@ -0,0 +1,267 @@ > > +/* > > + * Licensed to the Apache Software Foundation (ASF) under one > > + * or more contributor license agreements. See the NOTICE file > > + * distributed with this work for additional information > > + * regarding copyright ownership. The ASF licenses this file > > + * to you under the Apache License, Version 2.0 (the > > + * "License"); you may not use this file except in compliance > > + * with the License. You may obtain a copy of the License at > > + * > > + * http://www.apache.org/licenses/LICENSE-2.0 > > + * > > + * Unless required by applicable law or agreed to in writing, > > + * software distributed under the License is distributed on an > > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > > + * KIND, either express or implied. See the License for the > > + * specific language governing permissions and limitations > > + * under the License. > > + */ > > + > > +package org.apache.jackrabbit.oak.segment.osgi; > > + > > +import java.io.InputStream; > > +import java.util.HashSet; > > +import java.util.Set; > > + > > +import javax.xml.parsers.DocumentBuilder; > > +import javax.xml.parsers.DocumentBuilderFactory; > > + > > +import org.w3c.dom.Document; > > +import org.w3c.dom.Element; > > +import org.w3c.dom.NodeList; > > + > > +class MetatypeInformation { > > + > > +static MetatypeInformation open(InputStream stream) throws > Exception { > > +DocumentBuilderFactory factory = > DocumentBuilderFactory.newInstance(); > > +DocumentBuilder builder = factory.newDocumentBuilder(); > > +Document document = builder.parse(stream); > > +return new MetatypeInformation(document.getDocumentElement()); > > +} > > + > > +private static boolean hasAttribute(Element element, String name, > String value) { > > +return element.hasAttribute(name) && > element.getAttribute(name).equals(value); > > +} > > + > > +private final Element root; > > + > > +private MetatypeInformation(Element root) { > > +this.root = root; > > +} > > + > > +ObjectClassDefinition getObjectClassDefinition(String id) { > > +return new ObjectClassDefinition(id); > > +} > > + > > +class ObjectClassDefinition { > > + > > +private final String id; > > + > > +private ObjectClassDefinition(String id) { > > +this.id = id; > > +} > > + > > +HasAttributeDefinition hasAttributeDefinition(String id) { > > +return new HasAttributeDefinition(this.id, id); > > +} > > + > > +} > > + > > +class HasAttributeDefinition { > > + > > +private final String ocd; > > + > > +private final String id;
Re: svn commit: r1834852 - /jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/
Hi Francesco Have you considered using the MetaTypeReader from Felix' MetyType implementation[0]? I've used it before and found it easy enough to use. It's only a test dependency, and you don't need to worry about your implementation being in sync with the spec/Felix' implementation. Regards Julian [0] https://github.com/apache/felix/blob/trunk/metatype/src/main/java/org/apache/felix/metatype/MetaDataReader.java On Mon, Jul 2, 2018 at 4:57 PM, wrote: > Author: frm > Date: Mon Jul 2 14:57:25 2018 > New Revision: 1834852 > > URL: http://svn.apache.org/viewvc?rev=1834852&view=rev > Log: > OAK-6770 - Test the metatype information descriptors > > Added: > > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/MetatypeInformation.java >(with props) > Modified: > > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/SegmentNodeStoreFactoryTest.java > > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/SegmentNodeStoreMonitorServiceTest.java > > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/SegmentNodeStoreServiceTest.java > > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/StandbyStoreServiceTest.java > > Added: > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/MetatypeInformation.java > URL: > http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/MetatypeInformation.java?rev=1834852&view=auto > == > --- > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/MetatypeInformation.java > (added) > +++ > jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/osgi/MetatypeInformation.java > Mon Jul 2 14:57:25 2018 > @@ -0,0 +1,267 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one > + * or more contributor license agreements. See the NOTICE file > + * distributed with this work for additional information > + * regarding copyright ownership. The ASF licenses this file > + * to you under the Apache License, Version 2.0 (the > + * "License"); you may not use this file except in compliance > + * with the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, > + * software distributed under the License is distributed on an > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > + * KIND, either express or implied. See the License for the > + * specific language governing permissions and limitations > + * under the License. > + */ > + > +package org.apache.jackrabbit.oak.segment.osgi; > + > +import java.io.InputStream; > +import java.util.HashSet; > +import java.util.Set; > + > +import javax.xml.parsers.DocumentBuilder; > +import javax.xml.parsers.DocumentBuilderFactory; > + > +import org.w3c.dom.Document; > +import org.w3c.dom.Element; > +import org.w3c.dom.NodeList; > + > +class MetatypeInformation { > + > +static MetatypeInformation open(InputStream stream) throws Exception { > +DocumentBuilderFactory factory = > DocumentBuilderFactory.newInstance(); > +DocumentBuilder builder = factory.newDocumentBuilder(); > +Document document = builder.parse(stream); > +return new MetatypeInformation(document.getDocumentElement()); > +} > + > +private static boolean hasAttribute(Element element, String name, String > value) { > +return element.hasAttribute(name) && > element.getAttribute(name).equals(value); > +} > + > +private final Element root; > + > +private MetatypeInformation(Element root) { > +this.root = root; > +} > + > +ObjectClassDefinition getObjectClassDefinition(String id) { > +return new ObjectClassDefinition(id); > +} > + > +class ObjectClassDefinition { > + > +private final String id; > + > +private ObjectClassDefinition(String id) { > +this.id = id; > +} > + > +HasAttributeDefinition hasAttributeDefinition(String id) { > +return new HasAttributeDefinition(this.id, id); > +} > + > +} > + > +class HasAttributeDefinition { > + > +private final String ocd; > + > +private final String id; > + > +private String type; > + > +private String defaultValue; > + > +private String cardinality; > + > +private String[] options; > + > +private HasAttributeDefinition(String ocd, String id) { > +this.ocd = ocd; > +this.id = id; > +} > + > +HasAttributeDefinition withStringType() { > +this.type = "String"; > +