Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 77a0367

Browse files
committed
feat: Revert samples/ directory to match origin/main
1 parent 21f48c6 commit 77a0367

9 files changed

Lines changed: 72 additions & 119 deletions

File tree

samples/install-without-bom/pom.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,9 @@
3333
<!-- [END logging_install_without_bom] -->
3434

3535
<dependency>
36-
<groupId>org.junit.jupiter</groupId>
37-
<artifactId>junit-jupiter-api</artifactId>
38-
<version>5.10.1</version>
39-
<scope>test</scope>
40-
</dependency>
41-
<dependency>
42-
<groupId>org.junit.jupiter</groupId>
43-
<artifactId>junit-jupiter-engine</artifactId>
44-
<version>5.10.1</version>
36+
<groupId>junit</groupId>
37+
<artifactId>junit</artifactId>
38+
<version>4.13.2</version>
4539
<scope>test</scope>
4640
</dependency>
4741
<dependency>

samples/native-image-sample/pom.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,9 @@
4343
</dependency>
4444

4545
<dependency>
46-
<groupId>org.junit.jupiter</groupId>
47-
<artifactId>junit-jupiter-api</artifactId>
48-
<version>5.10.1</version>
49-
<scope>test</scope>
50-
</dependency>
51-
<dependency>
52-
<groupId>org.junit.jupiter</groupId>
53-
<artifactId>junit-jupiter-engine</artifactId>
54-
<version>5.10.1</version>
46+
<groupId>junit</groupId>
47+
<artifactId>junit</artifactId>
48+
<version>4.13.2</version>
5549
<scope>test</scope>
5650
</dependency>
5751
<dependency>
@@ -107,6 +101,12 @@
107101
<id>native</id>
108102

109103
<dependencies>
104+
<dependency>
105+
<groupId>org.junit.vintage</groupId>
106+
<artifactId>junit-vintage-engine</artifactId>
107+
<version>5.10.2</version>
108+
<scope>test</scope>
109+
</dependency>
110110
<dependency>
111111
<groupId>org.graalvm.buildtools</groupId>
112112
<artifactId>junit-platform-native</artifactId>

samples/native-image-sample/src/test/java/com/example/logging/ITNativeImageLoggingSample.java

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,18 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020

21-
import java.io.ByteArrayOutputStream;
22-
import java.io.PrintStream;
23-
import org.junit.jupiter.api.AfterEach;
24-
import org.junit.jupiter.api.BeforeEach;
25-
import org.junit.jupiter.api.Test;
21+
import com.google.cloud.testing.junit4.StdOutCaptureRule;
22+
import org.junit.Rule;
23+
import org.junit.Test;
2624

