EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[all classes][org.springframework.batch.test]

COVERAGE SUMMARY FOR SOURCE FILE [AssertFile.java]

nameclass, %method, %block, %line, %
AssertFile.java100% (1/1)80%  (4/5)93%  (105/113)94%  (23.5/25)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AssertFile100% (1/1)80%  (4/5)93%  (105/113)94%  (23.5/25)
AssertFile (): void 0%   (0/1)0%   (0/3)0%   (0/1)
assertLineCount (int, File): void 100% (1/1)81%  (22/27)94%  (7.5/8)
assertFileEquals (File, File): void 100% (1/1)100% (72/72)100% (12/12)
assertFileEquals (Resource, Resource): void 100% (1/1)100% (6/6)100% (2/2)
assertLineCount (int, Resource): void 100% (1/1)100% (5/5)100% (2/2)

1/*
2 * Copyright 2006-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17package org.springframework.batch.test;
18 
19import java.io.BufferedReader;
20import java.io.File;
21import java.io.FileReader;
22 
23import junit.framework.Assert;
24 
25import org.springframework.core.io.Resource;
26 
27/**
28 * This class can be used to assert that two files are the same.
29 * 
30 * @author Dan Garrette
31 * @since 2.0
32 */
33public abstract class AssertFile {
34 
35        public static void assertFileEquals(File expected, File actual) throws Exception {
36                BufferedReader expectedReader = new BufferedReader(new FileReader(expected));
37                BufferedReader actualReader = new BufferedReader(new FileReader(actual));
38                try {
39                        int lineNum = 1;
40                        for (String expectedLine = null; (expectedLine = expectedReader.readLine()) != null; lineNum++) {
41                                String actualLine = actualReader.readLine();
42                                Assert.assertEquals("Line number " + lineNum + " does not match.", expectedLine, actualLine);
43                        }
44 
45                        String actualLine = actualReader.readLine();
46                        Assert.assertEquals("More lines than expected.  There should not be a line number " + lineNum + ".", null,
47                                        actualLine);
48                }
49                finally {
50                        expectedReader.close();
51                        actualReader.close();
52                }
53        }
54 
55        public static void assertFileEquals(Resource expected, Resource actual) throws Exception {
56                AssertFile.assertFileEquals(expected.getFile(), actual.getFile());
57        }
58 
59        public static void assertLineCount(int expectedLineCount, File file) throws Exception {
60                BufferedReader expectedReader = new BufferedReader(new FileReader(file));
61                try {
62                        int lineCount = 0;
63                        while (expectedReader.readLine() != null) {
64                                lineCount++;
65                        }
66                        Assert.assertEquals(expectedLineCount, lineCount);
67                }
68                finally {
69                        expectedReader.close();
70                }
71        }
72 
73        public static void assertLineCount(int expectedLineCount, Resource resource) throws Exception {
74                AssertFile.assertLineCount(expectedLineCount, resource.getFile());
75        }
76}

[all classes][org.springframework.batch.test]
EMMA 2.0.5312 (C) Vladimir Roubtsov