[
https://issues.apache.org/jira/browse/DIRAPI-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16831497#comment-16831497
]
Emmanuel Lecharny edited comment on DIRAPI-333 at 5/2/19 1:38 PM:
------------------------------------------------------------------
Started to work around the migration. It's not trivial. Here are some of the
changes we must apply:
* Parent {{pom.xml}}
** Replace the {{junit}} dependency by three dependencies ({{hamcrest 2.1}},
{{junit-jupiter-engine 5.4.2}} and {{junit-platform-runner 1.4.2}})
** Add a property in the surefire plugin configuration in order to run tests
concurrently ({{junit.jupiter.execution.parallel.enabled=true}})
* Each project with tests {{pom.xml}}
** Add the {{hamcrest}}, {{junit-jupiter-engine}} and
{{junit-platform-runner}} dependencies and remove the {{junit}} one
* Tests
** Replace {{import org.junit.Test;}} with {{org.junit.jupiter.api.Test}}
** Replace {{@Before}} by {{@BeforeEach}}, replace {{import org.junit.Before}}
with {{import org.junit.jupiter.api.beforeEach;}}
** Replace {{@After}} by {{@AfterEach}}, replace {{import org.junit.After}}
with {{import org.junit.jupiter.api.AfterEach;}}
** Replace {{import static org.junit.Assert.assertThat;}} with {{import static
org.hamcrest.MatcherAssert.assertThat;}}
** Replace {{import static org.junit.Assert.*}} by {{import static
org.junit.jupiter.api.Assertions.*}}
* Concurrent tests
** Remove {{import com.mycila.junit.concurrent.Concurrency;}} and {{import
com.mycila.junit.concurrent.ConcurrentJunitRunner;}}
** Remove the {{junit-addons}} dependency
** Remove {{import org.junit.runner.RunWith;}}
** Replace {{@RunWith(ConcurrentJunitRunner.class)\n@Concurrency()}} by
{{@Execution(ExecutionMode.CONCURRENT)}}
* Tests with {{Rule}} (mainly use to create temporary files/directories)
** Remove the {{@Rule}}, replace it by a {{init}} function with the
{{@BeforeEach}} tag, and implement the logic. For instance, for a temporary
folder creation :
{code:java}
private Path tmpFolder;
@BeforeEach
public void init() throws IOException
{
tmpFolder = Files.createTempDirectory(
FileUtilsTest.class.getSimpleName() );
tmpFolder.toFile().deleteOnExit();
}
@Test
public void
testOpenOutputStreamAppendToNonExistingFileInNonExistingFolder() throws
Exception
{
File nonExistingFile = new File( tmpFolder.toFile(),
"testOpenOutputStreamAppendToNonExistingFileInNonExistingFolder/testOpenOutputStreamAppendToNonExistingFileInNonExistingFolder"
);
...
{code}
* Tests with expected exception: they must be replaced by a {{assertThrows}}
check:
{code:java}
@Test(expected = LdapLdifException.class)
public void testLdifEntryChangeTypeModifyNotSameAttr() throws Exception
{
String ldif =
"changetype: modify\n" +
"add: cn\n" +
"sn: v1\n" +
"sn: v2\n" +
"-";
new LdifEntry( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldif
);
}
{code}
becomes :
{code:java}
@Test
public void testLdifEntryChangeTypeModifyNotSameAttr() throws Exception
{
String ldif =
"changetype: modify\n" +
"add: cn\n" +
"sn: v1\n" +
"sn: v2\n" +
"-";
assertThrows( LdapLdifException.class, () ->
{
new LdifEntry( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org",
ldif );
} );
}
{code}
For most of the tests, this is trivial, but considering the vast number of
tests, it will take a while.
was (Author: elecharny):
Started to work around the migration. It's not trivial. Here are some of the
changes we must apply:
* Parent {{pom.xml}}
** Replace the {{junit}} dependency by three dependencies ({{hamcrest 2.1}},
{{junit-jupiter-engine 5.4.2}} and {{junit-platform-runner 1.4.2}})
** Add a property in the surefire plugin configuration in order to run tests
concurrently ({{junit.jupiter.execution.parallel.enabled=true}})
* Each project with tests {{pom.xml}}
** Add the {{hamcrest}}, {{junit-jupiter-engine}} and
{{junit-platform-runner}} dependencies and remove the {{junit}} one
* Tests
** Replace {{import org.junit.Test;}} with {{org.junit.jupiter.api.Test}}
** Replace {{@Before}} by {{@BeforeEach}}, replace {{import org.junit.Before}}
with {{import org.junit.jupiter.api.beforeEach;}}
** Replace {{@After}} by {{@AfterEach}}, replace {{import org.junit.After}}
with {{import org.junit.jupiter.api.AfterEach;}}
** Replace {{import static org.junit.Assert.assertThat;}} with {{import static
org.hamcrest.MatcherAssert.assertThat;}}
** Replace {{import static org.junit.Assert.*}} by {{import static
org.junit.jupiter.api.Assertions.*}}
* Concurrent tests
** Remove {{import com.mycila.junit.concurrent.Concurrency;}} and {{import
com.mycila.junit.concurrent.ConcurrentJunitRunner;}}
** Remove the {{junit-addons}} dependency
** Remove {{import org.junit.runner.RunWith;}}
** Replace {{@RunWith(ConcurrentJunitRunner.class)\n@Concurrency()}} by
{{@Execution(ExecutionMode.CONCURRENT)}}
* Tests with {{Rule}} (mainly use to create temporary files/directories)
** Remove the {{@Rule}}, replace it by a {{init}} function with the
{{@BeforeEach}} tag, and implement the logic. For instance, for a temporary
folder creation :
{code:java}
private Path tmpFolder;
@BeforeEach
public void init() throws IOException
{
tmpFolder = Files.createTempDirectory(
FileUtilsTest.class.getSimpleName() );
tmpFolder.toFile().deleteOnExit();
}
@Test
public void
testOpenOutputStreamAppendToNonExistingFileInNonExistingFolder() throws
Exception
{
File nonExistingFile = new File( tmpFolder.toFile(),
"testOpenOutputStreamAppendToNonExistingFileInNonExistingFolder/testOpenOutputStreamAppendToNonExistingFileInNonExistingFolder"
);
...
{code}
For most of the tests, this is trivial, but considering the vast number of
tests, it will take a while.
> Switch to Junit 5
> -----------------
>
> Key: DIRAPI-333
> URL: https://issues.apache.org/jira/browse/DIRAPI-333
> Project: Directory Client API
> Issue Type: Dependency upgrade
> Affects Versions: 2.0.0.AM2
> Reporter: Maxim Solodovnik
> Priority: Major
> Fix For: 2.0.0.AM3
>
>
> commons-lang and commons-collections need to be updated to most recent
> versions
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)