diff options
Diffstat (limited to 'das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup')
12 files changed, 1044 insertions, 0 deletions
diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetup.java new file mode 100644 index 0000000000..010baa800b --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetup.java @@ -0,0 +1,87 @@ +/* + * 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.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.directory.apacheds.testing.setup.ADSEmbeddedHotPartitionTemplate; +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.schema.constants.AttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.EnumeratedSchemaAttributeTypeValues; +import org.apache.tuscany.das.ldap.schema.constants.ObjectClassConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaAttributeTypeConstants; +import org.apache.tuscany.das.ldap.schema.constants.SchemaObjectClassConstants; +import org.apache.tuscany.das.ldap.testing.constants.DASTestingConstants; + +public abstract class AbstractTestSetup +extends ADSEmbeddedHotPartitionTemplate +implements +EnumeratedSchemaAttributeTypeValues, +SchemaAttributeTypeConstants, +AttributeTypeConstants, +SchemaObjectClassConstants, +ObjectClassConstants, +DASConstants, +DASTestingConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws Exception + { + super.setUp(); + + dasPartitionContext = + connect("das"); + + schemaPartitionContext = + connect("schema"); + } + + protected LdapContext schemaPartitionContext = + null; + + protected LdapContext dasPartitionContext = + null; + + protected static final String SYNTAXES_CONTEXT_RDN = + OU + "=" + SYNTAXES_CONTEXT_NAME; + + protected static final String SYNTAX_CHECKERS_CONTEXT_RDN = + OU + "=" + SYNTAX_CHECKERS_CONTEXT_NAME; + + protected static final String ATTRIBUTE_TYPES_CONTEXT_RDN = + OU + "=" + ATTRIBUTE_TYPES_CONTEXT_NAME; + + protected static final String OBJECT_CLASSES_CONTEXT_RDN = + OU + "=" + OBJECT_CLASSES_CONTEXT_NAME; + + + + protected static final String XSD_CONTEXT_RDN = + CN + "=" + XSD_CONTEXT_NAME; + protected static final String DAS_CONTEXT_RDN = + CN + "=" + DAS_CONTEXT_NAME; + protected static final String ECORE_CONTEXT_RDN = + CN + "=" + ECORE_CONTEXT_NAME; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetupTest.java new file mode 100644 index 0000000000..6477225e1c --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/AbstractTestSetupTest.java @@ -0,0 +1,46 @@ +/* + * 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.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +public class AbstractTestSetupTest +extends AbstractTestSetup +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws Exception + { + super.setUp(); + dasPartitionContext = + connect("das"); + schemaPartitionContext = + connect("schema"); + } + + public void testConnect() throws NamingException + { + assertNotNull(dasPartitionContext); + assertNotNull(schemaPartitionContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetup.java new file mode 100644 index 0000000000..fafd0144fb --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetup.java @@ -0,0 +1,47 @@ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.create.InitialContextCreator; +import org.apache.tuscany.das.ldap.create.MetaContextCreator; +import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer; +import org.apache.tuscany.das.ldap.destroy.MetaContextDestroyer; + +public class DASContextSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + MetaContextDestroyer. + destroy( modelContext ); + + InitialContextDestroyer. + destroy( + modelContext, + dasPartitionContext ); + super.tearDown(); + + dasPartitionContext.close(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + modelContext = + InitialContextCreator. + create( + xsdNamespace, + dasPartitionContext); + + metaContext = + MetaContextCreator. + create( modelContext); + } + + protected LdapContext modelContext = null; + protected LdapContext metaContext = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetupTest.java new file mode 100644 index 0000000000..d6ecc250c6 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASContextSetupTest.java @@ -0,0 +1,54 @@ +/* + * 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.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class DASContextSetupTest +extends DASContextSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testModelContext() throws NamingException + { + assertNotNull(modelContext); + assertEquals( + "cn=accounts,cn=users,cn=example,cn=com,ou=das", + modelContext.getNameInNamespace()); + } + + public void testMetaContext() throws NamingException + { + assertNotNull(metaContext); + assertEquals("cn=meta,cn=accounts,cn=users,cn=example,cn=com,ou=das", + metaContext.getNameInNamespace()); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetup.java new file mode 100644 index 0000000000..da620aaf34 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetup.java @@ -0,0 +1,191 @@ +/* + * 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.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.directory.DirContext; +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.schema.create.ComplexTypeRDNCreator; +import org.apache.tuscany.das.ldap.schema.create.SimpleTypeRDNCreator; + +public class DASSchemaContextsSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + dasSyntaxesContext.close(); + + dasSchemaSubContext.destroySubcontext( + SYNTAXES_CONTEXT_RDN ); + + dasAttributeTypesContext.close(); + + dasSchemaSubContext.destroySubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN ); + + dasSchemaSubContext.destroySubcontext( + OBJECT_CLASSES_CONTEXT_RDN ); + + dasSchemaSubContext.close(); + + schemaPartitionContext.destroySubcontext( + DAS_CONTEXT_RDN ); + + schemaPartitionContext.close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + dasSchemaSubContext = + createDasSchemaSubContext(); + dasSyntaxesContext = + createDasSyntaxesContext(); + dasAttributeTypesContext = + createDasAttributeTypesContext(); + dasObjectClassesContext = + createDasObjectClassesContext(); + + mComplexMayRDN = + SimpleTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS, + M_COMPLEX_MAY); + + mComplexMustRDN = + SimpleTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS, + M_COMPLEX_MUST); + + idRDN = + SimpleTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS, + ID); + + metaTopSDORDN = + ComplexTypeRDNCreator.create( + TUSCANY_OID_PREFIX_VALUE, + DAS_XSD_NAMESPACE, + M_META_TOP_SDO_OBJECT_CLASS); + } + + private DirContext createDasSchemaSubContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute ecoreAttribute = new BasicAttribute( + CN, + DAS_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return schemaPartitionContext.createSubcontext( + DAS_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createDasAttributeTypesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + ATTRIBUTE_TYPES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return dasSchemaSubContext.createSubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createDasSyntaxesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return dasSchemaSubContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + + private DirContext createDasObjectClassesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute attributeTypes = new BasicAttribute( + OU, + OBJECT_CLASSES_CONTEXT_NAME); + + contextAttributes.put( attributeTypes ); + contextAttributes.put( objectClassAttribute ); + + return dasSchemaSubContext.createSubcontext( + OBJECT_CLASSES_CONTEXT_RDN, + contextAttributes ); + } + + protected DirContext dasSchemaSubContext = null; + protected DirContext dasAttributeTypesContext = null; + protected DirContext dasSyntaxesContext = null; + protected DirContext dasObjectClassesContext = null; + + protected String mComplexMayRDN = null; + protected String mComplexMustRDN = null; + protected String idRDN = null; + protected String metaTopSDORDN = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetupTest.java new file mode 100644 index 0000000000..9adbe07463 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/DASSchemaContextsSetupTest.java @@ -0,0 +1,59 @@ +/* + * 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.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class DASSchemaContextsSetupTest +extends DASSchemaContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testCreateDASSchemaSubContext() + { + assertNotNull(dasSchemaSubContext); + } + + public void testCreateDasAttributeTypesContext() + { + assertNotNull(dasAttributeTypesContext); + } + + public void testCreateDasSyntaxesContext() + { + assertNotNull(dasSyntaxesContext); + } + + public void testCreateDasObjectClassesContext() + { + assertNotNull(dasObjectClassesContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetup.java new file mode 100644 index 0000000000..4fdaaea4b2 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetup.java @@ -0,0 +1,74 @@ +/* + * 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.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; +import org.apache.tuscany.das.ldap.create.InitialContextCreator; +import org.apache.tuscany.das.ldap.create.MetaContextCreator; +import org.apache.tuscany.das.ldap.destroy.InitialContextDestroyer; +import org.apache.tuscany.das.ldap.destroy.MetaContextDestroyer; + +/* + * TODO Document that the name of a root object cannot be "meta" + * TODO Change "meta" to meta-inf + */ +public class EcoreSchemaAndDASContextsSetup +extends EcoreSchemaContextsSetup +implements DASConstants +{ + public void tearDown() + throws NamingException, Exception + { + MetaContextDestroyer. + destroy( rootContext ); + + InitialContextDestroyer. + destroy( + rootContext, + dasPartitionContext ); + + super.tearDown(); + + dasPartitionContext.close(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + + rootContext = + (LdapContext) + InitialContextCreator. + create( + xsdNamespace, + dasPartitionContext); + + metaContext = + (LdapContext) + MetaContextCreator. + create( rootContext); + } + + protected LdapContext rootContext = null; + protected LdapContext metaContext = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetupTest.java new file mode 100644 index 0000000000..e272262998 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaAndDASContextsSetupTest.java @@ -0,0 +1,56 @@ +package org.apache.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class EcoreSchemaAndDASContextsSetupTest +extends EcoreSchemaAndDASContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testConnect() + { + assertNotNull(schemaPartitionContext); + } + + public void testCreateEcoreSchemaSubContext() + { + assertNotNull(ecoreSchemaSubContext); + } + + public void testCreateEcoreObjectClassesContext() + { + assertNotNull(ecoreObjectClassesContext); + } + + public void testCreateEcoreAttributeTypesContext() + { + assertNotNull(ecoreAttributeTypesContext); + } + + public void testCreateEcoreSyntaxesContext() + { + assertNotNull(ecoreSyntaxesContext); + } + + public void testCreateDasModelContext() + { + assertNotNull(rootContext); + } + + public void testCreateDasMetaContext() + { + assertNotNull(metaContext); + } + +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetup.java new file mode 100644 index 0000000000..88bd21f318 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetup.java @@ -0,0 +1,201 @@ +/* + * 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.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class EcoreSchemaContextsSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() + throws NamingException, Exception + { + ecoreSyntaxesContext. + close(); + + ecoreSchemaSubContext. + destroySubcontext( + SYNTAXES_CONTEXT_RDN ); + + ecoreSyntaxCheckersContext. + close(); + + ecoreSchemaSubContext. + destroySubcontext( + SYNTAX_CHECKERS_CONTEXT_RDN ); + + ecoreAttributeTypesContext. + close(); + ecoreSchemaSubContext. + destroySubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN ); + + ecoreObjectClassesContext. + close(); + + ecoreSchemaSubContext. + destroySubcontext( + OBJECT_CLASSES_CONTEXT_RDN ); + + ecoreSchemaSubContext. + close(); + schemaPartitionContext. + destroySubcontext( + ECORE_CONTEXT_RDN ); + + schemaPartitionContext.close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + ecoreSchemaSubContext = createEcoreSchemaSubContext(); + ecoreSyntaxesContext = createEcoreSyntaxesContext(); + ecoreSyntaxCheckersContext = createEcoreSyntaxCheckersContext(); + ecoreObjectClassesContext = createEcoreObjectClassesContext(); + ecoreAttributeTypesContext = createEcoreAttributeTypesContext(); + } + + private LdapContext createEcoreSchemaSubContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute ecoreAttribute = new BasicAttribute( + CN, + ECORE_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) + schemaPartitionContext.createSubcontext( + ECORE_CONTEXT_RDN, contextAttributes ); + } + + + private LdapContext createEcoreObjectClassesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + OBJECT_CLASSES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) + ecoreSchemaSubContext.createSubcontext( + OBJECT_CLASSES_CONTEXT_RDN, contextAttributes ); + } + + + + private LdapContext createEcoreAttributeTypesContext() + throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + ATTRIBUTE_TYPES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) + ecoreSchemaSubContext.createSubcontext( + ATTRIBUTE_TYPES_CONTEXT_RDN, contextAttributes ); + } + + private LdapContext createEcoreSyntaxesContext() throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) + ecoreSchemaSubContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + + private LdapContext createEcoreSyntaxCheckersContext() + throws NamingException + { + Attributes contextAttributes = new BasicAttributes(); + + Attribute objectClassAttribute = new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = new BasicAttribute( + OU, + SYNTAX_CHECKERS_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) + ecoreSchemaSubContext.createSubcontext( + SYNTAX_CHECKERS_CONTEXT_RDN, + contextAttributes); + } + + protected LdapContext ecoreSchemaSubContext = null; + protected LdapContext ecoreObjectClassesContext = null; + protected LdapContext ecoreAttributeTypesContext = null; + protected LdapContext ecoreSyntaxesContext = null; + protected LdapContext ecoreSyntaxCheckersContext = null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetupTest.java new file mode 100644 index 0000000000..f2c746dceb --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/EcoreSchemaContextsSetupTest.java @@ -0,0 +1,64 @@ +/* + * 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.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class EcoreSchemaContextsSetupTest +extends EcoreSchemaContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testCreateEcoreSchemaSubContext() + { + assertNotNull(ecoreSchemaSubContext); + } + + public void testCreateEcoreObjectClassesContext() + { + assertNotNull(ecoreObjectClassesContext); + } + + public void testCreateEcoreAttributeTypesContext() + { + assertNotNull(ecoreAttributeTypesContext); + } + + public void testCreateEcoreSyntaxesContext() + { + assertNotNull(ecoreSyntaxesContext); + } + + public void testCreateEcoreSyntaxCheckersContext() + { + assertNotNull(ecoreSyntaxCheckersContext); + } +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetup.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetup.java new file mode 100644 index 0000000000..619bc7a94f --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetup.java @@ -0,0 +1,116 @@ +/* + * 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.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.ldap.LdapContext; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class XSDSchemaContextsSetup +extends AbstractTestSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + xsdSyntaxesContext. + close(); + + xsdContext. + destroySubcontext( + SYNTAXES_CONTEXT_RDN ); + + xsdContext. + close(); + + schemaPartitionContext. + destroySubcontext( + XSD_CONTEXT_RDN ); + + schemaPartitionContext. + close(); + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + xsdContext = + createXsdContext(); + xsdSyntaxesContext = + createXsdSyntaxesContext(); + } + + private LdapContext createXsdContext() throws NamingException + { + Attributes contextAttributes = + new BasicAttributes(); + + Attribute objectClassAttribute = + new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(META_SCHEMA); + + Attribute ecoreAttribute = + new BasicAttribute( + CN, + XSD_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) schemaPartitionContext.createSubcontext( + XSD_CONTEXT_RDN, contextAttributes ); + } + + private LdapContext createXsdSyntaxesContext() throws NamingException + { + Attributes contextAttributes = + new BasicAttributes(); + + Attribute objectClassAttribute = + new BasicAttribute( + OBJECT_CLASS, + TOP); + objectClassAttribute.add(ORGANIZATIONAL_UNIT); + + Attribute ecoreAttribute = + new BasicAttribute( + OU, + SYNTAXES_CONTEXT_NAME); + + contextAttributes.put( ecoreAttribute ); + contextAttributes.put( objectClassAttribute ); + + return (LdapContext) xsdContext.createSubcontext( + SYNTAXES_CONTEXT_RDN, contextAttributes ); + } + protected LdapContext xsdContext = + null; + protected LdapContext xsdSyntaxCheckersContext = + null; + protected LdapContext xsdSyntaxesContext = + null; +}
\ No newline at end of file diff --git a/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetupTest.java b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetupTest.java new file mode 100644 index 0000000000..24ce5e6df1 --- /dev/null +++ b/das-java/contrib/ldap/das.ldap/src/main/java/org/apache/tuscany/das/ldap/schema/embedded/setup/test/XSDSchemaContextsSetupTest.java @@ -0,0 +1,49 @@ +/* + * 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.tuscany.das.ldap.schema.embedded.setup.test; + +import javax.naming.NamingException; + +import org.apache.tuscany.das.ldap.constants.DASConstants; + +public class XSDSchemaContextsSetupTest +extends XSDSchemaContextsSetup +implements DASConstants +{ + public void tearDown() throws NamingException, Exception + { + super.tearDown(); + } + + public void setUp() throws NamingException, Exception + { + super.setUp(); + } + + public void testCreateXsdContext() + { + assertNotNull(xsdContext); + } + + public void testCreateXsdSyntaxesContext() + { + assertNotNull(xsdSyntaxesContext); + } +}
\ No newline at end of file |