From aefdb477984bf64509bf0cf814e89c26d5b60bbb Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Mon, 11 Mar 2019 13:53:52 +0530 Subject: [PATCH] #1330 Remove the tests Removed the tests related to verify the behaviour of Jackson as they just add time it takes Micronaut to build. --- .../parser/JacksonProcessorSpec.groovy | 274 ------------------ 1 file changed, 274 deletions(-) diff --git a/runtime/src/test/groovy/io/micronaut/jackson/parser/JacksonProcessorSpec.groovy b/runtime/src/test/groovy/io/micronaut/jackson/parser/JacksonProcessorSpec.groovy index 061a328014c..c45b31c0f4d 100644 --- a/runtime/src/test/groovy/io/micronaut/jackson/parser/JacksonProcessorSpec.groovy +++ b/runtime/src/test/groovy/io/micronaut/jackson/parser/JacksonProcessorSpec.groovy @@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode import groovy.transform.ToString import io.micronaut.context.ApplicationContext import io.micronaut.context.DefaultApplicationContext -import io.micronaut.context.env.PropertySource import org.reactivestreams.Subscriber import org.reactivestreams.Subscription import spock.lang.AutoCleanup @@ -106,223 +105,6 @@ class JacksonProcessorSpec extends Specification { foo.age == 10 } - void "test Jackson polymorphic deserialization"() { - given: - ObjectMapper objectMapper = applicationContext.getBean(ObjectMapper) - JacksonProcessor processor = new JacksonProcessor() - Bicycle bicycle = new MountainBike(3, 30, 10) - Garage instance = new Garage(bicycle: bicycle) - - when: - def string = objectMapper.writeValueAsString(instance) - byte[] bytes = objectMapper.writeValueAsBytes(instance) - boolean complete = false - JsonNode node = null - Throwable error = null - int nodeCount = 0 - processor.subscribe(new Subscriber() { - @Override - void onSubscribe(Subscription s) { - s.request(Long.MAX_VALUE) - } - - @Override - void onNext(JsonNode jsonNode) { - nodeCount++ - node = jsonNode - } - - @Override - void onError(Throwable t) { - error = t - } - - @Override - void onComplete() { - complete = true - } - }) - processor.onSubscribe(new Subscription() { - @Override - void request(long n) { - - } - - @Override - void cancel() { - - } - }) - processor.onNext(bytes) - processor.onComplete() - - then: - complete - node != null - error == null - nodeCount == 1 - string == '{"bicycle":{"gear":3,"speed":30,"seatHeight":10}}' - - when: - Garage garage = objectMapper.treeToValue(node, Garage) - - then: - !(garage.bicycle instanceof MountainBike) - } - - void "test Jackson polymorphic deserialization, per class"() { - given: - ObjectMapper objectMapper = applicationContext.getBean(ObjectMapper) - JacksonProcessor processor = new JacksonProcessor() - Dog dog = new Dog(name: "Daisy", barkVolume: 1111.1D) - Zoo instance = new Zoo(animal: dog) - - when: - def string = objectMapper.writeValueAsString(instance) - byte[] bytes = objectMapper.writeValueAsBytes(instance) - boolean complete = false - JsonNode node = null - Throwable error = null - int nodeCount = 0 - processor.subscribe(new Subscriber() { - @Override - void onSubscribe(Subscription s) { - s.request(Long.MAX_VALUE) - } - - @Override - void onNext(JsonNode jsonNode) { - nodeCount++ - node = jsonNode - } - - @Override - void onError(Throwable t) { - error = t - } - - @Override - void onComplete() { - complete = true - } - }) - processor.onSubscribe(new Subscription() { - @Override - void request(long n) { - - } - - @Override - void cancel() { - - } - }) - processor.onNext(bytes) - processor.onComplete() - - then: - complete - node != null - error == null - nodeCount == 1 - string == '{"animal":{"@class":"io.micronaut.jackson.parser.Dog","name":"Daisy","barkVolume":1111.1}}' - - when: - Zoo zoo = objectMapper.treeToValue(node, Zoo) - - then: - zoo.animal instanceof Dog - - when: - Dog animal = (Dog) zoo.animal - - then: - animal != null - animal.name == "Daisy" - animal.barkVolume == 1111.1D - } - - void "test Jackson polymorphic deserialization, global default typing"() { - given: - ApplicationContext applicationContext1 = new DefaultApplicationContext("test") - applicationContext1.environment.addPropertySource(PropertySource.of( - 'test', ['jackson.defaultTyping':'NON_FINAL'] - )) - applicationContext1 = applicationContext1.start() - ObjectMapper objectMapper = applicationContext1.getBean(ObjectMapper) - JacksonProcessor processor = new JacksonProcessor() - Bicycle bicycle = new MountainBike(3, 30, 10) - Garage instance = new Garage(bicycle: bicycle) - - when: - def string = objectMapper.writeValueAsString(instance) - byte[] bytes = objectMapper.writeValueAsBytes(instance) - boolean complete = false - JsonNode node = null - Throwable error = null - int nodeCount = 0 - processor.subscribe(new Subscriber() { - @Override - void onSubscribe(Subscription s) { - s.request(Long.MAX_VALUE) - } - - @Override - void onNext(JsonNode jsonNode) { - nodeCount++ - node = jsonNode - } - - @Override - void onError(Throwable t) { - error = t - } - - @Override - void onComplete() { - complete = true - } - }) - processor.onSubscribe(new Subscription() { - @Override - void request(long n) { - - } - - @Override - void cancel() { - - } - }) - processor.onNext(bytes) - processor.onComplete() - - then: - complete - node != null - error == null - nodeCount == 1 - string == '["io.micronaut.jackson.parser.Garage",{"bicycle":["io.micronaut.jackson.parser.MountainBike",{"gear":3,"speed":30,"seatHeight":10}]}]' - - when: - Garage garage = objectMapper.treeToValue(node, Garage) - - then: - garage.bicycle instanceof MountainBike - - when: - MountainBike mountainBike = (MountainBike) garage.bicycle - - then: - mountainBike != null - mountainBike.gear == 3 - mountainBike.speed == 30 - mountainBike.seatHeight == 10 - - cleanup: - applicationContext1.close() - } - void "test publish JSON array async"() { given: @@ -508,59 +290,3 @@ class Foo { String name Integer age } - -@ToString -class Garage { - String name - Bicycle bicycle -} - -@ToString -class Bicycle { - int gear - int speed - - Bicycle() {} - - Bicycle(int gear, int speed) { - this.gear = gear - this.speed = speed - } - - void applyBrake(int decrement) { - speed -= decrement - } - - void speedUp(int increment) { - speed += increment - } -} - -@ToString -class MountainBike extends Bicycle { - int seatHeight - - MountainBike() {} - - MountainBike(int gear,int speed, int seatHeight) { - super(gear, speed) - this.seatHeight = seatHeight - } -} - -@ToString -class Zoo { - Animal animal -} - -@ToString -@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class") -class Animal { - String name -} - -@ToString -class Dog extends Animal { - double barkVolume - -}