0

Hi I am having a strange issue I am using spring data rest with spring boot for my rest api . Also I am doing some customization via jackson modules to add a custom BeanSerializerModifier to perform some filtering opertaions.The weird part is the beanserializer works fine while using eclipse test cases which is the below method

public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc,
     List<BeanPropertyWriter> beanProperties){

is applied to each class entity as well as spring data rest wrappers like PagedResources and HalLinks .But when I run the same via maven test cases it doesn't get applied (or gets skipped) on entity classes not sure why ?

the code how I am registering jackson modules is as below

@Configuration
public class JacksonCustomizations {

    private @Autowired FilteringSerializerModifier serializerModifier;

    @Autowired(required = true)
    public void configeJackson(Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder) {
        jackson2ObjectMapperBuilder.modules(new HfdServicesModule());
    }

    /*
     * @Autowired CustomIntrospector customIntrospector;
     */

  /*  public @Bean Module hfServicesModule() {

        return new HfServicesModule();
    }*/

    @SuppressWarnings("serial")
    class HfdServicesModule extends SimpleModule {
        public HfServicesModule() {
            setSerializerModifier(serializerModifier);

        }

        @Override
        public void setupModule(SetupContext context) {

            super.setupModule(context);
        }
}

Let me know what I am missing .

Gaurav Rawat
  • 1,294
  • 1
  • 25
  • 52

1 Answers1

0

Hi finally figured out that the issue is with maven reuseFork .The answer here helped me in understanding the same JUnit tests pass in Eclipse but fail in Maven Surefire

so for the fix I had to just put this in the maven surefore plugin

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
    <reuseForks>false</reuseForks>
    <forkCount>1</forkCount>
</configuration>

Hope it Helps ..

Community
  • 1
  • 1
Gaurav Rawat
  • 1,294
  • 1
  • 25
  • 52