Skip to content

Commit

Permalink
Convert MrBean; promote JUnit5 dep to parent level, remove per-module…
Browse files Browse the repository at this point in the history
… JUnit5 deps
  • Loading branch information
cowtowncoder committed Jan 19, 2025
1 parent 6b5d24b commit 4ff30d6
Show file tree
Hide file tree
Showing 25 changed files with 101 additions and 121 deletions.
11 changes: 0 additions & 11 deletions afterburner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,6 @@ field access and method calls
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
10 changes: 0 additions & 10 deletions android-record/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
10 changes: 0 additions & 10 deletions blackbird/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ that uses LambdaMetafactory based code generation to replace reflection calls.
</dependency>

<!-- Test dependencies: -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
10 changes: 0 additions & 10 deletions guice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
12 changes: 1 addition & 11 deletions guice7/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,7 @@
<version>${version.guice}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<!-- Test dependencies -->
</dependencies>

<build>
Expand Down
11 changes: 0 additions & 11 deletions jakarta-xmlbind/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,6 @@
<version>2.1.0</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<!-- may also need JAXB impl for tests -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
Expand Down
11 changes: 0 additions & 11 deletions jaxb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,6 @@ for configuring data-binding.
<version>1.2.2</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<!-- may also need JAXB impl for tests -->
<!-- 20-May-2024, tatu: no longer needed it seems:
<dependency>
Expand Down
6 changes: 0 additions & 6 deletions mrbean/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ ${project.groupId}.mrbean.*;version=${project.version}
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
import java.io.*;
import java.util.Arrays;

import junit.framework.TestCase;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;

//import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

