FileDocCategorySizeDatePackage
TStampTest.javaAPI DocApache Ant 1.703530Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs

TStampTest

public class TStampTest extends TestCase

Fields Summary
protected Tstamp
tstamp
protected org.apache.tools.ant.Project
project
protected org.apache.tools.ant.Location
location
Constructors Summary
public TStampTest(String s)

        super(s);
    
Methods Summary
protected voidsetUp()

        location = new Location("test.xml");
        project = new Project();
        tstamp = new Tstamp();
        tstamp.setLocation(location);
        tstamp.setProject(project);
    
public voidtestFormatPrefix()

	Tstamp.CustomFormat format = tstamp.createFormat();
        format.setProperty("format");
        format.setPattern("HH:mm:ss z");
        format.setTimezone("GMT");

        tstamp.setPrefix("prefix");
        tstamp.execute();
        String prop= project.getProperty("prefix.format");
        assertNotNull(prop);
    
public voidtestPrefix()
verifies that custom props have priority over the originals

throws
Exception

        tstamp.setPrefix("prefix");
        tstamp.execute();
        String prop= project.getProperty("prefix.DSTAMP");
        assertNotNull(prop);
    
public voidtestTimeZone()

        Tstamp.CustomFormat format = tstamp.createFormat();
        format.setProperty("today");
        format.setPattern("HH:mm:ss z");
        format.setTimezone("GMT");
        Date date = Calendar.getInstance().getTime();
        format.execute(project, date, location);
        String today = project.getProperty("today");

        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z");
        sdf.setTimeZone( TimeZone.getTimeZone("GMT") );
        String expected = sdf.format(date);

        assertEquals(expected, today);
    
public voidtestWriteOrder()
verifies that custom props have priority over the originals

throws
Exception

        Tstamp.CustomFormat format = tstamp.createFormat();
        format.setProperty("TODAY");
        format.setPattern("HH:mm:ss z");
        format.setTimezone("GMT");
        Date date = Calendar.getInstance().getTime();
        format.execute(project, date, location);
        String today = project.getProperty("TODAY");

        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z");
        sdf.setTimeZone( TimeZone.getTimeZone("GMT") );
        String expected = sdf.format(date);

        assertEquals(expected, today);