[ 
https://issues.apache.org/activemq/browse/CAMEL-2631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59114#action_59114
 ] 

Claus Ibsen commented on CAMEL-2631:
------------------------------------

Ashwin

Much better. Only one left.

{code}
 try {
+            long milliseconds = TimePatternConverter.toMilliSeconds(source);
+        } catch (IllegalArgumentException e) {
+            LOG.debug("Following exception thrown: " + e.getMessage());
+            assertIsInstanceOf(IllegalArgumentException.class, e);
+        }
{code}

Here you need to add a fail check if the exception was NOT thrown
{code}
 try {
+            long milliseconds = TimePatternConverter.toMilliSeconds(source);
              fail("Should throw exception");
+        } catch (IllegalArgumentException e) {
+            LOG.debug("Following exception thrown: " + e.getMessage());
+            assertIsInstanceOf(IllegalArgumentException.class, e);
+        }

And you catch an IllegalArgumentException which you then assert is the same 
instance :) You would often just have used
{code}
catch(Exception e)
         assertIsInstanceOf(IllegalArgumentException.class, e);
    assertEquals"The bla bla should have", e.getMessage());
{code}
And also check the error message is correct


And we should documented in the source code of the converter that it will 
*also* be used for regular numbers. i.e. its a String -> long converter which 
does that for all Strings.
The only problem which could occur is that *none* pattern matched, then you 
would return 0. I think we should add a fallback to let it use the following 
code
{code}
   // no pattern matched so fallback and let Long convert it
            return Long.valueOf(value);
{code}

> Add time millis converter which can convert from String to long
> ---------------------------------------------------------------
>
>                 Key: CAMEL-2631
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2631
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>            Reporter: Claus Ibsen
>            Assignee: Ashwin Karpe
>            Priority: Minor
>         Attachments: time-pattern-converter-patch.diff
>
>
> Its currently a bit annoying to set a delay by millis and if you need, like 1 
> hour 30 min period. What is this in millis?
> We should add a TypeConverter for that which has a String notation such as:
> {code}
> 1h30m
> 3h45m25s
> 10m
> 15m20s
> 30s
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to