svn commit: r745420 - in /commons/sandbox/monitoring/branches/modules: core/src/main/java/org/apache/commons/monitoring/ core/src/main/java/org/apache/commons/monitoring/stopwatches/ core/src/test/jav

2009-02-18 Thread nicolas
Author: nicolas
Date: Wed Feb 18 08:14:29 2009
New Revision: 745420

URL: http://svn.apache.org/viewvc?rev=745420view=rev
Log:
Cleaner Unit API

Modified:

commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Monitor.java

commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Unit.java

commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/stopwatches/CpuTimeStopWatch.java

commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/stopwatches/SimpleStopWatch.java

commons/sandbox/monitoring/branches/modules/core/src/test/java/org/apache/commons/monitoring/UnitTest.java

commons/sandbox/monitoring/branches/modules/instrumentation/src/main/java/org/apache/commons/monitoring/instrumentation/aop/AbstractPerformanceInterceptor.java

commons/sandbox/monitoring/branches/modules/reporting/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java

Modified: 
commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Monitor.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Monitor.java?rev=745420r1=745419r2=745420view=diff
==
--- 
commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Monitor.java
 (original)
+++ 
commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Monitor.java
 Wed Feb 18 08:14:29 2009
@@ -17,6 +17,8 @@
 
 package org.apache.commons.monitoring;
 
+import static org.apache.commons.monitoring.Unit.Time.MILLISECOND;
+
 import java.util.Collection;
 import java.util.EventListener;
 
@@ -50,10 +52,10 @@
 // --- Predefined roles 
---
 
 /** Predefined role key for code performances */
-Role PERFORMANCES = new Role( performances, Unit.MILLIS, 
Metric.Type.COUNTER );
+Role PERFORMANCES = new Role( performances, MILLISECOND, 
Metric.Type.COUNTER );
 
 /** Predefined role key for cpu time */
-Role CPU = new Role( cpu, Unit.MILLIS, Metric.Type.COUNTER );
+Role CPU = new Role( cpu, MILLISECOND, Metric.Type.COUNTER );
 
 /** Predefined role for multi-thread concurrency */
 Role CONCURRENCY = new Role( concurrency, Unit.UNARY, Metric.Type.GAUGE 
);

Modified: 
commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Unit.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Unit.java?rev=745420r1=745419r2=745420view=diff
==
--- 
commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Unit.java
 (original)
+++ 
commons/sandbox/monitoring/branches/modules/core/src/main/java/org/apache/commons/monitoring/Unit.java
 Wed Feb 18 08:14:29 2009
@@ -43,21 +43,54 @@
 private static final MapString, Unit UNITS = new 
ConcurrentHashMapString,Unit();
 
 /** Time based units */
-public static final Unit NANOS = new Unit( ns );
-public static final Unit MICROS = new Unit( µs, NANOS, 1000 );
-public static final Unit MILLIS = new Unit( ms, MICROS, 1000 );
-public static final Unit SECOND = new Unit( s, MILLIS, 1000 );
-public static final Unit MINUTE = new Unit( min, SECOND, 60 );
-public static final Unit HOUR = new Unit( h, MINUTE, 60 );
-public static final Unit DAY = new Unit( day, HOUR, 24 );
+public static class Time
+extends Unit
+{
+public static final Unit NANOSECOND = new Unit( ns );
+public static final Unit MICROSECOND = new Unit( µs, NANOSECOND, 
1000 );
+public static final Unit MILLISECOND = new Unit( ms, MICROSECOND, 
1000 );
+public static final Unit SECOND = new Unit( s, MILLISECOND, 1000 );
+public static final Unit MINUTE = new Unit( min, SECOND, 60 );
+public static final Unit HOUR = new Unit( h, MINUTE, 60 );
+public static final Unit DAY = new Unit( day, HOUR, 24 );
+
+public Time( String name )
+{
+super( name );
+}
+
+public Time( String name, Unit derived, long scale )
+{
+super( name, derived, scale );
+}
+
+}
 
 /** Binary data units */
