Skip to content

Commit c1861d1

Browse files
committed
Merge pull request #1 from wavesoftware/feature/support-for-jdk6
Support for compatibility with JDK 1.6
2 parents c221fa2 + 062d9d3 commit c1861d1

File tree

9 files changed

+36
-25
lines changed

9 files changed

+36
-25
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ script: mvn clean install -Pci
44
notifications:
55
email: false
66
jdk:
7+
- openjdk6
78
- openjdk7
8-
- oraclejdk8
99
- oraclejdk7
10+
- oraclejdk8

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This classes shouldn't be used in any public API or library. It is designed to b
1010

1111
## Requirements
1212

13-
* JDK >= 1.7
13+
* JDK >= 1.6
1414

1515
## Maven
1616

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<groupId>pl.wavesoftware</groupId>
1212
<artifactId>eid-exceptions</artifactId>
13-
<version>0.1.1-SNAPSHOT</version>
13+
<version>1.0.0-SNAPSHOT</version>
1414
<packaging>jar</packaging>
1515

1616
<name>EID Runtime Exceptions and Utilities</name>
@@ -23,8 +23,8 @@
2323
<netbeans.hint.license>apache20</netbeans.hint.license>
2424
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2525
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
26-
<maven.compiler.source>1.7</maven.compiler.source>
27-
<maven.compiler.target>1.7</maven.compiler.target>
26+
<maven.compiler.source>1.6</maven.compiler.source>
27+
<maven.compiler.target>1.6</maven.compiler.target>
2828
<coveralls.skip>${skipTests}</coveralls.skip>
2929
</properties>
3030

@@ -58,7 +58,7 @@
5858
<dependency>
5959
<groupId>org.assertj</groupId>
6060
<artifactId>assertj-core</artifactId>
61-
<version>2.1.0</version>
61+
<version>1.7.1</version> <!-- For compatibility with JDK 1.6 -->
6262
<scope>test</scope>
6363
</dependency>
6464
<dependency>
@@ -86,7 +86,7 @@
8686
<plugin>
8787
<groupId>org.jacoco</groupId>
8888
<artifactId>jacoco-maven-plugin</artifactId>
89-
<version>0.7.4.201502262128</version>
89+
<version>0.7.4.201502262128</version> <!-- 0.7.5 fails on SONAR -->
9090

9191
<executions>
9292
<execution>

