@Test
	public void testDuplicate() throws Exception
	{
		// create two persistence managers
		PersistenceManager persistOne = new PersistenceManager(driver, database, login, password);
		if (secondDatabase == null)
		{
			secondDatabase = database + "2";
		}
		PersistenceManager persistTwo = new PersistenceManager(driver, secondDatabase, login, password);

		// drop all tables in both
		persistOne.dropTable(Object.class);
		persistTwo.dropTable(Object.class);

		// create some objects in the first database
		ComplexObject co = new ComplexObject();
		co.setData(new double[] { 1, 2, 3 });
		co.setSimplestObject(new SimplestObject(5.0));
		persistOne.saveObject(co);
		LessSimpleObject lso = new LessSimpleObject();
		lso.setAge(50L);
		lso.setName("name");
		lso.setValue(6);
		persistOne.saveObject(lso);

		// peform a copy
		persistOne.duplicate(persistTwo);
		// close both persistence managers
		persistOne.close();
		persistTwo.close();

		// re-open the target persistence manager
		persistTwo = new PersistenceManager(driver, secondDatabase, login, password);
		// assert that there is 3 objects in all
		List<Object> allObjects = persistTwo.getObjects(Object.class, new All());
		assertEquals(3, allObjects.size());
		// assert that there is one LessSimpleObject
		List<LessSimpleObject> lessSimpleObjects = persistTwo.getObjects(LessSimpleObject.class, new All());
		assertEquals(1, lessSimpleObjects.size());
		// assert that the LessSimpleObject has "name" as name.
		LessSimpleObject first = lessSimpleObjects.get(0);
		assertEquals("name", first.getName());
		persistTwo.close();
		
		boolean thrown = false;
		persistOne = new PersistenceManager(driver, database, login, password);
		try
		{
			//this should throw an exception
			persistOne.duplicate(persistOne);
		}
		catch(IllegalArgumentException e)
		{
			thrown = true;
		}
		assertTrue("Copying database into itself did not throw exception",thrown);
		
		persistOne.close();
	}