Skip to content
Merged
Prev Previous commit
Next Next commit
refactor: use static import for assert
  • Loading branch information
zielint0 committed Oct 11, 2018
commit b94dd0ee7e617788a0263b7a5a708d15d076b82f
38 changes: 19 additions & 19 deletions src/test/java/spoon/test/jar/JarTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,7 @@
*/
package spoon.test.jar;

import static org.junit.Assert.assertEquals;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;

import spoon.Launcher;
import spoon.SpoonModelBuilder;
import spoon.compiler.SpoonFile;
Expand All @@ -38,6 +26,18 @@
import spoon.support.compiler.VirtualFile;
import spoon.support.compiler.ZipFolder;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class JarTest {

@Test
Expand All @@ -56,7 +56,7 @@ public void testJarResources() throws Exception {
"</classpath>\n" +
"", readFileString(files.stream().filter(f -> f.getName().equals(".classpath")).findFirst().get(), "ISO-8859-1"));
}

private byte[] readFileBytes(SpoonFile file) {
byte[] buff = new byte[1024];
try (InputStream is = file.getContent(); ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
Expand All @@ -72,6 +72,7 @@ private byte[] readFileBytes(SpoonFile file) {
throw new RuntimeException(e);
}
}

private String readFileString(SpoonFile file, String encoding) {
try {
return new String(readFileBytes(file), encoding);
Expand All @@ -89,7 +90,7 @@ public void testJar() throws Exception {
SpoonModelBuilder compiler = spoon.createCompiler(
factory,
SpoonResourceHelper.resources("./src/test/resources/sourceJar/test.jar"));
Assert.assertTrue(compiler.build());
assertTrue(compiler.build());
assertEquals(1, factory.getModel().getAllTypes().size());
assertEquals("spoon.test.strings.Main", factory.getModel().getAllTypes().iterator().next().getQualifiedName());
}
Expand All @@ -102,9 +103,9 @@ public void testFile() throws Exception {
launcher.getFactory(),
Arrays.asList(
SpoonResourceHelper.createFile(new File("./src/test/resources/spoon/test/api/Foo.java"))));
Assert.assertTrue(compiler.build());
assertTrue(compiler.build());

Assert.assertNotNull(launcher.getFactory().Type().get("Foo"));
assertNotNull(launcher.getFactory().Type().get("Foo"));
}

@Test
Expand All @@ -116,9 +117,8 @@ public void testResource() {
Arrays.asList(
new VirtualFile("class Foo {}" , "Foo.java")
));
Assert.assertTrue(compiler.build());
assertTrue(compiler.build());

Assert.assertNotNull(launcher.getFactory().Type().get("Foo"));
assertNotNull(launcher.getFactory().Type().get("Foo"));
}

}