package org.darkphoenixs.mq.util;

import kafka.serializer.Decoder;
import kafka.serializer.DefaultDecoder;
import kafka.utils.VerifiableProperties;

import org.darkphoenixs.mq.message.MessageBeanImpl;
import org.junit.Assert;
import org.junit.Test;

public class RefleToolTest {

	@Test
	public void test() throws Exception {

		Assert.assertNotNull(new RefleTool());

		Assert.assertTrue(RefleTool.newInstance(DefaultDecoder.class,
				new VerifiableProperties()) instanceof Decoder);

		try {
			RefleTool.newInstance(TestInter.class);

		} catch (Exception e) {
			Assert.assertTrue(e instanceof NoSuchMethodException);
		}


		MessageBeanImpl messageBean = new MessageBeanImpl();
		
		long date = System.currentTimeMillis();
		messageBean.setMessageNo("MessageNo");
		messageBean.setMessageType("MessageType");
		messageBean.setMessageAckNo("MessageAckNo");
		messageBean.setMessageDate(date);
		messageBean.setMessageContent("MessageContent".getBytes("UTF-8"));
		
		String mt = RefleTool.getFieldValue(messageBean, "messageType", String.class);
		
		System.out.println(mt);
	}

}

abstract class TestInter {

	public TestInter() {
	}
}
@@ -970,19 +970,42 @@
 %09%0A%09%09
-String mt =
+Assert.assertEquals(%22MessageType%22,
  Ref
@@ -1070,36 +1070,100 @@
 ass)
+)
 ;%0A%09%09%0A%09%09
-System.out.println(mt
+Assert.assertNull(RefleTool.getFieldValue(messageBean, %22messageType1%22, String.class)
 );%0A%09

fix testcase