How to run OSGi tests?

Do we have step by step manual about running *JavaOSGiTest from cmd?

I found how to run OSGi test:
mvn clean install inside itests/org.openhab.core.thing.tests run OSGi tests but
mvn clean install -Dtest=xxxxx doesn’t run specific test.

It was enough for me to test.

I had only one issue - rebuild some bundle instead rebuild whole project lead to error when execute mvn clean install inside itests/org.openhab.core.thing.tests:

[INFO] Resolved all Dependencies for org.openhab.core.itests:org.openhab.core.thing.tests:jar:5.0.0-SNAPSHOT. Checked: 294, Skipped(no need to revisit): 0, Failed: 0, Resulting Dependencies: 3
[INFO] Retrying invalid download: Invalid content checksum CA755FDC2C20F2AC362CBA9C4B10CEA17CD2EFDA9613D1E7077546FDA3D09900 for file:/home/maxx/openhab-core/bundles/org.openhab.core.thing/target/org.openhab.core.thing-5.0.0-SNAPSHOT.jar; expected 733C617A8A850F4C70E27E6552F51C8DF3757016C53FA9A9508EAC2DFB5230D8. delay=1000, retries=2
[INFO] Retrying invalid download: Invalid content checksum CA755FDC2C20F2AC362CBA9C4B10CEA17CD2EFDA9613D1E7077546FDA3D09900 for file:/home/maxx/openhab-core/bundles/org.openhab.core.thing/target/org.openhab.core.thing-5.0.0-SNAPSHOT.jar; expected 733C617A8A850F4C70E27E6552F51C8DF3757016C53FA9A9508EAC2DFB5230D8. delay=2000, retries=1
[INFO] Retrying invalid download: Invalid content checksum CA755FDC2C20F2AC362CBA9C4B10CEA17CD2EFDA9613D1E7077546FDA3D09900 for file:/home/maxx/openhab-core/bundles/org.openhab.core.thing/target/org.openhab.core.thing-5.0.0-SNAPSHOT.jar; expected 733C617A8A850F4C70E27E6552F51C8DF3757016C53FA9A9508EAC2DFB5230D8. delay=1000, retries=2
[ERROR] Tests not run because project has errors
[ERROR] Error   : Download java.io.IOException: Invalid content checksum CA755FDC2C20F2AC362CBA9C4B10CEA17CD2EFDA9613D1E7077546FDA3D09900 for file:/home/maxx/openhab-core/bundles/org.openhab.core.thing/target/org.openhab.core.thing-5.0.0-SNAPSHOT.jar; expected 733C617A8A850F4C70E27E6552F51C8DF3757016C53FA9A9508EAC2DFB5230D8 null
[ERROR] Error   : Bundle file "java.io.IOException: Invalid content checksum CA755FDC2C20F2AC362CBA9C4B10CEA17CD2EFDA9613D1E7077546FDA3D09900 for file:/home/maxx/openhab-core/bundles/org.openhab.core.thing/target/org.openhab.core.thing-5.0.0-SNAPSHOT.jar; expected 733C617A8A850F4C70E27E6552F51C8DF3757016C53FA9A9508EAC2DFB5230D8: null" does not exist, given error is java.io.IOException: Invalid content checksum CA755FDC2C20F2AC362CBA9C4B10CEA17CD2EFDA9613D1E7077546FDA3D09900 for file:/home/maxx/openhab-core/bundles/org.openhab.core.thing/target/org.openhab.core.thing-5.0.0-SNAPSHOT.jar; expected 733C617A8A850F4C70E27E6552F51C8DF3757016C53FA9A9508EAC2DFB5230D8

To fix this you need to rebuild whole project (20-30 minutes).

Why I don’t use eclipse with plugin - I can’t checkout OH on my Windows PC due error:

...
remote: Total 186036 (delta 562), reused 403 (delta 403), pack-reused 185313 (from 4)
Receiving objects: 100% (186036/186036), 40.75 MiB | 6.75 MiB/s, done.
Resolving deltas: 100% (104816/104816), done.
fatal: cannot create directory at 'itests/org.openhab.core.config.dispatch.tests/src/main/resources/configurations/exclusive_pid_configuration_removed_after_file_delete/exclusive_pid_configuration_removed_after_file_delete_services': Filename too long
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

inside WSL I able to checkout and build but only using command line.

1 Like

Thanks for the tip. I was looking for how to run the itests too :slight_smile:

In my case, I just needed to rebuild core, and it took about 4 minutes with this command:

$ mvn clean spotless:apply install -DskipChecks -DskipTests -T1C
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:41 min (Wall Clock)
[INFO] Finished at: 2025-07-27T11:12:12+10:00
[INFO] ------------------------------------------------------------------------

The above command is documented in the main core README.md for future reference, because I don’t always remember it.

PS I probably didn’t need to do spotless:apply

Maybe you can move your clone to another directory so the path does not exceed the default 260 char path limitation of Windows?

The longest path (measured from the repository root) after a full build is currently 212 chars. There are several other path lengths exceeding 200 chars so just renaming this one probably won’t fix your issue.

There’s also a registry configuration value to enable long path support in Windows which may help:

@wborn is there a way to resolve the above errors without doing a full mvn install for the whole core? e.g. how can I update the checksum of only the bundles that I have been working on.

What usually works for me is rebuilding the bom dir with mvn clean install.
Sometimes you also need to run mvn clean install -N in the itests dir.

These commands regenerate the bundle indices used in the itests.