Package org.springmodules.cache

Examples of org.springmodules.cache.CachingModel


    setUpCachingListener();
    expectMethodInvocationReturnsCacheableMethod();

    Serializable key = "Anakin Skywalker";
    Object expected = new Object();
    CachingModel model = expectGetFromCache(key, null);

    invocationControl.expectAndReturn(invocation.proceed(), expected);

    cacheProviderFacade.putInCache(key, model, expected);
View Full Code Here


  public void testInvokeWhenCacheReturnsNullWithoutCachingListeners()
      throws Throwable {
    expectMethodInvocationReturnsCacheableMethod();

    Serializable key = "Luke Skywalker";
    CachingModel model = expectGetFromCache(key, null);

    Object expected = new Object();
    invocationControl.expectAndReturn(invocation.proceed(), expected);

    cacheProviderFacade.putInCache(key, model, expected);
View Full Code Here

    Element element = new DomElementStub("caching");
    element.setAttribute("cronExpression", cronExpression);
    element.setAttribute("groups", groups);
    element.setAttribute("refreshPeriod", refreshPeriod);

    CachingModel actual = parser.parseCachingModel(element);
    CachingModel expected = new OsCacheCachingModel(groups, Integer
        .parseInt(refreshPeriod), cronExpression);

    assertEquals(expected, actual);
  }
View Full Code Here

    String refreshPeriod = "three";

    Element element = createCachingElement(cronExpression, groups,
        refreshPeriod);

    CachingModel actual = parser.parseCachingModel(element);
    CachingModel expected = new OsCacheCachingModel(groups, cronExpression);

    assertEquals(expected, actual);
  }
View Full Code Here

    String cronExpression = "* 0 * * *";
    String groups = "pojos,web";

    Element element = createCachingElement(cronExpression, groups);

    CachingModel actual = parser.parseCachingModel(element);
    CachingModel expected = new OsCacheCachingModel(groups, cronExpression);

    assertEquals(expected, actual);
  }
View Full Code Here

    String modelId = "Han";
    Cached cachingAttribute = new Cached(modelId);
    mockInterceptor.cachingAttribute = cachingAttribute;

    CachingModel expected = new MockCachingModel();
    Map models = new HashMap();
    models.put(modelId, expected);
    mockInterceptor.setCachingModels(models);

    assertSame(expected, mockInterceptor.model(invocation));
View Full Code Here

  private void expectAfterPropertiesSetOnCachingInterceptor() {
    cacheProviderFacadeControl.expectAndReturn(cacheProviderFacade
        .modelValidator(), validator);
    for (Iterator i = cachingModels.entrySet().iterator(); i.hasNext();) {
      Map.Entry entry = (Map.Entry) i.next();
      CachingModel model = (CachingModel) entry.getValue();
      validator.validateCachingModel(model);
    }
  }
View Full Code Here

  public void testOnAfterPropertiesSetWithCachingModelSourceEqualToNull()
      throws Exception {
    interceptor.setCachingModelSource(null);

    CachingModel model1 = new MockCachingModel();
    CachingModel model2 = new MockCachingModel();

    Map cachingModels = new HashMap();
    cachingModels.put("java.lang.String.indexO*", model1);
    cachingModels.put("java.lang.String.toUpperC*", model2);
    interceptor.setCachingModels(cachingModels);
View Full Code Here

  public Object invoke(MethodInvocation mi) throws Throwable {
    Method method = mi.getMethod();
    if (!CachingUtils.isCacheable(method))
      return methodNotCacheable(mi, method);

    CachingModel model = model(mi);
    if (model == null) return noModelFound(mi, method);

    Serializable key = keyGenerator.generateKey(mi);
    Object cached = cache.getFromCache(key, model);
View Full Code Here

    invocationControl.expectAndReturn(invocation.getThis(), thisObject);

    Method method = defaultMethod();
    invocationControl.expectAndReturn(invocation.getMethod(), method);

    CachingModel expected = new MockCachingModel();
    sourceControl.expectAndReturn(source.model(method, thisObject
        .getClass()), expected);

    replayMocks();
View Full Code Here

TOP

Related Classes of org.springmodules.cache.CachingModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.