Skip to content

Commit

Permalink
Add test for arrays (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Aug 3, 2023
1 parent c926520 commit 3a001a5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions injector/src/test/client/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public static void main(String[] args) throws Exception {
assertEquals(1,a.i());
assertEquals("http://kohsuke.org/",a.o());

String[] array = a.array();
assertEquals(1, array.length);
assertEquals("http://kohsuke.org/", array[0]);

new Adapter.SomeClass().someMethod();

assertEquals(1,a.l());
Expand Down
3 changes: 3 additions & 0 deletions injector/src/test/v1/Adapter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
public class Adapter {
public int i() { return 1; }
public String o() { return "http://kohsuke.org/"; }
public String[] array() {
return new String[]{ "http://kohsuke.org/" };
}

// Just making sure we do not barf on Java 8 constructs:
interface SomeInterface {
Expand Down
13 changes: 13 additions & 0 deletions injector/src/test/v2/Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ private Object _o(URL o, Class type) {
return o.toString();
}

@WithBridgeMethods(value = String[].class, adapterMethod = "_array")
URL[] array() throws IOException {
return new URL[]{ new URL("http://kohsuke.org/") };
}

private Object _array(URL[] array, Class<?> type) {
String[] result = new String[array.length];
for (int i = 0; i < result.length; i++) {
result[i] = array[i].toString();
}
return result;
}

interface SomeInterface {
default void someMethod() {}
}
Expand Down

0 comments on commit 3a001a5

Please sign in to comment.