4343import com .fasterxml .jackson .databind .ObjectMapper ;
4444import io .grpc .ManagedChannel ;
4545import io .grpc .ManagedChannelBuilder ;
46- import lombok .extern .slf4j .Slf4j ;
4746import org .junit .jupiter .api .AfterAll ;
4847import org .junit .jupiter .api .Assertions ;
4948import org .junit .jupiter .api .BeforeAll ;
5049import org .junit .jupiter .api .Tag ;
5150import org .junit .jupiter .api .TestInstance ;
51+ import org .slf4j .Logger ;
52+ import org .slf4j .LoggerFactory ;
5253import org .testcontainers .containers .DockerComposeContainer ;
5354import org .testcontainers .containers .output .Slf4jLogConsumer ;
5455import org .testcontainers .containers .wait .strategy .Wait ;
6061
6162@ TestInstance (TestInstance .Lifecycle .PER_CLASS )
6263@ Testcontainers
63- @ Slf4j
6464@ Tag ("E2ETest" )
6565public abstract class ExternalTestBase {
66+ private static final Logger LOG = LoggerFactory .getLogger (ExternalTestBase .class );
6667 public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper ();
6768 public static final int MAX_STARTUP_TIMEOUT = 120 ;
6869 public static final String GOV_DOCS_FOLDER = "/tika/govdocs1" ;
@@ -88,7 +89,7 @@ static void setup() throws Exception {
8889 }
8990
9091 private static void startLocalGrpcServer () throws Exception {
91- log .info ("Starting local tika-grpc server using Maven exec" );
92+ LOG .info ("Starting local tika-grpc server using Maven exec" );
9293
9394 Path tikaGrpcDir = findTikaGrpcDirectory ();
9495 Path configFile = Path .of ("src/test/resources/tika-config.json" ).toAbsolutePath ();
@@ -97,8 +98,8 @@ private static void startLocalGrpcServer() throws Exception {
9798 throw new IllegalStateException ("Config file not found: " + configFile );
9899 }
99100
100- log .info ("Using tika-grpc from: {}" , tikaGrpcDir );
101- log .info ("Using config file: {}" , configFile );
101+ LOG .info ("Using tika-grpc from: {}" , tikaGrpcDir );
102+ LOG .info ("Using config file: {}" , configFile );
102103
103104 String javaHome = System .getProperty ("java.home" );
104105 boolean isWindows = System .getProperty ("os.name" ).toLowerCase (Locale .ROOT ).contains ("win" );
@@ -131,18 +132,18 @@ private static void startLocalGrpcServer() throws Exception {
131132 new InputStreamReader (localGrpcProcess .getInputStream (), StandardCharsets .UTF_8 ))) {
132133 String line ;
133134 while ((line = reader .readLine ()) != null ) {
134- log .info ("tika-grpc: {}" , line );
135+ LOG .info ("tika-grpc: {}" , line );
135136 }
136137 } catch (IOException e ) {
137- log .error ("Error reading server output" , e );
138+ LOG .error ("Error reading server output" , e );
138139 }
139140 });
140141 logThread .setDaemon (true );
141142 logThread .start ();
142143
143144 waitForServerReady ();
144145
145- log .info ("Local tika-grpc server started successfully on port {}" , GRPC_PORT );
146+ LOG .info ("Local tika-grpc server started successfully on port {}" , GRPC_PORT );
146147 }
147148
148149 private static Path findTikaGrpcDirectory () {
@@ -173,10 +174,10 @@ private static void waitForServerReady() throws Exception {
173174 try {
174175 TikaGrpc .TikaBlockingStub stub = TikaGrpc .newBlockingStub (testChannel );
175176 stub .listFetchers (ListFetchersRequest .newBuilder ().build ());
176- log .info ("gRPC server is ready" );
177+ LOG .info ("gRPC server is ready" );
177178 return ;
178179 } catch (Exception e ) {
179- log .trace ("gRPC server not ready yet (attempt {}/{}): {}" , i + 1 , maxAttempts , e .getMessage ());
180+ LOG .trace ("gRPC server not ready yet (attempt {}/{}): {}" , i + 1 , maxAttempts , e .getMessage ());
180181 } finally {
181182 testChannel .shutdown ();
182183 testChannel .awaitTermination (1 , TimeUnit .SECONDS );
@@ -191,7 +192,7 @@ private static void waitForServerReady() throws Exception {
191192 }
192193
193194 private static void startDockerGrpcServer () {
194- log .info ("Starting Docker Compose tika-grpc server" );
195+ LOG .info ("Starting Docker Compose tika-grpc server" );
195196
196197 String composeFilePath = System .getProperty ("tika.docker.compose.file" );
197198 if (composeFilePath == null || composeFilePath .isBlank ()) {
@@ -208,11 +209,11 @@ private static void startDockerGrpcServer() {
208209 .withStartupTimeout (Duration .of (MAX_STARTUP_TIMEOUT , ChronoUnit .SECONDS ))
209210 .withExposedService ("tika-grpc" , 50052 ,
210211 Wait .forLogMessage (".*Server started.*\\ n" , 1 ))
211- .withLogConsumer ("tika-grpc" , new Slf4jLogConsumer (log ));
212+ .withLogConsumer ("tika-grpc" , new Slf4jLogConsumer (LOG ));
212213
213214 composeContainer .start ();
214215
215- log .info ("Docker Compose containers started successfully" );
216+ LOG .info ("Docker Compose containers started successfully" );
216217 }
217218
218219 private static void loadGovdocs1 () throws IOException , InterruptedException {
@@ -230,7 +231,7 @@ private static void loadGovdocs1() throws IOException, InterruptedException {
230231 if (attempt >= retries ) {
231232 throw e ;
232233 }
233- log .warn ("Download attempt {} failed, retrying in 10 seconds..." , attempt , e );
234+ LOG .warn ("Download attempt {} failed, retrying in 10 seconds..." , attempt , e );
234235 TimeUnit .SECONDS .sleep (10 );
235236 }
236237 }
@@ -253,13 +254,13 @@ public static void copyTestFixtures() throws IOException {
253254 Files .copy (in , targetDir .resolve (fixture ), StandardCopyOption .REPLACE_EXISTING );
254255 }
255256 }
256- log .info ("Copied {} test fixtures to {}" , fixtures .length , targetDir );
257+ LOG .info ("Copied {} test fixtures to {}" , fixtures .length , targetDir );
257258 }
258259
259260 @ AfterAll
260261 void close () {
261262 if (USE_LOCAL_SERVER && localGrpcProcess != null ) {
262- log .info ("Stopping local gRPC server" );
263+ LOG .info ("Stopping local gRPC server" );
263264 localGrpcProcess .destroy ();
264265 try {
265266 if (!localGrpcProcess .waitFor (10 , TimeUnit .SECONDS )) {
@@ -284,14 +285,14 @@ public static void downloadAndUnzipGovdocs1(int fromIndex, int toIndex) throws I
284285 Path zipPath = targetDir .resolve (zipName );
285286
286287 if (Files .exists (zipPath )) {
287- log .info ("{} already exists, skipping download" , zipName );
288+ LOG .info ("{} already exists, skipping download" , zipName );
288289 } else {
289- log .info ("Downloading {} from {}..." , zipName , url );
290+ LOG .info ("Downloading {} from {}..." , zipName , url );
290291 try (InputStream in = new URL (url ).openStream ()) {
291292 Files .copy (in , zipPath , StandardCopyOption .REPLACE_EXISTING );
292293 }
293294 }
294- log .info ("Unzipping {}..." , zipName );
295+ LOG .info ("Unzipping {}..." , zipName );
295296 try (ZipInputStream zis = new ZipInputStream (new FileInputStream (zipPath .toFile ()))) {
296297 ZipEntry entry ;
297298 while ((entry = zis .getNextEntry ()) != null ) {
@@ -309,7 +310,7 @@ public static void downloadAndUnzipGovdocs1(int fromIndex, int toIndex) throws I
309310 }
310311 }
311312
312- log .info ("Finished downloading and extracting govdocs1 files" );
313+ LOG .info ("Finished downloading and extracting govdocs1 files" );
313314 }
314315
315316 public static void assertAllFilesFetched (Path baseDir , List <FetchAndParseReply > successes ,
@@ -337,7 +338,7 @@ public static void assertAllFilesFetched(Path baseDir, List<FetchAndParseReply>
337338 }
338339
339340 Assertions .assertNotEquals (0 , successes .size (), "Should have some successful fetches" );
340- log .info ("Processed {} files: {} successes, {} errors" , allFetchKeys .size (), successes .size (), errors .size ());
341+ LOG .info ("Processed {} files: {} successes, {} errors" , allFetchKeys .size (), successes .size (), errors .size ());
341342 Assertions .assertEquals (keysFromGovdocs1 , allFetchKeys , () -> {
342343 Set <String > missing = new HashSet <>(keysFromGovdocs1 );
343344 missing .removeAll (allFetchKeys );
0 commit comments