Skip to content

Commit 2f35613

Browse files
Merge pull request #516 from JoyOfCodingPDX/Winter2026-SNAPSHOT
Changes for Winter 2026: - Resolve #478 by adding a tool to identify project submissions (.zip files) that need to be tested or need to be graded. - Resolve #515 by adding a salutation to the grade report when letter grades are assigned. - Resolve #498 by writing the grade totals for each student to a file in addition to standard output. - Resolve #511 by having the Survey program exit if the `me.xml` file already exists. - Improvements to the example `Student` project including fixes to typos and prevention of submission for grading. - Use version 3.9.11 of Maven in the wrapper. - Add an example of how to parse Phone Bill XML. - Update the versions of third-party dependencies and Maven Plugins - Resolve #526 by adding JDBC examples - Improve error messages when no arguments are supplied to out-of-the-box project main methods.
2 parents 8cd6f11 + aa22469 commit 2f35613

161 files changed

Lines changed: 8814 additions & 2534 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ target
1818
*/target
1919
dependency-reduced-pom.xml
2020

21+
# H2 database files
22+
*.db
Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
# Licensed to the Apache Software Foundation (ASF) under one
2-
# or more contributor license agreements. See the NOTICE file
3-
# distributed with this work for additional information
4-
# regarding copyright ownership. The ASF licenses this file
5-
# to you under the Apache License, Version 2.0 (the
6-
# "License"); you may not use this file except in compliance
7-
# with the License. You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing,
12-
# software distributed under the License is distributed on an
13-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14-
# KIND, either express or implied. See the License for the
15-
# specific language governing permissions and limitations
16-
# under the License.
17-
wrapperVersion=3.3.2
1+
wrapperVersion=3.3.4
182
distributionType=only-script
19-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
3+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip

