Author: phuong_vu
Date: 2010-11-17 02:23:30 -0500 (Wed, 17 Nov 2010)
New Revision: 5128
Modified:
exo/portal/branches/3.1.x/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java
Log:
EXOGTN-167 Fix TestTemplateRendering
Modified:
exo/portal/branches/3.1.x/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java
===================================================================
---
exo/portal/branches/3.1.x/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java 2010-11-17
06:50:14 UTC (rev 5127)
+++
exo/portal/branches/3.1.x/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java 2010-11-17
07:23:30 UTC (rev 5128)
@@ -24,6 +24,8 @@
import java.awt.*;
import java.io.*;
+import java.text.DateFormat;
+import java.util.Date;
import java.util.EmptyStackException;
import java.util.HashMap;
import java.util.Locale;
@@ -36,6 +38,19 @@
public class TestTemplateRendering extends AbstractGateInTest
{
+ private DateFormat dateFormatFR;
+ private DateFormat dateFormatEN;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ // TODO Auto-generated method stub
+ super.setUp();
+
+ dateFormatFR = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.FRANCE);
+ dateFormatEN = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH);
+ }
+
public void testOutputStreamWriter() throws Exception
{
GroovyTemplate template = new
GroovyTemplate("a<%='b'%>c<%out.print('d');%>e");
@@ -48,28 +63,31 @@
public void testDate1() throws Exception
{
+ Date dateToTest = new Date(0);
GroovyTemplate template = new GroovyTemplate("<% print(new Date(0));
%>");
- assertEquals("1 janv. 1970", template.render(Locale.FRENCH));
- assertEquals("Jan 1, 1970", template.render(Locale.ENGLISH));
- assertEquals("Thu Jan 01 07:00:00 ICT 1970", template.render());
+ assertEquals(dateFormatFR.format(dateToTest), template.render(Locale.FRENCH));
+ assertEquals(dateFormatEN.format(dateToTest), template.render(Locale.ENGLISH));
+ assertEquals(dateToTest.toString(), template.render());
}
public void testDate2() throws Exception
{
+ Date dateToTest = new Date(0);
GroovyTemplate template = new GroovyTemplate("<% def date = new Date(0)
%>$date");
System.out.println("template.getGroovy() = " + template.getGroovy());
- assertEquals("1 janv. 1970", template.render(Locale.FRENCH));
- assertEquals("Jan 1, 1970", template.render(Locale.ENGLISH));
- assertEquals("Thu Jan 01 07:00:00 ICT 1970", template.render());
+ assertEquals(dateFormatFR.format(dateToTest), template.render(Locale.FRENCH));
+ assertEquals(dateFormatEN.format(dateToTest), template.render(Locale.ENGLISH));
+ assertEquals(dateToTest.toString(), template.render());
}
public void testDate3() throws Exception
{
+ Date dateToTest = new Date(0);
GroovyTemplate template = new GroovyTemplate("<%= new Date(0)
%>");
System.out.println("template.getGroovy() = " + template.getGroovy());
- assertEquals("1 janv. 1970", template.render(Locale.FRENCH));
- assertEquals("Jan 1, 1970", template.render(Locale.ENGLISH));
- assertEquals("Thu Jan 01 07:00:00 ICT 1970", template.render());
+ assertEquals(dateFormatFR.format(dateToTest), template.render(Locale.FRENCH));
+ assertEquals(dateFormatEN.format(dateToTest), template.render(Locale.ENGLISH));
+ assertEquals(dateToTest.toString(), template.render());
}
public void testFoo() throws Exception
Show replies by date