2929import java .io .ByteArrayOutputStream ;
3030import java .io .PrintStream ;
3131import java .util .Collections ;
32- import org .junit .jupiter .api .AfterEach ;
33- import org .junit .jupiter .api .AfterAll ;
34- import org .junit .jupiter .api .BeforeEach ;
35- import org .junit .jupiter .api .BeforeAll ;
36- import org .junit .jupiter .api .Test ;
37- import org .junit .jupiter .api .Timeout ;
38- import java .util .concurrent .TimeUnit ;
39- import org .junit .jupiter .api .extension .ExtendWith ;
40- import org .junit .jupiter .api .extension .ExtendWith ;
32+ import org .junit .After ;
33+ import org .junit .AfterClass ;
34+ import org .junit .Before ;
35+ import org .junit .BeforeClass ;
36+ import org .junit .Test ;
37+ import org .junit .runner .RunWith ;
38+ import org .junit .runners .JUnit4 ;
4139
4240/** Tests for quickstart sample. */
43-
41+ @ RunWith ( JUnit4 . class )
4442@ SuppressWarnings ("checkstyle:abbreviationaswordinname" )
45- class LoggingIT {
43+ public class LoggingIT {
4644
4745 private static final String TEST_LOG = formatForTest ("test-log" );
4846 private static final String STRING_PAYLOAD = "Hello, world!" ;
@@ -69,40 +67,38 @@ private void deleteLog(String logName) throws InterruptedException {
6967 }
7068 }
7169
72- @ BeforeAll
70+ @ BeforeClass
7371 public static void startup () {
7472 logging = LoggingOptions .getDefaultInstance ().getService ();
7573 }
7674
77- @ AfterAll
75+ @ AfterClass
7876 public static void shutDown () throws Exception {
7977 logging .close ();
8078 }
8179
82- @ BeforeEach
83- void setUp () {
80+ @ Before
81+ public void setUp () {
8482 bout = new ByteArrayOutputStream ();
8583 out = new PrintStream (bout );
8684 System .setOut (out );
8785 }
8886
89- @ AfterEach
90- void tearDown () throws Exception {
87+ @ After
88+ public void tearDown () throws Exception {
9189 // Clean up created logs
9290 deleteLog (TEST_LOG );
9391 System .setOut (null );
9492 }
9593
96- @ Test
97- @ Timeout (value = 60000 , unit = TimeUnit .MILLISECONDS )
94+ @ Test (timeout = 60000 )
9895 public void testQuickstartSample () throws Exception {
9996 QuickstartSample .main (TEST_LOG );
10097 String got = bout .toString ();
10198 assertThat (got ).contains (String .format ("Logged: %s" , STRING_PAYLOAD ));
10299 }
103100
104- @ Test
105- @ Timeout (value = 60000 , unit = TimeUnit .MILLISECONDS )
101+ @ Test (timeout = 60000 )
106102 public void testListLogEntriesSample () throws Exception {
107103 // write a log entry
108104 LogEntry entry =
@@ -127,8 +123,7 @@ public void testListLogEntriesSample() throws Exception {
127123 assertThat (bout .toString ().contains (STRING_PAYLOAD2 )).isTrue ();
128124 }
129125
130- @ Test
131- @ Timeout (value = 60000 , unit = TimeUnit .MILLISECONDS )
126+ @ Test (timeout = 60000 )
132127 public void testWriteLogHttpRequestSample () throws Exception {
133128 HttpRequest request =
134129 HttpRequest .newBuilder ()
@@ -155,16 +150,14 @@ public void testWriteLogHttpRequestSample() throws Exception {
155150 assertThat (bout .toString ().contains (request .toString ())).isTrue ();
156151 }
157152
158- @ Test
159- @ Timeout (value = 60000 , unit = TimeUnit .MILLISECONDS )
153+ @ Test (timeout = 60000 )
160154 public void testWriteLogEntrySample () throws Exception {
161155 WriteLogEntry .main (new String [] {TEST_LOG });
162156 String got = bout .toString ();
163157 assertThat (got ).contains (String .format ("Wrote to %s" , TEST_LOG ));
164158 }
165159
166- @ Test
167- @ Timeout (value = 60000 , unit = TimeUnit .MILLISECONDS )
160+ @ Test (timeout = 60000 )
168161 public void testTailLogEntriesSample () throws Exception {
169162 Runnable task =
170163 () -> {
0 commit comments