Skip to content

Commit cf359b0

Browse files
committed
Add basic MrBeanTest, fix build/test
1 parent d40a598 commit cf359b0

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@
209209
<groupId>com.fasterxml.jackson.module</groupId>
210210
<artifactId>jackson-module-afterburner</artifactId>
211211
</dependency>
212+
<dependency>
213+
<groupId>com.fasterxml.jackson.module</groupId>
214+
<artifactId>jackson-module-mrbean</artifactId>
215+
</dependency>
212216

213217
<!-- 04-Jun-2020, tatu: And why not Protobuf value type support too? -->
214218
<dependency>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.fasterxml.jackson.integtest.mrbean;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
import com.fasterxml.jackson.databind.ObjectMapper;
8+
9+
import com.fasterxml.jackson.module.mrbean.MrBeanModule;
10+
11+
import com.fasterxml.jackson.integtest.BaseTest;
12+
13+
// Copied from mrbean module tests ("RoundTripTest")
14+
public class MrBeanTest extends BaseTest
15+
{
16+
public interface Bean {
17+
String getField();
18+
void setField(String field);
19+
}
20+
21+
public interface ReadOnlyBean {
22+
String getField();
23+
}
24+
25+
private final ObjectMapper MAPPER = jsonMapperBuilder()
26+
.addModule(new MrBeanModule())
27+
.build();
28+
29+
@Test
30+
public void testSimple() throws Exception
31+
{
32+
final String input = "{\"field\":\"testing\"}";
33+
final Bean bean = MAPPER.readValue(input, Bean.class);
34+
assertEquals("testing", bean.getField());
35+
final String output = MAPPER.writeValueAsString(bean);
36+
assertEquals(input, output);
37+
}
38+
39+
@Test
40+
public void testSimpleWithoutSetter() throws Exception
41+
{
42+
final String input = "{\"field\":\"testing\"}";
43+
final ReadOnlyBean bean = MAPPER.readValue(input, ReadOnlyBean.class);
44+
assertEquals("testing", bean.getField());
45+
final String output = MAPPER.writeValueAsString(bean);
46+
assertEquals(input, output);
47+
}
48+
}

src/test/resources/com/fasterxml/jackson/integtest/gradle/build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ plugins {
55
val modulesWithoutGradleMetadata = listOf(
66
"com.fasterxml.jackson.jr:jackson-jr-all", // TODO is there a reason not to add this?
77

8+
// 31-Oct-2025, tatu: does not depend on jackson-bom; 2.20 naming convention different
9+
"com.fasterxml.jackson.core:jackson-annotations",
10+
811
"com.fasterxml.jackson:jackson-bom", // does not need it
912
"com.fasterxml.jackson.module:jackson-module-scala_2.11", // built with sbt
1013
"com.fasterxml.jackson.module:jackson-module-scala_2.12", // built with sbt
@@ -17,10 +20,10 @@ val modulesWithoutGradleMetadata = listOf(
1720
)
1821

1922
dependencies {
20-
//implementation(platform("com.fasterxml.jackson:jackson-bom:+"))
23+
implementation(platform("com.fasterxml.jackson:jackson-bom:+"))
2124

2225
// 18-Jul-2025, tatu: Uncomment following (and comment ^^^) to test SNAPSHOT versions
23-
implementation(platform("com.fasterxml.jackson:jackson-bom:2.20.0-SNAPSHOT"))
26+
//implementation(platform("com.fasterxml.jackson:jackson-bom:2.20.2-SNAPSHOT"))
2427
repositories.maven("https://oss.sonatype.org/content/repositories/snapshots")
2528
}
2629

0 commit comments

Comments
 (0)