@Override
 public void setUp() {
   defaults = GWCConfig.getOldDefaults();
   defaultVectorInfo = TileLayerInfoUtil.create(defaults);
   defaultVectorInfo.getMimeFormats().clear();
   defaultVectorInfo.getMimeFormats().addAll(defaults.getDefaultVectorCacheFormats());
 }
  /**
   * Saves a tile layer info into the given metadata map using the old legacy metadata elements. For
   * unit testing only.
   *
   * @param source
   * @param metadata
   */
  public static void save(GeoServerTileLayerInfo source, MetadataMap metadata) {
    final boolean enabled = source.isEnabled();
    final int gutter = source.getGutter();
    final Set<XMLGridSubset> cachedGridSubsets = source.getGridSubsets();
    final int metaTilingX = source.getMetaTilingX();
    final int metaTilingY = source.getMetaTilingY();
    final Set<String> mimeFormats = source.getMimeFormats();
    final Boolean autoCacheStyles = source.isAutoCacheStyles();
    final Set<String> cachedStyles = source.cachedStyles();
    final boolean inMemoryCached = source.isInMemoryCached();

    metadata.put(CONFIG_KEY_ENABLED, Boolean.valueOf(enabled));
    metadata.put(CONFIG_KEY_GUTTER, Integer.valueOf(gutter));
    Collection<String> subsetNames = new ArrayList<String>();
    for (XMLGridSubset s : cachedGridSubsets) {
      subsetNames.add(s.getGridSetName());
    }
    metadata.put(CONFIG_KEY_GRIDSETS, marshalList(subsetNames));
    metadata.put(CONFIG_KEY_METATILING_X, Integer.valueOf(metaTilingX));
    metadata.put(CONFIG_KEY_METATILING_Y, Integer.valueOf(metaTilingY));
    metadata.put(CONFIG_KEY_FORMATS, marshalList(mimeFormats));
    metadata.put(CONFIG_KEY_AUTO_CACHE_STYLES, autoCacheStyles);
    metadata.put(CONFIG_KEY_IN_MEMORY_CACHED, inMemoryCached);

    if (cachedStyles.size() > 0) {
      metadata.put(CONFIG_KEY_CACHED_STYLES, marshalList(cachedStyles));
    } else {
      metadata.remove(CONFIG_KEY_CACHED_STYLES);
    }
  }
  public void testLoadLayerGroup() {
    LayerGroupInfoImpl lg = mockGroup("tesGroup", mockLayer("L1"), mockLayer("L2"));

    assertNull(LegacyTileLayerInfoLoader.load(lg));
    GeoServerTileLayerInfo info = defaultVectorInfo;
    info.getMimeFormats().clear();
    info.getMimeFormats().addAll(defaults.getDefaultOtherCacheFormats());

    LegacyTileLayerInfoLoader.save(info, lg.getMetadata());

    GeoServerTileLayerInfo actual;
    actual = LegacyTileLayerInfoLoader.load(lg);

    info.setId(lg.getId());
    info.setName(GWC.tileLayerName(lg));
    assertEquals(info, actual);
  }