File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
functions/spanner/src/test/java/functions Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 33
33
import java .io .IOException ;
34
34
import java .io .StringWriter ;
35
35
import java .util .logging .Logger ;
36
+ import org .junit .After ;
36
37
import org .junit .AfterClass ;
37
38
import org .junit .Before ;
38
39
import org .junit .BeforeClass ;
44
45
45
46
@ RunWith (JUnit4 .class )
46
47
public class HelloSpannerTest {
48
+ private AutoCloseable mocks ;
47
49
@ Mock private HttpRequest request ;
48
50
@ Mock private HttpResponse response ;
49
51
@ Mock private DatabaseClient client ;
@@ -70,7 +72,7 @@ public static void restoreLogging() {
70
72
71
73
@ Before
72
74
public void beforeTest () throws IOException {
73
- MockitoAnnotations .initMocks (this );
75
+ mocks = MockitoAnnotations .openMocks (this );
74
76
75
77
responseOut = new StringWriter ();
76
78
writerOut = new BufferedWriter (responseOut );
@@ -79,6 +81,13 @@ public void beforeTest() throws IOException {
79
81
logHandler .clear ();
80
82
}
81
83
84
+ @ After
85
+ public void releaseMocks () throws Exception {
86
+ if (mocks != null ) {
87
+ mocks .close ();
88
+ }
89
+ }
90
+
82
91
private void setupSuccessfulMockQuery () {
83
92
ReadContext readContext = mock (ReadContext .class );
84
93
ResultSet resultSet = mock (ResultSet .class );
You can’t perform that action at this time.
0 commit comments