public abstract class BaseTest
extends TestCase
{
/*
/**********************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.fasterxml.jackson.module.mrbean;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.*;

import static org.junit.jupiter.api.Assertions.*;

public class RoundTripTest extends BaseTest
{
public interface Bean {
Expand All @@ -14,6 +18,7 @@ public interface ReadOnlyBean {
}

// [mrbean#20]: naming convention caused under-score prefixed duplicates
@Test
public void testSimple() throws Exception
{
ObjectMapper mapper = new ObjectMapper()
Expand All @@ -25,6 +30,7 @@ public void testSimple() throws Exception
assertEquals(input, output);
}

@Test
public void testSimpleWithoutSetter() throws Exception
{
ObjectMapper mapper = new ObjectMapper()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.fasterxml.jackson.module.mrbean;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.ObjectMapper;

import static org.junit.jupiter.api.Assertions.*;

public class TestAbstractClasses
extends BaseTest
{
Expand Down Expand Up @@ -34,6 +38,7 @@ protected Bean() { }
*/

@SuppressWarnings("synthetic-access")
@Test
public void testSimpleInteface() throws Exception
{
ObjectMapper mapper = newMrBeanMapper();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.fasterxml.jackson.module.mrbean;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import static org.junit.jupiter.api.Assertions.*;

public class TestAbstractClassesWithOverrides
extends BaseTest
{
Expand Down Expand Up @@ -74,6 +78,7 @@ public abstract static class CoffeeBeanLackingPublicMethod extends CoffeeBean
/**********************************************************
*/

@Test
public void testOverrides() throws Exception
{
ObjectMapper mapper = newMrBeanMapper();
Expand All @@ -86,6 +91,7 @@ public void testOverrides() throws Exception
}

@SuppressWarnings("synthetic-access")
@Test
public void testReAbstractedMethods() throws Exception
{
AbstractTypeMaterializer mat = new AbstractTypeMaterializer();
Expand Down Expand Up @@ -130,6 +136,7 @@ private void verifyReAbstractedProperty(ObjectMapper mapper) throws com.fasterxm
assertEquals("Another Foo!", beanWithOtherFoo.getFoo());
}

@Test
public void testEagerFailureOnReAbstractedMethods() throws Exception
{
AbstractTypeMaterializer mat = new AbstractTypeMaterializer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.function.Consumer;
import java.util.function.Supplier;

import org.junit.jupiter.api.Test;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassReader;
Expand All @@ -22,6 +23,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.mrbean.AbstractTypeMaterializer.MyClassLoader;

import static org.junit.jupiter.api.Assertions.*;

// [modules-base#110]: avoid synthetic bridge method generation
public class TestBridgeMethods extends BaseTest
{
Expand Down Expand Up @@ -52,6 +55,7 @@ public interface SpecificCoffeeHolder extends GenericHolder<Coffee> {
Coffee getObject();
}

@Test
public void testSimpleCovariantProperty() throws Exception
{
ObjectMapper mapper = newMrBeanMapper();
Expand All @@ -64,6 +68,7 @@ public void testSimpleCovariantProperty() throws Exception
assertEquals("pumpkin spice", result.getDrink().getFlavor());
}

@Test
public void testGenericCovariantProperty() throws Exception
{
ObjectMapper mapper = newMrBeanMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class TestGenericTypes
extends BaseTest
{
Expand Down Expand Up @@ -37,6 +41,7 @@ public interface InterfaceWithReference8 {
/**
* Test simple leaf-level bean with 2 implied _beanProperties
*/
@Test
public void testSimpleInterface() throws Exception
{
ObjectMapper mapper = new ObjectMapper().registerModule(new MrBeanModule());
Expand All @@ -50,6 +55,7 @@ public void testSimpleInterface() throws Exception
assertEquals("foo", leaves.get(0).value);
}

@Test
public void testGenericInterface() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
Expand All @@ -68,6 +74,7 @@ public void testGenericInterface() throws Exception
}
}

@Test
public void testGenericClass() throws Exception
{
ObjectMapper mapper = new ObjectMapper()
Expand All @@ -87,6 +94,7 @@ public void testGenericClass() throws Exception
}

// for [mrbean#8]
@Test
public void testWithGenericReferenceType() throws Exception
{
ObjectMapper mapper = new ObjectMapper()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import java.io.Serializable;
import java.util.*;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

import static org.junit.jupiter.api.Assertions.*;

/**
* Tests stemming from [#12], where `Calendar` fails; however, bit more general
* problem.
Expand All @@ -27,6 +31,7 @@ static class Bean117UsingJsonSerialize {
private final ObjectMapper MAPPER = newMrBeanMapper();
private final ObjectMapper VANILLA_MAPPER = newPlainJsonMapper();

@Test
public void testDateTimeTypes() throws Exception
{
Calendar cal = MAPPER.readValue("0", Calendar.class);
Expand All @@ -38,6 +43,7 @@ public void testDateTimeTypes() throws Exception
assertEquals(0L, dt.getTime());
}

@Test
public void testNumbers() throws Exception
{
Number nr = MAPPER.readValue("0", Number.class);
Expand All @@ -49,6 +55,7 @@ public void testNumbers() throws Exception
assertSame(Double.class, nr.getClass());
}

@Test
public void testIterable() throws Exception
{
Object ob = MAPPER.readValue("[ ]", Iterable.class);
Expand All @@ -63,13 +70,15 @@ public void testIterable() throws Exception
assertEquals(Integer.valueOf(123), l.get(0));
}

@Test
public void testStringLike() throws Exception
{
CharSequence seq = MAPPER.readValue(q("abc"), CharSequence.class);
assertEquals("abc", (String) seq);
}

// [modules-base#74]: more types to skip
@Test
public void testSerializable() throws Exception
{
// Serializable value = MAPPER.readValue(quote("abc"), Serializable.class);
Expand All @@ -78,6 +87,7 @@ public void testSerializable() throws Exception
}

// Extra test inspired by Afterburner report
@Test
public void testIntAsString() throws Exception
{
final String EXP_JSON = "{\"value\":\"42\"}";
Expand All @@ -92,6 +102,7 @@ public void testIntAsString() throws Exception
}

// [modules-base#132]: Don't block "java.util.TimeZone"
@Test
public void testUtilTimeZone() throws Exception
{
final String json = q("PST");
Expand Down
Loading

0 comments on commit 4ff30d6

Please sign in to comment.