SimpleResource.java

1
package fr.sii.ogham.core.resource;
2
3
import java.io.ByteArrayInputStream;
4
import java.io.IOException;
5
import java.io.InputStream;
6
import java.util.Arrays;
7
8
import fr.sii.ogham.core.util.IOUtils;
9
10
/**
11
 * Basic implementation of a resource that simply stores a reference to the
12
 * provided bytes.
13
 * 
14
 * @author Aurélien Baudet
15
 *
16
 */
17
public class SimpleResource implements Resource {
18
19
	private byte[] bytes;
20
21
	public SimpleResource(InputStream stream) throws IOException {
22
		super();
23
		this.bytes = IOUtils.toByteArray(stream);
24
	}
25
26
	/**
27
	 * Initialize the resource with the provided bytes. The bytes are copied
28
	 * into a new array to prevent security leaks.
29
	 * 
30
	 * @param bytes
31
	 *            the bytes of the resource
32
	 */
33
	public SimpleResource(byte[] bytes) {
34
		super();
35
		this.bytes = Arrays.copyOf(bytes, bytes.length);
36
	}
37
38
	@Override
39
	public InputStream getInputStream() {
40 2 1. getInputStream : replaced return value with null for fr/sii/ogham/core/resource/SimpleResource::getInputStream → NO_COVERAGE
2. getInputStream : replaced return value with null for fr/sii/ogham/core/resource/SimpleResource::getInputStream → KILLED
		return new ByteArrayInputStream(bytes);
41
	}
42
43
}

Mutations

40

1.1
Location : getInputStream
Killed by : none
replaced return value with null for fr/sii/ogham/core/resource/SimpleResource::getInputStream → NO_COVERAGE

2.2
Location : getInputStream
Killed by : oghamall.it.email.FluentEmailTest.bodyTemplateString(oghamall.it.email.FluentEmailTest)
replaced return value with null for fr/sii/ogham/core/resource/SimpleResource::getInputStream → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM