Пример #1
0
  @Test
  public void testCacheClearing() throws IOException {
    cleared = false;
    ResourcePool pool =
        new ResourcePool(getCatalog()) {
          @Override
          public void clear(FeatureTypeInfo info) {
            cleared = true;
            super.clear(info);
          }
        };
    FeatureTypeInfo info =
        getCatalog()
            .getFeatureTypeByName(MockData.LAKES.getNamespaceURI(), MockData.LAKES.getLocalPart());

    assertNotNull(pool.getFeatureType(info));
    info.setTitle("changed");

    assertFalse(cleared);
    getCatalog().save(info);
    assertTrue(cleared);

    cleared = false;
    assertNotNull(pool.getFeatureType(info));

    for (LayerInfo l : getCatalog().getLayers(info)) {
      getCatalog().remove(l);
    }
    getCatalog().remove(info);
    assertTrue(cleared);
  }
Пример #2
0
 /**
  * Test that the {@link FeatureType} cache returns the same instance every time. This is assumed
  * by some nasty code in other places that tampers with the CRS. If a new {@link FeatureType} is
  * constructed for the same {@link FeatureTypeInfo}, Bad Things Happen (TM).
  */
 @Test
 public void testFeatureTypeCacheInstance() throws Exception {
   ResourcePool pool = ResourcePool.create(getCatalog());
   FeatureTypeInfo info =
       getCatalog()
           .getFeatureTypeByName(MockData.LAKES.getNamespaceURI(), MockData.LAKES.getLocalPart());
   FeatureType ft1 = pool.getFeatureType(info);
   FeatureType ft2 = pool.getFeatureType(info);
   FeatureType ft3 = pool.getFeatureType(info);
   assertSame(ft1, ft2);
   assertSame(ft1, ft3);
 }