1/* GENERATED SOURCE. DO NOT MODIFY. */ 2// © 2016 and later: Unicode, Inc. and others. 3// License & terms of use: http://www.unicode.org/copyright.html#License 4/* 5 ******************************************************************************* 6 * Copyright (C) 2005-2016, International Business Machines Corporation and * 7 * others. All Rights Reserved. * 8 ******************************************************************************* 9 */ 10package android.icu.dev.test.serializable; 11 12import java.io.IOException; 13import java.lang.reflect.Modifier; 14import java.util.List; 15 16import org.junit.Test; 17import org.junit.runner.RunWith; 18 19import android.icu.dev.test.TestFmwk; 20import android.icu.dev.test.serializable.SerializableTestUtility.Handler; 21 22import junitparams.JUnitParamsRunner; 23import junitparams.Parameters; 24 25/** 26 * @author sgill 27 * @author emader 28 * 29 */ 30@RunWith(JUnitParamsRunner.class) 31public class CoverageTest extends TestFmwk { 32 33 @Test 34 @Parameters(method="generateClassList") 35 public void testSerialization(String className) throws ClassNotFoundException, IOException { 36 Class c = Class.forName(className); 37 int m = c.getModifiers(); 38 39 Handler classHandler = SerializableTestUtility.getHandler(className); 40 if (classHandler == null) { 41 if (!Modifier.isAbstract(m)) { 42 errln("Missing test handler. Update the list of tests in SerializableTest.java to include a test case for " + className); 43 } 44 return; 45 } 46 Object[] testObjects = classHandler.getTestObjects(); 47 byte[] serializedBytes = SerializableTestUtility.getSerializedBytes(testObjects); 48 Object[] serializedObjects = SerializableTestUtility.getSerializedObjects(serializedBytes); 49 for (int i = 0; i < testObjects.length; i++) { 50 if (!classHandler.hasSameBehavior(serializedObjects[i], testObjects[i])) { 51 errln("Input object " + className + "(" + i + ") failed behavior test."); 52 } 53 } 54 } 55 56 List<String> generateClassList() throws IOException { 57 return SerializableTestUtility.getSerializationClassList(this); 58 } 59 60} 61