Programming Assignment 2
1 Purpose
The purpose of this assignment is to implement some of the
basic document-related classes in the application framework, and to use
these classes to display a document in the demonstration application,
The Big Pixel.
2 Learning Objectives
This assignment will help you review several design patterns
that you have seen in the past. It will also help you learn (and demonstrate
that you have learned) how to work with event multicasters and property
change events. Finally, while testing your code, you will gain some
experience with static nested classes.
3 Starting Point
You may start with either your solution to PA1 or with the solution
that you were given. However, note that, regardless of your starting point,
you are responsible for the correctness of your code to this assignment.
In other words, the code you were given is not guaranteed to be correct,
and you are responsible for any defects it contains.
4 Documents
The UML class diagram is available as an SVG file at:
The specifications are available as a PDF file at:
The main class (that can be used for integration testing) is available at:
The ResourceLoader
class has already been written and is
available at:
If you're interested in how this class works, see the Department's Wiki
on
resources in Java programs.
5 Tasks
For this assignment you must:
-
Implement all of the interfaces and classes in the class diagram and
specifications document.
-
Write JUnit tests for many of the classes in the class diagram and
specifications document.
6 Testing
Your JUnit test suite must cover 90% of all statements and all
branches (as measured by EclEmma) in the various
classes other than the
GridComponent
and BigPixelEditor
classes.
(This includes classes from earlier assignments.)
Your tests must be in a package
named edu.jmu.cs.academics.testing
and each test class
must include the word "Test" in its name.
Note that it may be impossible to get 100% coverage which is often
the case in "real-world" products (because, for example,
you will not be able to force IOExceptions
to be thrown).
However, you should strive for as high a percentage as possible, and 90%
coverage can definitely be achieved.
7 Files for Testing
The configuration file that you must use to test
the
Configuration
class is available at:
You must:
- In a file explorer, select and copy the file.
- In Eclipse, paste the file into the project directory (not
the
src
directory). Do not paste the file using the file
explorer.
You must use this file to test
your Configuration
class because it will be made
available to your code in the appropriate place on Autolab.
You must use .png
files to test
your ResourceLoader
class. Do not use other image files because
the style checker in Autolab has only been instructed to ignore
.png
files.
8 Submission
You must submit (using
Autolab) a
.zip
file
named pa2.zip
that contains:
- Your implementation of the required interfaces/classes/enums
in the appropriate package(s), including those from
previous assignments.
- JUnit tests for all of your classes/interfaces.
Do not submit the main class. Do not submit default.cfg
.
You must submit (using Canvas) one PDF file that contain
screenshots of The Big Pixel while it is running.
9 Grading
Your submission will be graded as follows:
- Conformity to the Style Guide (Style) - 20% (All or Nothing; Success Required)
- Passing your Tests (SelfTests) - 20% (All or Nothing; Success Required)
- Coverage of your Tests (Coverage) - 20% (All or Nothing)
- Correctness of your Code (OfficialTests) - 40% (Partial Credit Possible)
10 Help
The following help topics may be useful to you.
10.1 Closing Streams
When performing input/output operations, a variety of things can
go wrong. This makes it particularly difficult to close resources
properly. The best way to deal with this is using the try-with-resources
statement.
10.2 Location of the Default Configuration File
If your code is unable to find the default configuration file when
it is running it is because you did not add it to the project correctly.
(Remember, Eclipse has both src
and bin
directories/folders. So, the code is not edited in the same place
that it is execuuted.)
10.3 Testing the Document Management Functionality
While most of the classes that you must write for this assignment can be
tested in ways you have experience with, in order to test the document
management functionality you must be fairly sophisticated.
For one thing, you must use a
PropertyChangeListener
and check its state before and after events are fired. For another, your
tests must make use of both an
Editable
and a
DocumentManager
.
To help (both with the testing and in understanding how the
document management functionality should work), you are being
given two JUnit classes:
Note that they both use a static nested class for the listener.