-public static final Unit BYTE = new Unit( b );
-public static final Unit KBYTE = new Unit( Kb, BYTE, 1024 );
-public static final Unit MBYTE = new Unit( Mb, KBYTE, 1024 );
-public static final Unit GBYTE = new Unit( Gb, MBYTE, 1024 );
+public static class Binary
+extends Unit
+{
+
+public static final Unit BYTE = new Unit( b );
 
+public static 

svn commit: r745488 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers: jar/JarArchiveOutputStream.java zip/ZipArchiveOutputStream.java zip/ZipFile.java

2009-02-18 Thread bodewig
Author: bodewig
Date: Wed Feb 18 12:12:54 2009
New Revision: 745488

URL: http://svn.apache.org/viewvc?rev=745488view=rev
Log:
make ZipArchiveOutputStream and ZipFile use UTF-8 by default

Modified:

commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java

commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java

commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java

Modified: 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java?rev=745488r1=745487r2=745488view=diff
==
--- 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java
 (original)
+++ 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java
 Wed Feb 18 12:12:54 2009
@@ -29,7 +29,6 @@
 
 public JarArchiveOutputStream( final OutputStream out ) {
 super(out);
-setEncoding(UTF8);
 }
 
 public void putArchiveEntry(ArchiveEntry entry) throws IOException {

Modified: 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=745488r1=745487r2=745488view=diff
==
--- 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
 (original)
+++ 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
 Wed Feb 18 12:12:54 2009
@@ -94,6 +94,11 @@
 public static final int STORED = java.util.zip.ZipEntry.STORED;
 
 /**
+ * default encoding for file names and comment.
+ */
+static final String DEFAULT_ENCODING = UTF8;
+
+/**
  * Current entry.
  *
  * @since 1.1
@@ -205,11 +210,11 @@
  *
  * pFor a list of possible values see a
  * 
href=http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html;http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html/a.
- * Defaults to the platform's default character encoding./p
+ * Defaults to UTF-8./p
  *
  * @since 1.3
  */
-private String encoding = null;
+private String encoding = DEFAULT_ENCODING;
 
 // CheckStyle:VisibilityModifier OFF - bc
 
@@ -302,8 +307,9 @@
  *
  * pFor a list of possible values see a
  * 
href=http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html;http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html/a.
- * Defaults to the platform's default character encoding./p
- * @param encoding the encoding value
+ * Defaults to UTF-8./p
+ * @param encoding the encoding to use for file names, use null
+ * for the platform's default encoding
  * @since 1.3
  */
 public void setEncoding(String encoding) {

Modified: 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=745488r1=745487r2=745488view=diff
==
--- 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 (original)
+++ 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 Wed Feb 18 12:12:54 2009
@@ -91,9 +91,9 @@
  *
  * pFor a list of possible values see a
  * 
href=http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html;http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html/a.
- * Defaults to the platform's default character encoding./p
+ * Defaults to UTF-8./p
  */
-private String encoding = null;
+private final String encoding;
 
 /**
  * The actual data source.
@@ -101,27 +101,25 @@
 private RandomAccessFile archive;
 
 /**
- * Opens the given file for reading, assuming the platform's
- * native encoding for file names.
+ * Opens the given file for reading, assuming UTF8 for file names.
  *
  * @param f the archive.
  *
  * @throws IOException if an error occurs while reading the file.
  */
 public ZipFile(File f) throws IOException {
-this(f, null);
+this(f, ZipArchiveOutputStream.DEFAULT_ENCODING);
 }
 
 /**
- * Opens 

svn commit: r745516 - /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java

2009-02-18 Thread markt
Author: markt
Date: Wed Feb 18 13:59:21 2009
New Revision: 745516

URL: http://svn.apache.org/viewvc?rev=745516view=rev
Log:
Remove unused code identified by Eclipse

Modified:

commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java?rev=745516r1=745515r2=745516view=diff
==
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java
 (original)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java
 Wed Feb 18 13:59:21 2009
@@ -127,7 +127,7 @@
 }
 }
 catch (SQLException ex) {
-s = null;
+// Ignore
 }
 }
 




svn commit: r745528 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip: AbstractUnicodeExtraField.java ExtraFieldUtils.java UnicodeCommentExtraField.java Unic

2009-02-18 Thread bodewig
Author: bodewig
Date: Wed Feb 18 14:51:10 2009
New Revision: 745528

URL: http://svn.apache.org/viewvc?rev=745528view=rev
Log:
Add support for extra fields introduced by InfoZIP in order to store UTF-8 
filenames in ZIPs.  Submitted by Wolfgang Glas.  SANDBOX-176

Added:

commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
   (with props)

commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java
   (with props)

commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java
   (with props)

commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java
   (with props)
Modified:

commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java

Added: 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java?rev=745528view=auto
==
--- 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
 (added)
+++ 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
 Wed Feb 18 14:51:10 2009
@@ -0,0 +1,147 @@
+/*
+ *  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.commons.compress.archivers.zip;
+
+import java.io.UnsupportedEncodingException;
+import java.util.zip.CRC32;
+import java.util.zip.ZipException;
+
+/**
+ * A common base class for Unicode extra information extra fields.
+ */
+public abstract class AbstractUnicodeExtraField implements ZipExtraField {
+private long nameCRC32;
+private byte[] unicodeName;
+private byte[] data;
+
+protected AbstractUnicodeExtraField() {
+}
+
+/**
+ * Assemble as unicode path extension form the name and encoding
+ * of the orginal zip entry.
+ * 
+ * @param name The file name or comment.
+ * @param zipEncoding The encoding of the filenames in the zip
+ * file, usually codeCP437/code.
+ */
+protected AbstractUnicodeExtraField(String name, String zipEncoding) {
+
+byte[] filename = ZipEncodingHelper.encodeName(name, zipEncoding);
+
+CRC32 crc32 = new CRC32();
+crc32.update(filename);
+nameCRC32 = crc32.getValue();
+
+try {
+unicodeName = name.getBytes(UTF-8);
+} catch (UnsupportedEncodingException e) {
+throw new RuntimeException(FATAL: UTF-8 encoding not supported.,
+   e);
+}
+}
+
+private void assembleData() {
+if (unicodeName == null) {
+return;
+}
+
+data = new byte[5 + unicodeName.length];
+// version 1
+data[0] = 0x01;
+System.arraycopy(ZipLong.getBytes(nameCRC32), 0, data, 1, 4);
+System.arraycopy(unicodeName, 0, data, 5, unicodeName.length);
+}
+
+/**
+ * @return The CRC32 checksum of the filename or comment as
+ * encoded in the central directory of the zip file.
+ */
+public long getNameCRC32() {
+return nameCRC32;
+}
+
+/**
+ * @param nameCRC32 The CRC32 checksum of the filename as encoded
+ * in the central directory of the zip file to set.
+ */
+public void setNameCRC32(long nameCRC32) {
+nameCRC32 = nameCRC32;
+data = null;
+}
+
+/**
+ * @return The utf-8 encoded name.
+ */
+public byte[] getUnicodeName() {
+return unicodeName;
+}
+
+/**
+ * @param unicodeName The utf-8 encoded name to set.
+ */
+public void setUnicodeName(byte[] unicodeName) {
+unicodeName = unicodeName;
+data = null;
+}
+
+public byte[] getCentralDirectoryData() {
+if (data == null) {
+this.assembleData();

svn commit: r745563 - /commons/sandbox/validator2/tags/

2009-02-18 Thread mnour
Author: mnour
Date: Wed Feb 18 16:40:59 2009
New Revision: 745563

URL: http://svn.apache.org/viewvc?rev=745563view=rev
Log:
Creating tags directory

Added:
commons/sandbox/validator2/tags/



svn commit: r745569 - in /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp: AbandonedConfig.java AbandonedTrace.java

2009-02-18 Thread markt
Author: markt
Date: Wed Feb 18 16:46:36 2009
New Revision: 745569

URL: http://svn.apache.org/viewvc?rev=745569view=rev
Log:
Fix DBCP-4. This patch is a trade-off that provides developers an option to 
redirect the logging output without adding a new dependency on commons-logging 
or j.u.l.
App servers using DBCP will need to continue to use their existing mechanisms 
for redirecting stdout.

Modified:

commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedConfig.java

commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedTrace.java

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedConfig.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedConfig.java?rev=745569r1=745568r2=745569view=diff
==
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedConfig.java 
(original)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedConfig.java 
Wed Feb 18 16:46:36 2009
@@ -17,6 +17,8 @@
 
 package org.apache.commons.dbcp;
 
+import java.io.PrintWriter;
+
 /**
  * Configuration settings for handling abandoned db connections.
  *
@@ -130,4 +132,29 @@
 this.logAbandoned = logAbandoned;
 }
 
+/**
+ * PrintWriter to use to log information on abandoned objects.
+ */
+private PrintWriter logWriter = new PrintWriter(System.out);
+
+/**
+ * Returns the log writer being used by this configuration to log
+ * information on abandoned objects. If not set, a PrintWriter based on
+ * System.out is used.
+ *
+ * @return log writer in use
+ */
+public PrintWriter getLogWriter() {
+return logWriter;
+}
+
+/**
+ * Sets the log writer to be used by this configuration to log
+ * information on abandoned objects.
+ * 
+ * @param logWriter The new log writer
+ */
+public void setLogWriter(PrintWriter logWriter) {
+this.logWriter = logWriter;
+}
 }

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedTrace.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedTrace.java?rev=745569r1=745568r2=745569view=diff
==
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedTrace.java 
(original)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/AbandonedTrace.java 
Wed Feb 18 16:46:36 2009
@@ -188,9 +188,9 @@
  * created this object.
  */
 public void printStackTrace() {
-if (createdBy != null) {
-System.out.println(format.format(new Date(createdTime)));
-createdBy.printStackTrace(System.out);
+if (createdBy != null  config != null) {
+config.getLogWriter().println(format.format(new 
Date(createdTime)));
+createdBy.printStackTrace(config.getLogWriter());
 }
 synchronized(this.trace) {
 Iterator it = this.trace.iterator();




svn commit: r745594 - in /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp: BasicDataSource.java cpdsadapter/DriverAdapterCPDS.java

2009-02-18 Thread markt
Author: markt
Date: Wed Feb 18 18:30:14 2009
New Revision: 745594

URL: http://svn.apache.org/viewvc?rev=745594view=rev
Log:
Attempt to address DBCP-272.
We can never truely fix this since the way drivers are expected to register 
with the DriverManager is asking for a deadlock to occur in multi-thread 
environments - as per DBCP-272. What we can do is attempt to prevent this in 
environments where only DBCP is used. This patch calls 
DriverManager.getDrivers() to force initialisation before we ever do anything 
that might use Class.forName() to load (and register) a JDBC driver.

Modified:

commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSource.java

commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/cpdsadapter/DriverAdapterCPDS.java

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSource.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSource.java?rev=745594r1=745593r2=745594view=diff
==
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSource.java 
(original)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSource.java 
Wed Feb 18 18:30:14 2009
@@ -42,6 +42,11 @@
  * @version $Revision$ $Date$
  */
 public class BasicDataSource implements DataSource {
+
+static {
+// Attempt to prevent deadlocks - see DBCP - 272
+DriverManager.getDrivers();
+}
 
 // - Properties
 

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/cpdsadapter/DriverAdapterCPDS.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/cpdsadapter/DriverAdapterCPDS.java?rev=745594r1=745593r2=745594view=diff
==
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/cpdsadapter/DriverAdapterCPDS.java
 (original)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/cpdsadapter/DriverAdapterCPDS.java
 Wed Feb 18 18:30:14 2009
@@ -118,6 +118,11 @@
 
 private boolean getConnectionCalled = false;
 
+static {
+// Attempt to prevent deadlocks - see DBCP - 272
+DriverManager.getDrivers();
+}
+
 /**
  * Default no-arg constructor for Serialization
  */




svn commit: r745725 - /commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java

2009-02-18 Thread bayard
Author: bayard
Date: Thu Feb 19 05:06:16 2009
New Revision: 745725

URL: http://svn.apache.org/viewvc?rev=745725view=rev
Log:
Adjusting so that long lines are mercilessly cut off at the maxwidth and 
continued as before on the following line. 

Modified:

commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java

Modified: 
commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java
URL: 
http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java?rev=745725r1=745724r2=745725view=diff
==
--- 
commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java
 (original)
+++ 
commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java
 Thu Feb 19 05:06:16 2009
@@ -832,9 +832,7 @@
 }
 
 if ( (text.length()  width)  (pos == nextLineTabStop - 1) ) {
-sb.append(text);
-
-return sb;
+pos = width;
 }
 
 sb.append(rtrim(text.substring(0, pos))).append(defaultNewLine);




svn commit: r745727 - /commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java

2009-02-18 Thread bayard
Author: bayard
Date: Thu Feb 19 05:07:04 2009
New Revision: 745727

URL: http://svn.apache.org/viewvc?rev=745727view=rev
Log:
Always hard to remember to drop the braces in CLI

Modified:

commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java

Modified: 
commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java
URL: 
http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java?rev=745727r1=745726r2=745727view=diff
==
--- 
commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java
 (original)
+++ 
commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java
 Thu Feb 19 05:07:04 2009
@@ -831,7 +831,8 @@
 return sb;
 }
 
-if ( (text.length()  width)  (pos == nextLineTabStop - 1) ) {
+if ( (text.length()  width)  (pos == nextLineTabStop - 1) ) 
+{
 pos = width;
 }
 




svn commit: r745753 - /commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java

2009-02-18 Thread bayard
Author: bayard
Date: Thu Feb 19 06:34:17 2009
New Revision: 745753

URL: http://svn.apache.org/viewvc?rev=745753view=rev
Log:
Getting rid of the unnecessary testPrintHelp method

Modified:

commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java

Modified: 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
URL: 
http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java?rev=745753r1=745752r2=745753view=diff
==
--- 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
 (original)
+++ 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
 Thu Feb 19 06:34:17 2009
@@ -44,10 +44,6 @@
 formatter.setWidth(20);
 formatter.printHelp(app, options); // used to hang  crash
 }
-
-private void testPrintHelp(Options options) throws ParseException, 
IOException {
-new HelpFormatter().printHelp(this.getClass().getName(), options);
-}
 
 public void testPrintHelpLongLines() throws ParseException, IOException {
 // Constants used for options
@@ -233,7 +229,7 @@
 Converts the JDBC file in the first argument to an SMFD file 
specified in the second argument.);
 option.setArgs(2);
 commandLineOptions.addOption(option);
-this.testPrintHelp(commandLineOptions);
+new HelpFormatter().printHelp(this.getClass().getName(), options);
 }
 
 }




svn commit: r745755 - /commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java

2009-02-18 Thread bayard
Author: bayard
Date: Thu Feb 19 06:43:49 2009
New Revision: 745755

URL: http://svn.apache.org/viewvc?rev=745755view=rev
Log:
Fixing the previous commit so the right variable is used. There's no reason to 
share the options class between methods, so deleting the setUp()

Modified:

commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java

Modified: 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
URL: 
http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java?rev=745755r1=745754r2=745755view=diff
==
--- 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
 (original)
+++ 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
 Thu Feb 19 06:43:49 2009
@@ -32,14 +32,9 @@
 
 public class BugCLI162Test extends TestCase {
 
-private Options options;
-
-public void setUp() {
-options = new Options();
-options.addOption(h, help, false, This is a long 
description);
-}
-
 public void testInfiniteLoop() {
+Options options = new Options();
+options.addOption(h, help, false, This is a long 
description);
 HelpFormatter formatter = new HelpFormatter();
 formatter.setWidth(20);
 formatter.printHelp(app, options); // used to hang  crash
@@ -229,7 +224,7 @@
 Converts the JDBC file in the first argument to an SMFD file 
specified in the second argument.);
 option.setArgs(2);
 commandLineOptions.addOption(option);
-new HelpFormatter().printHelp(this.getClass().getName(), options);
+new HelpFormatter().printHelp(this.getClass().getName(), 
commandLineOptions);
 }
 
 }




svn commit: r745762 - /commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java

2009-02-18 Thread bayard
Author: bayard
Date: Thu Feb 19 07:14:40 2009
New Revision: 745762

URL: http://svn.apache.org/viewvc?rev=745762view=rev
Log:
Adding another test

Modified:

commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java

Modified: 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
URL: 
http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java?rev=745762r1=745761r2=745762view=diff
==
--- 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
 (original)
+++ 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
 Thu Feb 19 07:14:40 2009
@@ -19,6 +19,8 @@
 package org.apache.commons.cli.bug;
 
 import java.io.IOException;
+import java.io.StringWriter;
+import java.io.PrintWriter;
 import java.sql.ParameterMetaData;
 import java.sql.Types;
 
@@ -227,4 +229,36 @@
 new HelpFormatter().printHelp(this.getClass().getName(), 
commandLineOptions);
 }
 
+public void testLongLineChunking() throws ParseException, IOException {
+Options options = new Options();
+options.addOption(x, extralongarg, false,
+ This description has 
ReallyLongValuesThatAreLongerThanTheWidthOfTheColumns  +
+ and also other 
ReallyLongValuesThatAreHugerAndBiggerThanTheWidthOfTheColumnsBob,  +
+ yes. );
+HelpFormatter formatter = new HelpFormatter();
+StringWriter sw = new StringWriter();
+formatter.printHelp(new PrintWriter(sw), 35, 
this.getClass().getName(), Header, options, 0, 5, Footer);
+String expected = usage:\n +
+ org.apache.commons.cli.bug.B\n +
+ ugCLI162Test\n +
+  Header\n +
+  -x,--extralongarg This\n +
+description\n +
+has\n +
+ReallyLongVal\n +
+uesThatAreLon\n +
+gerThanTheWid\n +
+thOfTheColumn\n +
+s and also\n +
+other\n +
+ReallyLongVal\n +
+uesThatAreHug\n +
+erAndBiggerTh\n +
+anTheWidthOfT\n +
+heColumnsBob,\n +
+yes.\n +
+  Footer\n;
+assertEquals( Long arguments did not split as expected, expected, 
sw.toString() );
+}
+
 }