diff --git a/hibernate-core/src/test/java/org/hibernate/stat/internal/StatsNamedContainerNullComputedValueTest.java b/hibernate-core/src/test/java/org/hibernate/stat/internal/StatsNamedContainerNullComputedValueTest.java new file mode 100644 index 0000000000..afd5b1088d --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/stat/internal/StatsNamedContainerNullComputedValueTest.java @@ -0,0 +1,30 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.stat.internal; + +import org.hibernate.testing.TestForIssue; +import org.junit.Test; + +import static org.junit.Assert.assertNull; + +@TestForIssue(jiraKey = "HHH-13645") +public class StatsNamedContainerNullComputedValueTest { + + @Test + public void testNullComputedValue() { + final StatsNamedContainer statsNamedContainer = new StatsNamedContainer(); + assertNull( + statsNamedContainer.getOrCompute( + "key", + v -> { + return null; + } + ) + ); + } + +} \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/test/stats/StatisticsWithNoQueryCachingTest.java b/hibernate-core/src/test/java/org/hibernate/test/stats/StatisticsWithNoQueryCachingTest.java new file mode 100644 index 0000000000..2fd39d0a6d --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/stats/StatisticsWithNoQueryCachingTest.java @@ -0,0 +1,36 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.test.stats; + +import org.hibernate.cfg.AvailableSettings; +import org.hibernate.cfg.Configuration; +import org.hibernate.stat.Statistics; + +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Test; + +import static org.junit.Assert.assertNull; + +/** + * @author Gail Badner + */ +public class StatisticsWithNoQueryCachingTest extends BaseCoreFunctionalTestCase { + + @Override + protected void configure(Configuration configuration) { + configuration.setProperty( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" ); + configuration.setProperty( AvailableSettings.USE_QUERY_CACHE, "false" ); + } + + @Test + @TestForIssue( jiraKey = "HHH-13645") + public void testUncachedRegion() { + final Statistics statistics = sessionFactory().getStatistics(); + assertNull( statistics.getCacheRegionStatistics( "hibernate.test.unknown" ) ); + } +}