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 testNullFactory() { Factory factory = FactoryUtils.nullFactory(); assertNotNull(factory); Object created = factory.create(); assertNull(created); }
public void testConstantFactoryConstant() { Integer constant = new Integer(9); Factory factory = FactoryUtils.constantFactory(constant); assertNotNull(factory); Object created = factory.create(); assertSame(constant, created); }
public void testPrototypeFactoryPublicSerializationError() { Mock2 proto = new Mock2(new Object()); Factory factory = FactoryUtils.prototypeFactory(proto); assertNotNull(factory); try { Object created = factory.create(); } catch (FunctorException ex) { assertTrue(ex.getCause() instanceof IOException); return; } fail(); }
public void testExceptionFactory() { assertNotNull(FactoryUtils.exceptionFactory()); assertSame(FactoryUtils.exceptionFactory(), FactoryUtils.exceptionFactory()); try { FactoryUtils.exceptionFactory().create(); } catch (FunctorException ex) { try { FactoryUtils.exceptionFactory().create(); } catch (FunctorException ex2) { return; } } fail(); }
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()); }
public void testInstantiateFactoryNoConstructor() { try { Factory factory = FactoryUtils.instantiateFactory(Date.class, new Class[] {Long.class}, new Object[] {null}); } catch (IllegalArgumentException ex) { return; } fail(); }
/** * Main. * @param args */ public static void main(String[] args) { TestRunner.run(suite()); }
public void testPrototypeFactoryNull() { assertSame(ConstantFactory.NULL_INSTANCE, FactoryUtils.prototypeFactory(null)); }
public void testPrototypeFactoryPublicBad() { Object proto = new Object(); try { Factory factory = FactoryUtils.prototypeFactory(proto); } catch (IllegalArgumentException ex) { return; } fail(); }
suite.addTest(TestBufferUtils.suite()); suite.addTest(TestEnumerationUtils.suite()); suite.addTest(TestFactoryUtils.suite()); suite.addTest(TestListUtils.suite()); suite.addTest(TestMapUtils.suite());
public void testConstantFactoryNull() { Factory factory = FactoryUtils.constantFactory(null); assertNotNull(factory); Object created = factory.create(); assertNull(created); }
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(); }