@Test
	public void testAggregateOnInterface() throws Exception
	{

		int sum = (200 * 199) / 2;
		int min = 0;
		int max = 199;
		double avg = 199.0 / 2.0;

		// create a database connection
		PersistenceManager pm = new PersistenceManager(driver, database, login, password);
		// drop all tables
		pm.dropTable(Object.class);

		// create some test data
		int x = 0;
		for (; x < 100; x++)
		{
			ImplementerA so = new ImplementerA();
			so.setSomeValue(x);
			pm.saveObject(so);
		}
		for (; x < 200; x++)
		{
			ImplementerB so = new ImplementerB();
			so.setSomeValue(x);
			pm.saveObject(so);
		}
		// add some null values
		for (; x < 300; x++)
		{
			ImplementerB so = new ImplementerB();
			pm.saveObject(so);
		}

		// get the sum, max, min, and average of the long values
		Number[] tmp = pm.calculateAggregate(SubInterface.class, new AggregateFunction[] { new Sum("getSomeValue"),
				new Maximum("getSomeValue"), new Minimum("getSomeValue"), new Average("getSomeValue"), });
		assertEquals(4, tmp.length);
		// sum of an int field is long...
		assertEquals(Long.class, tmp[0].getClass());
		// max of an int field is int
		assertEquals(Integer.class, tmp[1].getClass());
		// min of an int field is int
		assertEquals(Integer.class, tmp[2].getClass());
		// ...and average is always double
		assertTrue(tmp[3] instanceof Double);

		// check that the correct values are returned
		assertEquals(sum, tmp[0].longValue());
		assertEquals(max, tmp[1].intValue());
		assertEquals(min, tmp[2].intValue());
		assertEquals(avg, tmp[3].doubleValue(), 0.0001);

		pm.close();

	}