blob: d8c22161522fe27c57556164516fc51f74cde107 (
plain)
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
|
/*******************************************************************************
* Copyright (c) Copyright (c) Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc R. Hoffmann - initial API and implementation
*
*******************************************************************************/
package org.jacoco.report;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
/**
* Unit tests for {@link FileMultiReportOutput}.
*/
public class FileMultiReportOutputTest {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void testCreateFileWithDirectories() throws IOException {
final IMultiReportOutput output = new FileMultiReportOutput(
folder.getRoot());
final OutputStream stream = output.createFile("a/b/c/test");
stream.write(1);
stream.write(2);
stream.write(3);
stream.close();
output.close();
final InputStream actual = new FileInputStream(new File(
folder.getRoot(), "a/b/c/test"));
assertEquals(1, actual.read());
assertEquals(2, actual.read());
assertEquals(3, actual.read());
assertEquals(-1, actual.read());
}
@Test(expected = IOException.class)
public void testCreateFileNegative() throws IOException {
folder.newFile("a");
final IMultiReportOutput output = new FileMultiReportOutput(
folder.getRoot());
output.createFile("a/b/c/test");
}
}
|