You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2008/07/30 12:19:38 UTC
svn commit: r680961 - in /mina/ftpserver/trunk/core/src:
main/java/org/apache/ftpserver/usermanager/
main/resources/org/apache/ftpserver/config/spring/
test/java/org/apache/ftpserver/config/spring/ test/resources/spring-config/
Author: ngn
Date: Wed Jul 30 03:19:37 2008
New Revision: 680961
URL: http://svn.apache.org/viewvc?rev=680961&view=rev
Log:
Fixing various issues with configuration of DbUserManager (FTPSERVER-141 and further issues). Thanks Peter!
Added:
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/XmlDbUserManagerConfigTest.java (with props)
mina/ftpserver/trunk/core/src/test/resources/spring-config/config-spring-db-user-manager.xml (with props)
Modified:
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/DbUserManager.java
mina/ftpserver/trunk/core/src/main/resources/org/apache/ftpserver/config/spring/ftpserver-1.0.xsd
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/DbUserManager.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/DbUserManager.java?rev=680961&r1=680960&r2=680961&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/DbUserManager.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/DbUserManager.java Wed Jul 30 03:19:37 2008
@@ -104,7 +104,7 @@
* @return The SQL statement
*/
public String getSqlUserDelete() {
- return insertUserStmt;
+ return deleteUserStmt;
}
/**
@@ -168,7 +168,7 @@
* @return The SQL statement
*/
public String getSqlUserAuthenticate() {
- return selectAllStmt;
+ return authenticateStmt;
}
/**
@@ -184,7 +184,7 @@
* @return The SQL statement
*/
public String getSqlUserAdmin() {
- return selectAllStmt;
+ return isAdminStmt;
}
/**
Modified: mina/ftpserver/trunk/core/src/main/resources/org/apache/ftpserver/config/spring/ftpserver-1.0.xsd
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/resources/org/apache/ftpserver/config/spring/ftpserver-1.0.xsd?rev=680961&r1=680960&r2=680961&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/resources/org/apache/ftpserver/config/spring/ftpserver-1.0.xsd (original)
+++ mina/ftpserver/trunk/core/src/main/resources/org/apache/ftpserver/config/spring/ftpserver-1.0.xsd Wed Jul 30 03:19:37 2008
@@ -179,19 +179,13 @@
<xs:complexType>
<xs:sequence>
<xs:element name="data-source" type="spring-bean-or-ref"/>
- <xs:element name="statements">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="insert-user" type="xs:string"/>
- <xs:element name="update-user" type="xs:string"/>
- <xs:element name="delete-user" type="xs:string"/>
- <xs:element name="select-user" type="xs:string"/>
- <xs:element name="select-all-users" type="xs:string"/>
- <xs:element name="is-admin" type="xs:string"/>
- <xs:element name="authenticate" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
+ <xs:element name="insert-user" type="xs:string"/>
+ <xs:element name="update-user" type="xs:string"/>
+ <xs:element name="delete-user" type="xs:string"/>
+ <xs:element name="select-user" type="xs:string"/>
+ <xs:element name="select-all-users" type="xs:string"/>
+ <xs:element name="is-admin" type="xs:string"/>
+ <xs:element name="authenticate" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Added: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/XmlDbUserManagerConfigTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/XmlDbUserManagerConfigTest.java?rev=680961&view=auto
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/XmlDbUserManagerConfigTest.java (added)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/XmlDbUserManagerConfigTest.java Wed Jul 30 03:19:37 2008
@@ -0,0 +1,50 @@
+/*
+ * 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.ftpserver.config.spring;
+
+import junit.framework.TestCase;
+
+import org.apache.ftpserver.FtpServer;
+import org.apache.ftpserver.usermanager.DbUserManager;
+import org.hsqldb.jdbc.jdbcDataSource;
+import org.springframework.beans.factory.xml.XmlBeanFactory;
+import org.springframework.core.io.FileSystemResource;
+
+public class XmlDbUserManagerConfigTest extends TestCase {
+
+ public void test() throws Throwable {
+ XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource(
+ "src/test/resources/spring-config/config-spring-db-user-manager.xml"));
+
+ FtpServer server = (FtpServer) factory.getBean("server");
+
+ DbUserManager um = (DbUserManager) server.getServerContext().getUserManager();
+ assertTrue(um.getDataSource() instanceof jdbcDataSource);
+
+ assertEquals("INSERT USER", um.getSqlUserInsert());
+ assertEquals("UPDATE USER", um.getSqlUserUpdate());
+ assertEquals("DELETE USER", um.getSqlUserDelete());
+ assertEquals("SELECT USER", um.getSqlUserSelect());
+ assertEquals("SELECT ALL USERS", um.getSqlUserSelectAll());
+ assertEquals("IS ADMIN", um.getSqlUserAdmin());
+ assertEquals("AUTHENTICATE", um.getSqlUserAuthenticate());
+
+ }
+}
Propchange: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/XmlDbUserManagerConfigTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/ftpserver/trunk/core/src/test/resources/spring-config/config-spring-db-user-manager.xml
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/resources/spring-config/config-spring-db-user-manager.xml?rev=680961&view=auto
==============================================================================
--- mina/ftpserver/trunk/core/src/test/resources/spring-config/config-spring-db-user-manager.xml (added)
+++ mina/ftpserver/trunk/core/src/test/resources/spring-config/config-spring-db-user-manager.xml Wed Jul 30 03:19:37 2008
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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. -->
+
+<server id="server" xmlns="http://mina.apache.org/ftpserver/spring/v1"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
+ "
+ >
+ <db-user-manager>
+ <data-source>
+ <beans:bean class="org.hsqldb.jdbc.jdbcDataSource">
+ <beans:property name="database" value="jdbc:hsqldb:mem:foo" />
+ <beans:property name="user" value="sa" />
+ <beans:property name="password" value="" />
+ </beans:bean>
+ </data-source>
+ <insert-user>INSERT USER</insert-user>
+ <update-user>UPDATE USER</update-user>
+ <delete-user>DELETE USER</delete-user>
+ <select-user>SELECT USER</select-user>
+ <select-all-users>SELECT ALL USERS</select-all-users>
+ <is-admin>IS ADMIN</is-admin>
+ <authenticate>AUTHENTICATE</authenticate>
+ </db-user-manager>
+</server>
+
Propchange: mina/ftpserver/trunk/core/src/test/resources/spring-config/config-spring-db-user-manager.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain