[joda-convert] 02/05: Imported Upstream version 1.3.1

Tony Mancill tmancill at moszumanska.debian.org
Sat Sep 5 21:38:38 UTC 2015


This is an automated email from the git hooks/post-receive script.

tmancill pushed a commit to branch master
in repository joda-convert.

commit e70fdb9cfe8a365ddc1c578c71ad3f1298facbc3
Author: tony mancill <tmancill at debian.org>
Date:   Sat Sep 5 14:37:13 2015 -0700

    Imported Upstream version 1.3.1
---
 RELEASE-NOTES.txt                                  |  16 ++--
 pom.xml                                            |  81 ++++++++++++-----
 src/changes/changes.xml                            |  16 ++++
 src/conf/MANIFEST.MF                               |   8 +-
 src/main/java/org/joda/convert/StringConvert.java  | 101 +++++++++++++++++----
 src/site/site.xml                                  |   9 +-
 src/site/xdoc/index.xml                            |  30 +++---
 .../java/org/joda/convert/TestStringConvert.java   |  48 +++++++++-
 8 files changed, 235 insertions(+), 74 deletions(-)

diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 0d18d7c..8b68324 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -1,21 +1,21 @@
-Joda-Convert version 1.1
-------------------------
 
+Joda-Convert
+================================================
 Joda-Convert is a small library providing conversion to and from String.
 
-This is the second release of Joda-Convert.
+This is release 1.3.1 of Joda-Convert.
 
-JDK 1.5 or later is required.
+The release runs on Java SE 6 or later.
+
+See http://joda-convert.sourceforge.net/changes-report.html for changes
 
 Joda-Convert is licensed under the business-friendly Apache License Version 2.
 This is the same license as all of Apache, plus other open source projects such as Spring.
-The intent is to make the code available to the Java community with the minimum
-of restrictions. If the license causes you problems please contact the mailing list.
 
 
 Feedback
 --------
-All feedback is welcomed via the joda-convert-interest mailing list.
+Feedback is best received using GitHub issues and Pull Requests.
+https://github.com/JodaOrg/joda-convert/
 
 The Joda team
-http://joda-convert.sourceforge.net
diff --git a/pom.xml b/pom.xml
index c068041..790610e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,12 +8,12 @@
   <artifactId>joda-convert</artifactId>
   <packaging>jar</packaging>
   <name>Joda convert</name>
-  <version>1.2</version>
+  <version>1.3.1</version>
   <description>Library to convert Objects to and from String</description>
   <url>http://joda-convert.sourceforge.net</url>
   <issueManagement>
-  	<system>Sourceforge</system>
-    <url>https://sourceforge.net/tracker/?group_id=344317&atid=1440693</url>
+  	<system>GitHub</system>
+    <url>https://github.com/JodaOrg/joda-convert/issues</url>
   </issueManagement>
   <inceptionYear>2010</inceptionYear>
   <mailingLists>
@@ -35,6 +35,16 @@
       <timezone>0</timezone>
     </developer>
   </developers>
+  <contributors>
+    <contributor>
+      <email>cjkent</email>
+      <name>Chris Kent</name>
+    </contributor>
+    <contributor>
+      <email>rocketraman</email>
+      <name>Raman Gupta</name>
+    </contributor>
+  </contributors>
   <licenses>
     <license>
       <name>Apache 2</name>
@@ -55,7 +65,7 @@
     <resources>
       <resource>
         <targetPath>META-INF</targetPath>
-        <directory>.</directory>
+        <directory>${basedir}</directory>
         <includes>
           <include>LICENSE.txt</include>
           <include>NOTICE.txt</include>
@@ -66,18 +76,18 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-clean-plugin</artifactId>
-        <version>2.4.1</version>
+        <version>2.5</version>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
-        <version>2.3.1</version>
+        <version>3.0</version>
         <configuration>
           <verbose>true</verbose>
           <fork>true</fork>
-          <compilerVersion>1.5</compilerVersion>
-          <source>1.5</source>
-          <target>1.5</target>
+          <compilerVersion>1.6</compilerVersion>
+          <source>1.6</source>
+          <target>1.6</target>
           <debug>true</debug>
           <debuglevel>lines,source</debuglevel>
           <optimize>true</optimize>
@@ -87,7 +97,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.5</version>
+        <version>2.13</version>
         <configuration>
           <includes>
             <include>**/Test*.java</include>
@@ -97,7 +107,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
-        <version>2.3.1</version>
+        <version>2.4</version>
         <configuration>
           <archive>
             <manifestFile>src/conf/MANIFEST.MF</manifestFile>
@@ -107,11 +117,11 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-javadoc-plugin</artifactId>
-        <version>2.7</version>
+        <version>2.9</version>
         <configuration>
           <linksource>true</linksource>
           <links>
-            <link>http://download.oracle.com/javase/1.5.0/docs/api/</link>
+            <link>http://download.oracle.com/javase/6/docs/api/</link>
           </links>
           <encoding>UTF-8</encoding>
         </configuration>
@@ -128,7 +138,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-source-plugin</artifactId>
-        <version>2.1.2</version>
+        <version>2.2.1</version>
         <executions>
           <execution>
             <id>attach-sources</id>
@@ -142,7 +152,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-site-plugin</artifactId>
-        <version>2.1.1</version>
+        <version>3.2</version>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
@@ -151,7 +161,18 @@
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <version>2.6</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <version>2.7</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-assembly-plugin</artifactId>
+        <version>2.4</version>
         <configuration>
           <descriptors>
             <descriptor>src/main/assembly/dist.xml</descriptor>
@@ -210,11 +231,11 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-javadoc-plugin</artifactId>
-        <version>2.7</version>
+        <version>2.9</version>
         <configuration>
           <linksource>true</linksource>
           <links>
-            <link>http://download.oracle.com/javase/1.5.0/docs/api/</link>
+            <link>http://download.oracle.com/javase/6/docs/api/</link>
           </links>
           <encoding>UTF-8</encoding>
         </configuration>
@@ -222,19 +243,15 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-report-plugin</artifactId>
-        <version>2.5</version>
+        <version>2.13</version>
         <configuration>
            <showSuccess>true</showSuccess>
         </configuration>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jxr-plugin</artifactId>
-        <version>2.2</version>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-changes-plugin</artifactId>
+        <version>2.8</version>
         <reportSets>
           <reportSet>
             <reports>
@@ -243,6 +260,22 @@
           </reportSet>
         </reportSets>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jxr-plugin</artifactId>
+        <version>2.3</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-pmd-plugin</artifactId>
+        <version>2.7.1</version>
+        <configuration>
+          <linkXref>true</linkXref>
+          <sourceEncoding>utf-8</sourceEncoding>
+          <minimumTokens>100</minimumTokens>
+          <targetJdk>1.6</targetJdk>
+        </configuration>
+      </plugin>
   	</plugins>
   </reporting>
   <distributionManagement>
@@ -292,7 +325,7 @@
             <configuration>
               <toolchains>
                 <jdk>
-                  <version>1.5</version>
+                  <version>1.6</version>
                   <vendor>sun</vendor>
                 </jdk>
               </toolchains>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0ddc2ac..05d0d12 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -7,6 +7,22 @@
 
   <body>
     <!-- types are add, fix, remove, update -->
+    <release version="1.3.1" date="2013-03-08">
+      <action dev="rocketraman" type="fix" >
+        Fix OSGI manifest.
+      </action>
+    </release>
+    <release version="1.3" date="2013-01-25">
+      <action dev="scolebourne" type="add" >
+        Add register method designed for JDK 1.8 method references or lambdas.
+      </action>
+      <action dev="scolebourne" type="update" >
+        Change to requiring JDK 1.6.
+      </action>
+      <action dev="scolebourne" type="add" >
+        Add alternate package locations for JSR-310 classes.
+      </action>
+    </release>
     <release version="1.2" date="2011-10-27">
       <action dev="scolebourne" type="add" >
         Add support for CharSequence based fromString methods.
diff --git a/src/conf/MANIFEST.MF b/src/conf/MANIFEST.MF
index 7da94d7..2fe0be5 100644
--- a/src/conf/MANIFEST.MF
+++ b/src/conf/MANIFEST.MF
@@ -2,16 +2,16 @@ Package: org.joda.convert
 Extension-Name: joda-convert
 Specification-Title: Joda-Convert
 Specification-Vendor: Joda.org
-Specification-Version: 1.2
+Specification-Version: 1.3
 Implementation-Vendor: Joda.org
 Implementation-Title: org.joda.convert
-Implementation-Version: 1.2
+Implementation-Version: 1.3.1
 Implementation-Vendor-Id: org.joda
 Bundle-ManifestVersion: 2
 Bundle-Vendor: Joda.org
 Bundle-Name: Joda-Convert
 Bundle-SymbolicName: joda-convert
-Bundle-Version: 1.2
-Export-Package: org.joda.time.convert;version=1.2
+Bundle-Version: 1.3.1
+Export-Package: org.joda.convert;version=1.3.1
 Bundle-License: Apache 2.0
 Bundle-DocURL: http://joda-convert.sourceforge.net/
diff --git a/src/main/java/org/joda/convert/StringConvert.java b/src/main/java/org/joda/convert/StringConvert.java
index 50197e8..61f6f5a 100644
--- a/src/main/java/org/joda/convert/StringConvert.java
+++ b/src/main/java/org/joda/convert/StringConvert.java
@@ -46,6 +46,11 @@ public final class StringConvert {
 
     /**
      * Creates a new conversion manager including the JDK converters.
+     * <p>
+     * The convert instance is mutable in a thread-safe manner.
+     * Converters may be altered at any time, including the JDK converters.
+     * It is strongly recommended to only alter the converters before performing
+     * actual conversions.
      */
     public StringConvert() {
         this(true);
@@ -53,6 +58,11 @@ public final class StringConvert {
 
     /**
      * Creates a new conversion manager.
+     * <p>
+     * The convert instance is mutable in a thread-safe manner.
+     * Converters may be altered at any time, including the JDK converters.
+     * It is strongly recommended to only alter the converters before performing
+     * actual conversions.
      * 
      * @param includeJdkConverters  true to include the JDK converters
      */
@@ -69,7 +79,37 @@ public final class StringConvert {
             registered.put(Float.TYPE, JDKStringConverter.FLOAT);
             registered.put(Double.TYPE, JDKStringConverter.DOUBLE);
             registered.put(Character.TYPE, JDKStringConverter.CHARACTER);
-            // JSR-310 classes
+            // JDK 1.8 classes
+            tryRegister("java.time.Instant", "parse");
+            tryRegister("java.time.Duration", "parse");
+            tryRegister("java.time.LocalDate", "parse");
+            tryRegister("java.time.LocalTime", "parse");
+            tryRegister("java.time.LocalDateTime", "parse");
+            tryRegister("java.time.OffsetTime", "parse");
+            tryRegister("java.time.OffsetDateTime", "parse");
+            tryRegister("java.time.ZonedDateTime", "parse");
+            tryRegister("java.time.Year", "parse");
+            tryRegister("java.time.YearMonth", "parse");
+            tryRegister("java.time.MonthDay", "parse");
+            tryRegister("java.time.Period", "parse");
+            tryRegister("java.time.ZoneOffset", "of");
+            tryRegister("java.time.ZoneId", "of");
+            // ThreeTen backport classes
+            tryRegister("org.threeten.bp.Instant", "parse");
+            tryRegister("org.threeten.bp.Duration", "parse");
+            tryRegister("org.threeten.bp.LocalDate", "parse");
+            tryRegister("org.threeten.bp.LocalTime", "parse");
+            tryRegister("org.threeten.bp.LocalDateTime", "parse");
+            tryRegister("org.threeten.bp.OffsetTime", "parse");
+            tryRegister("org.threeten.bp.OffsetDateTime", "parse");
+            tryRegister("org.threeten.bp.ZonedDateTime", "parse");
+            tryRegister("org.threeten.bp.Year", "parse");
+            tryRegister("org.threeten.bp.YearMonth", "parse");
+            tryRegister("org.threeten.bp.MonthDay", "parse");
+            tryRegister("org.threeten.bp.Period", "parse");
+            tryRegister("org.threeten.bp.ZoneOffset", "of");
+            tryRegister("org.threeten.bp.ZoneId", "of");
+            // Old ThreeTen/JSR-310 classes v0.6.3 and beyond
             tryRegister("javax.time.Instant", "parse");
             tryRegister("javax.time.Duration", "parse");
             tryRegister("javax.time.calendar.LocalDate", "parse");
@@ -317,8 +357,8 @@ public final class StringConvert {
      * @param <T>  the type of the converter
      * @param cls  the class to register a converter for, not null
      * @param converter  the String converter, not null
-     * @throws IllegalArgumentException if unable to register
-     * @throws IllegalStateException if class already registered
+     * @throws IllegalArgumentException if the class or converter are null
+     * @throws IllegalStateException if trying to alter the global singleton
      */
     public <T> void register(final Class<T> cls, StringConverter<T> converter) {
         if (cls == null ) {
@@ -330,10 +370,41 @@ public final class StringConvert {
         if (this == INSTANCE) {
             throw new IllegalStateException("Global singleton cannot be extended");
         }
-        StringConverter<?> old = registered.putIfAbsent(cls, converter);
-        if (old != null) {
-            throw new IllegalStateException("Converter already registered for class: " + cls);
+        registered.put(cls, converter);
+    }
+
+    /**
+     * Registers a converter for a specific type using two separate converters.
+     * <p>
+     * This method registers a converter for the specified class.
+     * It is primarily intended for use with JDK 1.8 method references or lambdas:
+     * <pre>
+     *  sc.register(Distance.class, Distance::toString, Distance::parse);
+     * </pre>
+     * The converter will be used for subclasses unless overidden.
+     * <p>
+     * No new converters may be registered for the global singleton.
+     * 
+     * @param <T>  the type of the converter
+     * @param cls  the class to register a converter for, not null
+     * @param toString  the to String converter, typically a method reference, not null
+     * @param fromString  the from String converter, typically a method reference, not null
+     * @throws IllegalArgumentException if the class or converter are null
+     * @throws IllegalStateException if trying to alter the global singleton
+     * @since 1.3
+     */
+    public <T> void register(final Class<T> cls, final ToStringConverter<T> toString, final FromStringConverter<T> fromString) {
+        if (fromString == null || toString == null) {
+            throw new IllegalArgumentException("Converters must not be null");
         }
+        register(cls, new StringConverter<T>() {
+            public String convertToString(T object) {
+                return toString.convertToString(object);
+            }
+            public T convertFromString(Class<? extends T> cls, String str) {
+                return fromString.convertFromString(cls, str);
+            }
+        });
     }
 
     /**
@@ -352,8 +423,8 @@ public final class StringConvert {
      * @param cls  the class to register a converter for, not null
      * @param toStringMethodName  the name of the method converting to a string, not null
      * @param fromStringMethodName  the name of the method converting from a string, not null
-     * @throws IllegalArgumentException if unable to register
-     * @throws IllegalStateException if class already registered
+     * @throws IllegalArgumentException if the class or method name are null or invalid
+     * @throws IllegalStateException if trying to alter the global singleton
      */
     public <T> void registerMethods(final Class<T> cls, String toStringMethodName, String fromStringMethodName) {
         if (cls == null ) {
@@ -368,10 +439,7 @@ public final class StringConvert {
         Method toString = findToStringMethod(cls, toStringMethodName);
         Method fromString = findFromStringMethod(cls, fromStringMethodName);
         MethodsStringConverter<T> converter = new MethodsStringConverter<T>(cls, toString, fromString);
-        StringConverter<?> old = registered.putIfAbsent(cls, converter);
-        if (old != null) {
-            throw new IllegalStateException("Converter already registered for class: " + cls);
-        }
+        registered.putIfAbsent(cls, converter);
     }
 
     /**
@@ -389,8 +457,8 @@ public final class StringConvert {
      * @param <T>  the type of the converter
      * @param cls  the class to register a converter for, not null
      * @param toStringMethodName  the name of the method converting to a string, not null
-     * @throws IllegalArgumentException if unable to register
-     * @throws IllegalStateException if class already registered
+     * @throws IllegalArgumentException if the class or method name are null or invalid
+     * @throws IllegalStateException if trying to alter the global singleton
      */
     public <T> void registerMethodConstructor(final Class<T> cls, String toStringMethodName) {
         if (cls == null ) {
@@ -405,10 +473,7 @@ public final class StringConvert {
         Method toString = findToStringMethod(cls, toStringMethodName);
         Constructor<T> fromString = findFromStringConstructorByType(cls);
         MethodConstructorStringConverter<T> converter = new MethodConstructorStringConverter<T>(cls, toString, fromString);
-        StringConverter<?> old = registered.putIfAbsent(cls, converter);
-        if (old != null) {
-            throw new IllegalStateException("Converter already registered for class: " + cls);
-        }
+        registered.putIfAbsent(cls, converter);
     }
 
     /**
diff --git a/src/site/site.xml b/src/site/site.xml
index 921885f..fc5e83a 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -17,20 +17,17 @@
       <item name="Overview" href="index.html"/>
       <item name="User guide" href="userguide.html"/>
       <!--item name="FAQ" href="faq.html"/-->
-      <item name="Javadoc (Release)" href="api-release/index.html"/>
+      <item name="Javadoc" href="apidocs/index.html"/>
       <item name="License" href="license.html"/>
+      <item name="Release notes" href="changes-report.html"/>
       <item name="Download" href="http://sourceforge.net/projects/joda-convert/files/joda-convert/"/>
     </menu>
 
     <menu name="Development">
       <item name="GitHub (Source code)" href="https://github.com/JodaOrg/joda-convert"/>
       <item name="Sourceforge" href="http://sourceforge.net/projects/joda-convert/"/>
-      <!--item name="Test results" href="/junit-report.html"/-->
-      <!--item name="Test coverage" href="/cobertura/index.html"/-->
+      <item name="Bugs/Issues" href="https://github.com/JodaOrg/joda-convert/issues"/>
       <item name="Mailing lists" href="mail-lists.html"/>
-      <!--item name="Tasks" href="tasks.html"/-->
-      <!--item name="Subversion" href="http://joda-convert.svn.sourceforge.net/viewvc/joda-convert/trunk/"/-->
-      <item name="Javadoc (Development)" href="apidocs/index.html"/>
     </menu>
 
     <menu name="Joda">
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index db94440..410f718 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -10,7 +10,6 @@
  <body>
 
 <section name="Joda Convert">
-
 <p>
 Joda-Convert provides a small set of classes to aid conversion between Objects and Strings.
 It is not intended to tackle the wider problem of Object to Object transformation.
@@ -55,43 +54,52 @@ then the annotations are checked. If they are found, then the methods are called
 <p>
 Joda-Convert is licensed under the business-friendly <a href="license.html">Apache 2.0 licence</a>.
 </p>
-
 </section>
 
+
 <section name="Documentation">
 <p>
 Various documentation is available:
 <ul>
 <li>The helpful <a href="userguide.html">user guide</a></li>
-<li>The javadoc for the <a href="api-release/index.html">current release</a></li>
-<li>The javadoc for the <a href="apidocs/index.html">latest source code</a></li>
+<li>The javadoc for the <a href="apidocs/index.html">current release</a></li>
 <li>The change notes <a href="changes-report.html">for the releases</a></li>
-<!--li>A <a href="faq.html">FAQ</a> list</li-->
-<!--li>Information on <a href="installation.html">downloading and installing</a> Joda-Convert</li-->
 <li>The <a href="https://github.com/JodaOrg/joda-convert">GitHub</a> source repository</li>
 </ul>
 </p>
 </section>
 
+
 <section name="Releases">
 <p>
-<a href="http://sourceforge.net/projects/joda-convert/files/joda-convert/1.2/">Release 1.2</a>
+<a href="http://sourceforge.net/projects/joda-convert/files/joda-convert/1.3.1/">Release 1.3.1</a>
 is the current latest release.
 This release is considered stable and worthy of the 1.x tag.
-It depends on JDK 1.5 or later.
+It depends on JDK 1.6 or later.
+</p>
+<p>
+Available in the <a href="http://search.maven.org/#artifactdetails|org.joda|joda-convert|1.3.1|jar">Maven Central repository</a>.
 </p>
 </section>
 
-<section name="Contact">
+
+<section name="Support">
 <p>
+Support on bugs, library usage or enhancement requests is available on a best efforts basis.
 If you have any questions, or want to volunteer to help, just email Stephen Colebourne
 via scolebourne.at.users.sourceforge.net.
 </p>
 <p>
+To suggest enhancements or contribute, please <a href="https://github.com/JodaOrg/joda-convert">fork the source code</a> on GitHub.
+Alternatively, use GitHub <a href="https://github.com/JodaOrg/joda-convert/issues">issues</a>.
+</p>
+<p>
 <br />
+</p>
+<p>
 <br />
-<br />
-<br />
+</p>
+<p>
 <br />
 </p>
 </section>
diff --git a/src/test/java/org/joda/convert/TestStringConvert.java b/src/test/java/org/joda/convert/TestStringConvert.java
index a893b5b..3a729ec 100644
--- a/src/test/java/org/joda/convert/TestStringConvert.java
+++ b/src/test/java/org/joda/convert/TestStringConvert.java
@@ -383,7 +383,7 @@ public class TestStringConvert {
         StringConvert.INSTANCE.register(Integer.class, MockIntegerStringConverter.INSTANCE);
     }
 
-    @Test(expected=IllegalStateException.class)
+    @Test
     public void test_register_classAlreadyRegistered() {
         new StringConvert().register(Integer.class, MockIntegerStringConverter.INSTANCE);
     }
@@ -395,6 +395,48 @@ public class TestStringConvert {
     }
 
     //-------------------------------------------------------------------------
+    ToStringConverter<DistanceNoAnnotations> DISTANCE_TO_STRING_CONVERTER = new ToStringConverter<DistanceNoAnnotations>() {
+        public String convertToString(DistanceNoAnnotations object) {
+            return object.toString();
+        }
+    };
+    FromStringConverter<DistanceNoAnnotations> DISTANCE_FROM_STRING_CONVERTER = new FromStringConverter<DistanceNoAnnotations>() {
+        public DistanceNoAnnotations convertFromString(Class<? extends DistanceNoAnnotations> cls, String str) {
+            return DistanceNoAnnotations.parse(str);
+        }
+    };
+
+    @Test
+    public void test_register_FunctionalInterfaces() {
+        StringConvert test = new StringConvert();
+        test.register(DistanceNoAnnotations.class, DISTANCE_TO_STRING_CONVERTER, DISTANCE_FROM_STRING_CONVERTER);
+        DistanceNoAnnotations d = new DistanceNoAnnotations(25);
+        assertEquals("Distance[25m]", test.convertToString(d));
+        assertEquals(d.amount, test.convertFromString(DistanceNoAnnotations.class, "25m").amount);
+        StringConverter<DistanceNoAnnotations> conv = test.findConverter(DistanceNoAnnotations.class);
+        assertEquals(true, conv.getClass().getName().contains("$"));
+        assertSame(conv, test.findConverter(DistanceNoAnnotations.class));
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void test_register_FunctionalInterfaces_nullClass() {
+        StringConvert test = new StringConvert();
+        test.register(null, DISTANCE_TO_STRING_CONVERTER, DISTANCE_FROM_STRING_CONVERTER);
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void test_register_FunctionalInterfaces_nullToString() {
+        StringConvert test = new StringConvert();
+        test.register(DistanceNoAnnotations.class, null, DISTANCE_FROM_STRING_CONVERTER);
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void test_register_FunctionalInterfaces_nullFromString() {
+        StringConvert test = new StringConvert();
+        test.register(DistanceNoAnnotations.class, DISTANCE_TO_STRING_CONVERTER, null);
+    }
+
+    //-------------------------------------------------------------------------
     @Test
     public void test_registerMethods() {
         StringConvert test = new StringConvert();
@@ -437,7 +479,7 @@ public class TestStringConvert {
         test.registerMethods(DistanceNoAnnotations.class, "toString", null);
     }
 
-    @Test(expected=IllegalStateException.class)
+    @Test
     public void test_registerMethods_classAlreadyRegistered() {
       StringConvert test = new StringConvert();
       test.registerMethods(DistanceNoAnnotations.class, "toString", "parse");
@@ -481,7 +523,7 @@ public class TestStringConvert {
         test.registerMethodConstructor(DistanceNoAnnotations.class, null);
     }
 
-    @Test(expected=IllegalStateException.class)
+    @Test
     public void test_registerMethodConstructor_classAlreadyRegistered() {
       StringConvert test = new StringConvert();
       test.registerMethodConstructor(DistanceNoAnnotations.class, "toString");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/joda-convert.git



More information about the pkg-java-commits mailing list