StarteamChangeLogConsumerTest does not work if locale is not en or fr
---------------------------------------------------------------------

         Key: SCM-124
         URL: http://jira.codehaus.org/browse/SCM-124
     Project: Maven SCM
        Type: Bug

  Components: maven-scm-provider-starteam  
 Environment: Maven 2.0.1, JDK 1.4.2_09, Win XP Pro, Swedish locale
    Reporter: Dennis Lundberg


The testcase StarteamChangeLogConsumerTest makes assumptions about the user's 
locale that are not always true.
Lines 45-52 uses the default locale and if a suitable changelog for that locale 
is not found, it defaults to using the English changelog file. This works well 
for English and French which have changelog files. But it does not work for 
other locales that use a different dateformat than English, i.e most of Europe.

The problem is that the class StarteamChangeLogConsumer has a private instance 
variable of SimpleDateFormat called localFormat. This variable can not be set 
from outside the class. On line 390 localFormat is used to parse dates. This 
will fail if the user has a different locale than the one being used in the 
logfile being parsed. I imagine that it is common (at least not uncommon) to 
have different locales on the server and the client.

So the locale used in the StarteamChangeLogConsumer needs to be set to the 
locale used by the *server* and not the *client*. A simple getter/setter would 
do the trick. The locale would need to be configurable in some way so that the 
user can set the locale that is used by his/her server.

The reason I stumbled upon this was when I tried to do "mvn test" for 
maven-scm. It produced this stacktrace:

...

[INFO] 
----------------------------------------------------------------------------
[INFO] Building Maven SCM Starteam Provider
[INFO]    task-segment: [test]
[INFO] 
----------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
Compiling 25 source files to 
G:\svn\maven-scm\maven-scm-providers\maven-scm-provider-starteam\target\classes
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
Compiling 22 source files to 
G:\svn\maven-scm\maven-scm-providers\maven-scm-provider-starteam\target\test-classes
[INFO] [surefire:test]
[INFO] Setting reports dir: 
G:\svn\maven-scm\maven-scm-providers\maven-scm-provider-starteam\target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
[WARNING] Your scm URL use a deprecated format. The new format is 
:[username[:[EMAIL PROTECTED]:port:/projectName/[viewName/][folderHiearchy/]
[WARNING] Your scm URL use a deprecated format. The new format is 
:[username[:[EMAIL PROTECTED]:port:/projectName/[viewName/][folderHiearchy/]
[WARNING] Your scm URL use a deprecated format. The new format is 
:[username[:[EMAIL PROTECTED]:port:/projectName/[viewName/][folderHiearchy/]
[surefire] Running 
org.apache.maven.scm.provider.starteam.command.add.StarteamAddCommandTest
[surefire] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0,02 sec
Added: ./maven.xml
Added: ./target/checkout/maven.xml
Added: ./target/checkout/project.properties
Added: ./target/checkout/project.xml
Added: ./target/checkout/bootstrap/maven.xml
Added: ./target/checkout/bootstrap/project.properties
Added: ./target/checkout/bootstrap/project.xml
[surefire] Running 
org.apache.maven.scm.provider.starteam.command.add.StarteamAddConsumerTest
[surefire] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0,03 sec
[WARNING] Your scm URL use a deprecated format. The new format is 
:[username[:[EMAIL PROTECTED]:port:/projectName/[viewName/][folderHiearchy/]
[WARNING] Your scm URL use a deprecated format. The new format is 
:[username[:[EMAIL PROTECTED]:port:/projectName/[viewName/][folderHiearchy/]
[surefire] Running 
org.apache.maven.scm.provider.starteam.command.changelog.StarteamChangeLogCommandTest
[surefire] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0,02 sec
[ERROR] ParseException Caught
java.text.ParseException: Unparseable date: "4/21/04 1:05:00 PM PDT"
        at java.text.DateFormat.parse(DateFormat.java:335)
        at 
org.apache.maven.scm.provider.starteam.command.changelog.StarteamChangeLogConsumer.parseDate(StarteamChangeLogConsumer.java:390)
        at 
org.apache.maven.scm.provider.starteam.command.changelog.StarteamChangeLogConsumer.processGetAuthor(StarteamChangeLogConsumer.java:281
        at 
org.apache.maven.scm.provider.starteam.command.changelog.StarteamChangeLogConsumer.consumeLine(StarteamChangeLogConsumer.java:174)
        at 
org.apache.maven.scm.provider.starteam.command.changelog.StarteamChangeLogConsumerTest.testParse(StarteamChangeLogConsumerTest.java:68
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at 
org.codehaus.surefire.battery.JUnitBattery.executeJUnit(JUnitBattery.java:246)
        at 
org.codehaus.surefire.battery.JUnitBattery.execute(JUnitBattery.java:220)
        at org.codehaus.surefire.Surefire.executeBattery(Surefire.java:204)
        at org.codehaus.surefire.Surefire.run(Surefire.java:153)
        at org.codehaus.surefire.Surefire.run(Surefire.java:77)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.codehaus.surefire.SurefireBooter.run(SurefireBooter.java:104)
        at org.apache.maven.test.SurefirePlugin.execute(SurefirePlugin.java:303)
        at 
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:432)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:530)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:472)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:451)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:303)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:270)
        at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[surefire] Running 
org.apache.maven.scm.provider.starteam.command.changelog.StarteamChangeLogConsumerTest
[surefire] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0,03 sec 
<<<<<<<< FAILURE !!

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to