public void testInstantiateFactoryNoConstructor() { try { Factory factory = FactoryUtils.instantiateFactory(Date.class, new Class[] {Long.class}, new Object[] {null}); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testInstantiateFactoryMismatch() { try { Factory factory = FactoryUtils.instantiateFactory(Date.class, null, new Object[] {null}); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testInstantiateFactoryNull() { try { Factory factory = FactoryUtils.instantiateFactory(null); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testInstantiateFactoryComplex() { TimeZone.setDefault(TimeZone.getTimeZone("GMT")); // 2nd Jan 1970 Factory factory = FactoryUtils.instantiateFactory(Date.class, new Class[] {Integer.TYPE, Integer.TYPE, Integer.TYPE}, new Object[] {new Integer(70), new Integer(0), new Integer(2)}); assertNotNull(factory); Object created = factory.create(); assertTrue(created instanceof Date); // long time of 1 day (== 2nd Jan 1970) assertEquals(new Date(1000 * 60 * 60 * 24), created); }
public void testInstantiateFactorySimple() { Factory factory = FactoryUtils.instantiateFactory(Mock3.class); assertNotNull(factory); Object created = factory.create(); assertEquals(0, ((Mock3) created).getValue()); created = factory.create(); assertEquals(1, ((Mock3) created).getValue()); }