source: trunk/quest-core-assertions/src/main/java/de/ugoe/cs/quest/assertions/FileEqualsReplay.java @ 560

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