Skip to content

Commit e7f3ae1

Browse files
philwebbwilkinsona
andcommitted
Add Jackson 2 smoke tests
See gh-47688 Co-authored-by: Andy Wilkinson <[email protected]>
1 parent ca37f4e commit e7f3ae1

File tree

19 files changed

+643
-0
lines changed

19 files changed

+643
-0
lines changed

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ include ":smoke-test:spring-boot-smoke-test-graphql"
414414
include ":smoke-test:spring-boot-smoke-test-hateoas"
415415
include ":smoke-test:spring-boot-smoke-test-hibernate"
416416
include ":smoke-test:spring-boot-smoke-test-integration"
417+
include ":smoke-test:spring-boot-smoke-test-jackson2-mixed"
418+
include ":smoke-test:spring-boot-smoke-test-jackson2-only"
417419
include ":smoke-test:spring-boot-smoke-test-jetty"
418420
include ":smoke-test:spring-boot-smoke-test-jetty-jsp"
419421
include ":smoke-test:spring-boot-smoke-test-jetty-ssl"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the License);
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id "java"
19+
}
20+
21+
description = "Spring Boot Jackson 2 mixed with Jackson 3 smoke test"
22+
23+
dependencies {
24+
implementation(project(":module:spring-boot-jackson2"))
25+
implementation(project(":starter:spring-boot-starter-actuator"))
26+
implementation(project(":starter:spring-boot-starter-webmvc"))
27+
28+
testImplementation(project(":starter:spring-boot-starter-test"))
29+
testImplementation(project(":starter:spring-boot-starter-webmvc-test"))
30+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.jackson2.mixed;
18+
19+
public record Name(String first, String last) {
20+
21+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.jackson2.mixed;
18+
19+
import java.util.List;
20+
21+
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
22+
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
23+
import org.springframework.stereotype.Component;
24+
25+
/**
26+
* Names endpoint.
27+
*
28+
* @author Andy Wilkinson
29+
*/
30+
@Component
31+
@Endpoint(id = "names")
32+
public class NamesEndpoint {
33+
34+
@ReadOperation
35+
List<Name> names() {
36+
return List.of(new Name("Spring", "Boot"));
37+
}
38+
39+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.jackson2.mixed;
18+
19+
import java.util.List;
20+
21+
import org.springframework.web.bind.annotation.GetMapping;
22+
import org.springframework.web.bind.annotation.RestController;
23+
24+
@RestController
25+
public class SampleController {
26+
27+
@GetMapping("/names")
28+
List<Name> names() {
29+
return List.of(new Name("Spring", "Boot"));
30+
}
31+
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.jackson2.mixed;
18+
19+
import org.springframework.boot.SpringApplication;
20+
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
22+
@SpringBootApplication
23+
public class SampleJackson2MixedApplication {
24+
25+
public static void main(String[] args) {
26+
SpringApplication.run(SampleJackson2MixedApplication.class, args);
27+
}
28+
29+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.jackson2.mixed;
18+
19+
import tools.jackson.core.JacksonException;
20+
import tools.jackson.core.JsonGenerator;
21+
import tools.jackson.databind.SerializationContext;
22+
import tools.jackson.databind.ValueSerializer;
23+
24+
import org.springframework.boot.jackson.JacksonComponent;
25+
26+
@JacksonComponent
27+
public class SampleJacksonComponent {
28+
29+
public static class Serializer extends ValueSerializer<Name> {
30+
31+
@Override
32+
public void serialize(Name value, JsonGenerator gen, SerializationContext ctxt) throws JacksonException {
33+
gen.writeString("JACKSON:%s:%s".formatted(value.first(), value.last()));
34+
}
35+
36+
}
37+
38+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package smoketest.jackson2.mixed;
18+
19+
import java.io.IOException;
20+
21+
import com.fasterxml.jackson.core.JsonGenerator;
22+
import com.fasterxml.jackson.databind.JsonSerializer;
23+
import com.fasterxml.jackson.databind.SerializerProvider;
24+
25+
import org.springframework.boot.jackson2.JsonComponent;
26+
27+
@JsonComponent
28+
@SuppressWarnings("removal")
29+
public class SampleJsonComponent {
30+
31+
public static class Serializer extends JsonSerializer<Name> {
32+
33+
@Override
34+
public void serialize(Name value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
35+
gen.writeString("JACKSON2:%s:%s".formatted(value.first(), value.last()));
36+
}
37+
38+
}
39+
40+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@NullMarked
18+
package smoketest.jackson2.mixed;
19+
20+
import org.jspecify.annotations.NullMarked;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
management.endpoints.web.exposure.include=*
2+
spring.http.converters.preferred-json-mapper=jackson2

0 commit comments

Comments
 (0)