/*
 * The MIT License (MIT)
 * 
 * Copyright (c) 2013 Jeff Nelson, Cinchapi Software Collective
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.cinchapi.concourse.server.io;

import org.junit.Assert;
import org.junit.Test;

/**
 * Tests for {@link Byteable} objects.
 * 
 * @author jnelson
 */
public abstract class ByteableTest {

	/**
	 * Return a random instance of the test class.
	 * 
	 * @return a random instance
	 */
	protected abstract Byteable getRandomTestInstance();

	/**
	 * Return the test class
	 * 
	 * @return the test class
	 */
	protected abstract Class<?> getTestClass();

	@Test
	public void testSerialization() {
		Byteable object = getRandomTestInstance();
		Assert.assertTrue(Byteables.read(object.getBytes(), getTestClass())
				.equals(object));
	}

}

@@ -1225,304 +1225,1013 @@
 ort 
-org.junit.Assert;%0Aimport org.junit.Test;%0A%0A/**%0A * Tests for %7B@link Byteable%7D objects.%0A * %0A * @author jnelson%0A */%0Apublic abstract class ByteableTest %7B%0A%0A%09/**%0A%09 * Return a random instance of the test class.%0A%09 * %0A%09 * @return a random instance%0A%09 */%0A%09protected abstract Byteable getRandomTestInstanc
+java.lang.reflect.Method;%0A%0Aimport org.cinchapi.concourse.util.TestData;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport com.google.common.base.Throwables;%0A%0A/**%0A * Tests for %7B@link Byteable%7D objects.%0A * %0A * @author jnelson%0A */%0Apublic abstract class ByteableTest %7B%0A%0A%09/**%0A%09 * Return a random instance of the test class defined in%0A%09 * %7B@link #getTestClass()%7D. This method assumes that there is a method in%0A%09 * %7B@link TestData%7D that takes no arguments and returns the appropriate%0A%09 * type.%0A%09 * %0A%09 * @return a random instance%0A%09 */%0A%09protected Byteable getRandomTestInstance() %7B%0A%09%09try %7B%0A%09%09%09for (Method method : TestData.class.getMethods()) %7B%0A%09%09%09%09if(method.getReturnType() == getTestClass()%0A%09%09%09%09%09%09&& method.getParameterTypes().length == 0) %7B%0A%09%09%09%09%09return (Byteable) method.invoke(null);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09throw new IllegalStateException(%0A%09%09%09%09%09%22There is no method in TestData that takes no parameters and returns a %22%0A%09%09%09%09%09%09%09+ getTestClass());%0A%09%09%7D%0A%09%09catch (Exception e) %7B%0A%09%09%09throw Throwables.propagat
 e(
+e
 );
+%0A%09%09%7D%0A%0A%09%7D
 %0A%0A%09/
@@ -2323,16 +2323,33 @@
  Class%3C?
+ extends Byteable
 %3E getTes
@@ -2446,16 +2446,46 @@
 ance();%0A
+%09%09System.out.println(object);%0A
 %09%09Assert

use reflection to get test instances