People

Serialization

The first version of this program is an exemple of serialization. To be serializable, an object must be an instance of a class which implement Serializable.
Documentation is here.
A first example shows how to save, and then read an instance of the class People in a file using serialization. This example contains also a class Test.
In the second example, People and Test have been modified, in order to show that serialization runs even when using references.

Unit test

In this example, we use JUnit in order to test our classes.

First, if you want to use JUnit test with Eclipse, we recommand to separate the sources of your program and the tests. For that, create a new source folder in your project, for example named unittests.
Then choose a class for which you want to create a unit test and, after a right-click, choose the item "New" and the item "JUnit Test Case" in the submenu.

See the code of the example : People, Directory, DuplicatePeopleException
and the corresponding unit tests : PeopleTest and DirectoryTest