File tree Expand file tree Collapse file tree 8 files changed +232
-0
lines changed
jakarta-jsonp/src/test/java/com/fasterxml/jackson/datatype/jsonp
jakarta-mail/src/test/java/com/fasterxml/jackson/datatype/jakarta/mail
javax-money/src/test/java/com/fasterxml/jackson/datatype/javax/money
joda-money/src/test/java/com/fasterxml/jackson/datatype/jodamoney
json-org/src/test/java/com/fasterxml/jackson/datatype/jsonorg
jsr-353/src/test/java/com/fasterxml/jackson/datatype/jsr353
moneta/src/test/java/com/fasterxml/jackson/datatype/moneta Expand file tree Collapse file tree 8 files changed +232
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .fasterxml .jackson .datatype .jsonp ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import static org .junit .jupiter .api .Assertions .*;
6+
7+ import java .util .ServiceLoader ;
8+
9+ public class ModuleSPIMetadataTest extends TestBase
10+ {
11+ @ Test
12+ void testModuleSPIMetadata () {
13+ ServiceLoader <com .fasterxml .jackson .databind .Module > loader
14+ = ServiceLoader .load (com .fasterxml .jackson .databind .Module .class );
15+ assertTrue (loader .iterator ().hasNext (),
16+ "Expected at least one `Module` implementation to be found via `ServiceLoader`" );
17+ final String exp = JSONPModule .class .getName ();
18+ int count = 0 ;
19+
20+ try {
21+ for (com .fasterxml .jackson .databind .Module service : loader ) {
22+ ++count ;
23+ if (service .getClass ().getName ().equals (exp )) {
24+ return ;
25+ }
26+ }
27+ } catch (Throwable t ) {
28+ fail ("Expected to find `" +exp +"` Module (found " +count +" so far), problem: " +t );
29+ }
30+ fail ("Expecteed to find `" +exp +"` Module (found " +count +" others)" );
31+ assertEquals (1 , count );
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ package com .fasterxml .jackson .datatype .jakarta .mail ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import static org .junit .jupiter .api .Assertions .*;
6+
7+ import java .util .ServiceLoader ;
8+
9+ public class ModuleSPIMetadataTest extends TestBase
10+ {
11+ @ Test
12+ void testModuleSPIMetadata () {
13+ ServiceLoader <com .fasterxml .jackson .databind .Module > loader
14+ = ServiceLoader .load (com .fasterxml .jackson .databind .Module .class );
15+ assertTrue (loader .iterator ().hasNext (),
16+ "Expected at least one `Module` implementation to be found via `ServiceLoader`" );
17+ final String exp = JakartaMailModule .class .getName ();
18+ int count = 0 ;
19+
20+ try {
21+ for (com .fasterxml .jackson .databind .Module service : loader ) {
22+ ++count ;
23+ if (service .getClass ().getName ().equals (exp )) {
24+ return ;
25+ }
26+ }
27+ } catch (Throwable t ) {
28+ fail ("Expected to find `" +exp +"` Module (found " +count +" so far), problem: " +t );
29+ }
30+ fail ("Expecteed to find `" +exp +"` Module (found " +count +" others)" );
31+ assertEquals (1 , count );
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ package com .fasterxml .jackson .datatype .javax .money ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import static org .junit .jupiter .api .Assertions .*;
6+
7+ import java .util .ServiceLoader ;
8+
9+ public class ModuleSPIMetadataTest
10+ {
11+ @ Test
12+ void testModuleSPIMetadata () {
13+ ServiceLoader <com .fasterxml .jackson .databind .Module > loader
14+ = ServiceLoader .load (com .fasterxml .jackson .databind .Module .class );
15+ assertTrue (loader .iterator ().hasNext (),
16+ "Expected at least one `Module` implementation to be found via `ServiceLoader`" );
17+ final String exp = JavaxMoneyModule .class .getName ();
18+ int count = 0 ;
19+
20+ try {
21+ for (com .fasterxml .jackson .databind .Module service : loader ) {
22+ ++count ;
23+ if (service .getClass ().getName ().equals (exp )) {
24+ return ;
25+ }
26+ }
27+ } catch (Throwable t ) {
28+ fail ("Expected to find `" +exp +"` Module (found " +count +" so far), problem: " +t );
29+ }
30+ fail ("Expected to find `" +exp +"` Module (found " +count +" others)" );
31+ assertEquals (1 , count );
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ package com .fasterxml .jackson .datatype .jodamoney ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import static org .junit .jupiter .api .Assertions .*;
6+
7+ import java .util .ServiceLoader ;
8+
9+ public class ModuleSPIMetadataTest extends ModuleTestBase
10+ {
11+ @ Test
12+ void testModuleSPIMetadata () {
13+ ServiceLoader <com .fasterxml .jackson .databind .Module > loader
14+ = ServiceLoader .load (com .fasterxml .jackson .databind .Module .class );
15+ assertTrue (loader .iterator ().hasNext (),
16+ "Expected at least one `Module` implementation to be found via `ServiceLoader`" );
17+ final String exp = JodaMoneyModule .class .getName ();
18+ int count = 0 ;
19+
20+ try {
21+ for (com .fasterxml .jackson .databind .Module service : loader ) {
22+ ++count ;
23+ if (service .getClass ().getName ().equals (exp )) {
24+ return ;
25+ }
26+ }
27+ } catch (Throwable t ) {
28+ fail ("Expected to find `" +exp +"` Module (found " +count +" so far), problem: " +t );
29+ }
30+ fail ("Expected to find `" +exp +"` Module (found " +count +" others)" );
31+ assertEquals (1 , count );
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ package com .fasterxml .jackson .datatype .jsonorg ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import static org .junit .jupiter .api .Assertions .*;
6+
7+ import java .util .ServiceLoader ;
8+
9+ public class ModuleSPIMetadataTest extends ModuleTestBase
10+ {
11+ @ Test
12+ void testModuleSPIMetadata () {
13+ ServiceLoader <com .fasterxml .jackson .databind .Module > loader
14+ = ServiceLoader .load (com .fasterxml .jackson .databind .Module .class );
15+ assertTrue (loader .iterator ().hasNext (),
16+ "Expected at least one `Module` implementation to be found via `ServiceLoader`" );
17+ final String exp = JsonOrgModule .class .getName ();
18+ int count = 0 ;
19+
20+ try {
21+ for (com .fasterxml .jackson .databind .Module service : loader ) {
22+ ++count ;
23+ if (service .getClass ().getName ().equals (exp )) {
24+ return ;
25+ }
26+ }
27+ } catch (Throwable t ) {
28+ fail ("Expected to find `" +exp +"` Module (found " +count +" so far), problem: " +t );
29+ }
30+ fail ("Expected to find `" +exp +"` Module (found " +count +" others)" );
31+ assertEquals (1 , count );
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ package com .fasterxml .jackson .datatype .jsr353 ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import static org .junit .jupiter .api .Assertions .*;
6+
7+ import java .util .ServiceLoader ;
8+
9+ public class ModuleSPIMetadataTest extends TestBase
10+ {
11+ @ Test
12+ void testModuleSPIMetadata () {
13+ ServiceLoader <com .fasterxml .jackson .databind .Module > loader
14+ = ServiceLoader .load (com .fasterxml .jackson .databind .Module .class );
15+ assertTrue (loader .iterator ().hasNext (),
16+ "Expected at least one `Module` implementation to be found via `ServiceLoader`" );
17+ final String exp = JSR353Module .class .getName ();
18+ int count = 0 ;
19+
20+ try {
21+ for (com .fasterxml .jackson .databind .Module service : loader ) {
22+ ++count ;
23+ if (service .getClass ().getName ().equals (exp )) {
24+ return ;
25+ }
26+ }
27+ } catch (Throwable t ) {
28+ fail ("Expected to find `" +exp +"` Module (found " +count +" so far), problem: " +t );
29+ }
30+ fail ("Expected to find `" +exp +"` Module (found " +count +" others)" );
31+ assertEquals (1 , count );
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ package com .fasterxml .jackson .datatype .moneta ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import static org .junit .jupiter .api .Assertions .*;
6+
7+ import java .util .ServiceLoader ;
8+
9+ public class ModuleSPIMetadataTest
10+ {
11+ @ Test
12+ void testModuleSPIMetadata () {
13+ ServiceLoader <com .fasterxml .jackson .databind .Module > loader
14+ = ServiceLoader .load (com .fasterxml .jackson .databind .Module .class );
15+ assertTrue (loader .iterator ().hasNext (),
16+ "Expected at least one `Module` implementation to be found via `ServiceLoader`" );
17+ final String exp = MonetaMoneyModule .class .getName ();
18+ int count = 0 ;
19+
20+ try {
21+ for (com .fasterxml .jackson .databind .Module service : loader ) {
22+ ++count ;
23+ if (service .getClass ().getName ().equals (exp )) {
24+ return ;
25+ }
26+ }
27+ } catch (Throwable t ) {
28+ fail ("Expected to find `" +exp +"` Module (found " +count +" so far), problem: " +t );
29+ }
30+ fail ("Expected to find `" +exp +"` Module (found " +count +" others)" );
31+ assertEquals (1 , count );
32+ }
33+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ Modules:
1313
14142.20.0 (not yet released)
1515
16+ #68 : Add unit tests to verify goodness of SPI metadata for Modules
1617- Generate SBOMs [JSTEP-14 ]
1718
18192.19.0 (24 -Apr-2025 )
You can’t perform that action at this time.
0 commit comments