@Test public void testGetVariableResolver() { VariableResolverFactory nextFactory = createMock(VariableResolverFactory.class); VariableResolver nextResolver = createMock(VariableResolver.class); VariableResolver requestResolver = createMock(VariableResolver.class); VariableResolver applicationResolver = createMock(VariableResolver.class); expect(nextFactory.getVariableResolver("other")).andReturn(nextResolver); expect(nextFactory.isResolveable("other")).andReturn(true); expect(factory.isTarget("requestScope")).andReturn(true).anyTimes(); expect(factory.isTarget("applicationScope")).andReturn(true).anyTimes(); expect(factory.isTarget("other")).andReturn(false).anyTimes(); expect(factory.createVariableResolver("requestScope")).andReturn(requestResolver); expect(factory.createVariableResolver("applicationScope")).andReturn(applicationResolver); replay(factory, request, applicationContext, nextFactory, nextResolver, requestResolver, applicationResolver); factory.setNextFactory(nextFactory); VariableResolver resolver = factory.getVariableResolver("requestScope"); assertEquals(requestResolver, resolver); resolver = factory.getVariableResolver("requestScope"); assertEquals(requestResolver, resolver); resolver = factory.getVariableResolver("applicationScope"); assertEquals(applicationResolver, resolver); resolver = factory.getVariableResolver("other"); assertEquals(nextResolver, resolver); verify(factory, request, applicationContext, nextFactory, nextResolver, requestResolver, applicationResolver); }
@Override public VariableResolver getVariableResolver(String name) { if (isResolveable(name)) { if (variableResolvers != null && variableResolvers.containsKey(name)) { return variableResolvers.get(name); } else if (isTarget(name)) { VariableResolver variableResolver = createVariableResolver(name); variableResolvers.put(name, variableResolver); return variableResolver; } else if (nextFactory != null) { return nextFactory.getVariableResolver(name); } } throw new UnresolveablePropertyException("unable to resolve variable '" + name + "'"); }
ReadOnlyVariableResolverFactory extends
        BaseVariableResolverFactory { @Override public VariableResolver getVariableResolver(String name) { if (isResolveable(name)) { if (variableResolvers != null && variableResolvers.containsKey(name)) { return variableResolvers.get(name); } else if (isTarget(name)) { VariableResolver variableResolver = createVariableResolver(name); variableResolvers.put(name, variableResolver); return variableResolver; } else if (nextFactory != null) { return nextFactory.getVariableResolver(name); } } throw new UnresolveablePropertyException("unable to resolve variable '" + name + "'"); } }
ReadOnlyVariableResolverFactory extends
        BaseVariableResolverFactory { @Override public VariableResolver getVariableResolver(String name) { if (isResolveable(name)) { if (variableResolvers != null && variableResolvers.containsKey(name)) { return variableResolvers.get(name); } else if (isTarget(name)) { VariableResolver variableResolver = createVariableResolver(name); variableResolvers.put(name, variableResolver); return variableResolver; } else if (nextFactory != null) { return nextFactory.getVariableResolver(name); } } throw new UnresolveablePropertyException("unable to resolve variable '" + name + "'"); } ReadOnlyVariableResolverFactory(TilesRequestContextHolder requestHolder); }
ReadOnlyVariableResolverFactory extends
        BaseVariableResolverFactory { @Override public VariableResolver getVariableResolver(String name) { if (isResolveable(name)) { if (variableResolvers != null && variableResolvers.containsKey(name)) { return variableResolvers.get(name); } else if (isTarget(name)) { VariableResolver variableResolver = createVariableResolver(name); variableResolvers.put(name, variableResolver); return variableResolver; } else if (nextFactory != null) { return nextFactory.getVariableResolver(name); } } throw new UnresolveablePropertyException("unable to resolve variable '" + name + "'"); } 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); }
ReadOnlyVariableResolverFactory extends
        BaseVariableResolverFactory { @Override public VariableResolver getVariableResolver(String name) { if (isResolveable(name)) { if (variableResolvers != null && variableResolvers.containsKey(name)) { return variableResolvers.get(name); } else if (isTarget(name)) { VariableResolver variableResolver = createVariableResolver(name); variableResolvers.put(name, variableResolver); return variableResolver; } else if (nextFactory != null) { return nextFactory.getVariableResolver(name); } } throw new UnresolveablePropertyException("unable to resolve variable '" + name + "'"); } 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);  }