examples/pom.xml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,23 @@
33
<parent>
44
<artifactId>joy</artifactId>
55
<groupId>io.github.davidwhitlock.joy</groupId>
6-
<version>1.2.3</version>
6+
<version>1.2.4-SNAPSHOT</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>examples</artifactId>
1010
<name>examples</name>
11-
<version>1.3.4</version>
11+
<version>1.4.0-SNAPSHOT</version>
1212
<url>https://www.cs.pdx.edu/~whitlock</url>
1313
<dependencies>
14-
<dependency>
15-
<groupId>io.github.davidwhitlock.joy</groupId>
16-
<artifactId>family</artifactId>
17-
<version>1.1.5</version>
18-
</dependency>
1914
<dependency>
2015
<groupId>io.github.davidwhitlock.joy</groupId>
2116
<artifactId>projects</artifactId>
22-
<version>3.0.3</version>
17+
<version>3.0.4-SNAPSHOT</version>
2318
</dependency>
2419
<dependency>
2520
<groupId>com.sun.mail</groupId>
2621
<artifactId>jakarta.mail</artifactId>
27-
<version>2.0.1</version>
22+
<version>2.0.2</version>
2823
</dependency>
2924
<dependency>
3025
<groupId>com.google.inject</groupId>
@@ -34,20 +29,39 @@
3429
<dependency>
3530
<groupId>jakarta.xml.bind</groupId>
3631
<artifactId>jakarta.xml.bind-api</artifactId>
37-
<version>4.0.2</version>
32+
<version>4.0.4</version>
3833
</dependency>
3934
<dependency>
4035
<groupId>com.sun.xml.bind</groupId>
4136
<artifactId>jaxb-impl</artifactId>
42-
<version>4.0.5</version>
37+
<version>4.0.6</version>
4338
<scope>runtime</scope>
4439
</dependency>
40+
<dependency>
41+
<groupId>com.h2database</groupId>
42+
<artifactId>h2</artifactId>
43+
<version>${h2.version}</version>
44+
</dependency>
4545
<dependency>
4646
<groupId>io.github.davidwhitlock.joy</groupId>
4747
<artifactId>projects</artifactId>
48-
<version>3.0.3</version>
48+
<version>3.0.4-SNAPSHOT</version>
4949
<classifier>tests</classifier>
5050
<scope>test</scope>
5151
</dependency>
5252
</dependencies>
53+
<build>
54+
<plugins>
55+
<plugin>
56+
<groupId>org.codehaus.mojo</groupId>
57+
<artifactId>build-helper-maven-plugin</artifactId>
58+
<version>${build-helper-maven-plugin.version}</version>
59+
</plugin>
60+
<plugin>
61+
<groupId>org.apache.maven.plugins</groupId>
62+
<artifactId>maven-failsafe-plugin</artifactId>
63+
<version>${surefire.version}</version>
64+
</plugin>
65+
</plugins>
66+
</build>
5367
</project>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package edu.pdx.cs.joy.jdbc;
2+
3+
import org.junit.jupiter.api.*;
4+
5+
import java.io.File;
6+
import java.sql.Connection;
7+
import java.sql.SQLException;
8+
9+
import static org.hamcrest.MatcherAssert.assertThat;
10+
import static org.hamcrest.Matchers.*;
11+
12+
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
13+
public class DepartmentDAOIT {
14+
15+
private static final String TEST_DEPARTMENT_NAME = "Computer Science";
16+
private static int generatedDepartmentId;
17+
18+
private static String dbFilePath;
19+
private Connection connection;
20+
private DepartmentDAO departmentDAO;
21+
22+
@BeforeAll
23+
public static void createTable() throws SQLException {
24+
// Create database file in temporary directory
25+
String tempDir = System.getProperty("java.io.tmpdir");
26+
dbFilePath = tempDir + File.separator + "DepartmentDAOIT.db";
27+
28+
// Connect to the file-based H2 database
29+
Connection connection = H2DatabaseHelper.createFileBasedConnection(new File(dbFilePath));
30+
31+
// Create the departments table
32+
DepartmentDAOImpl.createTable(connection);
33+
34+
connection.close();
35+
}
36+
37+
@BeforeEach
38+
public void setUp() throws SQLException {
39+
// Connect to the existing database file
40+
connection = H2DatabaseHelper.createFileBasedConnection(new File(dbFilePath));
41+
departmentDAO = new DepartmentDAOImpl(connection);
42+
}
43+
44+
@AfterEach
45+
public void tearDown() throws SQLException {
46+
if (connection != null && !connection.isClosed()) {
47+
connection.close();
48+
}
49+
}
50+
51+
@AfterAll
52+
public static void cleanUp() throws SQLException {
53+
// Connect one final time to drop the table and clean up
54+
Connection connection = H2DatabaseHelper.createFileBasedConnection(new File(dbFilePath));
55+
DepartmentDAOImpl.dropTable(connection);
56+
connection.close();
57+
58+
// Delete the database files
59+
deleteIfExists(new File(dbFilePath + ".mv.db"));
60+
deleteIfExists(new File(dbFilePath + ".trace.db"));
61+
}
62+
63+
private static void deleteIfExists(File file) {
64+
if (file.exists()) {
65+
assertThat(file.delete(), is(true));
66+
}
67+
}
68+
69+
@Test
70+
@Order(1)
71+
public void testPersistDepartment() throws SQLException {
72+
// Create and persist a department (ID will be auto-generated)
73+
Department department = new Department(TEST_DEPARTMENT_NAME);
74+
departmentDAO.save(department);
75+
76+
// Store the auto-generated ID for use in subsequent tests
77+
generatedDepartmentId = department.getId();
78+
79+
// Verify that an ID was auto-generated
80+
assertThat(generatedDepartmentId, is(greaterThan(0)));
81+
82+
// Verify the department was saved by fetching it in the same test
83+
Department fetchedDepartment = departmentDAO.findById(generatedDepartmentId);
84+
assertThat(fetchedDepartment, is(notNullValue()));
85+
assertThat(fetchedDepartment.getId(), is(equalTo(generatedDepartmentId)));
86+
assertThat(fetchedDepartment.getName(), is(equalTo(TEST_DEPARTMENT_NAME)));
87+
}
88+
89+
@Test
90+
@Order(2)
91+
public void testFindPersistedDepartment() throws SQLException {
92+
// Search for the department that was persisted in the previous test
93+
// using the auto-generated ID
94+
Department fetchedDepartment = departmentDAO.findById(generatedDepartmentId);
95+
96+
// Validate that the department persisted between test methods
97+
assertThat(fetchedDepartment, is(notNullValue()));
98+
assertThat(fetchedDepartment.getId(), is(equalTo(generatedDepartmentId)));
99+
assertThat(fetchedDepartment.getName(), is(equalTo(TEST_DEPARTMENT_NAME)));
100+
}
101+
}

0 commit comments

Comments
 (0)