Skip to content

Commit

Permalink
Merge branch '2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 18, 2025
2 parents 57dd2d2 + dbb5df4 commit e955c90
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 108 deletions.
17 changes: 11 additions & 6 deletions guice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@
<version>${version.guice}</version>
</dependency>

<!-- 20-Apr-2024, tatu: JUnit4 no longer from jackson-base -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</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>

Expand Down
3 changes: 2 additions & 1 deletion guice/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

// Additional test lib/framework dependencies

requires junit; // JUnit4 To Be Removed in future
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;

// Further, need to open up some packages for JUnit et al
opens tools.jackson.module.guice;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package tools.jackson.module.guice;

import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import javax.inject.Inject;

import tools.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;

import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.name.Names;
import org.junit.Assert;
import org.junit.Test;

import javax.inject.Inject;
import com.fasterxml.jackson.annotation.*;

import tools.jackson.databind.ObjectMapper;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;

/**
*/
Expand Down Expand Up @@ -64,30 +65,30 @@ public void configure(Binder binder)

final ReadableBean bean = mapper.readValue("{\"constructor_value\":\"myConstructor\",\"field_value\":\"myField\",\"method_value\":\"myMethod\"}", ReadableBean.class);

Assert.assertEquals("myConstructor", bean.constructorValue);
Assert.assertEquals("myMethod", bean.methodValue);
Assert.assertEquals("myField", bean.fieldValue);
assertEquals("myConstructor", bean.constructorValue);
assertEquals("myMethod", bean.methodValue);
assertEquals("myField", bean.fieldValue);

verifyInjections("From Jackson's ObjectMapper", bean);

}

private void verifyInjections(String message, InjectableBean injected)
{
Assert.assertSame(message, constructorInjected, injected.constructorInjected);
Assert.assertSame(message, constructorInjectedWithJavaAnnotation, injected.constructorInjectedWithJavaAnnotation);
Assert.assertSame(message, constructorInjectedWithGuiceAnnotation, injected.constructorInjectedWithGuiceAnnotation);
Assert.assertSame(message, constructorInjectedWithCustomAnnotation, injected.constructorInjectedWithCustomAnnotation);

Assert.assertSame(message, methodInjected, injected.methodInjected);
Assert.assertSame(message, methodInjectedWithJavaAnnotation, injected.methodInjectedWithJavaAnnotation);
Assert.assertSame(message, methodInjectedWithGuiceAnnotation, injected.methodInjectedWithGuiceAnnotation);
Assert.assertSame(message, methodInjectedWithCustomAnnotation, injected.methodInjectedWithCustomAnnotation);

Assert.assertSame(message, fieldInjected, injected.fieldInjected);
Assert.assertSame(message, fieldInjectedWithJavaAnnotation, injected.fieldInjectedWithJavaAnnotation);
Assert.assertSame(message, fieldInjectedWithGuiceAnnotation, injected.fieldInjectedWithGuiceAnnotation);
Assert.assertSame(message, fieldInjectedWithCustomAnnotation, injected.fieldInjectedWithCustomAnnotation);
assertSame(constructorInjected, injected.constructorInjected);
assertSame(constructorInjectedWithJavaAnnotation, injected.constructorInjectedWithJavaAnnotation);
assertSame(constructorInjectedWithGuiceAnnotation, injected.constructorInjectedWithGuiceAnnotation);
assertSame(constructorInjectedWithCustomAnnotation, injected.constructorInjectedWithCustomAnnotation);

assertSame(methodInjected, injected.methodInjected);
assertSame(methodInjectedWithJavaAnnotation, injected.methodInjectedWithJavaAnnotation);
assertSame(methodInjectedWithGuiceAnnotation, injected.methodInjectedWithGuiceAnnotation);
assertSame(methodInjectedWithCustomAnnotation, injected.methodInjectedWithCustomAnnotation);

assertSame(fieldInjected, injected.fieldInjected);
assertSame(fieldInjectedWithJavaAnnotation, injected.fieldInjectedWithJavaAnnotation);
assertSame(fieldInjectedWithGuiceAnnotation, injected.fieldInjectedWithGuiceAnnotation);
assertSame(fieldInjectedWithCustomAnnotation, injected.fieldInjectedWithCustomAnnotation);
}

/* ===================================================================== */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

import java.math.BigInteger;

import org.junit.jupiter.api.Test;

import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.name.Names;

import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;

Expand All @@ -12,15 +21,7 @@
import tools.jackson.databind.SerializationContext;
import tools.jackson.databind.module.SimpleModule;

import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.name.Names;

import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class ObjectMapperModuleTest
{
Expand Down Expand Up @@ -65,7 +66,7 @@ public void testModulesRegisteredThroughNormalInstantiation() throws Exception

final ObjectMapper mapper = injector.getInstance(ObjectMapper.class);

Assert.assertEquals(mapper.writeValueAsString(Integer.valueOf(10)), "\"A\"");
assertEquals(mapper.writeValueAsString(10), "\"A\"");
}

@Test
Expand All @@ -77,7 +78,7 @@ public void testModulesRegisteredThroughInjection() throws Exception

final ObjectMapper mapper = injector.getInstance(ObjectMapper.class);

Assert.assertEquals(mapper.writeValueAsString(Integer.valueOf(10)), "\"A\"");
assertEquals(mapper.writeValueAsString(10), "\"A\"");
}

@Test
Expand All @@ -97,7 +98,7 @@ public void configure(Binder binder)

final ObjectMapper mapper = injector.getInstance(ObjectMapper.class);

Assert.assertEquals(mapper.writeValueAsString(Integer.valueOf(10)), "\"A\"");
assertEquals(mapper.writeValueAsString(10), "\"A\"");
}

