Skip to content

Commit c30663c

Browse files
authored
Removing all API calls not compatible with Java 1.5 (#9)
1 parent 55db6a2 commit c30663c

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

src/main/java/com/github/karczews/utilsverifier/UtilsVerifier.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ private void verifyPrivateConstructor() {
198198
if (!suppressPrivateConstructorCheck && !Modifier.isPrivate(constructor.getModifiers())) {
199199
throw new AssertionError("Constructor should be private");
200200
}
201-
} catch (final NoSuchMethodException noSuchMethod) {
202-
throw new AssertionError(classUnderTest.getSimpleName() + " has no constructor", noSuchMethod);
201+
} catch (final NoSuchMethodException ignore) {
202+
throw new AssertionError(classUnderTest.getSimpleName() + " has no constructor");
203203
}
204204

205205
try {
@@ -213,7 +213,7 @@ private void verifyPrivateConstructor() {
213213
throw new AssertionError("expected exception: " + expectedConstructorException.getName() +
214214
" got: " + e.getTargetException().getClass().getName());
215215
}
216-
} catch (final ReflectiveOperationException e) {
216+
} catch (final Exception e) {
217217
throw new IllegalStateException(e);
218218
}
219219
}

src/test/java/com/github/karczews/utilsverifier/UtilsVerifierTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.github.karczews.utilsverifier.subjects.InstanceMethods;
2121
import com.github.karczews.utilsverifier.subjects.MultipleConstructors;
2222
import com.github.karczews.utilsverifier.subjects.MutableStaticFields;
23+
import com.github.karczews.utilsverifier.subjects.NoConstructor;
2324
import com.github.karczews.utilsverifier.subjects.NonFinalClass;
2425
import com.github.karczews.utilsverifier.subjects.NonPrivateConstructor;
2526
import com.github.karczews.utilsverifier.subjects.ThrowingConstructor;
@@ -89,8 +90,9 @@ public void shouldFailOnInstanceMethod() {
8990
}
9091

9192
@Test
92-
public void shouldFailWhenNoConstructor() {
93+
public void shouldFailWhenOnlyADefaultPublicConstructor() {
9394
expectedException.expect(AssertionError.class);
95+
expectedException.expectMessage(containsString("should be private"));
9496

9597
suppressedVerifier(DefaultConstructor.class)
9698
.suppressPrivateConstructorCheck(false)
@@ -107,6 +109,16 @@ public void shouldFailWhenNoPrivateConstructor() {
107109
.verify();
108110
}
109111

112+
@Test
113+
public void shouldFailWhenNoConstructor() {
114+
expectedException.expect(AssertionError.class);
115+
expectedException.expectMessage(containsString("has no constructor"));
116+
117+
suppressedVerifier(NoConstructor.class)
118+
.suppressPrivateConstructorCheck(false)
119+
.verify();
120+
}
121+
110122
@Test
111123
public void shouldFailOnMultipleConstructors() {
112124
expectedException.expect(AssertionError.class);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright (c) 2017-present, UtilsVerifier Contributors.
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5+
* compliance with the License. You may obtain a copy of the License at
6+
* <p>
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* <p>
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is
10+
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11+
* the License for the specific language governing permissions and limitations under the License.
12+
*/
13+
package com.github.karczews.utilsverifier.subjects;
14+
15+
public interface NoConstructor {
16+
}

0 commit comments

Comments
 (0)