From b6a5974f856fd550c018384c84a33dec9cacb828 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Sat, 21 Aug 2021 14:14:24 +0530 Subject: [PATCH] JAVA-3247 Reduce logging of tutorials-integration job --- .../algorithms/astar/RouteFinder.java | 13 +- .../RouteFinderIntegrationTest.java | 9 +- drools/src/main/resources/logback.xml | 3 +- .../server/config/HelloDynamicBinding.java | 6 - .../JMapperRelationalIntegrationTest.java | 6 - .../LazyCollectionIntegrationTest.java | 7 +- .../src/test/resources/log4j.xml | 11 +- .../src/test/resources/log4j2.xml | 6 +- .../src/test/resources/logback.xml | 6 +- .../test/resources/META-INF/persistence.xml | 212 ++++++++++++++++++ .../test/resources/META-INF/persistence.xml | 152 +++++++++++++ .../java-jpa-3/src/test/resources/logback.xml | 15 ++ persistence-modules/java-jpa/README.md | 2 +- ...lication-lazy-load-no-trans-off.properties | 2 +- ...plication-lazy-load-no-trans-on.properties | 2 +- .../application/entities/User.java | 9 + .../src/test/resources/application.properties | 2 +- ...st.java => ArticleRepositoryLiveTest.java} | 5 +- 18 files changed, 427 insertions(+), 41 deletions(-) create mode 100644 persistence-modules/java-jpa-2/src/test/resources/META-INF/persistence.xml create mode 100644 persistence-modules/java-jpa-3/src/test/resources/META-INF/persistence.xml create mode 100644 persistence-modules/java-jpa-3/src/test/resources/logback.xml rename persistence-modules/spring-data-arangodb/src/test/java/com/baeldung/arangodb/{ArticleRepositoryIntegrationTest.java => ArticleRepositoryLiveTest.java} (96%) diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/RouteFinder.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/RouteFinder.java index 35458093c5..f8b66fec88 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/RouteFinder.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/RouteFinder.java @@ -8,6 +8,9 @@ import java.util.PriorityQueue; import java.util.Queue; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; + +@Slf4j public class RouteFinder { private final Graph graph; private final Scorer nextNodeScorer; @@ -28,11 +31,11 @@ public class RouteFinder { openSet.add(start); while (!openSet.isEmpty()) { - System.out.println("Open Set contains: " + openSet.stream().map(RouteNode::getCurrent).collect(Collectors.toSet())); + log.debug("Open Set contains: " + openSet.stream().map(RouteNode::getCurrent).collect(Collectors.toSet())); RouteNode next = openSet.poll(); - System.out.println("Looking at node: " + next); + log.debug("Looking at node: " + next); if (next.getCurrent().equals(to)) { - System.out.println("Found our destination!"); + log.debug("Found our destination!"); List route = new ArrayList<>(); RouteNode current = next; @@ -41,7 +44,7 @@ public class RouteFinder { current = allNodes.get(current.getPrevious()); } while (current != null); - System.out.println("Route: " + route); + log.debug("Route: " + route); return route; } @@ -55,7 +58,7 @@ public class RouteFinder { nextNode.setRouteScore(newScore); nextNode.setEstimatedScore(newScore + targetScorer.computeCost(connection, to)); openSet.add(nextNode); - System.out.println("Found a better route to node: " + nextNode); + log.debug("Found a better route to node: " + nextNode); } }); } diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/underground/RouteFinderIntegrationTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/underground/RouteFinderIntegrationTest.java index 1e4ad56d94..aba7f149da 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/underground/RouteFinderIntegrationTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/astar/underground/RouteFinderIntegrationTest.java @@ -1,5 +1,7 @@ package com.baeldung.algorithms.astar.underground; +import static org.assertj.core.api.Assertions.assertThat; + import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -10,9 +12,13 @@ import java.util.stream.Stream; import com.baeldung.algorithms.astar.Graph; import com.baeldung.algorithms.astar.RouteFinder; + +import lombok.extern.slf4j.Slf4j; + import org.junit.Before; import org.junit.Test; +@Slf4j public class RouteFinderIntegrationTest { private Graph underground; @@ -637,7 +643,8 @@ public class RouteFinderIntegrationTest { @Test public void findRoute() { List route = routeFinder.findRoute(underground.getNode("74"), underground.getNode("7")); + assertThat(route).size().isPositive(); - System.out.println(route.stream().map(Station::getName).collect(Collectors.toList())); + route.stream().map(Station::getName).collect(Collectors.toList()).forEach(station -> log.debug(station)); } } diff --git a/drools/src/main/resources/logback.xml b/drools/src/main/resources/logback.xml index 7d900d8ea8..b928039804 100644 --- a/drools/src/main/resources/logback.xml +++ b/drools/src/main/resources/logback.xml @@ -6,7 +6,8 @@ - + + diff --git a/jersey/src/main/java/com/baeldung/jersey/server/config/HelloDynamicBinding.java b/jersey/src/main/java/com/baeldung/jersey/server/config/HelloDynamicBinding.java index e56cdec140..19c407f80d 100644 --- a/jersey/src/main/java/com/baeldung/jersey/server/config/HelloDynamicBinding.java +++ b/jersey/src/main/java/com/baeldung/jersey/server/config/HelloDynamicBinding.java @@ -5,20 +5,14 @@ import javax.ws.rs.container.ResourceInfo; import javax.ws.rs.core.FeatureContext; import javax.ws.rs.ext.Provider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.baeldung.jersey.server.Greetings; import com.baeldung.jersey.server.filter.ResponseServerFilter; @Provider public class HelloDynamicBinding implements DynamicFeature { - private static final Logger LOG = LoggerFactory.getLogger(HelloDynamicBinding.class); - @Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { - LOG.info("Hello dynamic binding"); if (Greetings.class.equals(resourceInfo.getResourceClass()) && resourceInfo.getResourceMethod() .getName() diff --git a/libraries-data/src/test/java/com/baeldung/jmapper/JMapperRelationalIntegrationTest.java b/libraries-data/src/test/java/com/baeldung/jmapper/JMapperRelationalIntegrationTest.java index 7a497c4a83..15a16e22da 100644 --- a/libraries-data/src/test/java/com/baeldung/jmapper/JMapperRelationalIntegrationTest.java +++ b/libraries-data/src/test/java/com/baeldung/jmapper/JMapperRelationalIntegrationTest.java @@ -22,8 +22,6 @@ public class JMapperRelationalIntegrationTest { UserDto1 result1 = relationalMapper.oneToMany(UserDto1.class, user); UserDto2 result2= relationalMapper.oneToMany(UserDto2.class, user); - System.out.println(result1); - System.out.println(result2); assertEquals(user.getId(), result1.getId()); assertEquals(user.getEmail(), result1.getUsername()); assertEquals(user.getId(), result2.getId()); @@ -40,8 +38,6 @@ public class JMapperRelationalIntegrationTest { UserDto1 result1 = relationalMapper.oneToMany(UserDto1.class, user); UserDto2 result2 = relationalMapper.oneToMany(UserDto2.class, user); - System.out.println(result1); - System.out.println(result2); assertEquals(user.getId(), result1.getId()); assertEquals(user.getEmail(), result1.getUsername()); assertEquals(user.getId(), result2.getId()); @@ -64,8 +60,6 @@ public class JMapperRelationalIntegrationTest { UserDto1 result1 = relationalMapper.oneToMany(UserDto1.class, user); UserDto2 result2 = relationalMapper.oneToMany(UserDto2.class, user); - System.out.println(result1); - System.out.println(result2); assertEquals(user.getId(), result1.getId()); assertEquals(user.getEmail(), result1.getUsername()); assertEquals(user.getId(), result2.getId()); diff --git a/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/lazycollection/LazyCollectionIntegrationTest.java b/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/lazycollection/LazyCollectionIntegrationTest.java index 97888471a4..dd86820c03 100644 --- a/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/lazycollection/LazyCollectionIntegrationTest.java +++ b/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/lazycollection/LazyCollectionIntegrationTest.java @@ -1,7 +1,5 @@ package com.baeldung.hibernate.lazycollection; -import com.baeldung.hibernate.lazycollection.model.Branch; -import com.baeldung.hibernate.lazycollection.model.Employee; import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.SessionFactory; @@ -9,15 +7,14 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.dialect.H2Dialect; import org.hibernate.service.ServiceRegistry; - -import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import javax.annotation.PostConstruct; +import com.baeldung.hibernate.lazycollection.model.Branch; +import com.baeldung.hibernate.lazycollection.model.Employee; public class LazyCollectionIntegrationTest { diff --git a/persistence-modules/hibernate-annotations/src/test/resources/log4j.xml b/persistence-modules/hibernate-annotations/src/test/resources/log4j.xml index 2d153af124..7e2895f1e0 100644 --- a/persistence-modules/hibernate-annotations/src/test/resources/log4j.xml +++ b/persistence-modules/hibernate-annotations/src/test/resources/log4j.xml @@ -1,6 +1,5 @@ - - + @@ -10,16 +9,16 @@ - + - + - + - \ No newline at end of file + \ No newline at end of file diff --git a/persistence-modules/hibernate-annotations/src/test/resources/log4j2.xml b/persistence-modules/hibernate-annotations/src/test/resources/log4j2.xml index c5d0f12462..69352715da 100644 --- a/persistence-modules/hibernate-annotations/src/test/resources/log4j2.xml +++ b/persistence-modules/hibernate-annotations/src/test/resources/log4j2.xml @@ -8,9 +8,9 @@ - - - + + + diff --git a/persistence-modules/hibernate-annotations/src/test/resources/logback.xml b/persistence-modules/hibernate-annotations/src/test/resources/logback.xml index 9e591977d7..ed39d69fc2 100644 --- a/persistence-modules/hibernate-annotations/src/test/resources/logback.xml +++ b/persistence-modules/hibernate-annotations/src/test/resources/logback.xml @@ -8,9 +8,9 @@ - - - + + + diff --git a/persistence-modules/java-jpa-2/src/test/resources/META-INF/persistence.xml b/persistence-modules/java-jpa-2/src/test/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..00c7274dd4 --- /dev/null +++ b/persistence-modules/java-jpa-2/src/test/resources/META-INF/persistence.xml @@ -0,0 +1,212 @@ + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.queryparams.Employee + true + + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.text.Exam + true + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.defaultvalues.User + true + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.querytypes.UserEntity + true + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.projections.Product + true + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.criteria.Item + true + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.multipletables.multipleentities.MealWithMultipleEntities + com.baeldung.jpa.multipletables.multipleentities.AllergensAsEntity + + com.baeldung.jpa.multipletables.secondarytable.MealAsSingleEntity + + com.baeldung.jpa.multipletables.secondarytable.embeddable.MealWithEmbeddedAllergens + com.baeldung.jpa.multipletables.secondarytable.embeddable.AllergensAsEmbeddable + + true + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.unrelated.entities.Cocktail + com.baeldung.jpa.unrelated.entities.Recipe + com.baeldung.jpa.unrelated.entities.MultipleRecipe + true + + + + + + + + + + + + + + org.eclipse.persistence.jpa.PersistenceProvider + com.baeldung.jpa.generateidvalue.Admin + com.baeldung.jpa.generateidvalue.Article + com.baeldung.jpa.generateidvalue.IdGenerator + com.baeldung.jpa.generateidvalue.Task + com.baeldung.jpa.generateidvalue.User + true + + + + + + + + + + + + + + diff --git a/persistence-modules/java-jpa-3/src/test/resources/META-INF/persistence.xml b/persistence-modules/java-jpa-3/src/test/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..9a33f912bf --- /dev/null +++ b/persistence-modules/java-jpa-3/src/test/resources/META-INF/persistence.xml @@ -0,0 +1,152 @@ + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.equality.EqualByJavaDefault + com.baeldung.jpa.equality.EqualById + com.baeldung.jpa.equality.EqualByBusinessKey + true + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.removal.ShipmentInfo + com.baeldung.jpa.removal.LineItem + com.baeldung.jpa.removal.OrderRequest + true + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.index.Student + true + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.multiplebagfetchexception.Album + com.baeldung.jpa.multiplebagfetchexception.Song + com.baeldung.jpa.multiplebagfetchexception.User + com.baeldung.jpa.multiplebagfetchexception.Artist + com.baeldung.jpa.multiplebagfetchexception.Offer + com.baeldung.jpa.multiplebagfetchexception.Playlist + com.baeldung.jpa.multiplebagfetchexception.FavoriteSong + true + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.hibernateunproxy.Payment + com.baeldung.jpa.hibernateunproxy.CreditCardPayment + com.baeldung.jpa.hibernateunproxy.PaymentReceipt + com.baeldung.jpa.hibernateunproxy.WebUser + true + + + + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.IdGeneration.User + true + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.uniqueconstraints.Person + com.baeldung.jpa.uniqueconstraints.Address + true + + + + + + + + + + + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.returnmultipleentities.Channel + com.baeldung.jpa.returnmultipleentities.Subscription + com.baeldung.jpa.returnmultipleentities.User + com.baeldung.jpa.returnmultipleentities.ReportRepository + true + + + + + + + + + + + + + + diff --git a/persistence-modules/java-jpa-3/src/test/resources/logback.xml b/persistence-modules/java-jpa-3/src/test/resources/logback.xml new file mode 100644 index 0000000000..0e1b193434 --- /dev/null +++ b/persistence-modules/java-jpa-3/src/test/resources/logback.xml @@ -0,0 +1,15 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - + %msg%n + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/java-jpa/README.md b/persistence-modules/java-jpa/README.md index be4c7fb79a..9dd76b13d6 100644 --- a/persistence-modules/java-jpa/README.md +++ b/persistence-modules/java-jpa/README.md @@ -14,4 +14,4 @@ This module contains articles about the Java Persistence API (JPA) in Java. - [Defining JPA Entities](https://www.baeldung.com/jpa-entities) - [JPA @Basic Annotation](https://www.baeldung.com/jpa-basic-annotation) - [Persisting Enums in JPA](https://www.baeldung.com/jpa-persisting-enums-in-jpa) -- More articles: [[next -->]](/java-jpa-2) +- More articles: [[next -->]](/persistence-modules/java-jpa-2) diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties index 1055806ecf..ca60ef3ce3 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties @@ -8,7 +8,7 @@ spring.h2.console.path=/h2-console spring.datasource.data=data-trans.sql logging.level.org.hibernate.SQL=INFO -logging.level.org.hibernate.type=TRACE +logging.level.org.hibernate.type=INFO spring.jpa.properties.hibernate.validator.apply_to_ddl=false spring.jpa.properties.hibernate.enable_lazy_load_no_trans=false spring.jpa.open-in-view=false \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties index 77aacf0d77..0469ea0dde 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties @@ -8,7 +8,7 @@ spring.h2.console.path=/h2-console spring.datasource.data=data-trans.sql logging.level.org.hibernate.SQL=INFO -logging.level.org.hibernate.type=TRACE +logging.level.org.hibernate.type=INFO spring.jpa.properties.hibernate.validator.apply_to_ddl=false spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true spring.jpa.open-in-view=false \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/entities/User.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/entities/User.java index 518a11701f..84a9ae74ff 100644 --- a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/entities/User.java +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/springbootdatasourceconfig/application/entities/User.java @@ -13,6 +13,7 @@ public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; + private long status; private String name; private String email; @@ -39,6 +40,14 @@ public class User { this.email = email; } + public void setStatus(long status) { + this.status = status; + } + + public long getStatus() { + return status; + } + @Override public String toString() { return "User{" + "id=" + id + ", name=" + name + ", email=" + email + '}'; diff --git a/persistence-modules/spring-boot-persistence/src/test/resources/application.properties b/persistence-modules/spring-boot-persistence/src/test/resources/application.properties index 3a6470c8dc..559522ddbc 100644 --- a/persistence-modules/spring-boot-persistence/src/test/resources/application.properties +++ b/persistence-modules/spring-boot-persistence/src/test/resources/application.properties @@ -12,5 +12,5 @@ hibernate.cache.use_second_level_cache=true hibernate.cache.use_query_cache=true hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory -spring.jpa.properties.hibernate.hbm2ddl.import_files=migrated_users.sql, import_books.sql +#spring.jpa.properties.hibernate.hbm2ddl.import_files=import_active_users.sql,import_inactive_users.sql spring.datasource.data=import_*_users.sql \ No newline at end of file diff --git a/persistence-modules/spring-data-arangodb/src/test/java/com/baeldung/arangodb/ArticleRepositoryIntegrationTest.java b/persistence-modules/spring-data-arangodb/src/test/java/com/baeldung/arangodb/ArticleRepositoryLiveTest.java similarity index 96% rename from persistence-modules/spring-data-arangodb/src/test/java/com/baeldung/arangodb/ArticleRepositoryIntegrationTest.java rename to persistence-modules/spring-data-arangodb/src/test/java/com/baeldung/arangodb/ArticleRepositoryLiveTest.java index 1d4258688a..35232766ab 100644 --- a/persistence-modules/spring-data-arangodb/src/test/java/com/baeldung/arangodb/ArticleRepositoryIntegrationTest.java +++ b/persistence-modules/spring-data-arangodb/src/test/java/com/baeldung/arangodb/ArticleRepositoryLiveTest.java @@ -16,8 +16,11 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +/** + * ArangoDB server should be up and running for this test case to run successfully + */ @SpringBootTest -public class ArticleRepositoryIntegrationTest { +public class ArticleRepositoryLiveTest { @Autowired ArticleRepository articleRepository;