|
22 | 22 | import java.io.FileInputStream;
|
23 | 23 | import java.io.FileNotFoundException;
|
24 | 24 | import java.io.IOException;
|
| 25 | +import java.io.InputStream; |
25 | 26 | import java.net.URI;
|
26 | 27 | import java.net.URISyntaxException;
|
27 | 28 | import java.nio.file.Path;
|
|
35 | 36 | import org.eclipse.esmf.metamodel.HasDescription;
|
36 | 37 | import org.eclipse.esmf.samm.KnownVersion;
|
37 | 38 |
|
38 |
| -import org.apache.commons.io.IOUtils; |
39 | 39 | import org.assertj.core.api.Assertions;
|
40 | 40 | import org.junit.jupiter.api.Test;
|
41 | 41 |
|
@@ -204,14 +204,13 @@ void testSerializeNamespacePackage() throws IOException {
|
204 | 204 | @Test
|
205 | 205 | void testNamespacePackageAsResolutionStrategy() throws IOException {
|
206 | 206 | final File archivePath = getPackage( "namespaces.zip" ).toFile();
|
207 |
| - final FileInputStream input = new FileInputStream( archivePath ); |
208 |
| - final byte[] content = IOUtils.toByteArray( input ); |
209 |
| - final NamespacePackage namespacePackage = new NamespacePackage( content, archivePath.toURI() ); |
210 |
| - |
211 |
| - // By using the NamespacePackage as an AspectModelLoader constructor argument, it is used as a ResolutionStrategy |
212 |
| - final AspectModelLoader aspectModelLoader = new AspectModelLoader( namespacePackage ); |
213 |
| - final AspectModel aspectModel = aspectModelLoader.load( |
214 |
| - AspectModelUrn.fromUrn( "urn:samm:org.eclipse.esmf.examples:1.0.0#Movement" ) ); |
215 |
| - assertThat( aspectModel ).hasSingleAspectThat().hasName( "Movement" ); |
| 207 | + try ( final InputStream input = new FileInputStream( archivePath ) ) { |
| 208 | + final NamespacePackage namespacePackage = new NamespacePackage( input, archivePath.toURI() ); |
| 209 | + // By using the NamespacePackage as an AspectModelLoader constructor argument, it is used as a ResolutionStrategy |
| 210 | + final AspectModelLoader aspectModelLoader = new AspectModelLoader( namespacePackage ); |
| 211 | + final AspectModel aspectModel = aspectModelLoader.load( |
| 212 | + AspectModelUrn.fromUrn( "urn:samm:org.eclipse.esmf.examples:1.0.0#Movement" ) ); |
| 213 | + assertThat( aspectModel ).hasSingleAspectThat().hasName( "Movement" ); |
| 214 | + } |
216 | 215 | }
|
217 | 216 | }
|
0 commit comments