11d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert/*
21d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Copyright (C) 2011 The Guava Authors
31d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert *
41d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License");
51d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * you may not use this file except in compliance with the License.
61d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * You may obtain a copy of the License at
71d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert *
81d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * http://www.apache.org/licenses/LICENSE-2.0
91d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert *
101d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Unless required by applicable law or agreed to in writing, software
111d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS,
121d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * See the License for the specific language governing permissions and
141d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * limitations under the License.
151d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */
161d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
171d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertpackage com.google.common.collect;
181d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
191d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertimport static com.google.common.testing.SerializableTester.reserialize;
201d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertimport static junit.framework.Assert.assertEquals;
211d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertimport static junit.framework.Assert.assertTrue;
221d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
231d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertimport com.google.common.annotations.GwtCompatible;
241d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertimport com.google.common.annotations.GwtIncompatible;
251d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertimport com.google.common.testing.SerializableTester;
261d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
271d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertimport java.util.Set;
281d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
291d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert/**
301d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * Variant of {@link SerializableTester} that does not require the reserialized object's class to be
311d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * identical to the original.
321d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert *
331d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * @author Chris Povirk
341d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */
351d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert/*
361d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * The whole thing is really @GwtIncompatible, but GwtJUnitConvertedTestModule doesn't have a
371d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert * parameter for non-GWT, non-test files, and it didn't seem worth adding one for this unusual case.
381d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert */
391d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert@GwtCompatible(emulated = true)
401d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringertfinal class LenientSerializableTester {
411d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  /*
421d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * TODO(cpovirk): move this to c.g.c.testing if we allow for c.g.c.annotations dependencies so
431d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   * that it can be GWTified?
441d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert   */
451d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  @GwtIncompatible("SerializableTester")
461d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  static <E> Set<E> reserializeAndAssertLenient(Set<E> original) {
471d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert    Set<E> copy = reserialize(original);
481d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert    assertEquals(original, copy);
491d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert    assertTrue(copy instanceof ImmutableSet);
501d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert    return copy;
511d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  }
521d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert
531d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert  private LenientSerializableTester() {}
541d580d0f6ee4f21eb309ba7b509d2c6d671c4044Bjorn Bringert}
55