Skip to content

Commit 336d85c

Browse files
author
Bruce Eckel
committed
Trying to get everything to build with JUnit5
1 parent 2ca00a4 commit 336d85c

22 files changed

+238
-198
lines changed

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ subprojects {
191191
main {
192192
java {
193193
srcDir projectDir
194-
exclude "*Test.java"
194+
// exclude "*Test.java"
195195
exclude "*Tests.java"
196196
exclude "*JUnit.java"
197197
exclude "StringInverter*.java"
198-
exclude "Queue.java"
198+
// exclude "Queue.java"
199199
}
200200
resources {
201201
srcDir projectDir
@@ -207,11 +207,11 @@ subprojects {
207207
srcDir projectDir
208208
}
209209
}
210-
test {
210+
/* test {
211211
java {
212212
srcDir projectDir
213213
}
214-
}
214+
}*/
215215
}
216216

217217
/*test {

generics/Amphibian.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// generics/Amphibian.java
2+
// (c)2016 MindView LLC: see Copyright.txt
3+
// We make no guarantees that this code is fit for any purpose.
4+
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5+
public class Amphibian {}

generics/ApplyTest.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,6 @@
66
import java.util.function.*;
77
import onjava.*;
88

9-
class Shape {
10-
private static long counter = 0;
11-
private final long id = counter++;
12-
@Override
13-
public String toString() {
14-
return getClass().getSimpleName() + " " + id;
15-
}
16-
public void rotate() {
17-
System.out.println(this + " rotate");
18-
}
19-
public void resize(int newSize) {
20-
System.out.println(this + " resize " + newSize);
21-
}
22-
}
23-
24-
class Square extends Shape {}
25-
26-
class FilledList<T> extends ArrayList<T> {
27-
public FilledList(Supplier<T> gen, int size) {
28-
Suppliers.fill(this, gen, size);
29-
}
30-
}
31-
329
public class ApplyTest {
3310
public static void main(String[] args) throws Exception {
3411
List<Shape> shapes =

generics/FilledList.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// generics/FilledList.java
2+
// (c)2016 MindView LLC: see Copyright.txt
3+
// We make no guarantees that this code is fit for any purpose.
4+
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5+
import java.util.*;
6+
import java.util.function.*;
7+
import onjava.*;
8+
9+
class FilledList<T> extends ArrayList<T> {
10+
public FilledList(Supplier<T> gen, int size) {
11+
Suppliers.fill(this, gen, size);
12+
}
13+
public FilledList(T t, int size) {
14+
for(int i = 0; i < size; i++)
15+
this.add(t);
16+
}
17+
public static void main(String[] args) {
18+
List<String> list = new FilledList<>("Hello", 4);
19+
System.out.println(list);
20+
// Supplier version:
21+
List<Integer> ilist = new FilledList<>(() -> 47, 4);
22+
System.out.println(ilist);
23+
}
24+
}
25+
/* Output:
26+
[Hello, Hello, Hello, Hello]
27+
[47, 47, 47, 47]
28+
*/

generics/FilledListMaker.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

generics/MultipleInterfaceVariants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
// {CompileTimeError} (Will not compile)
6+
package generics;
67

78
interface Payable<T> {}
89

generics/Shape.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// generics/Shape.java
2+
// (c)2016 MindView LLC: see Copyright.txt
3+
// We make no guarantees that this code is fit for any purpose.
4+
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5+
6+
public class Shape {
7+
private static long counter = 0;
8+
private final long id = counter++;
9+
@Override
10+
public String toString() {
11+
return getClass().getSimpleName() + " " + id;
12+
}
13+
public void rotate() {
14+
System.out.println(this + " rotate");
15+
}
16+
public void resize(int newSize) {
17+
System.out.println(this + " resize " + newSize);
18+
}
19+
}

generics/SimpleQueue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// (c)2016 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5-
// A different kind of collection that is Iterable
5+
// A different kind of Iterable collection
66
import java.util.*;
77

88
public class SimpleQueue<T> implements Iterable<T> {

generics/Square.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// generics/Square.java
2+
// (c)2016 MindView LLC: see Copyright.txt
3+
// We make no guarantees that this code is fit for any purpose.
4+
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5+
public class Square extends Shape {}

generics/TupleTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
55
import onjava.*;
66

7-
class Amphibian {}
8-
class Vehicle {}
9-
107
public class TupleTest {
118
static Tuple2<String, Integer> f() {
129
// Autoboxing converts the int to Integer:

0 commit comments

Comments
 (0)