<T extends StoreInfo> void initStore(
      T s, Class<T> clazz, String sId, String name, WorkspaceInfo ws) {
    expect(s.getId()).andReturn(sId).anyTimes();
    expect(s.getName()).andReturn(name).anyTimes();
    expect(s.getWorkspace()).andReturn(ws).anyTimes();
    expect(s.getCatalog()).andReturn(catalog).anyTimes();
    expect(s.isEnabled()).andReturn(true).anyTimes();

    expect(catalog.getStore(sId, clazz)).andReturn(s).anyTimes();
    expect(catalog.getStore(sId, StoreInfo.class)).andReturn(s).anyTimes();

    expect(catalog.getStoreByName(name, clazz)).andReturn(s).anyTimes();
    expect(catalog.getStoreByName(name, StoreInfo.class)).andReturn(s).anyTimes();

    expect(catalog.getStoreByName(ws.getName(), name, clazz)).andReturn(s).anyTimes();
    expect(catalog.getStoreByName(ws.getName(), name, StoreInfo.class)).andReturn(s).anyTimes();

    expect(catalog.getStoreByName(ws, name, clazz)).andReturn(s).anyTimes();
    expect(catalog.getStoreByName(ws, name, StoreInfo.class)).andReturn(s).anyTimes();
  }
  <T extends ResourceInfo> void initResource(
      T r,
      Class<T> clazz,
      String rId,
      String name,
      StoreInfo s,
      NamespaceInfo ns,
      String srs,
      ProjectionPolicy projPolicy,
      ReferencedEnvelope envelope,
      ReferencedEnvelope latLonEnvelope) {

    expect(r.getId()).andReturn(rId).anyTimes();
    expect(r.getName()).andReturn(name).anyTimes();
    expect(r.getQualifiedName()).andReturn(new NameImpl(ns.getURI(), name)).anyTimes();
    expect(r.getNativeName()).andReturn(name).anyTimes();
    expect(r.getQualifiedNativeName()).andReturn(new NameImpl(ns.getURI(), name)).anyTimes();
    expect(r.getTitle()).andReturn(name).anyTimes();
    expect(r.getAbstract()).andReturn("abstract about " + name).anyTimes();
    expect(r.getStore()).andReturn(s).anyTimes();
    expect(r.getNamespace()).andReturn(ns).anyTimes();

    srs = srs != null ? srs : "EPSG:4326";
    expect(r.getSRS()).andReturn(srs).anyTimes();
    try {
      expect(r.getNativeCRS()).andReturn(CRS.decode(srs));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    expect(r.getKeywords()).andReturn((List) Arrays.asList(new Keyword(name))).anyTimes();
    expect(r.isEnabled()).andReturn(true).anyTimes();
    expect(r.isAdvertised()).andReturn(true).anyTimes();
    expect(r.getProjectionPolicy()).andReturn(projPolicy).anyTimes();
    expect(r.getLatLonBoundingBox()).andReturn(latLonEnvelope).anyTimes();
    ;
    expect(r.getNativeBoundingBox()).andReturn(envelope).anyTimes();

    expect(catalog.getResource(rId, clazz)).andReturn(r).anyTimes();

    expect(catalog.getResourceByName(ns.getPrefix() + ":" + name, clazz)).andReturn(r).anyTimes();
    expect(catalog.getResourceByName(ns.getPrefix() + ":" + name, ResourceInfo.class))
        .andReturn(r)
        .anyTimes();

    expect(catalog.getResourceByName(name, clazz)).andReturn(r).anyTimes();
    expect(catalog.getResourceByName(name, ResourceInfo.class)).andReturn(r).anyTimes();

    expect(catalog.getResourceByName(new NameImpl(ns.getPrefix(), name), clazz))
        .andReturn(r)
        .anyTimes();
    expect(catalog.getResourceByName(new NameImpl(ns.getPrefix(), name), ResourceInfo.class))
        .andReturn(r)
        .anyTimes();

    expect(catalog.getResourceByName(new NameImpl(ns.getURI(), name), clazz))
        .andReturn(r)
        .anyTimes();
    expect(catalog.getResourceByName(new NameImpl(ns.getURI(), name), ResourceInfo.class))
        .andReturn(r)
        .anyTimes();

    expect(catalog.getResourceByName(ns, name, clazz)).andReturn(r).andReturn(r).anyTimes();
    expect(catalog.getResourceByName(ns, name, ResourceInfo.class))
        .andReturn(r)
        .andReturn(r)
        .anyTimes();

    expect(catalog.getResourceByName(ns.getPrefix(), name, clazz)).andReturn(r).anyTimes();
    expect(catalog.getResourceByName(ns.getPrefix(), name, ResourceInfo.class))
        .andReturn(r)
        .anyTimes();
    // expect(catalog.getResourceByName(or(eq(ns.getPrefix()), eq(ns.getURI())), name,
    //    clazz)).andReturn(r).anyTimes();
    expect(catalog.getResourceByStore(s, name, clazz)).andReturn(r).anyTimes();
    expect(catalog.getResourceByStore(s, name, ResourceInfo.class)).andReturn(r).anyTimes();
  }