forked from IHoffman5214/Calendar-Event-File-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitTests.java
More file actions
executable file
·74 lines (67 loc) · 2.2 KB
/
UnitTests.java
File metadata and controls
executable file
·74 lines (67 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import java.io.*;
/*
all unit testing is done here
*/
public class UnitTests
{
@Test
/*
Ensures that what is imported into a calendar object is exactly the same
as what is exported
*/
public void evaluateImportExport()
{
System.out.println("\n\n");
System.out.println("--------------------------------------------");
MD5Checksum myCheckSum = new MD5Checksum();
String sampleInput = "testInput.ics";
String sampleOutput = sampleInput;
String sum1, sum2;
sum1 = sum2 = "";
//retrieves an MD5 hash of sample input
try
{
System.out.println("Using MD5 to hash " + sampleInput);
sum1 = myCheckSum.getMD5Checksum(sampleInput);
System.out.println("MD5 is " + sum1);
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
//import input into calendar object
Calendar calendar = new Calendar(sampleInput);
System.out.println("Imported .ics file into new Calendar object");
//export from calendar object
calendar.exportIcs();
System.out.println("Exporting .ics file");
//hash the output
try
{
System.out.println("Using MD5 to hash " + sampleOutput);
sum2 = myCheckSum.getMD5Checksum(sampleOutput);
System.out.println("MD5 is " + sum2);
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
//compare the old hash and the new hash
//if they are different, then import did not export perfectly
System.out.println("Comparing " + sum1 + " and " + sum2 + "...");
if(sum1.equals(sum2))
{
System.out.println("The import and export file are the same\nTestPassed");
}
else
{
System.out.println("The import and export file are not the same\nTestFailed");
}
//use junit to compare
assertEquals(sum1, sum2);
System.out.println("--------------------------------------------");
System.out.println("\n\n");
}
}