1 | package de.ugoe.cs.eventbench.assertions;
|
---|
2 |
|
---|
3 | import java.security.InvalidParameterException;
|
---|
4 |
|
---|
5 | import de.ugoe.cs.eventbench.data.IReplayable;
|
---|
6 | import de.ugoe.cs.util.StringTools;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * <p>
|
---|
10 | * This class defines the replay for file equals assertions.
|
---|
11 | * </p>
|
---|
12 | *
|
---|
13 | * @author Jeffrey Hall, Steffen Herbold
|
---|
14 | * @version 2.0
|
---|
15 | */
|
---|
16 | public class FileEqualsReplay implements IReplayable {
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * <p>
|
---|
20 | * The file that should be equal to expectedFile.
|
---|
21 | * </p>
|
---|
22 | */
|
---|
23 | protected final String actualFile;
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * <p>
|
---|
27 | * The file that is used as the reference.
|
---|
28 | * </p>
|
---|
29 | */
|
---|
30 | protected final String expectedFile;
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * <p>
|
---|
34 | * Id for object serialization.
|
---|
35 | * </p>
|
---|
36 | */
|
---|
37 | private static final long serialVersionUID = 1L;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * <p>
|
---|
41 | * Constructor. Creates a new FileEqualsReplay.
|
---|
42 | * </p>
|
---|
43 | *
|
---|
44 | * @param expectedFile
|
---|
45 | * name and path of the expected file
|
---|
46 | * @param actualFile
|
---|
47 | * name and path of the actual file
|
---|
48 | * @throws InvalidParameterException
|
---|
49 | * thrown if expectedFile or actualFile are null
|
---|
50 | */
|
---|
51 | public FileEqualsReplay(String expectedFile, String actualFile) {
|
---|
52 | if (expectedFile == null) {
|
---|
53 | throw new InvalidParameterException(
|
---|
54 | "expected file must not be null");
|
---|
55 | }
|
---|
56 | if (actualFile == null) {
|
---|
57 | throw new InvalidParameterException("actual file must not be null");
|
---|
58 | }
|
---|
59 | this.expectedFile = expectedFile;
|
---|
60 | this.actualFile = actualFile;
|
---|
61 | }
|
---|
62 |
|
---|
63 | /*
|
---|
64 | * (non-Javadoc)
|
---|
65 | *
|
---|
66 | * @see de.ugoe.cs.eventbench.data.IReplayable#getReplay()
|
---|
67 | */
|
---|
68 | public String getReplay() {
|
---|
69 |
|
---|
70 | String actualFileTmp = StringTools.xmlEntityReplacement(actualFile);
|
---|
71 | String expectedFileTmp = StringTools.xmlEntityReplacement(expectedFile);
|
---|
72 |
|
---|
73 | StringBuilder currentMsgStr = new StringBuilder(800);
|
---|
74 | currentMsgStr.append(" <fileEquals ");
|
---|
75 | currentMsgStr.append("actualFile=\"" + actualFileTmp + "\" ");
|
---|
76 | currentMsgStr.append("expectedFile=\"" + expectedFileTmp + "\"/>");
|
---|
77 | currentMsgStr.append(StringTools.ENDLINE);
|
---|
78 | return currentMsgStr.toString();
|
---|
79 | }
|
---|
80 |
|
---|
81 | /*
|
---|
82 | * (non-Javadoc)
|
---|
83 | *
|
---|
84 | * @see de.ugoe.cs.eventbench.data.IReplayable#getTarget()
|
---|
85 | */
|
---|
86 | @Override
|
---|
87 | public String getTarget() {
|
---|
88 | return "targetNotUsed";
|
---|
89 | }
|
---|
90 |
|
---|
91 | }
|
---|