Skip to content

Commit 6da9170

Browse files
committed
Convert tests to JUnit 5, move samples to sample folder
1 parent de79cee commit 6da9170

File tree

10 files changed

+33
-54
lines changed

10 files changed

+33
-54
lines changed

pom.xml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@
201201
<artifactId>maven-compiler-plugin</artifactId>
202202
<version>3.8.1</version>
203203
</plugin>
204+
<plugin>
205+
<groupId>org.apache.maven.plugins</groupId>
206+
<artifactId>maven-surefire-plugin</artifactId>
207+
<version>3.0.0-M5</version>
208+
</plugin>
204209

205210
<plugin>
206211
<groupId>org.apache.maven.plugins</groupId>
@@ -284,16 +289,9 @@
284289

285290
<dependency>
286291
<groupId>org.junit.jupiter</groupId>
287-
<artifactId>junit-jupiter-api</artifactId>
288-
<version>5.5.1</version>
292+
<artifactId>junit-jupiter</artifactId>
293+
<version>5.7.0</version>
289294
<scope>test</scope>
290295
</dependency>
291-
<dependency>
292-
<groupId>org.junit.vintage</groupId>
293-
<artifactId>junit-vintage-engine</artifactId>
294-
<version>5.5.1</version>
295-
<scope>test</scope>
296-
</dependency>
297-
298296
</dependencies>
299297
</project>
File renamed without changes.

src/test/java/ca/weblite/objc/NSOpenPanelSample.java renamed to src/sample/java/ca/weblite/objc/samples/NSOpenPanelSample.java

File renamed without changes.

src/test/java/ca/weblite/objc/NSSavePanelSample.java renamed to src/sample/java/ca/weblite/objc/samples/NSSavePanelSample.java

File renamed without changes.
File renamed without changes.

src/test/java/ca/weblite/objc/ClientTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package ca.weblite.objc;
22

3-
import static org.junit.Assert.*;
3+
import static org.junit.jupiter.api.Assertions.*;
44

5-
import org.junit.Test;
5+
import org.junit.jupiter.api.Test;
66

