@Test
	public void testAvg() throws Exception
	{

		double average = 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
		for (int x = 0; x < 200; x++)
		{
			SimpleObject so = new SimpleObject();
			so.setAge((long) x);
			so.setCount(x);
			so.setValue(x);
			pm.saveObject(so);
		}

		// get the average of the Long values
		Number n = pm.calculateAggregate(SimpleObject.class, new Average("getAge"));
		assertEquals(Double.class, n.getClass());
		// assertEquals(average, n.doubleValue(), 0.0001);

		// get the average of the int values
		n = pm.calculateAggregate(SimpleObject.class, new Average("getCount"));
		assertEquals(Double.class, n.getClass());
		// assertEquals(average, n.doubleValue(), 0.0001);

		// get the average of the double values
		n = pm.calculateAggregate(SimpleObject.class, new Average("getValue"));
		assertEquals(Double.class, n.getClass());
		assertEquals(average, n.doubleValue(), 0.0001);

		// get the average of the long, int, and double values
		Number[] tmp = pm.calculateAggregate(SimpleObject.class,
				new AggregateFunction[] { new Average("getAge"), new Average("getCount"), new Average("getValue") });
		assertEquals(3, tmp.length);
		for (int x = 0; x < 3; x++)
		{
			assertTrue(tmp[x] instanceof Double);
			assertEquals(average, tmp[x].doubleValue(), 0.0001);
		}

		pm.close();

	}