/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.flink.api.common.typeutils;


public class SerializerTestInstance<T> extends SerializerTestBase<T> {

	private final TypeSerializer<T> serializer;

	private final Class<T> typeClass;

	private final int length;

	private final T[] testData;

	// --------------------------------------------------------------------------------------------

	@SafeVarargs
	public SerializerTestInstance(TypeSerializer<T> serializer, Class<T> typeClass, int length, T... testData) {
		this.serializer = serializer;
		this.typeClass = typeClass;
		this.length = length;
		this.testData = testData;
	}
	
	// --------------------------------------------------------------------------------------------
	
	@Override
	protected TypeSerializer<T> createSerializer() {
		return this.serializer;
	}

	@Override
	protected int getLength() {
		return this.length;
	}

	@Override
	protected Class<T> getTypeClass() {
		return this.typeClass;
	}

	@Override
	protected T[] getTestData() {
		return this.testData;
	}
	
	// --------------------------------------------------------------------------------------------
	
	public void testAll() {
		testInstantiate();
		testGetLength();
		testCopy();
		testCopyIntoNewElements();
		testCopyIntoReusedElements();
		testSerializeIndividually();
		testSerializeIndividuallyReusingValues();
		testSerializeAsSequenceNoReuse();
		testSerializeAsSequenceReusingValues();
		testSerializedCopyIndividually();
		testSerializedCopyAsSequence();
		testSerializabilityAndEquals();
	}
}

@@ -849,16 +849,126 @@
 tils;%0A%0A%0A
+import org.junit.Test;%0A%0Aimport java.lang.reflect.InvocationTargetException;%0Aimport java.lang.reflect.Method;%0A%0A
 public c
@@ -1502,34 +1502,33 @@
  = testData;%0A%09%7D%0A
-%09
 %0A
+
 %09// ------------
@@ -1608,18 +1608,17 @@
 -------%0A
-%09
 %0A
+
 %09@Overri
@@ -1912,18 +1912,17 @@
 ata;%0A%09%7D%0A
-%09
 %0A
+
 %09// ----
@@ -2014,10 +2014,9 @@
 ---%0A
-%09
 %0A
+
 %09pub
@@ -2042,376 +2042,505 @@
 %7B%0A%09%09
-testInstantiate();%0A%09%09testGetLength();%0A%09%09testCopy();%0A%09%09testCopyIntoNewElements();%0A%09%09testCopyIntoReusedElements();%0A%09%09testSerializeIndividually();%0A%09%09testSerializeIndividuallyReusingValues();%0A%09%09testSerializeAsSequenceNoRe
+for (Method method : SerializerTestBase.class.getMethods()) %7B%0A%09%09%09if (method.getAnnotation(Test.class) == null) %7B%0A%09%09%09%09continue;%0A%09%09%09%7D%0A%09%09%09try %7B%0A%09%09%09%09method.invoke(this);%0A%09%09%09%7D catch (IllegalAccessException e) %7B%0A%09%09%09%09throw new RuntimeException(%22Unable to invoke test %22 + method.getName(), e);%0A%09%09%09%7D catch (InvocationTargetException e) %7B%0A%09%09%09%09sneakyThrow(e.getCa
 use()
+)
 ;%0A%09%09
-testSerializeAsSequenceReusingValues();%0A%09%09testSerializedCopyIndividually();%0A%09%09testSerializedCopyAsSequence();%0A%09%09testSerializabilityAndEquals()
+%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09@SuppressWarnings(%22unchecked%22)%0A%09private static %3CE extends Throwable%3E void sneakyThrow(Throwable e) throws E %7B%0A%09%09throw (E) e
 ;%0A%09%7D

Call all methods from SerializerTestBase in SerializerTestInstance by reflection