Skip to content

Commit 13e9d3b

Browse files
committed
Complete test addition
1 parent e97a32b commit 13e9d3b

File tree

5 files changed

+165
-0
lines changed

5 files changed

+165
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}

0 commit comments

Comments
 (0)