Last active
December 17, 2015 06:58
-
-
Save tskardal/5568903 to your computer and use it in GitHub Desktop.
Test case to catch GWT serialization errors due to missing empty constructor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example; | |
import java.util.Set; | |
import org.junit.Test; | |
import org.reflections.Reflections; | |
/* | |
Entity is something like this --> public interface Entity extends Serializable { } | |
*/ | |
public class EntityTest { | |
@Test | |
public void ensureGWTSerializationRequirementsAreFulfilled() throws Exception { | |
Reflections reflections = new Reflections("org.example"); | |
Set<Class<? extends Entity>> subTypes = reflections.getSubTypesOf(Entity.class); | |
for (Class<? extends Entity> c : subTypes) { | |
try { | |
c.getDeclaredConstructor(); | |
} catch (NoSuchMethodException e) { | |
throw new NoSuchMethodException("Class " + c.getName() + " doesn't have an empty constructor"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment