Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit 3b7003b

Browse files
authored
Merge pull request #105 from cpwright/test_for_issue102
Test for default interfaces.
2 parents 72f1f3c + 8f364b5 commit 3b7003b

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2015 Brockmann Consult GmbH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.jpy.fixtures;
18+
19+
import static org.jpy.fixtures.MethodOverloadTestFixture.stringifyArgs;
20+
21+
/**
22+
* Used as a test class for the test cases in jpy_overload_test.py
23+
*
24+
* @author Charles Wright
25+
*/
26+
@SuppressWarnings("UnusedDeclaration")
27+
public class DefaultInterfaceImplTestFixture implements DefaultInterfaceTestFixture {
28+
public int doIt() {
29+
return 2;
30+
}
31+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2015 Brockmann Consult GmbH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.jpy.fixtures;
18+
19+
import static org.jpy.fixtures.MethodOverloadTestFixture.stringifyArgs;
20+
21+
/**
22+
* Used as a test class for the test cases in jpy_overload_test.py
23+
*
24+
* @author Charles Wright
25+
*/
26+
@SuppressWarnings("UnusedDeclaration")
27+
public interface DefaultInterfaceTestFixture {
28+
int doIt();
29+
30+
default public int doItPlusOne() {
31+
return 1 + doIt();
32+
}
33+
}

src/test/python/jpy_overload_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ def test_toReproduceAndFixIssue54(self):
129129
# without the fix, we get str(s) = "java.lang.String@xxxxxx"
130130
self.assertEqual(str(s), '[A, B, C]')
131131

132+
class TestDefaultMethods(unittest.TestCase):
133+
def setUp(self):
134+
self.Fixture = jpy.get_type('org.jpy.fixtures.DefaultInterfaceImplTestFixture')
135+
self.assertIsNotNone(self.Fixture)
136+
137+
# see https://github.com/bcdev/jpy/issues/102
138+
def test_defaultedInterfaces(self):
139+
fixture = self.Fixture()
140+
self.assertEqual(fixture.doItPlusOne(), 3)
141+
132142

133143
if __name__ == '__main__':
134144
print('\nRunning ' + __file__)

0 commit comments

Comments
 (0)