Skip to content

Commit

Permalink
test: migrate PositionTest to JUnit 5 (#4503)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWitt authored Jan 16, 2022
1 parent f0add99 commit bf60467
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/test/java/spoon/test/position/PositionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
*/
package spoon.test.position;


import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;

import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import org.apache.commons.io.FileUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import spoon.Launcher;
import spoon.reflect.CtModel;
import spoon.reflect.code.CtAssignment;
Expand Down Expand Up @@ -72,6 +77,7 @@
import spoon.test.comment.testclasses.BlockComment;
import spoon.test.comment.testclasses.Comment1;
import spoon.test.position.testclasses.AnnonymousClassNewIface;
import spoon.test.position.testclasses.AnnotationWithAngleBracket;
import spoon.test.position.testclasses.ArrayArgParameter;
import spoon.test.position.testclasses.CatchPosition;
import spoon.test.position.testclasses.CompilationUnitComments;
Expand All @@ -91,25 +97,24 @@
import spoon.test.position.testclasses.FooLambda;
import spoon.test.position.testclasses.FooMethod;
import spoon.test.position.testclasses.FooStatement;
import spoon.test.position.testclasses.AnnotationWithAngleBracket;
import spoon.test.position.testclasses.FooSwitch;
import spoon.test.position.testclasses.Kokos;
import spoon.test.position.testclasses.MoreLambda;
import spoon.test.position.testclasses.NoMethodModifiers;
import spoon.test.position.testclasses.PositionParameterTypeWithReference;
import spoon.test.position.testclasses.PositionTry;
import spoon.test.position.testclasses.SomeEnum;
import spoon.test.position.testclasses.TypeParameter;
import spoon.test.position.testclasses.MoreLambda;
import spoon.test.query_function.testclasses.VariableReferencesModelTest;
import spoon.testing.utils.ModelUtils;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static spoon.testing.utils.ModelUtils.build;
import static spoon.testing.utils.ModelUtils.buildClass;

Expand Down Expand Up @@ -427,7 +432,8 @@ public void testPositionGeneric() throws Exception {
assertEquals("protected static", contentAtPosition(classContent, position3.getModifierSourceStart(), position3.getModifierSourceEnd()));
}

@Test(timeout=10000)
@Test
@Timeout(unit = TimeUnit.MILLISECONDS, value = 10000L)
public void testPositionTerminates() {
assertDoesNotThrow(() -> {
final Factory build = build(AnnotationWithAngleBracket.class);
Expand Down Expand Up @@ -1420,8 +1426,7 @@ public void testLinePositionOkWithOneLineClassCode() {
.filter(elt -> elt.getPosition().isValidPosition())
.collect(Collectors.toList());

assertTrue("Some Spoon elements have an invalid line position",
listOfBadPositionElements.stream().allMatch(elt -> elt.getPosition().getLine() == 1));
assertTrue(listOfBadPositionElements.stream().allMatch(elt -> elt.getPosition().getLine() == 1), "Some Spoon elements have an invalid line position");
}

@Test
Expand Down

0 comments on commit bf60467

Please sign in to comment.