Class ClassesSerializableTest

java.lang.Object
com.vaadin.flow.testutil.ClassFinder
com.vaadin.flow.testutil.ClassesSerializableTest

public abstract class ClassesSerializableTest extends ClassFinder
A superclass for serialization testing. The test scans all the classpath and tries to serialize every single class (except ones from whitelist) in the classpath. Subclasses may adjust the whitelist by overriding getExcludedPatterns(), ClassFinder.getBasePackages(), ClassFinder.getJarPattern()
Since:
1.0
  • Constructor Details

    • ClassesSerializableTest

      public ClassesSerializableTest()
  • Method Details

    • getExcludedPatterns

      protected Stream<String> getExcludedPatterns()
    • serializeAndDeserialize

      public <T> T serializeAndDeserialize(T instance) throws Throwable
      Performs actual serialization/deserialization
      Type Parameters:
      T - the type of the instance
      Parameters:
      instance - the instance
      Returns:
      the copy of the source object
      Throws:
      Throwable - if something goes wrong.
    • resetThreadLocals

      protected void resetThreadLocals()
      The method is called right after a class instantiation and might be overriden by subclasses to reset thread local values (ex. current UI).
      See Also:
    • setupThreadLocals

      protected void setupThreadLocals()
      The method is called right a class instantiation and might be overriden by subclasses to install some necessary thread local values (ex. current UI).
      See Also:
    • classesSerializable

      public void classesSerializable() throws Throwable
      Tests that all the relevant classes and interfaces under ClassFinder.getBasePackages() implement Serializable.
      Throws:
      Throwable - serialization goes wrong