KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > util > license > DurationLicenseTest


1 package org.sapia.util.license;
2
3 import java.util.Date JavaDoc;
4
5 import junit.framework.TestCase;
6
7 /**
8  * @author Yanick Duchesne
9  *
10  * <dl>
11  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2004 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
12  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
13  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
14  * </dl>
15  */

16 public class DurationLicenseTest extends TestCase{
17   
18   public DurationLicenseTest(String JavaDoc name){
19     super(name);
20   }
21   
22   public void testIsValidDays() throws Exception JavaDoc{
23     DurationLicense license = new DurationLicense(30);
24     super.assertTrue("license should be valid", license.isValid(DurationLicense.computeEndDate(new Date JavaDoc(), 29)));
25     super.assertTrue("license should be valid", !license.isValid(DurationLicense.computeEndDate(new Date JavaDoc(), 30)));
26     super.assertTrue("license should not be valid", !license.isValid(DurationLicense.computeEndDate(new Date JavaDoc(), 31)));
27   }
28   
29   public void testIsValidYear() throws Exception JavaDoc{
30     DurationLicense license = new DurationLicense(365);
31     super.assertTrue("license should be valid", license.isValid(DurationLicense.computeEndDate(new Date JavaDoc(), 364)));
32     super.assertTrue("license should be valid", !license.isValid(DurationLicense.computeEndDate(new Date JavaDoc(), 365)));
33     super.assertTrue("license should not be valid", !license.isValid(DurationLicense.computeEndDate(new Date JavaDoc(), 366)));
34   }
35   
36   public void testIsValidMultiYears() throws Exception JavaDoc{
37     DurationLicense license = new DurationLicense(800);
38     super.assertTrue("license should be valid", license.isValid(DurationLicense.computeEndDate(new Date JavaDoc(), 799)));
39     super.assertTrue("license should be valid", !license.isValid(DurationLicense.computeEndDate(new Date JavaDoc(), 800)));
40     super.assertTrue("license should not be valid", !license.isValid(DurationLicense.computeEndDate(new Date JavaDoc(), 801)));
41   }
42
43 }
44
Popular Tags