diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-07-05 11:44:48 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-07-05 11:45:13 +0200 |
commit | c7ac7ab21c5f094e60ad6c3287a508d774aaaff6 (patch) | |
tree | ecf660dfc5cba797cc1dcc0c9e471d19e1610fb7 | |
parent | b98d208e187c54598729076581c2f2849b812ad2 (diff) | |
download | sonarqube-c7ac7ab21c5f094e60ad6c3287a508d774aaaff6.tar.gz sonarqube-c7ac7ab21c5f094e60ad6c3287a508d774aaaff6.zip |
Improve performance of TestDatabase
+ use it in MeasureFilterExecutorTest
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/measure/MeasureFilterExecutorTest.java | 94 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/persistence/TestDatabase.java | 19 |
2 files changed, 53 insertions, 60 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/measure/MeasureFilterExecutorTest.java b/sonar-core/src/test/java/org/sonar/core/measure/MeasureFilterExecutorTest.java index 682dfb3c174..214ceba319c 100644 --- a/sonar-core/src/test/java/org/sonar/core/measure/MeasureFilterExecutorTest.java +++ b/sonar-core/src/test/java/org/sonar/core/measure/MeasureFilterExecutorTest.java @@ -20,10 +20,11 @@ package org.sonar.core.measure; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.sonar.api.measures.Metric; import org.sonar.api.utils.DateUtils; -import org.sonar.core.persistence.AbstractDaoTestCase; +import org.sonar.core.persistence.TestDatabase; import org.sonar.core.resource.ResourceDao; import org.sonar.core.resource.SnapshotDto; @@ -33,7 +34,7 @@ import java.util.List; import static org.fest.assertions.Assertions.assertThat; -public class MeasureFilterExecutorTest extends AbstractDaoTestCase { +public class MeasureFilterExecutorTest { private static final long JAVA_PROJECT_ID = 1L; private static final long JAVA_FILE_BIG_ID = 3L; private static final long JAVA_FILE_TINY_ID = 4L; @@ -50,14 +51,17 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { private MeasureFilterExecutor executor; + @Rule + public TestDatabase db = new TestDatabase(); + @Before public void before() { - executor = new MeasureFilterExecutor(getMyBatis(), getDatabase(), new ResourceDao(getMyBatis())); + executor = new MeasureFilterExecutor(db.myBatis(), db.database(), new ResourceDao(db.myBatis())); } @Test public void should_return_empty_results_if_empty_filter() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter(); assertThat(filter.isEmpty()).isTrue(); @@ -66,7 +70,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void invalid_filter_should_not_return_results() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setUserFavourites(true); // anonymous user does not have favourites assertThat(executor.execute(filter, new MeasureFilterContext())).isEmpty(); @@ -74,7 +78,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_is_not_valid_if_missing_base_snapshot() { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilterContext context = new MeasureFilterContext(); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setOnBaseResourceChildren(true); assertThat(MeasureFilterExecutor.isValid(filter, context)).isFalse(); @@ -85,7 +89,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_is_not_valid_if_condition_on_unknown_metric() { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilterContext context = new MeasureFilterContext(); MeasureFilter filter = new MeasureFilter().addCondition(new MeasureFilterCondition(null, MeasureFilterCondition.Operator.LESS, 3.0)); assertThat(MeasureFilterExecutor.isValid(filter, context)).isFalse(); @@ -93,7 +97,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_is_not_valid_if_sorting_on_unknown_metric() { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilterContext context = new MeasureFilterContext(); MeasureFilter filter = new MeasureFilter().setSortOnMetric(null); assertThat(MeasureFilterExecutor.isValid(filter, context)).isFalse(); @@ -101,7 +105,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_is_not_valid_if_anonymous_favourites() { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilterContext context = new MeasureFilterContext(); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setUserFavourites(true); assertThat(MeasureFilterExecutor.isValid(filter, context)).isFalse(); @@ -112,7 +116,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void projects_without_measure_conditions() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setSortOn(MeasureFilterSort.Field.LANGUAGE); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -123,7 +127,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void should_prevent_sql_injection_through_parameters() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter() .setResourceQualifiers(Arrays.asList("'")) .setResourceLanguages(Arrays.asList("'")) @@ -139,7 +143,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void test_default_sort() { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("CLA")); assertThat(filter.sort().isAsc()).isTrue(); @@ -149,7 +153,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_ascending_resource_name() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("CLA")).setSortAsc(true); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -161,7 +165,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_ascending_resource_key() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("CLA")).setSortAsc(true).setSortOn(MeasureFilterSort.Field.KEY); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -173,7 +177,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_ascending_resource_version() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setSortAsc(true).setSortOn(MeasureFilterSort.Field.VERSION); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -185,7 +189,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_descending_resource_name() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("CLA")).setSortAsc(false); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -197,7 +201,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_ascending_text_measure() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setSortOnMetric(METRIC_PROFILE); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -208,7 +212,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_descending_text_measure() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setSortOnMetric(METRIC_PROFILE).setSortAsc(false); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -219,7 +223,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_missing_text_measure() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); // the metric 'profile' is not set on files MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("CLA")).setSortOnMetric(METRIC_PROFILE); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -229,7 +233,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_ascending_numeric_measure() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("CLA")).setSortOnMetric(METRIC_LINES); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -241,7 +245,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_descending_numeric_measure() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("CLA")).setSortOnMetric(METRIC_LINES).setSortAsc(false); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -253,7 +257,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void null_measures_are_ordered_after_descending_numeric_measures() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")) .setSortOnMetric(METRIC_COVERAGE).setSortAsc(false); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -266,7 +270,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void null_measures_are_ordered_after_ascending_numeric_measures() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")) .setSortOnMetric(METRIC_COVERAGE).setSortAsc(true); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -279,7 +283,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_missing_numeric_measure() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); // coverage measures are not computed MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("CLA")).setSortOnMetric(METRIC_UNKNOWN); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -290,7 +294,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_ascending_variation() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setSortOnMetric(METRIC_LINES).setSortOnPeriod(5); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -301,7 +305,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_descending_variation() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")) .setSortOnMetric(METRIC_LINES).setSortOnPeriod(5).setSortAsc(false); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -313,7 +317,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_ascending_date() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setSortOn(MeasureFilterSort.Field.DATE); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -323,7 +327,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void sort_by_descending_date() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setSortOn(MeasureFilterSort.Field.DATE).setSortAsc(false); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -333,7 +337,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void condition_on_numeric_measure() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("CLA")) .setSortOnMetric(METRIC_LINES) .addCondition(new MeasureFilterCondition(METRIC_LINES, MeasureFilterCondition.Operator.GREATER, 200)); @@ -345,7 +349,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void condition_on_measure_variation() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")) .setSortOnMetric(METRIC_LINES) .addCondition(new MeasureFilterCondition(METRIC_LINES, MeasureFilterCondition.Operator.GREATER, 1000).setPeriod(5)); @@ -357,7 +361,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void multiple_conditions_on_numeric_measures() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("CLA")) .setSortOnMetric(METRIC_LINES) .addCondition(new MeasureFilterCondition(METRIC_LINES, MeasureFilterCondition.Operator.GREATER, 2)) @@ -370,7 +374,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_by_language() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setResourceLanguages(Arrays.asList("java", "cobol")); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -380,7 +384,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_by_min_date() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setFromDate(DateUtils.parseDate("2012-12-13")); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -391,7 +395,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_by_range_of_dates() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")) .setFromDate(DateUtils.parseDate("2007-01-01")) .setToDate(DateUtils.parseDate("2010-01-01")); @@ -404,7 +408,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_by_resource_name() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setResourceName("PHP Proj"); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -414,7 +418,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_by_resource_key_star_regexp() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setResourceKeyRegexp("java*"); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -424,7 +428,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_by_resource_key_exclamation_mark() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setResourceKeyRegexp("JaV?_proje*"); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); assertThat(rows).hasSize(1); @@ -433,7 +437,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_by_base_resource() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("CLA")).setBaseResourceKey("java_project"); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -445,7 +449,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_by_parent_resource() throws SQLException { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setBaseResourceKey("java_project").setOnBaseResourceChildren(true); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -455,7 +459,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_by_parent_without_children() throws Exception { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK", "PAC", "CLA")).setBaseResourceKey("java_project:org.sonar.foo.Big").setOnBaseResourceChildren(true); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext()); @@ -464,7 +468,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void filter_by_user_favourites() throws Exception { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK", "FIL")).setUserFavourites(true); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext().setUserId(50L)); @@ -475,7 +479,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void ignore_person_measures_in_condition() throws Exception { - setupData("ignore_person_measures"); + db.prepareDbUnit(getClass(), "ignore_person_measures.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).addCondition( new MeasureFilterCondition(new Metric("ncloc").setId(1), MeasureFilterCondition.Operator.GREATER, 0.0) ); @@ -487,7 +491,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void ignore_person_measures_in_sort() throws Exception { - setupData("ignore_person_measures"); + db.prepareDbUnit(getClass(), "ignore_person_measures.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setSortOnMetric(new Metric("ncloc").setId(1)); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext().setUserId(50L)); @@ -497,7 +501,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void ignore_quality_model_measures_in_condition() throws Exception { - setupData("ignore_quality_model_measures"); + db.prepareDbUnit(getClass(), "ignore_quality_model_measures.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).addCondition( new MeasureFilterCondition(new Metric("ncloc").setId(1), MeasureFilterCondition.Operator.GREATER, 0.0) ); @@ -509,7 +513,7 @@ public class MeasureFilterExecutorTest extends AbstractDaoTestCase { @Test public void ignore_quality_model_measures_in_sort() throws Exception { - setupData("ignore_quality_model_measures"); + db.prepareDbUnit(getClass(), "ignore_quality_model_measures.xml"); MeasureFilter filter = new MeasureFilter().setResourceQualifiers(Arrays.asList("TRK")).setSortOnMetric(new Metric("ncloc").setId(1)); List<MeasureFilterRow> rows = executor.execute(filter, new MeasureFilterContext().setUserId(50L)); diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/TestDatabase.java b/sonar-core/src/test/java/org/sonar/core/persistence/TestDatabase.java index 39d0bf63762..796625ca1be 100644 --- a/sonar-core/src/test/java/org/sonar/core/persistence/TestDatabase.java +++ b/sonar-core/src/test/java/org/sonar/core/persistence/TestDatabase.java @@ -66,10 +66,10 @@ public class TestDatabase extends ExternalResource { private static final Logger LOG = LoggerFactory.getLogger(TestDatabase.class); - private Database db; - private DatabaseCommands commands; - private IDatabaseTester tester; - private MyBatis myBatis; + private static Database db; + private static DatabaseCommands commands; + private static IDatabaseTester tester; + private static MyBatis myBatis; private String schemaPath = null; @@ -111,17 +111,6 @@ public class TestDatabase extends ExternalResource { commands.truncateDatabase(db.getDataSource()); } - - @Override - protected void after() { - if (db != null) { - db.stop(); - db = null; - commands = null; - myBatis = null; - } - } - public Database database() { return db; } |