Skip to content

Commit 6f0c7eb

Browse files
committed
Update test source and target JDK compatibility
"test" source and target compatibility has been upgraded to 1.7 except where noted, allowing us to use 1.7 language features such as diamond-style (<>) generics declarations, automatic resource management and multi-catch. More importantly, we will be able to upgrade to 1.8 once it is available in order to make use of lambda expressions, etc in our test cases. IDE configurations must be relaxed to allow 1.7 across the board, as neither Eclipse nor IDEA are clever enough to allow for different language levels across production and test resources. See [1] for a feature request on that front. spring-oxm is a special case here, and has been pinned at 1.6 compatibility even for its test sources in order to avoid a class verification error that JibX throws when encountering 1.7-level bytecode [2]. Likewise with spring-orm, toplink encounters a similar class verification error, so has been pinned to 1.6 for the time being. When we remove the (already deprecated since 3.2) Toplink support we can restore compatibility to 1.7. [1]: http://youtrack.jetbrains.com/issue/IDEA-97814 [2]: http://jira.codehaus.org/browse/JIBX-465 Issue: SPR-10129
1 parent aa82464 commit 6f0c7eb

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

build.gradle

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ configure(allprojects) {
3232

3333
group = "org.springframework"
3434

35-
sourceCompatibility=1.5
36-
targetCompatibility=1.5
35+
compileJava {
36+
sourceCompatibility=1.5
37+
targetCompatibility=1.5
38+
}
39+
compileTestJava {
40+
sourceCompatibility=1.7
41+
targetCompatibility=1.7
42+
}
3743

3844
[compileJava, compileTestJava]*.options*.compilerArgs = [
3945
"-Xlint:serial",
@@ -333,6 +339,14 @@ project("spring-tx") {
333339
project("spring-oxm") {
334340
description = "Spring Object/XML Marshalling"
335341
apply from: "oxm.gradle"
342+
343+
compileTestJava {
344+
// necessary to avoid java.lang.VerifyError on jibx compilation
345+
// see http://jira.codehaus.org/browse/JIBX-465
346+
sourceCompatibility=1.6
347+
targetCompatibility=1.6
348+
}
349+
336350
dependencies {
337351
compile(project(":spring-beans"))
338352
compile(project(":spring-core"))
@@ -458,6 +472,14 @@ project("spring-web") {
458472

459473
project("spring-orm") {
460474
description = "Spring Object/Relational Mapping"
475+
476+
compileTestJava {
477+
// necessary to avoid java.lang.VerifyError on toplink compilation
478+
// TODO: remove this block when we remove toplink
479+
sourceCompatibility=1.6
480+
targetCompatibility=1.6
481+
}
482+
461483
dependencies {
462484
compile("aopalliance:aopalliance:1.0")
463485
optional("org.hibernate:hibernate-core:3.3.2.GA")

spring-oxm/src/test/java/org/springframework/oxm/castor/CastorUnmarshallerTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,8 @@
2929
import org.springframework.oxm.MarshallingException;
3030
import org.springframework.oxm.Unmarshaller;
3131

32+
import static org.hamcrest.CoreMatchers.*;
33+
3234
import static org.junit.Assert.*;
3335

3436
/**
@@ -66,7 +68,7 @@ protected void testFlights(Object o) {
6668
protected void testFlight(Object o) {
6769
Flight flight = (Flight) o;
6870
assertNotNull("Flight is null", flight);
69-
assertEquals("Number is invalid", 42L, flight.getNumber());
71+
assertThat("Number is invalid", flight.getNumber(), equalTo(42L));
7072
}
7173

7274
@Override
@@ -104,10 +106,10 @@ public void testSetBothTargetClassesAndMapping() throws IOException {
104106
assertEquals("Invalid amount of items", 2, order.getOrderItemCount());
105107
OrderItem item = order.getOrderItem(0);
106108
assertEquals("Invalid items", "1", item.getId());
107-
assertEquals("Invalid items", 15, item.getQuantity());
109+
assertThat("Invalid items", item.getQuantity(), equalTo(15));
108110
item = order.getOrderItem(1);
109111
assertEquals("Invalid items", "3", item.getId());
110-
assertEquals("Invalid items", 20, item.getQuantity());
112+
assertThat("Invalid items", item.getQuantity(), equalTo(20));
111113
}
112114

113115
@Test

0 commit comments

Comments
 (0)