snoopdave commented on code in PR #182:
URL: https://github.com/apache/roller/pull/182#discussion_r3952523529
##########
app/src/test/java/org/apache/roller/weblogger/business/startup/DatabaseInstallerUpgradeTest.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0.
+ */
+package org.apache.roller.weblogger.business.startup;
+
+import java.sql.*;
+import org.apache.roller.weblogger.business.DatabaseProvider;
+import org.junit.jupiter.api.Test;
+import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+class DatabaseInstallerUpgradeTest {
+ @Test
+ void versionOnlyUpgradeReportsCompletion() throws Exception {
+ DatabaseProvider db = mock(DatabaseProvider.class);
+ DatabaseScriptProvider scripts = mock(DatabaseScriptProvider.class);
+ Connection con = mock(Connection.class);
+ Statement query = mock(Statement.class);
+ ResultSet rows = mock(ResultSet.class);
+ PreparedStatement update = mock(PreparedStatement.class);
+ when(db.getConnection()).thenReturn(con);
+ when(con.createStatement()).thenReturn(query);
+ when(query.executeQuery(anyString())).thenReturn(rows);
+ when(rows.next()).thenReturn(true);
+ when(rows.getString(1)).thenReturn("610");
+ when(con.prepareStatement(anyString())).thenReturn(update);
+ DatabaseInstaller installer = new DatabaseInstaller(db, scripts);
+ installer.upgradeDatabase(true);
+ verify(update).setString(1, "616");
+ verify(update).executeUpdate();
+ verifyNoInteractions(scripts);
+ assertTrue(installer.getMessages().stream().anyMatch(m ->
m.contains("No table changes were required.")));
+ assertTrue(installer.getMessages().stream().anyMatch(m ->
m.contains("Database version updated to 616.")));
Review Comment:
🐞GLM Issue: **Resolved** in 4a89f02f45884cfd0e4ed3cdfc4700bbb40a86e0 — the
test now derives the expected version from the same source the installer reads
(the ro.version property in /roller-version.properties, parsed with
DatabaseInstaller.parseVersionString, widened to package-private static so the
test parses exactly as production does), instead of pinning the release
constant. Full JDK 11 app verify unchanged: 301 tests, 0 failures, 0 errors, 1
skipped.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]