27-
class ITNativeImageLoggingSample {
25+
public class ITNativeImageLoggingSample {
2826

29-
private final ByteArrayOutputStream stdOutCaptor = new ByteArrayOutputStream();
30-
private final PrintStream originalStdOut = System.out;
31-
32-
@BeforeEach
33-
void setUp() {
34-
System.setOut(new PrintStream(stdOutCaptor));
35-
}
36-
37-
@AfterEach
38-
void tearDown() {
39-
System.setOut(originalStdOut);
40-
}
27+
@Rule public StdOutCaptureRule stdOut = new StdOutCaptureRule();
4128

4229
@Test
43-
void testLogging() throws Exception {
30+
public void testLogging() throws Exception {
4431
NativeImageLoggingSample.main(new String[] {});
45-
assertThat(stdOutCaptor.toString("UTF-8"))
32+
assertThat(stdOut.getCapturedOutputAsUtf8String())
4633
.contains("Logged: This is a log produced by Native Image.");
4734
}
48-
}
35+
}

samples/pom.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,9 @@
5757

5858
<dependencies>
5959
<dependency>
60-
<groupId>org.junit.jupiter</groupId>
61-
<artifactId>junit-jupiter-api</artifactId>
62-
<version>5.10.1</version>
63-
<scope>test</scope>
64-
</dependency>
65-
<dependency>
66-
<groupId>org.junit.jupiter</groupId>
67-
<artifactId>junit-jupiter-engine</artifactId>
68-
<version>5.10.1</version>
60+
<groupId>junit</groupId>
61+
<artifactId>junit</artifactId>
62+
<version>4.13.2</version>
6963
<scope>test</scope>
7064
</dependency>
7165
<dependency>

samples/snapshot/pom.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,9 @@
3232
</dependency>
3333
<!-- {x-version-update-end} -->
3434
<dependency>
35-
<groupId>org.junit.jupiter</groupId>
36-
<artifactId>junit-jupiter-api</artifactId>
37-
<version>5.10.1</version>
38-
<scope>test</scope>
39-
</dependency>
40-
<dependency>
41-
<groupId>org.junit.jupiter</groupId>
42-
<artifactId>junit-jupiter-engine</artifactId>
43-
<version>5.10.1</version>
35+
<groupId>junit</groupId>
36+
<artifactId>junit</artifactId>
37+
<version>4.13.2</version>
4438
<scope>test</scope>
4539
</dependency>
4640
<dependency>

samples/snippets/pom.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,9 @@
4444

4545
<!-- [START_EXCLUDE] -->
4646
<dependency>
47-
<groupId>org.junit.jupiter</groupId>
48-
<artifactId>junit-jupiter-api</artifactId>
49-
<version>5.10.1</version>
50-
<scope>test</scope>
51-
</dependency>
52-
<dependency>
53-
<groupId>org.junit.jupiter</groupId>
54-
<artifactId>junit-jupiter-engine</artifactId>
55-
<version>5.10.1</version>
47+
<groupId>junit</groupId>
48+
<artifactId>junit</artifactId>
49+
<version>4.13.2</version>
5650
<scope>test</scope>
5751
</dependency>
5852
<dependency>

samples/snippets/src/test/java/com/example/logging/LoggingIT.java

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,18 @@
2929
import java.io.ByteArrayOutputStream;
3030
import java.io.PrintStream;
3131
import 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
() -> {

samples/snippets/src/test/java/com/example/logging/LogsIT.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,29 @@
2020

2121
import java.io.ByteArrayOutputStream;
2222
import java.io.PrintStream;
23-
import org.junit.jupiter.api.AfterEach;
24-
import org.junit.jupiter.api.BeforeEach;
25-
import org.junit.jupiter.api.Test;
26-
import org.junit.jupiter.api.Timeout;
27-
import java.util.concurrent.TimeUnit;
23+
import org.junit.After;
24+
import org.junit.Before;
25+
import org.junit.Test;
2826

29-
class LogsIT {
27+
public class LogsIT {
3028
private static final String GOOGLEAPIS_AUDIT_LOGNAME = "cloudaudit.googleapis.com%2Factivity";
3129

3230
private ByteArrayOutputStream bout;
3331
private PrintStream out;
3432

35-
@BeforeEach
36-
void setUp() {
33+
@Before
34+
public void setUp() {
3735
bout = new ByteArrayOutputStream();
3836
out = new PrintStream(bout);
3937
System.setOut(out);
4038
}
4139

42-
@AfterEach
43-
void tearDown() {
40+
@After
41+
public void tearDown() {
4442
System.setOut(null);
4543
}
4644

47-
@Test
48-
@Timeout(value = 60000, unit = TimeUnit.MILLISECONDS)
45+
@Test(timeout = 60000)
4946
public void testListLogNamesSample() throws Exception {
5047
ListLogs.main();
5148
// Check for mocked STDOUT having data

samples/snippets/src/test/java/com/example/logging/SinkIT.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package com.example.logging;
1818

19-
import static org.junit.jupiter.api.Assertions.assertNotNull;
20-
import static org.junit.jupiter.api.Assertions.assertTrue;
19+
import static org.junit.Assert.assertNotNull;
20+
import static org.junit.Assert.assertTrue;
2121

2222
import com.google.cloud.logging.Logging;
2323
import com.google.cloud.logging.LoggingOptions;
@@ -26,21 +26,21 @@
2626
import java.io.ByteArrayOutputStream;
2727
import java.io.PrintStream;
2828
import java.util.UUID;
29-
import org.junit.jupiter.api.AfterEach;
30-
import org.junit.jupiter.api.BeforeEach;
31-
import org.junit.jupiter.api.Test;
32-
import org.junit.jupiter.api.extension.ExtendWith;
33-
import org.junit.jupiter.api.extension.ExtendWith;
29+
import org.junit.After;
30+
import org.junit.Before;
31+
import org.junit.Test;
32+
import org.junit.runner.RunWith;
33+
import org.junit.runners.JUnit4;
3434

3535
/** Tests for sink sample. */
36-
37-
class SinkIT {
36+
@RunWith(JUnit4.class)
37+
public class SinkIT {
3838

3939
private Logging logging = LoggingOptions.getDefaultInstance().getService();
4040
private static final String SINK_NAME = "test-sink" + UUID.randomUUID().toString();
4141

42-
@BeforeEach
43-
void setUp() {
42+
@Before
43+
public void setUp() {
4444
// Create sink
4545
logging.create(
4646
SinkInfo.newBuilder(SINK_NAME, SinkInfo.Destination.DatasetDestination.of("dataset"))
@@ -49,15 +49,15 @@ void setUp() {
4949
.build());
5050
}
5151

52-
@AfterEach
53-
void tearDown() throws Exception {
52+
@After
53+
public void tearDown() throws Exception {
5454
// Delete sink
5555
logging.deleteSink(SINK_NAME);
5656
logging.close();
5757
}
5858

5959
@Test
60-
void testGetSinkMetadata() throws Exception {
60+
public void testGetSinkMetadata() throws Exception {
6161
Sink sink = logging.getSink(SINK_NAME);
6262
assertNotNull(sink);
6363
PrintStream standardOut = System.out;

0 commit comments

Comments
 (0)