Well, oh, well...

I was optimistic when I started migrating the LDAP API and ApacheDS from Junit4 to Junit5. The rational for doing so was that Eclipse now expect tests to be Junit5 by default, which meant that running Junit4 tests started to be a PITA.

It was all but smooth. Let's say that if you just have plain tests, it's pretty straightforward.

But as soon as you use Rules or Runners this is a whole different story. At the end, I had to spend a couple of months (not full time) to get the migration working...

In your case, I think it should not be that costly.

However, you have plenty of TestSuite in Fortress tests. It may require some love too (I'm not a heavy user of testSuite, as I prefer having tests being ran in their own env, but I understand the need).

All in all, you can also taking baby steps, by migrating some of your tests to Junit5 and keeping some other in Junit4, smothering the migration effort. It's explained here:

https://junit.org/junit5/docs/current/user-guide/#migrating-from-junit4

Let me konw if you need more specific feedback!

On 17/10/2023 14:27, Shawn McKinney wrote:
Hi Emmanuel,

I don’t want this discussion to get in the way of the vote so I’ve renamed it.

There’s a bit more. Now, we must use junit5. Doesn’t seem like too big of a 
deal as it’s backward compatible and in the test scope.

There are two tests that utilize the apacheDS test runner. They both are 
failing after the upgrade. Since I have not been running these not sure if it’s 
a new problem.

I’ll do some investigation and report back here.

Thanks

—
Shawn

On Oct 16, 2023, at 10:48 PM, Emmanuel Lécharny <elecha...@gmail.com> wrote:

Hi Shawn,

regarding the FrameworkRunner class, it has been removed from ApacheDS code 
base when we migrated from Junit4 to Junit 5.

I do think that you need to replace calls to FrameworkRunner by:

@ExtendWith( ApacheDSTestExtension.class )

it should do the trick.


For instance, the AddIT test class for core-integ was:

/**
* Test the add operation
*
* @author <a href="mailto:dev@directory.apache.org";>Apache Directory Project</a>
*/
@RunWith(FrameworkRunner.class)
@CreateDS(
    name = "AddITDS",
        loadedSchemas =
        { @LoadSchema(name = "nis", enabled = true) },
    partitions =
        {
            @CreatePartition(
                name = "example",
                suffix = "dc=example,dc=com",
                contextEntry = @ContextEntry(
                    entryLdif =
                    "dn: dc=example,dc=com\n" +
                        "dc: example\n" +
                        "objectClass: top\n" +
                        "objectClass: domain\n\n"),
                indexes =
                    {
                        @CreateIndex(attribute = "objectClass"),
                        @CreateIndex(attribute = "sn"),
                        @CreateIndex(attribute = "cn")
                })

    },
    enableChangeLog = false)
public class AddIT extends AbstractLdapTestUnit
{
   /**
     * Test an add operation with a value that needs to be normalized
     */
    @Test
    public void testAddNotNormalized() throws Exception
    {
        LdapConnection connection = IntegrationUtils.getAdminConnection( 
getService() );

        Dn dn = new Dn( "cn=test,ou=system" );
        Entry entry = new DefaultEntry( dn,
            "ObjectClass: top",
            "ObjectClass: person",
            "sn:  TEST    ",
            "cn: test" );

        connection.add( entry );

        entry = connection.lookup( entry.getDn(), 
SchemaConstants.ALL_ATTRIBUTES_ARRAY );
        Entry contextEntry = connection.lookup( "ou=system", 
SchemaConstants.ALL_ATTRIBUTES_ARRAY );

        String expectedCsn = entry.get( SchemaConstants.ENTRY_CSN_AT 
).getString();
        String contextCsn = contextEntry.get( SchemaConstants.CONTEXT_CSN_AT 
).getString();
        assertEquals( expectedCsn, contextCsn );
    }



...
}


and now is:

**
* Test the add operation
*
* @author <a href="mailto:dev@directory.apache.org";>Apache Directory Project</a>
*/
@ExtendWith( { ApacheDSTestExtension.class } )
@CreateDS(
    name = "AddITDS",
        loadedSchemas =
        { @LoadSchema(name = "nis", enabled = true) },
    partitions =
        {
            @CreatePartition(
                name = "example",
                suffix = "dc=example,dc=com",
                contextEntry = @ContextEntry(
                    entryLdif =
                    "dn: dc=example,dc=com\n" +
                        "dc: example\n" +
                        "objectClass: top\n" +
                        "objectClass: domain\n\n"),
                indexes =
                    {
                        @CreateIndex(attribute = "objectClass"),
                        @CreateIndex(attribute = "sn"),
                        @CreateIndex(attribute = "cn")
                })

    },
    enableChangeLog = false)
public class AddIT extends AbstractLdapTestUnit
{
    /**
     * Test an add operation with a value that needs to be normalized
     */
    @Test
    public void testAddNotNormalized() throws Exception
    {
        LdapConnection connection = IntegrationUtils.getAdminConnection( 
getService() );

        Dn dn = new Dn( "cn=test,ou=system" );
        Entry entry = new DefaultEntry( dn,
            "ObjectClass: top",
            "ObjectClass: person",
            "sn:  TEST    ",
            "cn: test" );

        connection.add( entry );

        entry = connection.lookup( entry.getDn(), 
SchemaConstants.ALL_ATTRIBUTES_ARRAY );
        Entry contextEntry = connection.lookup( "ou=system", 
SchemaConstants.ALL_ATTRIBUTES_ARRAY );

        String expectedCsn = entry.get( SchemaConstants.ENTRY_CSN_AT 
).getString();
        String contextCsn = contextEntry.get( SchemaConstants.CONTEXT_CSN_AT 
).getString();
        assertEquals( expectedCsn, contextCsn );
    }


That should not be such a big change.


On 16/10/2023 19:31, Shawn McKinney wrote:
On Oct 16, 2023, at 9:12 AM, Emmanuel Lécharny <elecha...@gmail.com> wrote:

Hi Colm,

just pushed the packages to dist!
Hi Emmanuel.
I’m still testing. I can build and run tests on Java 17. Can install the server 
using the snapshots. Have run fortress core integration tests and they all pass.
To use the latest AM27 in fortress core had to remove these dependencies:
apacheds-interceptor-kerberos
apacheds-kerberos-codec
apacheds-protocol-kerberos
 From test scope in pom. No problem, Kerb is not supported in the server as 
indicated by the issue list.
Not sure why it was in fortress core. There are no compile time dependencies on 
these packages. Extraneous?
In any case, not a server issue.
But, there’s also this when I compile fortress core using AM27:
```
[ERROR]
/opt/fortress/directory-fortress-core/src/test/java/org/apache/directory/fortress/core/impl/apacheds/FortressJUnitApachedsTest.java:[29,46]
 cannot find symbol
   symbol:   class FrameworkRunner
   location: package
org.apache.directory.server.core.integ
```
Did this package move? We do have a compile dependency in test scope for:
org.apache.directory.server.core.integ.FrameworkRunner;
Probably not a showstopper for release. Something needs to be worked out in 
Fortress going forward.
Thanks
—
Shawn

--
*Emmanuel Lécharny* P. +33 (0)6 08 33 32 61
elecha...@apache.org


--
*Emmanuel Lécharny* P. +33 (0)6 08 33 32 61
elecha...@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@directory.apache.org
For additional commands, e-mail: dev-h...@directory.apache.org

Reply via email to