77
/**
88
*

src/test/java/ca/weblite/objc/NSObjectTest.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package ca.weblite.objc;
22

33
import static ca.weblite.objc.RuntimeUtils.*;
4-
import static org.junit.Assert.*;
4+
import static org.junit.jupiter.api.Assertions.*;
55

66
import java.util.List;
77

8-
import org.junit.Test;
8+
import org.junit.jupiter.api.Test;
99

1010
import com.sun.jna.Pointer;
1111
import com.sun.jna.Structure;
@@ -20,8 +20,11 @@ public class NSObjectTest {
2020

2121
public static class NSRange extends Structure {
2222

23-
public static class ByReference extends NSRange implements Structure.ByReference{}
24-
public static class ByValue extends NSRange implements Structure.ByValue{}
23+
public static class ByReference extends NSRange implements Structure.ByReference{
24+
}
25+
public static class ByValue extends NSRange implements Structure.ByValue {
26+
}
27+
2528
public long location;
2629
public int length;
2730

@@ -99,9 +102,7 @@ public void testCustomClass(){
99102

100103
String res = (String)cls.send("myCustomString");
101104
assertEquals("My custom string", res);
102-
System.out.println("Before");
103105
cls.send("setMyCustomString:", "Changed String");
104-
System.out.println("Here now");
105106
res = (String)cls.send("myCustomString");
106107
assertEquals("Changed String", res);
107108

@@ -112,27 +113,22 @@ public void testCustomClass(){
112113
assertEquals(12, cls.sendInt("getCustomInt"));
113114

114115
double dRes = cls.sendDouble("getMyDouble");
115-
System.out.println("The double val is "+dRes);
116116

117-
assertTrue(1.5==dRes);
117+
assertEquals(1.5, dRes);
118118

119119
cls.send("setMyDouble:", 3.0);
120120
dRes = cls.sendDouble("getMyDouble");
121-
//System.out.println("Double is now "+dRes);
122-
//System.out.println("Double is (in java) "+cls.dNum);
123-
assertTrue(3.0==dRes);
121+
assertEquals(3.0, dRes);
122+
assertEquals(3.0, cls.dNum);
124123

125124
Proxy myObj = (Proxy)cls.send("getMyObj");
126-
assertEquals(null, myObj);
125+
assertNull(myObj);
127126

128127
Proxy array = Client.getInstance().sendProxy("NSMutableArray", "array");
129128
cls.send("setMyObj:", array);
130129

131130
myObj = cls.sendProxy("getMyObj");
132131
assertEquals(array, myObj);
133-
134-
135-
136132
}
137133

138134
public static class TestCustomClass extends NSObject {

src/test/java/ca/weblite/objc/ProxyTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package ca.weblite.objc;
22

33
import static ca.weblite.objc.RuntimeUtils.*;
4-
import static org.junit.Assert.*;
4+
import static org.junit.jupiter.api.Assertions.*;
55

66
import java.util.List;
77

8-
import org.junit.Test;
8+
import org.junit.jupiter.api.Test;
99

1010
import com.sun.jna.Pointer;
1111
import com.sun.jna.Structure;
@@ -18,8 +18,11 @@ public class ProxyTest {
1818

1919
public static class NSRange extends Structure {
2020

21-
public static class ByReference extends NSRange implements Structure.ByReference{}
22-
public static class ByValue extends NSRange implements Structure.ByValue{}
21+
public static class ByReference extends NSRange implements Structure.ByReference {
22+
}
23+
public static class ByValue extends NSRange implements Structure.ByValue {
24+
}
25+
2326
public long location;
2427
public int length;
2528

@@ -77,14 +80,11 @@ public void testNSArray() {
7780
Proxy enumerator = o.sendProxy("objectEnumerator");
7881

7982
String placeHolder = (String)enumerator.send("nextObject");
80-
assertEquals(aString, placeHolder);
83+
assertEquals(aString, placeHolder);
8184

8285
Proxy newArray = o.sendProxy("arrayByAddingObject:", "Another String");
8386

8487
assertEquals(2, newArray.sendInt("count"));
85-
86-
87-
8888
}
8989

9090
}

src/test/java/ca/weblite/objc/RuntimeTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package ca.weblite.objc;
22

3-
import static org.junit.Assert.*;
3+
import static org.junit.jupiter.api.Assertions.*;
44

5-
import org.junit.Test;
5+
import org.junit.jupiter.api.Test;
66

77
import com.sun.jna.Pointer;
88

@@ -51,7 +51,6 @@ public void testObjc_lookUpClass() {
5151
Pointer stringPtr = new Pointer(string);
5252

5353

54-
5554
long outStringPtr = Runtime.INSTANCE.objc_msgSend(stringPtr, utf8StringSelector);
5655

5756
//outStringPtr is a pointer to a CString, so let's convert it into
@@ -60,9 +59,6 @@ public void testObjc_lookUpClass() {
6059

6160
String outString = new Pointer(outStringPtr).getString(0);
6261
assertEquals("Test String", outString);
63-
64-
6562
}
6663

67-
6864
}

src/test/java/ca/weblite/objc/RuntimeUtilsTest.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package ca.weblite.objc;
22

33
import static ca.weblite.objc.RuntimeUtils.*;
4-
import static org.junit.Assert.*;
4+
import static org.junit.jupiter.api.Assertions.*;
55

6-
import org.junit.Test;
6+
import org.junit.jupiter.api.Test;
77

88
import com.sun.jna.Pointer;
99

@@ -59,14 +59,10 @@ public void testObjc_lookUpClass() {
5959

6060
String outString = new Pointer(outStringPtr).getString(0);
6161
assertEquals("Test String", outString);
62-
63-
6462
}
6563

6664
@Test
6765
public void testObjc_lookUpClass2() {
68-
69-
7066
// Create a new string with the stringWithUTF8String: message
7167
// We are sending the message directly to the NSString class.
7268
long string = msg("NSString", "stringWithUTF8String:", "Test String");
@@ -79,14 +75,10 @@ public void testObjc_lookUpClass2() {
7975

8076
String outString = new Pointer(outStringPtr).getString(0);
8177
assertEquals("Test String", outString);
82-
83-
8478
}
8579

8680
@Test
8781
public void testObjc_lookUpClass3() {
88-
89-
9082
// Create a new string with the stringWithUTF8String: message
9183
// We are sending the message directly to the NSString class.
9284
// Because we are asking to coerce outputs, this will simply
@@ -136,7 +128,7 @@ public void testObjc_lookUpClass3() {
136128
true,
137129
cls("NSMutableArray"),
138130
sel("array")
139-
);
131+
);
140132

141133

142134
// Add out test string to the array
@@ -155,9 +147,6 @@ public void testObjc_lookUpClass3() {
155147
// directly and have it return a string.
156148
String firstItem = array.sendString("objectAtIndex:", 0);
157149
assertEquals(outString, firstItem);
158-
159-
160-
161150
}
162151

163152
}

0 commit comments

Comments
 (0)