Skip to content

Commit d640a9f

Browse files
Update junit [4.12 -> 4.13], use assertThrows instead of rule.
1 parent a95f2f0 commit d640a9f

File tree

6 files changed

+39
-27
lines changed

6 files changed

+39
-27
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ buildscript {
2828
objectboxNativeDependency = "io.objectbox:objectbox-$objectboxPlatform:$ob_native_version"
2929
println "ObjectBox native dependency: $objectboxNativeDependency"
3030
}
31+
ext.junit_version = '4.13'
3132

3233
repositories {
3334
mavenCentral()

objectbox-kotlin/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ dependencies {
5858
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
5959

6060
compile project(':objectbox-java')
61-
62-
//testCompile 'junit:junit:4.12'
6361
}
6462

6563

objectbox-rxjava/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99
compile project(':objectbox-java')
1010
compile 'io.reactivex.rxjava2:rxjava:2.2.9'
1111

12-
testCompile 'junit:junit:4.12'
12+
testCompile "junit:junit:$junit_version"
1313
testCompile 'org.mockito:mockito-core:2.25.1'
1414
}
1515

tests/objectbox-java-test/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies {
3333
println "Did NOT add native dependency"
3434
}
3535

36-
testCompile 'junit:junit:4.12'
36+
testCompile "junit:junit:$junit_version"
3737
}
3838

3939
test {

tests/objectbox-java-test/src/test/java/io/objectbox/query/PropertyQueryTest.java

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,39 @@
1616

1717
package io.objectbox.query;
1818

19+
import org.junit.Test;
20+
21+
import java.util.Arrays;
22+
import java.util.List;
23+
1924
import io.objectbox.TestEntity;
2025
import io.objectbox.TestEntityCursor;
2126
import io.objectbox.exception.DbException;
2227
import io.objectbox.exception.NumericOverflowException;
2328
import io.objectbox.query.QueryBuilder.StringOrder;
24-
import org.junit.Rule;
25-
import org.junit.Test;
26-
import org.junit.rules.ExpectedException;
2729

28-
import java.util.Arrays;
29-
import java.util.List;
3030

31-
import static io.objectbox.TestEntity_.*;
32-
import static org.junit.Assert.*;
31+
import static io.objectbox.TestEntity_.simpleBoolean;
32+
import static io.objectbox.TestEntity_.simpleByte;
33+
import static io.objectbox.TestEntity_.simpleByteArray;
34+
import static io.objectbox.TestEntity_.simpleDouble;
35+
import static io.objectbox.TestEntity_.simpleFloat;
36+
import static io.objectbox.TestEntity_.simpleInt;
37+
import static io.objectbox.TestEntity_.simpleIntU;
38+
import static io.objectbox.TestEntity_.simpleLong;
39+
import static io.objectbox.TestEntity_.simpleLongU;
40+
import static io.objectbox.TestEntity_.simpleShort;
41+
import static io.objectbox.TestEntity_.simpleShortU;
42+
import static io.objectbox.TestEntity_.simpleString;
43+
import static org.junit.Assert.assertEquals;
44+
import static org.junit.Assert.assertFalse;
45+
import static org.junit.Assert.assertNull;
46+
import static org.junit.Assert.assertThrows;
47+
import static org.junit.Assert.assertTrue;
48+
import static org.junit.Assert.fail;
3349

3450
public class PropertyQueryTest extends AbstractQueryTest {
3551

36-
@Rule
37-
public ExpectedException exceptionRule = ExpectedException.none();
38-
3952
private void putTestEntityInteger(byte vByte, short vShort, int vInt, long vLong) {
4053
TestEntity entity = new TestEntity();
4154
entity.setSimpleByte(vByte);
@@ -753,35 +766,35 @@ public void sum_unsignedShortIntOverflow() {
753766

754767
@Test
755768
public void sum_longOverflow_exception() {
756-
exceptionRule.expect(NumericOverflowException.class);
757-
exceptionRule.expectMessage("Numeric overflow");
758-
759769
putTestEntityInteger((byte) 0, (short) 0, 0, Long.MAX_VALUE);
760770
putTestEntityInteger((byte) 0, (short) 0, 0, 1);
761771

762-
box.query().build().property(simpleLong).sum();
772+
NumericOverflowException exception = assertThrows(NumericOverflowException.class, () ->
773+
box.query().build().property(simpleLong).sum()
774+
);
775+
assertTrue(exception.getMessage().contains("Numeric overflow"));
763776
}
764777

765778
@Test
766779
public void sum_longUnderflow_exception() {
767-
exceptionRule.expect(NumericOverflowException.class);
768-
exceptionRule.expectMessage("Numeric overflow");
769-
770780
putTestEntityInteger((byte) 0, (short) 0, 0, Long.MIN_VALUE);
771781
putTestEntityInteger((byte) 0, (short) 0, 0, -1);
772782

773-
box.query().build().property(simpleLong).sum();
783+
NumericOverflowException exception = assertThrows(NumericOverflowException.class, () ->
784+
box.query().build().property(simpleLong).sum()
785+
);
786+
assertTrue(exception.getMessage().contains("Numeric overflow"));
774787
}
775788

776789
@Test
777790
public void sum_unsignedLongOverflow_exception() {
778-
exceptionRule.expect(NumericOverflowException.class);
779-
exceptionRule.expectMessage("Numeric overflow");
780-
781791
putTestEntityUnsignedInteger((short) 0, 0, -1);
782792
putTestEntityUnsignedInteger((short) 0, 0, 1);
783793

784-
box.query().build().property(simpleLongU).sum();
794+
NumericOverflowException exception = assertThrows(NumericOverflowException.class, () ->
795+
box.query().build().property(simpleLongU).sum()
796+
);
797+
assertTrue(exception.getMessage().contains("Numeric overflow"));
785798
}
786799

787800
@Test

tests/test-proguard/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ dependencies {
3333
println "Did NOT add native dependency"
3434
}
3535

36-
testCompile 'junit:junit:4.12'
36+
testCompile "junit:junit:$junit_version"
3737
}

0 commit comments

Comments
 (0)