ReadOnlyVariableResolverFactory extends
        BaseVariableResolverFactory { public VariableResolver createVariable(String name, Object value) { if (nextFactory != null) { return nextFactory.createVariable(name, value); } throw new UnsupportedOperationException("This variable resolver factory is read only"); } ReadOnlyVariableResolverFactory(TilesRequestContextHolder requestHolder); VariableResolver createVariable(String name, Object value); VariableResolver createVariable(String name, Object value,
            Class<?> type); boolean isResolveable(String name); @Override VariableResolver getVariableResolver(String name); abstract VariableResolver createVariableResolver(String name);  }
@Test(expected = UnsupportedOperationException.class) public void testCreateVariableStringObject() { replay(factory, request, applicationContext); try { factory.createVariable("myName", "myValue"); } finally { verify(factory, request, applicationContext); } }
@Test public void testCreateVariableStringObjectNextFactory() { VariableResolverFactory nextFactory = createMock(VariableResolverFactory.class); VariableResolver resolver = createMock(VariableResolver.class); expect(nextFactory.createVariable("myName", "myValue")).andReturn(resolver); replay(factory, request, applicationContext, nextFactory, resolver); factory.setNextFactory(nextFactory); assertEquals(resolver, factory.createVariable("myName", "myValue")); verify(factory, request, applicationContext, nextFactory, resolver); }
@Test(expected = UnsupportedOperationException.class) public void testCreateVariableStringObjectClassOfQ() { replay(factory, request, applicationContext); try { factory.createVariable("myName", "myValue", String.class); } finally { verify(factory, request, applicationContext); } }
@Test public void testCreateVariableStringObjectClassNextFactory() { VariableResolverFactory nextFactory = createMock(VariableResolverFactory.class); VariableResolver resolver = createMock(VariableResolver.class); expect(nextFactory.createVariable("myName", "myValue", String.class)).andReturn(resolver); replay(factory, request, applicationContext, nextFactory, resolver); factory.setNextFactory(nextFactory); assertEquals(resolver, factory.createVariable("myName", "myValue", String.class)); verify(factory, request, applicationContext, nextFactory, resolver); }