@Test
Expand All @@ -119,7 +120,7 @@ public void configure(Binder binder)

final ObjectMapper mapper = injector.getInstance(ObjectMapper.class);

Assert.assertEquals(mapper.writeValueAsString(Integer.valueOf(10)), "\"A\"");
assertEquals(mapper.writeValueAsString(10), "\"A\"");
}

@Test
Expand All @@ -131,7 +132,7 @@ public void testModulesRegisteredThroughInjectionWithKey() throws Exception

final ObjectMapper mapper = injector.getInstance(ObjectMapper.class);

Assert.assertEquals(mapper.writeValueAsString(Integer.valueOf(10)), "\"A\"");
assertEquals(mapper.writeValueAsString(10), "\"A\"");
}

private static class SomeBean
Expand Down Expand Up @@ -186,15 +187,15 @@ private void injectNine(long n)

public boolean verify()
{
Assert.assertEquals(1, one);
Assert.assertEquals(2, two);
Assert.assertEquals(3, three);
Assert.assertEquals(4, four);
Assert.assertEquals(5, five);
Assert.assertEquals(6, six);
Assert.assertEquals(7, seven);
Assert.assertEquals(8, eight);
Assert.assertEquals(9, nine);
assertEquals(1, one);
assertEquals(2, two);
assertEquals(3, three);
assertEquals(4, four);
assertEquals(5, five);
assertEquals(6, six);
assertEquals(7, seven);
assertEquals(8, eight);
assertEquals(9, nine);
return true;
}

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

<!-- 20-Apr-2024, tatu: JUnit4 no longer from jackson-base -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</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
3 changes: 2 additions & 1 deletion guice7/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

// Additional test lib/framework dependencies

requires junit; // JUnit4 To Be Removed in future
requires org.junit.jupiter.api;
requires org.junit.jupiter.params;

// Further, need to open up some packages for JUnit et al
opens tools.jackson.module.guice7;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package tools.jackson.module.guice7;

import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.inject.Inject;

import tools.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;

import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.name.Names;
import org.junit.Assert;
import org.junit.Test;

import jakarta.inject.Inject;
import com.fasterxml.jackson.annotation.*;

import tools.jackson.databind.ObjectMapper;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;

public class ExtendInjectableTest
{
Expand Down Expand Up @@ -62,30 +63,30 @@ public void configure(Binder binder)

final ReadableBean bean = mapper.readValue("{\"constructor_value\":\"myConstructor\",\"field_value\":\"myField\",\"method_value\":\"myMethod\"}", ReadableBean.class);

Assert.assertEquals("myConstructor", bean.constructorValue);
Assert.assertEquals("myMethod", bean.methodValue);
Assert.assertEquals("myField", bean.fieldValue);
assertEquals("myConstructor", bean.constructorValue);
assertEquals("myMethod", bean.methodValue);
assertEquals("myField", bean.fieldValue);

verifyInjections("From Jackson's ObjectMapper", bean);

}

private void verifyInjections(String message, InjectableBean injected)
{
Assert.assertSame(message, constructorInjected, injected.constructorInjected);
Assert.assertSame(message, constructorInjectedWithJavaAnnotation, injected.constructorInjectedWithJavaAnnotation);
Assert.assertSame(message, constructorInjectedWithGuiceAnnotation, injected.constructorInjectedWithGuiceAnnotation);
Assert.assertSame(message, constructorInjectedWithCustomAnnotation, injected.constructorInjectedWithCustomAnnotation);

Assert.assertSame(message, methodInjected, injected.methodInjected);
Assert.assertSame(message, methodInjectedWithJavaAnnotation, injected.methodInjectedWithJavaAnnotation);
Assert.assertSame(message, methodInjectedWithGuiceAnnotation, injected.methodInjectedWithGuiceAnnotation);
Assert.assertSame(message, methodInjectedWithCustomAnnotation, injected.methodInjectedWithCustomAnnotation);

Assert.assertSame(message, fieldInjected, injected.fieldInjected);
Assert.assertSame(message, fieldInjectedWithJavaAnnotation, injected.fieldInjectedWithJavaAnnotation);
Assert.assertSame(message, fieldInjectedWithGuiceAnnotation, injected.fieldInjectedWithGuiceAnnotation);
Assert.assertSame(message, fieldInjectedWithCustomAnnotation, injected.fieldInjectedWithCustomAnnotation);
assertSame(constructorInjected, injected.constructorInjected);
assertSame(constructorInjectedWithJavaAnnotation, injected.constructorInjectedWithJavaAnnotation);
assertSame(constructorInjectedWithGuiceAnnotation, injected.constructorInjectedWithGuiceAnnotation);
assertSame(constructorInjectedWithCustomAnnotation, injected.constructorInjectedWithCustomAnnotation);

assertSame(methodInjected, injected.methodInjected);
assertSame(methodInjectedWithJavaAnnotation, injected.methodInjectedWithJavaAnnotation);
assertSame(methodInjectedWithGuiceAnnotation, injected.methodInjectedWithGuiceAnnotation);
assertSame(methodInjectedWithCustomAnnotation, injected.methodInjectedWithCustomAnnotation);

assertSame(fieldInjected, injected.fieldInjected);
assertSame(fieldInjectedWithJavaAnnotation, injected.fieldInjectedWithJavaAnnotation);
assertSame(fieldInjectedWithGuiceAnnotation, injected.fieldInjectedWithGuiceAnnotation);
assertSame(fieldInjectedWithCustomAnnotation, injected.fieldInjectedWithCustomAnnotation);
}

/* ===================================================================== */
Expand Down
Loading

0 comments on commit e955c90

Please sign in to comment.