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/31 13:49:29 UTC
svn commit: r681345 - in /mina/ftpserver/trunk:
core/src/main/java/org/apache/ftpserver/
core/src/main/java/org/apache/ftpserver/listener/nio/
core/src/main/java/org/apache/ftpserver/listing/
core/src/main/java/org/apache/ftpserver/usermanager/ core/sr...
Author: ngn
Date: Thu Jul 31 04:49:25 2008
New Revision: 681345
URL: http://svn.apache.org/viewvc?rev=681345&view=rev
Log:
Minor code fixes
Added:
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/BaseProperties.java (with props)
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/ClassUtils.java (with props)
mina/ftpserver/trunk/deprecated/src/test/java/org/apache/ftpserver/util/ConfigurationClassUtilsCastTest.java (with props)
Removed:
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/ClassUtilsCastTest.java
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/ClassUtilsTest.java
Modified:
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/PassivePorts.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/ListArgument.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/MLSTFileFormater.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/BaseUser.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/DbUserManager.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/PropertiesUserManager.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/UserMetadata.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/UsernamePasswordAuthentication.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/WritePermission.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/WriteRequest.java
mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/IoUtils.java
mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.java
mina/ftpserver/trunk/deprecated/src/main/java/org/apache/ftpserver/util/ConfigurationClassUtils.java
mina/ftpserver/trunk/deprecated/src/test/java/org/apache/ftpserver/util/ConfigurationClassUtilsTest.java
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/PassivePorts.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/PassivePorts.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/PassivePorts.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/PassivePorts.java Thu Jul 31 04:49:25 2008
@@ -50,18 +50,18 @@
List<Integer> passivePortsList = new ArrayList<Integer>();
boolean inRange = false;
- Integer lastPort = new Integer(1);
+ Integer lastPort = 1;
StringTokenizer st = new StringTokenizer(portsString, ",;-", true);
while(st.hasMoreTokens()) {
String token = st.nextToken().trim();
if(",".equals(token) || ";".equals(token)) {
if(inRange) {
- fillRange(passivePortsList, lastPort, new Integer(MAX_PORT));
+ fillRange(passivePortsList, lastPort, MAX_PORT);
}
// reset state
- lastPort = new Integer(1);
+ lastPort = 1;
inRange = false;
} else if("-".equals(token)) {
inRange = true;
@@ -86,7 +86,7 @@
}
if(inRange) {
- fillRange(passivePortsList, lastPort, new Integer(MAX_PORT));
+ fillRange(passivePortsList, lastPort, MAX_PORT);
}
int[] passivePorts = new int[passivePortsList.size()];
@@ -139,7 +139,7 @@
}
public PassivePorts(int[] passivePorts) {
- this.passivePorts = passivePorts;
+ this.passivePorts = passivePorts.clone();
reservedPorts = new boolean[passivePorts.length];
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/nio/NioListener.java Thu Jul 31 04:49:25 2008
@@ -264,7 +264,7 @@
* Retrives the {@link InetAddress} for which this listener blocks connections
* @return The list of {@link InetAddress}es
*/
- public List<InetAddress> getBlockedAddresses() {
+ public synchronized List<InetAddress> getBlockedAddresses() {
return blockedAddresses;
}
@@ -281,7 +281,7 @@
* Retrives the {@link Subnet}s for which this acceptor blocks connections
* @return The list of {@link Subnet}s
*/
- public List<Subnet> getBlockedSubnets() {
+ public synchronized List<Subnet> getBlockedSubnets() {
return blockedSubnets;
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/ListArgument.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/ListArgument.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/ListArgument.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/ListArgument.java Thu Jul 31 04:49:25 2008
@@ -38,7 +38,7 @@
if(options == null) {
this.options = new char[0];
} else {
- this.options = options;
+ this.options = options.clone();
}
}
@@ -47,7 +47,7 @@
* @return All options
*/
public char[] getOptions() {
- return options;
+ return options.clone();
}
/**
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/MLSTFileFormater.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/MLSTFileFormater.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/MLSTFileFormater.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listing/MLSTFileFormater.java Thu Jul 31 04:49:25 2008
@@ -37,7 +37,7 @@
*/
public MLSTFileFormater(String[] selectedTypes) {
if(selectedTypes != null) {
- this.selectedTypes = selectedTypes;
+ this.selectedTypes = selectedTypes.clone();
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/BaseUser.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/BaseUser.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/BaseUser.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/BaseUser.java Thu Jul 31 04:49:25 2008
@@ -104,11 +104,11 @@
}
public Authority[] getAuthorities() {
- return authorities;
+ return authorities.clone();
}
public void setAuthorities(Authority[] authorities) {
- this.authorities = authorities;
+ this.authorities = authorities.clone();
}
/**
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=681345&r1=681344&r2=681345&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 Thu Jul 31 04:49:25 2008
@@ -399,18 +399,18 @@
map.put( ATTR_ENABLE, String.valueOf(user.getEnabled()) );
map.put( ATTR_WRITE_PERM, String.valueOf(user.authorize(new WriteRequest()) != null) );
- map.put( ATTR_MAX_IDLE_TIME, new Integer(user.getMaxIdleTime()) );
+ map.put( ATTR_MAX_IDLE_TIME, user.getMaxIdleTime() );
TransferRateRequest transferRateRequest = new TransferRateRequest();
transferRateRequest = (TransferRateRequest) user.authorize(transferRateRequest);
if(transferRateRequest != null) {
- map.put( ATTR_MAX_UPLOAD_RATE, new Integer(transferRateRequest.getMaxUploadRate()) );
- map.put( ATTR_MAX_DOWNLOAD_RATE, new Integer(transferRateRequest.getMaxDownloadRate()) );
+ map.put( ATTR_MAX_UPLOAD_RATE, transferRateRequest.getMaxUploadRate() );
+ map.put( ATTR_MAX_DOWNLOAD_RATE, transferRateRequest.getMaxDownloadRate() );
} else {
- map.put( ATTR_MAX_UPLOAD_RATE, new Integer(0));
- map.put( ATTR_MAX_DOWNLOAD_RATE, new Integer(0) );
+ map.put( ATTR_MAX_UPLOAD_RATE, 0);
+ map.put( ATTR_MAX_DOWNLOAD_RATE, 0 );
}
// request that always will succeed
@@ -419,12 +419,12 @@
if(concurrentLoginRequest != null) {
map.put( ATTR_MAX_LOGIN_NUMBER,
- new Integer(concurrentLoginRequest.getMaxConcurrentLogins()));
+ concurrentLoginRequest.getMaxConcurrentLogins());
map.put( ATTR_MAX_LOGIN_PER_IP,
- new Integer(concurrentLoginRequest.getMaxConcurrentLoginsPerIP()));
+ concurrentLoginRequest.getMaxConcurrentLoginsPerIP());
} else {
- map.put( ATTR_MAX_LOGIN_NUMBER, new Integer(0));
- map.put( ATTR_MAX_LOGIN_PER_IP, new Integer(0));
+ map.put( ATTR_MAX_LOGIN_NUMBER, 0);
+ map.put( ATTR_MAX_LOGIN_PER_IP, 0);
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/PropertiesUserManager.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/PropertiesUserManager.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/PropertiesUserManager.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/PropertiesUserManager.java Thu Jul 31 04:49:25 2008
@@ -260,7 +260,7 @@
}
Iterator<String> remKeysIt = remKeys.iterator();
while (remKeysIt.hasNext()) {
- userDataProp.remove(remKeysIt.next().toString());
+ userDataProp.remove(remKeysIt.next());
}
saveUserData();
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/UserMetadata.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/UserMetadata.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/UserMetadata.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/UserMetadata.java Thu Jul 31 04:49:25 2008
@@ -37,7 +37,7 @@
* is available (e.g. SSL not used)
*/
public Certificate[] getCertificateChain() {
- return certificateChain;
+ return certificateChain.clone();
}
/**
@@ -45,8 +45,8 @@
* @param certificateChain
* The certificate chain to set
*/
- public void setCertificateChain(Certificate[] certificateChain) {
- this.certificateChain = certificateChain;
+ public void setCertificateChain(final Certificate[] certificateChain) {
+ this.certificateChain = certificateChain.clone();
}
/**
@@ -62,7 +62,7 @@
* @param inetAddress
* The client IP adress
*/
- public void setInetAddress(InetAddress inetAddress) {
+ public void setInetAddress(final InetAddress inetAddress) {
this.inetAddress = inetAddress;
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/UsernamePasswordAuthentication.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/UsernamePasswordAuthentication.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/UsernamePasswordAuthentication.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/UsernamePasswordAuthentication.java Thu Jul 31 04:49:25 2008
@@ -37,7 +37,7 @@
* @param username The user name
* @param password The password, can be null
*/
- public UsernamePasswordAuthentication(String username, String password) {
+ public UsernamePasswordAuthentication(final String username, final String password) {
this.username = username;
this.password = password;
}
@@ -48,7 +48,7 @@
* @param password The password, can be null
* @param userMetadata The user metadata
*/
- public UsernamePasswordAuthentication(String username, String password, UserMetadata userMetadata) {
+ public UsernamePasswordAuthentication(final String username, final String password, final UserMetadata userMetadata) {
this(username, password);
this.userMetadata = userMetadata;
}
@@ -76,7 +76,4 @@
public UserMetadata getUserMetadata() {
return userMetadata;
}
-
-
-
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/WritePermission.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/WritePermission.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/WritePermission.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/WritePermission.java Thu Jul 31 04:49:25 2008
@@ -40,14 +40,14 @@
* Construct a write permission for a file or directory relative to the user home directory
* @param permissionRoot The file or directory
*/
- public WritePermission(String permissionRoot) {
+ public WritePermission(final String permissionRoot) {
this.permissionRoot = permissionRoot;
}
/**
* @see Authority#authorize(AuthorizationRequest)
*/
- public AuthorizationRequest authorize(AuthorizationRequest request) {
+ public AuthorizationRequest authorize(final AuthorizationRequest request) {
if(request instanceof WriteRequest) {
WriteRequest writeRequest = (WriteRequest) request;
@@ -66,7 +66,7 @@
/**
* @see Authority#canAuthorize(AuthorizationRequest)
*/
- public boolean canAuthorize(AuthorizationRequest request) {
+ public boolean canAuthorize(final AuthorizationRequest request) {
return request instanceof WriteRequest;
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/WriteRequest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/WriteRequest.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/WriteRequest.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/usermanager/WriteRequest.java Thu Jul 31 04:49:25 2008
@@ -40,7 +40,7 @@
* Request write access to a file or directory relative to the user home directory
* @param file
*/
- public WriteRequest(String file) {
+ public WriteRequest(final String file) {
this.file = file;
}
Added: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/BaseProperties.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/BaseProperties.java?rev=681345&view=auto
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/BaseProperties.java (added)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/BaseProperties.java Thu Jul 31 04:49:25 2008
@@ -0,0 +1,430 @@
+/*
+ * 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.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+import java.util.TimeZone;
+
+import org.apache.ftpserver.ftplet.FtpException;
+
+/**
+ * This class encapsulates <code>java.util.Properties</code> to
+ * add java primitives and some other java classes.
+ */
+public
+class BaseProperties extends Properties {
+
+ private static final long serialVersionUID = 5572645129592131953L;
+
+ /**
+ * Default constructor.
+ */
+ public BaseProperties() {
+ }
+
+ /**
+ * Load existing property.
+ */
+ public BaseProperties(final Properties prop) {
+ super(prop);
+ }
+
+ /**
+ * Load properties from file
+ */
+ public BaseProperties(final File fl) throws IOException {
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(fl);
+ load(fis);
+ } finally {
+ IoUtils.close(fis);
+ }
+ }
+
+ /**
+ * Load properties from <code>InputStream</code>
+ */
+ public BaseProperties(final InputStream is) throws IOException {
+ load(is);
+ }
+
+
+ //////////////////////////////////////////
+ //////// Properties Get Methods ////////
+ //////////////////////////////////////////
+ /**
+ * Get boolean value.
+ */
+ public boolean getBoolean(final String str) throws FtpException {
+ String prop = getProperty(str);
+ if (prop == null) {
+ throw new FtpException(str + " not found");
+ }
+
+ return prop.toLowerCase().equals("true");
+ }
+
+ public boolean getBoolean(final String str, final boolean bol) {
+ try {
+ return getBoolean(str);
+ } catch (FtpException ex) {
+ return bol;
+ }
+ }
+
+
+ /**
+ * Get integer value.
+ */
+ public int getInteger(final String str) throws FtpException {
+ String value = getProperty(str);
+ if (value == null) {
+ throw new FtpException(str + " not found");
+ }
+
+ try {
+ return Integer.parseInt(value);
+ }
+ catch (NumberFormatException ex) {
+ throw new FtpException("BaseProperties.getInteger()", ex);
+ }
+ }
+
+ public int getInteger(final String str, final int intVal) {
+ try {
+ return getInteger(str);
+ }
+ catch (FtpException ex) {
+ return intVal;
+ }
+ }
+
+ /**
+ * Get long value.
+ */
+ public long getLong(final String str) throws FtpException {
+ String value = getProperty(str);
+ if (value == null) {
+ throw new FtpException(str + " not found");
+ }
+
+ try {
+ return Long.parseLong(value);
+ }
+ catch (NumberFormatException ex) {
+ throw new FtpException("BaseProperties.getLong()", ex);
+ }
+ }
+
+ public long getLong(final String str, final long val) {
+ try {
+ return getLong(str);
+ }
+ catch (FtpException ex) {
+ return val;
+ }
+ }
+
+
+ /**
+ * Get double value.
+ */
+ public double getDouble(final String str) throws FtpException {
+ String value = getProperty(str);
+ if (value == null) {
+ throw new FtpException(str + " not found");
+ }
+
+ try {
+ return Double.parseDouble(value);
+ }
+ catch (NumberFormatException ex) {
+ throw new FtpException("BaseProperties.getDouble()", ex);
+ }
+ }
+
+ public double getDouble(final String str, final double doubleVal) {
+ try {
+ return getDouble(str);
+ }
+ catch (FtpException ex) {
+ return doubleVal;
+ }
+ }
+
+ /**
+ * Get <code>InetAddress</code>.
+ */
+ public InetAddress getInetAddress(final String str) throws FtpException {
+ String value = getProperty(str);
+ if(value == null) {
+ throw new FtpException(str + " not found");
+ }
+
+ try {
+ return InetAddress.getByName(value);
+ }
+ catch(UnknownHostException ex) {
+ throw new FtpException("Host " + value + " not found");
+ }
+ }
+
+ public InetAddress getInetAddress(final String str, final InetAddress addr) {
+ try {
+ return getInetAddress(str);
+ }
+ catch(FtpException ex) {
+ return addr;
+ }
+ }
+
+ /**
+ * Get <code>String</code>.
+ */
+ public String getString(final String str) throws FtpException {
+ String value = getProperty(str);
+ if(value == null) {
+ throw new FtpException(str + " not found");
+ }
+
+ return value;
+ }
+
+ public String getString(final String str, final String s) {
+ try {
+ return getString(str);
+ }
+ catch(FtpException ex) {
+ return s;
+ }
+ }
+
+ /**
+ * Get <code>File</code> object.
+ */
+ public File getFile(final String str) throws FtpException {
+ String value = getProperty(str);
+ if (value == null) {
+ throw new FtpException(str + " not found");
+ }
+ return new File(value);
+ }
+
+ public File getFile(final String str, final File fl) {
+ try {
+ return getFile(str);
+ }
+ catch (FtpException ex) {
+ return fl;
+ }
+ }
+
+
+ /**
+ * Get <code>Class</code> object
+ */
+ public Class<?> getClass(final String str) throws FtpException {
+ String value = getProperty(str);
+ if (value == null) {
+ throw new FtpException(str + " not found");
+ }
+
+ try {
+ return Class.forName(value);
+ }
+ catch (ClassNotFoundException ex) {
+ throw new FtpException("BaseProperties.getClass()", ex);
+ }
+ }
+
+ public Class<?> getClass(final String str, final Class<?> cls) {
+ try {
+ return getClass(str);
+ }
+ catch (FtpException ex) {
+ return cls;
+ }
+ }
+
+ /**
+ * Get <code>TimeZone</code>
+ */
+ public TimeZone getTimeZone(final String str) throws FtpException {
+ String value = getProperty(str);
+ if (value == null) {
+ throw new FtpException(str + " not found");
+ }
+ return TimeZone.getTimeZone(value);
+ }
+
+ public TimeZone getTimeZone(final String str, final TimeZone tz) {
+ try {
+ return getTimeZone(str);
+ }
+ catch (FtpException ex) {
+ return tz;
+ }
+ }
+
+ /**
+ * Get <code>DateFormat</code> object.
+ */
+ public SimpleDateFormat getDateFormat(final String str) throws FtpException {
+ String value = getProperty(str);
+ if (value == null) {
+ throw new FtpException(str + " not found");
+ }
+ try {
+ return new SimpleDateFormat(value);
+ } catch(IllegalArgumentException e) {
+ throw new FtpException("Date format was incorrect: " + value, e);
+ }
+ }
+
+ public SimpleDateFormat getDateFormat(final String str, final SimpleDateFormat fmt) {
+ try {
+ return getDateFormat(str);
+ }
+ catch (FtpException ex) {
+ return fmt;
+ }
+ }
+
+
+ /**
+ * Get <code>Date</code> object.
+ */
+ public Date getDate(final String str, final DateFormat fmt) throws FtpException {
+ String value = getProperty(str);
+ if (value == null) {
+ throw new FtpException(str + " not found");
+ }
+
+ try {
+ return fmt.parse(value);
+ }
+ catch (ParseException ex) {
+ throw new FtpException("BaseProperties.getdate()", ex);
+ }
+ }
+
+ public Date getDate(final String str, final DateFormat fmt, final Date dt) {
+ try {
+ return getDate(str, fmt);
+ }
+ catch (FtpException ex) {
+ return dt;
+ }
+ }
+
+
+ //////////////////////////////////////////
+ //////// Properties Set Methods ////////
+ //////////////////////////////////////////
+ /**
+ * Set boolean value.
+ */
+ public void setProperty(final String key, final boolean val) {
+ setProperty(key, String.valueOf(val));
+ }
+
+ /**
+ * Set integer value.
+ */
+ public void setProperty(final String key, final int val) {
+ setProperty(key, String.valueOf(val));
+ }
+
+
+ /**
+ * Set double value.
+ */
+ public void setProperty(final String key, final double val) {
+ setProperty(key, String.valueOf(val));
+ }
+
+ /**
+ * Set float value.
+ */
+ public void setProperty(final String key, final float val) {
+ setProperty(key, String.valueOf(val));
+ }
+
+ /**
+ * Set long value.
+ */
+ public void setProperty(final String key, final long val) {
+ setProperty(key, String.valueOf(val));
+ }
+
+ /**
+ * Set <code>InetAddress</code>.
+ */
+ public void setInetAddress(final String key, final InetAddress val) {
+ setProperty(key, val.getHostAddress());
+ }
+
+ /**
+ * Set <code>File</code> object.
+ */
+ public void setProperty(final String key, final File val) {
+ setProperty(key, val.getAbsolutePath());
+ }
+
+ /**
+ * Set <code>DateFormat</code> object.
+ */
+ public void setProperty(final String key, final SimpleDateFormat val) {
+ setProperty(key, val.toPattern());
+ }
+
+ /**
+ * Set <code>TimeZone</code> object.
+ */
+ public void setProperty(final String key, final TimeZone val) {
+ setProperty(key, val.getID());
+ }
+
+ /**
+ * Set <code>Date</code> object.
+ */
+ public void setProperty(final String key, final Date val, final DateFormat fmt) {
+ setProperty(key, fmt.format(val));
+ }
+
+ /**
+ * Set <code>Class</code> object.
+ */
+ public void setProperty(final String key, final Class<?> val) {
+ setProperty(key, val.getName());
+ }
+
+}
Propchange: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/BaseProperties.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/ClassUtils.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/ClassUtils.java?rev=681345&view=auto
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/ClassUtils.java (added)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/ClassUtils.java Thu Jul 31 04:49:25 2008
@@ -0,0 +1,45 @@
+/*
+ * 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.util;
+
+public class ClassUtils {
+
+ /**
+ * Checks if a class is a subclass of a class with the specified name.
+ * Used as an instanceOf without having to load the class, useful when
+ * trying to check for classes that might not be available in the runtime
+ * JRE.
+ * @param clazz The class to check
+ * @param className The class name to look for in the super classes
+ * @return true if the class extends a class by the specified name.
+ */
+ public static boolean extendsClass(final Class<?> clazz, String className) {
+ Class<?> superClass = clazz.getSuperclass();
+
+ while(superClass != null) {
+ if(superClass.getName().equals(className)) {
+ return true;
+ }
+ superClass = superClass.getSuperclass();
+
+ }
+ return false;
+ }
+}
Propchange: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/ClassUtils.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/IoUtils.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/IoUtils.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/IoUtils.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/util/IoUtils.java Thu Jul 31 04:49:25 2008
@@ -262,6 +262,7 @@
private final static void deleteFile(File file) throws IOException {
if (!file.delete()) {
+ // hack around bug where files will sometimes not be deleted on Windows
if (OS.isFamilyWindows()) {
System.gc();
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/config/spring/SpringConfigTest.java Thu Jul 31 04:49:25 2008
@@ -32,7 +32,6 @@
import org.apache.ftpserver.listener.Listener;
import org.apache.ftpserver.listener.nio.NioListener;
import org.apache.ftpserver.ssl.DefaultSslConfiguration;
-import org.apache.ftpserver.ssl.SslConfiguration;
import org.apache.mina.filter.firewall.Subnet;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
Modified: mina/ftpserver/trunk/deprecated/src/main/java/org/apache/ftpserver/util/ConfigurationClassUtils.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/deprecated/src/main/java/org/apache/ftpserver/util/ConfigurationClassUtils.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/deprecated/src/main/java/org/apache/ftpserver/util/ConfigurationClassUtils.java (original)
+++ mina/ftpserver/trunk/deprecated/src/main/java/org/apache/ftpserver/util/ConfigurationClassUtils.java Thu Jul 31 04:49:25 2008
@@ -19,6 +19,9 @@
package org.apache.ftpserver.util;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.File;
import java.lang.reflect.Array;
@@ -32,10 +35,13 @@
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.StringTokenizer;
import org.apache.ftpserver.FtpServerConfigurationException;
import org.apache.ftpserver.ftplet.Configuration;
@@ -44,6 +50,123 @@
public class ConfigurationClassUtils {
+
+ public static void setProperty(Object target, String propertyName, String propertyValue) {
+ PropertyDescriptor setter = getDescriptor(target.getClass(), propertyName);
+
+ setProperty(target, setter, propertyValue);
+ }
+
+ public static void setProperty(Object target, String propertyName, Object propertyValue) {
+ PropertyDescriptor setter = getDescriptor(target.getClass(), propertyName);
+
+ if(setter == null) {
+ return;
+ }
+
+ setProperty(target, setter, propertyValue);
+ }
+
+ static void setProperty(Object target, PropertyDescriptor setter, Object castValue) {
+ if(setter != null) {
+ Method setterMethod = setter.getWriteMethod();
+
+ if(setterMethod != null) {
+ try {
+ setterMethod.invoke(target, new Object[]{castValue});
+ } catch (Exception e) {
+ throw new RuntimeException("Failed invoking setter " + setter.getDisplayName() + " on " + target, e);
+ }
+ } else {
+ throw new RuntimeException("Property \"" + setter.getDisplayName() + "\" is not settable on class "+ target.getClass());
+ }
+ } else {
+ throw new RuntimeException("Property is not settable on class "+ target.getClass());
+ }
+ }
+
+ private static void setProperty(Object target, PropertyDescriptor setter, String propertyValue) {
+ Object castValue = cast(setter.getPropertyType(), propertyValue);
+
+ setProperty(target, setter, castValue);
+ }
+
+ public static String normalizePropertyName(String propertyName){
+ StringTokenizer st = new StringTokenizer(propertyName, "-");
+
+ if(st.countTokens() > 1) {
+ StringBuffer sb = new StringBuffer();
+
+ // add first unchanged
+ sb.append(st.nextToken());
+
+ while(st.hasMoreTokens()) {
+ String token = st.nextToken().trim();
+
+ if(token.length() > 0) {
+ sb.append(Character.toUpperCase(token.charAt(0)));
+ sb.append(token.substring(1));
+ }
+ }
+
+ return sb.toString();
+ } else {
+ return propertyName;
+ }
+
+ }
+
+ static PropertyDescriptor getDescriptor(Class<?> clazz, String propertyName) {
+ propertyName = normalizePropertyName(propertyName);
+
+ BeanInfo beanInfo;
+ try {
+ beanInfo = Introspector.getBeanInfo(clazz);
+ } catch (IntrospectionException e) {
+ throw new RuntimeException("Failed to introspect class: " + clazz);
+ }
+ PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+
+ for (int i = 0; i < propertyDescriptors.length; i++) {
+ PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+ if(propertyDescriptor.getName().equals(propertyName)) {
+ return propertyDescriptor;
+ }
+ }
+
+ return null;
+ }
+
+
+ public static class KeyComparator implements Comparator<String> {
+ public int compare(String key1, String key2) {
+
+ // assume they are integers
+ try {
+ int intKey1 = Integer.parseInt(key1);
+ int intKey2 = Integer.parseInt(key2);
+
+ return intKey1 - intKey2;
+ } catch(NumberFormatException e) {
+ return key1.compareToIgnoreCase(key2);
+ }
+ }
+ }
+
+ static Iterator<String> getKeysInOrder(Iterator<String> keys) {
+ List<String> keyList = new ArrayList<String>();
+
+ while (keys.hasNext()) {
+ String key = keys.next();
+ keyList.add(key);
+ }
+
+ Collections.sort(keyList, new KeyComparator());
+
+ return keyList.iterator();
+ }
+
+
private static Object createObject(Class<?> clazz, Configuration config, String propValue) {
Object value;
@@ -68,7 +191,7 @@
if(Map.class.isAssignableFrom(clazz)) {
Map<String, Object> map = new HashMap<String, Object>();
- Iterator<String> mapKeys = ClassUtils.getKeysInOrder(config.getKeys());
+ Iterator<String> mapKeys = getKeysInOrder(config.getKeys());
while (mapKeys.hasNext()) {
String mapKey = mapKeys.next();
@@ -82,7 +205,7 @@
} else if(Collection.class.isAssignableFrom(clazz)) {
List<Object> list = new ArrayList<Object>();
- Iterator<String> mapKeys = ClassUtils.getKeysInOrder(config.getKeys());
+ Iterator<String> mapKeys = getKeysInOrder(config.getKeys());
while (mapKeys.hasNext()) {
String mapKey = mapKeys.next();
@@ -96,7 +219,7 @@
} else if(clazz.isArray()) {
List<Object> list = new ArrayList<Object>();
- Iterator<String> mapKeys = ClassUtils.getKeysInOrder(config.getKeys());
+ Iterator<String> mapKeys = getKeysInOrder(config.getKeys());
while (mapKeys.hasNext()) {
String mapKey = mapKeys.next();
@@ -156,7 +279,7 @@
String propValue = config.getString(key, null);
- PropertyDescriptor descriptor = ClassUtils.getDescriptor(clazz, key);
+ PropertyDescriptor descriptor = getDescriptor(clazz, key);
if(descriptor == null) {
throw new FtpServerConfigurationException("Unknown property \"" + key + "\" on class " + className);
@@ -164,7 +287,7 @@
Object value = createObject(descriptor.getPropertyType(), subConfig, propValue);
- ClassUtils.setProperty(bean, descriptor, value);
+ setProperty(bean, descriptor, value);
}
Added: mina/ftpserver/trunk/deprecated/src/test/java/org/apache/ftpserver/util/ConfigurationClassUtilsCastTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/deprecated/src/test/java/org/apache/ftpserver/util/ConfigurationClassUtilsCastTest.java?rev=681345&view=auto
==============================================================================
--- mina/ftpserver/trunk/deprecated/src/test/java/org/apache/ftpserver/util/ConfigurationClassUtilsCastTest.java (added)
+++ mina/ftpserver/trunk/deprecated/src/test/java/org/apache/ftpserver/util/ConfigurationClassUtilsCastTest.java Thu Jul 31 04:49:25 2008
@@ -0,0 +1,163 @@
+/*
+ * 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.util;
+
+import java.io.File;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+public class ConfigurationClassUtilsCastTest extends TestCase {
+ public void testCastToInt() {
+ assertEquals(new Integer(123), ConfigurationClassUtils.cast(Integer.TYPE, "123"));
+ assertEquals(new Integer(123), ConfigurationClassUtils.cast(Integer.class, "123"));
+
+ try {
+ ConfigurationClassUtils.cast(Integer.class, "foo");
+ fail("Must throw exception");
+ } catch(NumberFormatException e) {
+ // ok
+ }
+ }
+
+ public void testCastToLong() {
+ assertEquals(new Long(123), ConfigurationClassUtils.cast(Long.TYPE, "123"));
+ assertEquals(new Long(123), ConfigurationClassUtils.cast(Long.class, "123"));
+
+ try {
+ ConfigurationClassUtils.cast(Long.class, "foo");
+ fail("Must throw exception");
+ } catch(NumberFormatException e) {
+ // ok
+ }
+ }
+
+ public void testCastToFloat() {
+ assertEquals(new Float(123), ConfigurationClassUtils.cast(Float.TYPE, "123"));
+ assertEquals(new Float(123), ConfigurationClassUtils.cast(Float.class, "123"));
+ assertEquals(new Float(1.23), ConfigurationClassUtils.cast(Float.TYPE, "1.23"));
+ assertEquals(new Float(1.23), ConfigurationClassUtils.cast(Float.class, "1.23"));
+
+ try {
+ ConfigurationClassUtils.cast(Float.class, "foo");
+ fail("Must throw exception");
+ } catch(NumberFormatException e) {
+ // ok
+ }
+ }
+
+ public void testCastToDouble() {
+ assertEquals(new Double(123), ConfigurationClassUtils.cast(Double.TYPE, "123"));
+ assertEquals(new Double(123), ConfigurationClassUtils.cast(Double.class, "123"));
+ assertEquals(new Double(1.23), ConfigurationClassUtils.cast(Double.TYPE, "1.23"));
+ assertEquals(new Double(1.23), ConfigurationClassUtils.cast(Double.class, "1.23"));
+
+ try {
+ ConfigurationClassUtils.cast(Double.class, "foo");
+ fail("Must throw exception");
+ } catch(NumberFormatException e) {
+ // ok
+ }
+ }
+
+ public void testCastToByte() {
+ assertEquals(new Byte("3"), ConfigurationClassUtils.cast(Byte.TYPE, "3"));
+ assertEquals(new Byte("3"), ConfigurationClassUtils.cast(Byte.class, "3"));
+
+ try {
+ ConfigurationClassUtils.cast(Byte.class, "foo");
+ fail("Must throw exception");
+ } catch(NumberFormatException e) {
+ // ok
+ }
+ }
+
+ public void testCastToBigDecimal() {
+ assertEquals(new BigDecimal("1.23"), ConfigurationClassUtils.cast(BigDecimal.class, "1.23"));
+
+ try {
+ ConfigurationClassUtils.cast(BigDecimal.class, "foo");
+ fail("Must throw exception");
+ } catch(NumberFormatException e) {
+ // ok
+ }
+ }
+
+ public void testCastToBigInteger() {
+ assertEquals(new BigInteger("123"), ConfigurationClassUtils.cast(BigInteger.class, "123"));
+
+ try {
+ ConfigurationClassUtils.cast(BigInteger.class, "foo");
+ fail("Must throw exception");
+ } catch(NumberFormatException e) {
+ // ok
+ }
+ }
+
+ public void testCastToChar() {
+ assertEquals(new Character('a'), ConfigurationClassUtils.cast(Character.TYPE, "a"));
+ assertEquals(new Character('a'), ConfigurationClassUtils.cast(Character.class, "a"));
+
+ try {
+ ConfigurationClassUtils.cast(Character.class, "foo");
+ fail("Must throw exception");
+ } catch(RuntimeException e) {
+ // ok
+ }
+ }
+
+ public void testCastToBoolean() {
+ assertEquals(Boolean.TRUE, ConfigurationClassUtils.cast(Boolean.TYPE, "true"));
+ assertEquals(Boolean.TRUE, ConfigurationClassUtils.cast(Boolean.class, "true"));
+ assertEquals(Boolean.FALSE, ConfigurationClassUtils.cast(Boolean.TYPE, "false"));
+ assertEquals(Boolean.FALSE, ConfigurationClassUtils.cast(Boolean.class, "false"));
+ assertEquals(Boolean.FALSE, ConfigurationClassUtils.cast(Boolean.class, "foo"));
+ }
+
+ public void testCastToURL() throws Exception {
+ assertEquals(new URL("http://localhost"), ConfigurationClassUtils.cast(URL.class, "http://localhost"));
+
+ try {
+ ConfigurationClassUtils.cast(URL.class, "foo://foo://foo");
+ fail("Must throw exception");
+ } catch(RuntimeException e) {
+ // ok
+ }
+ }
+
+ public void testCastToFile() throws Exception {
+ assertEquals(new File("foo"), ConfigurationClassUtils.cast(File.class, "foo"));
+ }
+
+ public void testCastToInetAddress() throws Exception {
+ assertEquals(InetAddress.getByName("localhost"), ConfigurationClassUtils.cast(InetAddress.class, "localhost"));
+ assertEquals(InetAddress.getByName("1.2.3.4"), ConfigurationClassUtils.cast(InetAddress.class, "1.2.3.4"));
+
+ try {
+ ConfigurationClassUtils.cast(InetAddress.class, "1.2.3.4.5");
+ fail("Must throw exception");
+ } catch(RuntimeException e) {
+ // ok
+ }
+ }
+}
\ No newline at end of file
Propchange: mina/ftpserver/trunk/deprecated/src/test/java/org/apache/ftpserver/util/ConfigurationClassUtilsCastTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: mina/ftpserver/trunk/deprecated/src/test/java/org/apache/ftpserver/util/ConfigurationClassUtilsTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/deprecated/src/test/java/org/apache/ftpserver/util/ConfigurationClassUtilsTest.java?rev=681345&r1=681344&r2=681345&view=diff
==============================================================================
--- mina/ftpserver/trunk/deprecated/src/test/java/org/apache/ftpserver/util/ConfigurationClassUtilsTest.java (original)
+++ mina/ftpserver/trunk/deprecated/src/test/java/org/apache/ftpserver/util/ConfigurationClassUtilsTest.java Thu Jul 31 04:49:25 2008
@@ -326,5 +326,66 @@
this.myBean = myBean;
}
}
+
+ public void testImplementsInterface() {
+ assertTrue(ClassUtils.extendsClass(MySubBean.class, MyBean.class.getName()));
+ assertFalse(ClassUtils.extendsClass(MySubBean.class, "foo"));
+ }
+ public void testNormalizePropertyName() {
+ assertEquals("foo", ConfigurationClassUtils.normalizePropertyName("foo"));
+ assertEquals("fooBar", ConfigurationClassUtils.normalizePropertyName("fooBar"));
+ assertEquals("fooBar", ConfigurationClassUtils.normalizePropertyName("foo-bar"));
+ }
+
+ public void testSetProperty() {
+ MyBean bean = new MyBean();
+
+ ConfigurationClassUtils.setProperty(bean, "foo", "flopp");
+ assertEquals("flopp", bean.getFoo());
+
+ ConfigurationClassUtils.setProperty(bean, "foo", "flipp");
+ assertEquals("flipp", bean.getFoo());
+
+ ConfigurationClassUtils.setProperty(bean, "bar", "123");
+
+ assertEquals(123, bean.getBar());
+ }
+
+ public void testSetCamelCasesProperty() {
+ MyBean bean = new MyBean();
+
+ ConfigurationClassUtils.setProperty(bean, "camelCasedProp", "flopp");
+ assertEquals("flopp", bean.getCamelCasedProp());
+ }
+
+ public void testSetDashedProperty() {
+ MyBean bean = new MyBean();
+
+ ConfigurationClassUtils.setProperty(bean, "camel-cased-prop", "flopp");
+ assertEquals("flopp", bean.getCamelCasedProp());
+ }
+
+ public void testSetPropertyWrongCast() {
+ MyBean bean = new MyBean();
+
+ try{
+ ConfigurationClassUtils.setProperty(bean, "bar", "flopp");
+ fail("Must throw exception");
+ } catch(RuntimeException e) {
+ // ok
+ }
+ }
+
+ public void testSetPropertyUnknownProperty() {
+ MyBean bean = new MyBean();
+
+ try{
+ ConfigurationClassUtils.setProperty(bean, "dummy", "flopp");
+ fail("Must throw exception");
+ } catch(RuntimeException e) {
+ // ok
+ }
+ }
+
}
\ No newline at end of file