Skip to content

Commit c5f1416

Browse files
committed
Refactor logging in integration tests and remove unused dependency
- Removed the unused 'jakarta.persistence:jakarta.persistence-api' dependency from build.gradle. - Updated error logging in AirlineIntegrationTest, AirportIntegrationTest, and RouteIntegrationTest to use debug level for expected cleanup failures. These changes streamline the project by eliminating unnecessary dependencies and improving logging clarity during test cleanup.
1 parent 0d51a47 commit c5f1416

File tree

5 files changed

+51
-4
lines changed

5 files changed

+51
-4
lines changed

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ dependencies {
2424
implementation 'org.springframework.data:spring-data-couchbase'
2525
implementation 'org.springframework.boot:spring-boot-devtools'
2626

27-
implementation 'jakarta.persistence:jakarta.persistence-api'
2827
implementation 'jakarta.servlet:jakarta.servlet-api'
2928

3029
// Environment variable loading from .env file

src/test/java/org/couchbase/quickstart/springdata/controllers/AirlineIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private void deleteAirline(String baseUri, String airlineId) {
4747
} catch (DocumentNotFoundException | DataRetrievalFailureException | ResourceAccessException e) {
4848
log.warn("Document " + airlineId + " not present prior to test");
4949
} catch (Exception e) {
50-
log.error("Error deleting test data for airline {}: {}", airlineId, e.getMessage());
50+
log.debug("Cleanup: Could not delete test airline {}: {} (this is expected during test cleanup)", airlineId, e.getMessage());
5151
// Continue with cleanup even if one deletion fails
5252
}
5353
}

src/test/java/org/couchbase/quickstart/springdata/controllers/AirportIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void deleteAirport(String baseUri, String airportId) {
4949
} catch (DocumentNotFoundException | DataRetrievalFailureException | ResourceAccessException e) {
5050
log.warn("Document {} not present prior to test", airportId);
5151
} catch (Exception e) {
52-
log.error("Error deleting test data for airport {}: {}", airportId, e.getMessage());
52+
log.debug("Cleanup: Could not delete test airport {}: {} (this is expected during test cleanup)", airportId, e.getMessage());
5353
// Continue with cleanup even if one deletion fails
5454
}
5555
}

src/test/java/org/couchbase/quickstart/springdata/controllers/RouteIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void deleteRoute(String baseUri, String routeId) {
4949
} catch (DocumentNotFoundException | DataRetrievalFailureException | ResourceAccessException e) {
5050
log.warn("Document " + routeId + " not present prior to test");
5151
} catch (Exception e) {
52-
log.error("Error deleting test data for route {}: {}", routeId, e.getMessage());
52+
log.debug("Cleanup: Could not delete test route {}: {} (this is expected during test cleanup)", routeId, e.getMessage());
5353
// Continue with cleanup even if one deletion fails
5454
}
5555
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<!-- Console appender for test output -->
4+
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
5+
<encoder>
6+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
7+
</encoder>
8+
</appender>
9+
10+
<!-- Set root logger to INFO level (reduces noise) -->
11+
<root level="INFO">
12+
<appender-ref ref="CONSOLE"/>
13+
</root>
14+
15+
<!-- Suppress noisy Spring Framework warnings during tests -->
16+
<logger name="org.springframework.context.support.AbstractApplicationContext" level="ERROR"/>
17+
<logger name="org.springframework.beans.factory.support.DefaultListableBeanFactory" level="ERROR"/>
18+
<logger name="org.springframework.boot.autoconfigure.AutoConfigurationPackages" level="ERROR"/>
19+
<logger name="org.springframework.data.repository.config.RepositoryConfigurationDelegate" level="ERROR"/>
20+
21+
<!-- Suppress Couchbase client noise -->
22+
<logger name="com.couchbase" level="WARN"/>
23+
<logger name="com.couchbase.tracing" level="ERROR"/>
24+
<logger name="com.couchbase.client.core.compression.snappy.SnappyHelper" level="ERROR"/>
25+
26+
<!-- Suppress Spring Data pagination warning -->
27+
<logger name="org.springframework.data.web.config.PageableHandlerMethodArgumentResolverCustomizer" level="ERROR"/>
28+
<logger name="org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration" level="ERROR"/>
29+
30+
<!-- Suppress Jakarta persistence warnings -->
31+
<logger name="jakarta.persistence.spi" level="ERROR"/>
32+
33+
<!-- Suppress Spring Boot DevTools noise -->
34+
<logger name="org.springframework.boot.devtools" level="ERROR"/>
35+
36+
<!-- Suppress Tomcat initialization noise in tests -->
37+
<logger name="org.apache.catalina" level="WARN"/>
38+
<logger name="org.springframework.boot.web.embedded.tomcat" level="WARN"/>
39+
40+
<!-- Keep our application logs at appropriate levels -->
41+
<logger name="org.couchbase.quickstart.springdata" level="INFO"/>
42+
43+
<!-- Show test-related logs for debugging when needed -->
44+
<logger name="org.couchbase.quickstart.springdata.controllers" level="WARN"/>
45+
46+
<!-- Suppress JVM warnings -->
47+
<logger name="jdk.internal" level="ERROR"/>
48+
</configuration>

0 commit comments

Comments
 (0)