src/main/java/pl/wavesoftware/eid/exceptions/Eid.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public Eid(String id) {
9393
* @throws IllegalArgumentException if given format hasn't got two format specifiers <tt>"%s"</tt>, or if given format was
9494
* null
9595
*/
96+
@SuppressWarnings("UnusedReturnValue")
9697
public static String setMessageFormat(String format) {
9798
validateFormat(format, MESSAGE_FORMAT_NUM_SPEC);
9899
String oldFormat = Eid.messageFormat;
@@ -195,7 +196,7 @@ private static void validateFormat(String format, int numSpecifiers) {
195196
if (format == null) {
196197
throw new IllegalArgumentException("Format can't be null, but just received one");
197198
}
198-
List<String> specifiers = new ArrayList<>();
199+
List<String> specifiers = new ArrayList<String>();
199200
for (int i = 0; i < numSpecifiers; i++) {
200201
specifiers.add(i + "-test-id");
201202
}

src/main/java/pl/wavesoftware/eid/utils/EidPreconditions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
* @since 0.1.0 (idea imported from Guava Library and COI code)
105105
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
106106
*/
107+
@SuppressWarnings("WeakerAccess")
107108
public final class EidPreconditions {
108109

109110
protected EidPreconditions() {
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/sh
22
unset MAVEN_OPTS
33
unset JAVA_TOOL_OPTIONS
4-
exec mvn -Pci sonar:sonar \
5-
-DskipTests \
6-
-Dsonar.language=java \
7-
-Dsonar.analysis.mode=incremental \
8-
-Dsonar.host.url=https://sonar.wavesoftware.pl \
9-
-Dsonar.preview.excludePlugins=buildstability,devcockpit,pdfreport,report,views,jira,buildbreaker,issueassign,scmstats
4+
exec mvn -P ci sonar:sonar \
5+
-D skipTests \
6+
-D sonar.language=java \
7+
-D sonar.analysis.mode=incremental \
8+
-D sonar.host.url=https://sonar.wavesoftware.pl \
9+
-D sonar.preview.excludePlugins=buildstability,devcockpit,pdfreport,report,views,jira,buildbreaker,issueassign,scmstats

src/test/java/pl/wavesoftware/eid/exceptions/EidTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
*
2727
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2828
*/
29+
@SuppressWarnings({"ConstantConditions", "unused"})
2930
public class EidTest {
3031

3132
@Rule
32-
public ExpectedException thrown = ExpectedException.none();
33+
public final ExpectedException thrown = ExpectedException.none();
3334

3435
@Test
3536
public void testSetMessageFormat_Null() {

src/test/java/pl/wavesoftware/eid/exceptions/ExceptionsTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*
3232
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
3333
*/
34+
@SuppressWarnings("unused")
3435
@RunWith(Parameterized.class)
3536
public class ExceptionsTest {
3637

@@ -104,7 +105,9 @@ private static void addParameters(Map.Entry<Class<? extends EidRuntimeException>
104105
constructor,
105106
args
106107
});
107-
} catch (NoSuchMethodException | SecurityException ex) {
108+
} catch (NoSuchMethodException ex) {
109+
throw new RuntimeException(ex);
110+
} catch (SecurityException ex) {
108111
throw new RuntimeException(ex);
109112
}
110113
}
@@ -158,7 +161,13 @@ public void testConstruction() {
158161
private <T extends EidRuntimeException> T construct() {
159162
try {
160163
return (T) constructor.newInstance(arguments);
161-
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
164+
} catch (InstantiationException ex) {
165+
throw new RuntimeException(ex);
166+
} catch (IllegalAccessException ex) {
167+
throw new RuntimeException(ex);
168+
} catch (IllegalArgumentException ex) {
169+
throw new RuntimeException(ex);
170+
} catch (InvocationTargetException ex) {
162171
throw new RuntimeException(ex);
163172
}
164173
}

src/test/java/pl/wavesoftware/eid/utils/EidPreconditionsTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.hamcrest.Matcher;
2424
import org.hamcrest.Matchers;
2525
import static org.hamcrest.Matchers.*;
26-
import org.junit.Before;
2726
import org.junit.Rule;
2827
import org.junit.Test;
2928
import static org.junit.internal.matchers.ThrowableMessageMatcher.hasMessage;
@@ -39,17 +38,14 @@
3938
*
4039
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
4140
*/
41+
@SuppressWarnings({"ConstantConditions", "unused"})
4242
public class EidPreconditionsTest {
4343

4444
@Rule
45-
public ExpectedException thrown = ExpectedException.none();
45+
public final ExpectedException thrown = ExpectedException.none();
4646

4747
private final String eid = "20150718:075046";
4848

49-
@Before
50-
public void setUp() throws Exception {
51-
}
52-
5349
@Test
5450
public void testCheckArgument() {
5551
// given
@@ -227,8 +223,8 @@ public String execute() throws InterruptedIOException {
227223
public void testCreate() throws NoSuchMethodException {
228224
// given
229225
Class<EidPreconditions> cls = EidPreconditions.class;
230-
Constructor<?> constr = cls.getDeclaredConstructor();
231-
boolean access = constr.isAccessible();
226+
Constructor<?> constructor = cls.getDeclaredConstructor();
227+
boolean access = constructor.isAccessible();
232228

233229
// then
234230
assertThat(access).isFalse();
@@ -237,6 +233,7 @@ public void testCreate() throws NoSuchMethodException {
237233

238234
@Override
239235
public boolean matches(Object item) {
236+
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
240237
Eid eidObject = EidRuntimeException.class.cast(item).getEid();
241238
return eidObject.getId().equals("20150718:083450")
242239
&& !eidObject.getRef().isEmpty()
@@ -406,6 +403,7 @@ public String execute() {
406403
assertThat(result).isEqualTo(tester);
407404
}
408405

406+
@SuppressWarnings("SameReturnValue")
409407
private Eid getNullEid() {
410408
return null;
411409
}

0 commit comments

Comments
 (0)