Package org.cedj.geekseek.domain.conference.test.unit

Source Code of org.cedj.geekseek.domain.conference.test.unit.DurationValidationTestCase

package org.cedj.geekseek.domain.conference.test.unit;

import java.util.Date;

import org.cedj.geekseek.domain.conference.model.Duration;
import org.junit.Assert;
import org.junit.Test;

public class DurationValidationTestCase {

    @Test(expected = IllegalArgumentException.class)
    public void shouldNotAllowNullConstructorStart() throws Exception {
        new Duration(null, new Date());
    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldNotAllowNullConstructorEnd() throws Exception {
        new Duration(new Date(), null);
    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldNotAllowNullConstructorEndBeforeStart() throws Exception {
        new Duration(new Date(), new Date(System.currentTimeMillis()-4000));
    }

    @Test
    public void shouldNotLeakOnConststructStart() throws Exception {
        Date start = new Date();
        Duration dur = new Duration(start, new Date());
        start.setTime(100);

        Assert.assertNotEquals(start, dur.getStart());
    }

    @Test
    public void shouldNotLeakOnConststructEnd() throws Exception {
        Date end = new Date();
        Duration dur = new Duration(new Date(), end);
        end.setTime(100);

        Assert.assertNotEquals(end, dur.getEnd());
    }

    @Test
    public void shouldNotLeakOnGetStart() throws Exception {
        Duration dur = new Duration(new Date(), new Date());
        Date start = dur.getStart();
        start.setTime(100);

        Assert.assertNotEquals(start, dur.getStart());
    }

    @Test
    public void shouldNotLeakOnGetEnd() throws Exception {
        Duration dur = new Duration(new Date(), new Date());
        Date end = dur.getEnd();
        end.setTime(100);

        Assert.assertNotEquals(end, dur.getEnd());
    }
}
TOP

Related Classes of org.cedj.geekseek.domain.conference.test.unit.DurationValidationTestCase

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.