directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szoer...@apache.org
Subject svn commit: r581994 - in /directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp: DummyStoredProcEngine.java DummyStoredProcEngineConfig.java StoredProcExecutionManagerTest.java
Date Thu, 04 Oct 2007 19:50:53 GMT
Author: szoerner
Date: Thu Oct  4 12:50:47 2007
New Revision: 581994

URL: http://svn.apache.org/viewvc?rev=581994&view=rev
Log:
Simple test for StoredProcExecutionManager added.

Added:
    directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngine.java
  (with props)
    directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngineConfig.java
  (with props)
    directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/StoredProcExecutionManagerTest.java
  (with props)

Added: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngine.java?rev=581994&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngine.java
(added)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngine.java
Thu Oct  4 12:50:47 2007
@@ -0,0 +1,57 @@
+/*
+ *  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.directory.server.core.sp;
+
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.ldap.LdapContext;
+
+
+/**
+ * Dummy implementation of StoredProcEngine for tests.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DummyStoredProcEngine implements StoredProcEngine
+{
+    public DummyStoredProcEngine()
+    {
+    }
+
+
+    public String getSPLangId()
+    {
+        return null;
+    }
+
+
+    public Object invokeProcedure( LdapContext rootDSE, String fullSPName, Object[] spArgs
) throws NamingException
+    {
+        return null;
+    }
+
+
+    public void setSPUnitEntry( Attributes spUnit )
+    {
+    }
+}

Propchange: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngine.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngine.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Thu Oct  4 12:50:47 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Added: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngineConfig.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngineConfig.java?rev=581994&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngineConfig.java
(added)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngineConfig.java
Thu Oct  4 12:50:47 2007
@@ -0,0 +1,52 @@
+/*
+ *  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.directory.server.core.sp;
+
+
+/**
+ * Dummy implementation of StoredProcEngineConfig for tests.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DummyStoredProcEngineConfig implements StoredProcEngineConfig
+{
+
+    private String langId;
+
+
+    protected DummyStoredProcEngineConfig( String langId )
+    {
+        this.langId = langId;
+    }
+
+
+    public Class<? extends StoredProcEngine> getStoredProcEngineType()
+    {
+        return DummyStoredProcEngine.class;
+    }
+
+
+    public String getStoredProcLangId()
+    {
+        return langId;
+    }
+}

Propchange: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngineConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/DummyStoredProcEngineConfig.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Thu Oct  4 12:50:47 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Added: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/StoredProcExecutionManagerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/StoredProcExecutionManagerTest.java?rev=581994&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/StoredProcExecutionManagerTest.java
(added)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/StoredProcExecutionManagerTest.java
Thu Oct  4 12:50:47 2007
@@ -0,0 +1,88 @@
+/*
+ *  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.directory.server.core.sp;
+
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+
+import org.junit.Test;
+
+
+/**
+ * Tests for class StoredProcExecutionManager.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class StoredProcExecutionManagerTest
+{
+    private StoredProcExecutionManager manager;
+    private List<StoredProcEngineConfig> cfgs;
+
+
+    /**
+     * The StoredProcExecutionManager should find an engine for a known language.
+     */
+    @Test
+    public void shouldFindAnEngineForKnownLanguage() throws NamingException
+    {
+        String langId = "myLanguage";
+
+        cfgs = new ArrayList<StoredProcEngineConfig>();
+
+        cfgs.add( new DummyStoredProcEngineConfig( "aLanguage" ) );
+        cfgs.add( new DummyStoredProcEngineConfig( langId ) );
+        cfgs.add( new DummyStoredProcEngineConfig( "yourLanguage" ) );
+        manager = new StoredProcExecutionManager( "cn=anyContainer", cfgs );
+
+        Attributes attrs = new BasicAttributes( "storedProcLangId", langId );
+
+        StoredProcEngine engine = manager.getStoredProcEngineInstance( attrs );
+        assertNotNull( engine );
+    }
+
+
+    /**
+     * The StoredProcExecutionManager should throw an exception for an unknown language.
+     */
+    @Test(expected = NamingException.class)
+    public void shouldThrowExceptionOnUnknownLanguage() throws NamingException
+    {
+        String langId = "myUnknownLanguage";
+
+        cfgs = new ArrayList<StoredProcEngineConfig>();
+
+        cfgs.add( new DummyStoredProcEngineConfig( "aLanguage" ) );
+        cfgs.add( new DummyStoredProcEngineConfig( "bLanguage" ) );
+        manager = new StoredProcExecutionManager( "cn=anyContainer", cfgs );
+
+        Attributes attrs = new BasicAttributes( "storedProcLangId", langId );
+
+        manager.getStoredProcEngineInstance( attrs );
+    }
+}

Propchange: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/StoredProcExecutionManagerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/StoredProcExecutionManagerTest.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Thu Oct  4 12:50:47 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id



Mime
View raw message