You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2007/07/04 18:19:21 UTC
svn commit: r553252 - in /roller/trunk:
apps/planet/src/java/org/apache/roller/planet/config/
apps/planet/src/java/org/apache/roller/planet/ui/rendering/model/
apps/planet/src/java/org/apache/roller/planet/util/
apps/planet/src/java/org/apache/roller/u...
Author: agilliland
Date: Wed Jul 4 09:19:19 2007
New Revision: 553252
URL: http://svn.apache.org/viewvc?view=rev&rev=553252
Log:
moving PropertyExpander and RegexUtil to core library since they are redundant between Weblogger and Planet. also moved unit tests for these utilities into core project and updated roller-core.jar integration library.
Added:
roller/trunk/components/core/src/java/org/apache/roller/util/PropertyExpander.java
- copied, changed from r552896, roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/PropertyExpander.java
roller/trunk/components/core/src/java/org/apache/roller/util/RegexUtil.java
- copied, changed from r552896, roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/RegexUtil.java
roller/trunk/components/core/test/
roller/trunk/components/core/test/java/
roller/trunk/components/core/test/java/org/
roller/trunk/components/core/test/java/org/apache/
roller/trunk/components/core/test/java/org/apache/roller/
roller/trunk/components/core/test/java/org/apache/roller/util/
roller/trunk/components/core/test/java/org/apache/roller/util/PropertyExpanderTest.java
- copied, changed from r552896, roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/util/PropertyExpanderTest.java
roller/trunk/components/core/test/java/org/apache/roller/util/RegexUtilTest.java
- copied, changed from r552896, roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/util/RegexUtilTest.java
roller/trunk/components/core/test/java/org/apache/roller/util/UtilitiesTestSuite.java
Removed:
roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/PropertyExpander.java
roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/RegexUtil.java
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/util/PropertyExpander.java
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/util/RegexUtil.java
roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/util/PropertyExpanderTest.java
roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/util/RegexUtilTest.java
Modified:
roller/trunk/apps/planet/src/java/org/apache/roller/planet/config/PlanetConfig.java
roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/rendering/model/UtilitiesModel.java
roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/Utilities.java
roller/trunk/apps/planet/src/java/org/apache/roller/util/OldUtilities.java
roller/trunk/apps/planet/src/java/org/apache/roller/util/UtilitiesModel.java
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/plugins/entry/ObfuscateEmailPlugin.java
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/WebloggerConfig.java
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/UtilitiesModel.java
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/velocity/deprecated/ContextLoader.java
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/velocity/deprecated/OldUtilities.java
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/util/Utilities.java
roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/webservices/xmlrpc/RollerXmlRpcServerTest.java
roller/trunk/components/core/build.xml
roller/trunk/tools/roller-core/roller-core.jar
Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/config/PlanetConfig.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/config/PlanetConfig.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/config/PlanetConfig.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/config/PlanetConfig.java Wed Jul 4 09:19:19 2007
@@ -25,7 +25,7 @@
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.roller.planet.util.PropertyExpander;
+import org.apache.roller.util.PropertyExpander;
/**
Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/rendering/model/UtilitiesModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/rendering/model/UtilitiesModel.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/rendering/model/UtilitiesModel.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/rendering/model/UtilitiesModel.java Wed Jul 4 09:19:19 2007
@@ -34,7 +34,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.roller.planet.PlanetException;
import org.apache.roller.util.DateUtil;
-import org.apache.roller.planet.util.RegexUtil;
+import org.apache.roller.util.RegexUtil;
import org.apache.roller.planet.util.Utilities;
Modified: roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/Utilities.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/Utilities.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/Utilities.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/Utilities.java Wed Jul 4 09:19:19 2007
@@ -24,6 +24,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.roller.util.RegexUtil;
/**
* General purpose utilities, not for use in templates.
Modified: roller/trunk/apps/planet/src/java/org/apache/roller/util/OldUtilities.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/util/OldUtilities.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/util/OldUtilities.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/util/OldUtilities.java Wed Jul 4 09:19:19 2007
@@ -30,7 +30,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.roller.planet.util.RegexUtil;
+import org.apache.roller.util.RegexUtil;
import org.apache.roller.planet.util.Utilities;
Modified: roller/trunk/apps/planet/src/java/org/apache/roller/util/UtilitiesModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/planet/src/java/org/apache/roller/util/UtilitiesModel.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/util/UtilitiesModel.java (original)
+++ roller/trunk/apps/planet/src/java/org/apache/roller/util/UtilitiesModel.java Wed Jul 4 09:19:19 2007
@@ -37,7 +37,7 @@
//import org.apache.roller.ui.core.RollerSession;
//import org.apache.roller.ui.rendering.util.WeblogRequest;
import org.apache.roller.util.DateUtil;
-import org.apache.roller.planet.util.RegexUtil;
+import org.apache.roller.util.RegexUtil;
import org.apache.roller.planet.util.Utilities;
/**
Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/plugins/entry/ObfuscateEmailPlugin.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/plugins/entry/ObfuscateEmailPlugin.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/plugins/entry/ObfuscateEmailPlugin.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/plugins/entry/ObfuscateEmailPlugin.java Wed Jul 4 09:19:19 2007
@@ -26,7 +26,7 @@
import org.apache.roller.weblogger.business.plugins.entry.WeblogEntryPlugin;
import org.apache.roller.weblogger.pojos.WeblogEntry;
import org.apache.roller.weblogger.pojos.Weblog;
-import org.apache.roller.weblogger.util.RegexUtil;
+import org.apache.roller.util.RegexUtil;
/**
Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/WebloggerConfig.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/WebloggerConfig.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/WebloggerConfig.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/WebloggerConfig.java Wed Jul 4 09:19:19 2007
@@ -25,7 +25,7 @@
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.roller.weblogger.util.PropertyExpander;
+import org.apache.roller.util.PropertyExpander;
/**
Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/UtilitiesModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/UtilitiesModel.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/UtilitiesModel.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/UtilitiesModel.java Wed Jul 4 09:19:19 2007
@@ -38,7 +38,7 @@
import org.apache.roller.weblogger.ui.core.RollerSession;
import org.apache.roller.weblogger.ui.rendering.util.WeblogRequest;
import org.apache.roller.util.DateUtil;
-import org.apache.roller.weblogger.util.RegexUtil;
+import org.apache.roller.util.RegexUtil;
import org.apache.roller.weblogger.util.Utilities;
/**
Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/velocity/deprecated/ContextLoader.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/velocity/deprecated/ContextLoader.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/velocity/deprecated/ContextLoader.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/velocity/deprecated/ContextLoader.java Wed Jul 4 09:19:19 2007
@@ -48,7 +48,7 @@
import org.apache.roller.weblogger.ui.rendering.util.WeblogEntryCommentForm;
import org.apache.roller.weblogger.ui.rendering.util.WeblogPageRequest;
import org.apache.roller.util.DateUtil;
-import org.apache.roller.weblogger.util.RegexUtil;
+import org.apache.roller.util.RegexUtil;
import org.apache.roller.weblogger.util.URLUtilities;
/**
Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/velocity/deprecated/OldUtilities.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/velocity/deprecated/OldUtilities.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/velocity/deprecated/OldUtilities.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/velocity/deprecated/OldUtilities.java Wed Jul 4 09:19:19 2007
@@ -30,7 +30,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.util.DateUtil;
-import org.apache.roller.weblogger.util.RegexUtil;
+import org.apache.roller.util.RegexUtil;
import org.apache.roller.weblogger.util.Utilities;
import org.apache.commons.codec.binary.Base64;
Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/util/Utilities.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/util/Utilities.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/util/Utilities.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/util/Utilities.java Wed Jul 4 09:19:19 2007
@@ -26,6 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.codec.binary.Base64;
+import org.apache.roller.util.RegexUtil;
/**
Modified: roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/webservices/xmlrpc/RollerXmlRpcServerTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/webservices/xmlrpc/RollerXmlRpcServerTest.java?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/webservices/xmlrpc/RollerXmlRpcServerTest.java (original)
+++ roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/webservices/xmlrpc/RollerXmlRpcServerTest.java Wed Jul 4 09:19:19 2007
@@ -46,7 +46,7 @@
import org.apache.roller.weblogger.pojos.WeblogEntry;
import org.apache.roller.weblogger.pojos.Weblog;
import org.apache.roller.weblogger.ui.MockRollerContext;
-import org.apache.roller.weblogger.util.RegexUtil;
+import org.apache.roller.util.RegexUtil;
import org.apache.xmlrpc.webserver.XmlRpcServlet;
Modified: roller/trunk/components/core/build.xml
URL: http://svn.apache.org/viewvc/roller/trunk/components/core/build.xml?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
--- roller/trunk/components/core/build.xml (original)
+++ roller/trunk/components/core/build.xml Wed Jul 4 09:19:19 2007
@@ -26,6 +26,7 @@
<property name="build" value="${basedir}/build" />
<property name="dist" value="${basedir}/dist" />
<property name="src" value="${basedir}/src/java" />
+ <property name="test" value="${basedir}/test/java" />
<property name="tools" value="${basedir}/../../tools" />
<!-- build properties -->
@@ -33,15 +34,31 @@
<property name="build.compile.business" value="${build.compile}/business"/>
<property name="build.compile.test" value="${build.compile}/test"/>
<property name="build.lib" value="${build}/lib"/>
+ <property name="build.test" value="${build}/test"/>
+ <property name="build.test.reports" value="${build.test}/reports"/>
+
<fileset id="core-jars" dir="${tools}">
<include name="lib/commons-lang-2.1.jar"/>
+ <include name="lib/commons-codec-1.3.jar"/>
</fileset>
<path id="core.path">
<fileset refid="core-jars" />
</path>
+ <path id="test.path">
+ <!-- testing jars -->
+ <pathelement location="${tools}/buildtime/junit-4.1.jar"/>
+
+ <!-- plus normal jars -->
+ <path refid="core.path"/>
+
+ <!-- compiled code -->
+ <pathelement location="${build.lib}/roller-core.jar"/>
+ </path>
+
+
<!-- ============================================== -->
<!-- clean out any contents from last build -->
<target name="clean" description="Clean (i.e. remove) build and dist dirs">
@@ -52,13 +69,9 @@
<!-- ============================================== -->
<!-- build all code -->
- <target name="build" depends="build-business" >
- </target>
-
- <!-- build the business layer code and jar it up -->
- <target name="build-business">
+ <target name="build">
- <!-- compile planet classes -->
+ <!-- compile core classes -->
<mkdir dir="${build.compile.business}"/>
<javac destdir="${build.compile.business}"
debug="${build.debug}"
@@ -77,7 +90,7 @@
<fileset dir="${src}" excludes="**/*.java, **/*.html, **/*.png" />
</copy>
- <!-- Jar up the business layer -->
+ <!-- Jar it up -->
<mkdir dir="${build.lib}"/>
<jar basedir="${build.compile.business}"
jarfile="${build.lib}/roller-core.jar"/>
@@ -87,7 +100,7 @@
<!-- ============================================== -->
<!-- create distributable components -->
- <target name="dist" depends="build-business" description="Create Roller core distributables">
+ <target name="dist" depends="build" >
<!-- distributable libraries -->
<mkdir dir="${dist}/lib" />
@@ -96,5 +109,73 @@
</copy>
</target>
+
+
+ <!-- ============================================== -->
+ <!-- build code used for unit testing -->
+ <target name="build-tests" depends="build" >
+
+ <!-- compile all test classes -->
+ <mkdir dir="${build.compile.test}" />
+ <javac destdir="${build.compile.test}"
+ includeantruntime="false"
+ debug="${build.debug}"
+ source="${build.sourcelevel}"
+ deprecation="${build.deprectation}">
+
+ <src path="${test}" />
+
+ <classpath>
+ <!-- testing jars -->
+ <path refid="test.path"/>
+
+ <!-- plus our compiled classes -->
+ <pathelement location="${build.compile.business}"/>
+ </classpath>
+ </javac>
+ <!-- Copy test resources -->
+ <copy todir="${build.compile.test}">
+ <fileset dir="${test}" excludes="**/*.java, **/*.html, **/*.png" />
+ </copy>
+
+ </target>
+
+
+ <!-- ===================================== -->
+ <!-- test core functionality -->
+ <target name="test" depends="build-tests" >
+
+ <mkdir dir="${build.test.reports}/business/xml"/>
+ <mkdir dir="${build.test.reports}/business/html"/>
+
+ <junit dir="${build.test}" fork="${junit.fork}" printsummary="on" showOutput="true">
+ <classpath>
+ <!-- testing jars -->
+ <path refid="test.path"/>
+
+ <!-- plus our compiled test classes -->
+ <pathelement location="${build.compile.test}"/>
+ </classpath>
+
+ <!-- needed to satisfy ref in log4j.properties -->
+ <jvmarg value="-Dcatalina.base=${build.test}"/>
+ <jvmarg value="-Dbuild=${build}"/>
+ <formatter type="xml"/>
+ <batchtest toDir="${build.test.reports}/business/xml" haltonerror="${junit.haltonerror}">
+ <fileset dir="${build.compile.test}">
+ <include name="org/apache/roller/util/UtilitiesTestSuite.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+
+ <junitreport todir="${build.test.reports}/business/xml">
+ <fileset dir="${build.test.reports}/business/xml">
+ <include name="TEST-*.xml"/>
+ </fileset>
+ <report format="noframes" toDir="${build.test.reports}/business/html"/>
+ </junitreport>
+
+ </target>
+
</project>
Copied: roller/trunk/components/core/src/java/org/apache/roller/util/PropertyExpander.java (from r552896, roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/PropertyExpander.java)
URL: http://svn.apache.org/viewvc/roller/trunk/components/core/src/java/org/apache/roller/util/PropertyExpander.java?view=diff&rev=553252&p1=roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/PropertyExpander.java&r1=552896&p2=roller/trunk/components/core/src/java/org/apache/roller/util/PropertyExpander.java&r2=553252
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/PropertyExpander.java (original)
+++ roller/trunk/components/core/src/java/org/apache/roller/util/PropertyExpander.java Wed Jul 4 09:19:19 2007
@@ -16,12 +16,13 @@
* directory of this distribution.
*/
-package org.apache.roller.planet.util;
+package org.apache.roller.util;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
/**
* Property expansion utility. This utility provides static methods to expand properties appearing in strings.
*
@@ -29,13 +30,16 @@
* ROL-613)
* @since Roller 1.3
*/
-public class PropertyExpander {
- private PropertyExpander() {
- }
-
+public final class PropertyExpander {
+
// The pattern for a system property. Matches ${property.name}, with the interior matched reluctantly.
private static final Pattern EXPANSION_PATTERN = Pattern.compile("(\\$\\{([^}]+?)\\})", java.util.regex.Pattern.MULTILINE);
-
+
+
+ // non-instantiable
+ private PropertyExpander() {}
+
+
/**
* Expand property expressions in the input. Expands property expressions of the form <code>${propertyname}</code>
* in the input, replacing each such expression with the value associated to the respective key
@@ -53,10 +57,11 @@
* supplied property map, null if the input string is null.
*/
public static String expandProperties(String input, Map props) {
+
if (input == null) return null;
-
+
Matcher matcher = EXPANSION_PATTERN.matcher(input);
-
+
StringBuffer expanded = new StringBuffer(input.length());
while (matcher.find()) {
String propName = matcher.group(2);
@@ -68,10 +73,11 @@
expanded.append(value);
}
matcher.appendTail(expanded);
-
+
return expanded.toString();
}
-
+
+
/**
* Expand system properties in the input string. This is equivalent to calling <code>expandProperties(input,
* System.getProperties())</code>.
@@ -83,4 +89,5 @@
public static String expandSystemProperties(String input) {
return expandProperties(input, System.getProperties());
}
+
}
Copied: roller/trunk/components/core/src/java/org/apache/roller/util/RegexUtil.java (from r552896, roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/RegexUtil.java)
URL: http://svn.apache.org/viewvc/roller/trunk/components/core/src/java/org/apache/roller/util/RegexUtil.java?view=diff&rev=553252&p1=roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/RegexUtil.java&r1=552896&p2=roller/trunk/components/core/src/java/org/apache/roller/util/RegexUtil.java&r2=553252
==============================================================================
--- roller/trunk/apps/planet/src/java/org/apache/roller/planet/util/RegexUtil.java (original)
+++ roller/trunk/components/core/src/java/org/apache/roller/util/RegexUtil.java Wed Jul 4 09:19:19 2007
@@ -1,48 +1,47 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. 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. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
-/*
- * Created on Nov 8, 2003
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
*/
-package org.apache.roller.planet.util;
-import org.apache.commons.codec.binary.Hex;
+
+package org.apache.roller.util;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.codec.binary.Hex;
/**
- * @author lance
+ * Regular expressions utility class.
*/
-public class RegexUtil
-{
- public static final Pattern mailtoPattern = Pattern.compile("mailto:([a-zA-Z0-9\\.]+@[a-zA-Z0-9\\.]+\\.[a-zA-Z0-9]+)");
- public static final Pattern emailPattern = Pattern.compile("\\b[a-zA-Z0-9\\.]+(@)([a-zA-Z0-9\\.]+)(\\.)([a-zA-Z0-9]+)\\b");
+public final class RegexUtil {
+
+ public static final Pattern mailtoPattern =
+ Pattern.compile("mailto:([a-zA-Z0-9\\.]+@[a-zA-Z0-9\\.]+\\.[a-zA-Z0-9]+)");
+
+ public static final Pattern emailPattern =
+ Pattern.compile("\\b[a-zA-Z0-9\\.]+(@)([a-zA-Z0-9\\.]+)(\\.)([a-zA-Z0-9]+)\\b");
- public static String encodeEmail(String str)
- {
+
+ public static String encodeEmail(String str) {
// obfuscate mailto's: turns them into hex encoded,
// so that browsers can still understand the mailto link
Matcher mailtoMatch = mailtoPattern.matcher(str);
- while (mailtoMatch.find())
- {
+ while (mailtoMatch.find()) {
String email = mailtoMatch.group(1);
//System.out.println("email=" + email);
String hexed = encode(email);
@@ -51,20 +50,16 @@
return obfuscateEmail(str);
}
-
+
+
/**
* obfuscate plaintext emails: makes them
* "human-readable" - still too easy for
* machines to parse however.
- *
- * @param str
- * @return
*/
- public static String obfuscateEmail(String str)
- {
+ public static String obfuscateEmail(String str) {
Matcher emailMatch = emailPattern.matcher(str);
- while (emailMatch.find())
- {
+ while (emailMatch.find()) {
String at = emailMatch.group(1);
//System.out.println("at=" + at);
str = str.replaceFirst(at, "-AT-");
@@ -77,35 +72,34 @@
return str;
}
+
/**
* Return the specified match "groups" from the pattern.
* For each group matched a String will be entered in the ArrayList.
- *
+ *
* @param pattern The Pattern to use.
* @param match The String to match against.
* @param group The group number to return in case of a match.
* @return
*/
- public static ArrayList getMatches(Pattern pattern, String match, int group)
- {
+ public static ArrayList getMatches(Pattern pattern, String match, int group) {
ArrayList matches = new ArrayList();
Matcher matcher = pattern.matcher(match);
- while (matcher.find())
- {
+ while (matcher.find()) {
matches.add( matcher.group(group) );
}
return matches;
}
-
- /**
+
+
+ /**
* Thanks to the folks at Blojsom (http://sf.net/projects/blojsom)
* for showing me what I was doing wrong with the Hex class.
- *
- * @param email
- * @return
- */
- public static String encode(String email)
- {
+ *
+ * @param email
+ * @return
+ */
+ public static String encode(String email) {
StringBuffer result = new StringBuffer();
try {
char[] hexString = Hex.encodeHex(email.getBytes("UTF-8"));
@@ -118,7 +112,8 @@
} catch (UnsupportedEncodingException e) {
return email;
}
-
+
return result.toString();
- }
+ }
+
}
Copied: roller/trunk/components/core/test/java/org/apache/roller/util/PropertyExpanderTest.java (from r552896, roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/util/PropertyExpanderTest.java)
URL: http://svn.apache.org/viewvc/roller/trunk/components/core/test/java/org/apache/roller/util/PropertyExpanderTest.java?view=diff&rev=553252&p1=roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/util/PropertyExpanderTest.java&r1=552896&p2=roller/trunk/components/core/test/java/org/apache/roller/util/PropertyExpanderTest.java&r2=553252
==============================================================================
--- roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/util/PropertyExpanderTest.java (original)
+++ roller/trunk/components/core/test/java/org/apache/roller/util/PropertyExpanderTest.java Wed Jul 4 09:19:19 2007
@@ -16,11 +16,12 @@
* directory of this distribution.
*/
-package org.apache.roller.weblogger.util;
+package org.apache.roller.util;
import java.util.HashMap;
import java.util.Map;
import junit.framework.TestCase;
+import org.apache.roller.util.PropertyExpander;
/**
Copied: roller/trunk/components/core/test/java/org/apache/roller/util/RegexUtilTest.java (from r552896, roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/util/RegexUtilTest.java)
URL: http://svn.apache.org/viewvc/roller/trunk/components/core/test/java/org/apache/roller/util/RegexUtilTest.java?view=diff&rev=553252&p1=roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/util/RegexUtilTest.java&r1=552896&p2=roller/trunk/components/core/test/java/org/apache/roller/util/RegexUtilTest.java&r2=553252
==============================================================================
--- roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/util/RegexUtilTest.java (original)
+++ roller/trunk/components/core/test/java/org/apache/roller/util/RegexUtilTest.java Wed Jul 4 09:19:19 2007
@@ -16,11 +16,13 @@
* directory of this distribution.
*/
-package org.apache.roller.weblogger.util;
+package org.apache.roller.util;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.roller.util.RegexUtil;
+
/**
* Test regex utils.
Added: roller/trunk/components/core/test/java/org/apache/roller/util/UtilitiesTestSuite.java
URL: http://svn.apache.org/viewvc/roller/trunk/components/core/test/java/org/apache/roller/util/UtilitiesTestSuite.java?view=auto&rev=553252
==============================================================================
--- roller/trunk/components/core/test/java/org/apache/roller/util/UtilitiesTestSuite.java (added)
+++ roller/trunk/components/core/test/java/org/apache/roller/util/UtilitiesTestSuite.java Wed Jul 4 09:19:19 2007
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.util;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * Test various utility classes that do not require a database or container.
+ */
+public class UtilitiesTestSuite {
+
+ public static Test suite() {
+
+ TestSuite suite = new TestSuite();
+
+ suite.addTestSuite(PropertyExpanderTest.class);
+ suite.addTestSuite(RegexUtilTest.class);
+
+ return suite;
+ }
+
+}
Modified: roller/trunk/tools/roller-core/roller-core.jar
URL: http://svn.apache.org/viewvc/roller/trunk/tools/roller-core/roller-core.jar?view=diff&rev=553252&r1=553251&r2=553252
==============================================================================
Binary files - no diff available.