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

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:mime-type set to text/plain
File size: 3.1 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.assertions;
16
17import de.ugoe.cs.autoquest.IReplayDecorator;
18import de.ugoe.cs.autoquest.eventcore.IReplayable;
19import de.ugoe.cs.util.StringTools;
20
21/**
22 * <p>
23 * This class defines the replay for file equals assertions.
24 * </p>
25 *
26 * @author Jeffrey Hall, Steffen Herbold
27 * @version 2.0
28 */
29public class FileEqualsReplay implements IReplayable {
30
31    /**
32     * <p>
33     * The file that should be equal to expectedFile.
34     * </p>
35     */
36    protected final String actualFile;
37
38    /**
39     * <p>
40     * The file that is used as the reference.
41     * </p>
42     */
43    protected final String expectedFile;
44
45    /**
46     * <p>
47     * Id for object serialization.
48     * </p>
49     */
50    private static final long serialVersionUID = 1L;
51
52    /**
53     * <p>
54     * Constructor. Creates a new FileEqualsReplay.
55     * </p>
56     *
57     * @param expectedFile
58     *            name and path of the expected file
59     * @param actualFile
60     *            name and path of the actual file
61     * @throws IllegalArgumentException
62     *             thrown if expectedFile or actualFile are null
63     */
64    public FileEqualsReplay(String expectedFile, String actualFile) {
65        if (expectedFile == null) {
66            throw new IllegalArgumentException("expected file must not be null");
67        }
68        if (actualFile == null) {
69            throw new IllegalArgumentException("actual file must not be null");
70        }
71        this.expectedFile = expectedFile;
72        this.actualFile = actualFile;
73    }
74
75    /*
76     * (non-Javadoc)
77     *
78     * @see de.ugoe.cs.autoquest.eventcore.IReplayable#getReplay()
79     */
80    public String getReplay() {
81
82        String actualFileTmp = StringTools.xmlEntityReplacement(actualFile);
83        String expectedFileTmp = StringTools.xmlEntityReplacement(expectedFile);
84
85        StringBuilder currentMsgStr = new StringBuilder(800);
86        currentMsgStr.append("  <fileEquals ");
87        currentMsgStr.append("actualFile=\"" + actualFileTmp + "\" ");
88        currentMsgStr.append("expectedFile=\"" + expectedFileTmp + "\"/>");
89        currentMsgStr.append(StringTools.ENDLINE);
90        return currentMsgStr.toString();
91    }
92
93    /*
94     * (non-Javadoc)
95     *
96     * @see de.ugoe.cs.autoquest.eventcore.IReplayable#getDecorator()
97     */
98    @Override
99    public IReplayDecorator getDecorator() {
100        return null;
101    }
102
103}
Note: See TracBrowser for help on using the repository browser.