Chapter 12. Creating Java Projects

Table of Contents

1. Create the project and canonical solution
2. Create JUnit tests
3. Create the test.properties file
4. Create the security.policy file (optional)
5. Package the test setup jarfile and canonical solution zipfile
6. Package the Starter files (Skeleton)

This chapter describes how to create a Java project that will work with the BuildServer. Also see: Marmoset Movies: Setting up a project with Marmoset.

1. Create the project and canonical solution

Start by creating the project and canonical solution. You can use any Java development environment: for example, Eclipse .

A good way to get started is to use the JavaProjectTemplate included with the Marmoset distribution. This is also available in examples.jar.

2. Create JUnit tests

As you are developing the canonical solution, you can start writing JUnit tests for the project. Marmoset supports three kinds of tests: public, release, and secret. Each kind of test is embodied by a class which extends junit.framework.TestCase. A test class may contain any number of test methods: each such method is considered a single test case.

Note that test classes are optional: you may provide or omit public, release, and secret tests in any combination.

Your canonical solution should pass all of the test cases.

3. Create the test.properties file

You should define whichever combination of the "test.class.public", "test.class.release", "test.class.secret", "test.class.student" properties are needed to define which classes represent your JUnit test cases. (See Section 3, “Test Properties”).

4. Create the security.policy file (optional)

The default security.policy file in the JavaProjectTemplate should be adequate for most Java projects. Note that Clover, the code coverage tool used by the BuildServer, needs permission to create and write a special file in /tmp and permission to create shutdownHooks. Both of these permissions are granted in the sample file. You may want to selectively grant privileges to student code for certain kinds of tests: for example, writing files.

5.  Package the test setup jarfile and canonical solution zipfile

The Java Project Template provides an ANT build.xml file that can be used to build the test-setup and canonical archives. It does this by selecting the appropriate files from the project and archiving them in a jar file. To use this file, be sure to change the properties at the top of the page to point to the right files in your project.

You can also create the jar files manually. Here is a description of what the test-setup jar file should contain:

  1. Any classes required to build and execute a student submission. These should placed in the test setup jarfile according to the usual Java conventions for packages. For example, if the class edu.umd.cs.Foobar is needed by submissions, the test setup jarfile should contain a file edu/umd/cs/Foobar.class.

    [Warning]Warning
    Since we are uploading class file, make sure the version of the class files is compatible with the version of java running on the Build Server. E.g. If you compile your test setup with Java 1.6 but the Build Server is running Java 1.5, the Build Server will fail. Check with your Marmoset Administrator for information on the Build Server version.

  2. JUnit TestCase classes for the public, release, secret, and/or student tests. These should also follow the usual Java package conventions.

  3. The test.properties file, and optionally a security.policy file.

  4. Any data files needed by the student submissions or test cases at runtime.

  5. You should also include the source files for your test cases. This is not necessary but is recommended because the test-setup.jar file is the only record in the Submit Server database of your tests. This is useful if you or another instructor wish to review this information in a future semester.

[Warning]Warning

The test setup jarfile should never contain any classes from the canonical solution (i.e., any classes that the student is supposed to write), because they will take precedence over the student classes at runtime. Leaving them in basically means that the test results will be for the canonical solution, and not the student's work.

The canonical solution zipfile represents what students are expected to implement, and should pass all of the project tests. The zipfile should contain the source files corresponding to classes that are meant to be implemented by the student. The source files do not need to be in any particular directory structure, although using normal Java conventions is recommended. If the an Eclipse ".project" file is present, that is used as the base directory for the project, and no files outside that directory will be extracted. If an Eclipse ".classpath" file is present, it will be used to find source directories in the project, and no source files outside those directories will be compiled.

6.  Package the Starter files (Skeleton)

You may optionally provide some starter files for students to use at the start of their projects. These files include the methods in the specification emptied of their implementation. Typically these empty methods simply throw a java.lang.UnsupportedOperationException. The advantage of this is that the skeleton will compile and fail all the tests. Also Submit Server recognizes this exception and accurately indicates that a test fails because the associated functionality is not implemented.

The skeleton files should be packaged into a jar file that can be uploaded into the submit server. You may also include a .submit file which is used by the Eclipse Plugin and the Command Line Submission Utility to automatically upload student submissions into the submit server. This file can be found in the Project Utilities page on the Submit Server.