package org.nybatis.core.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.activity.InvalidActivityException;

import org.nybatis.core.log.NLogger;

import org.nybatis.core.model.NMap;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;

public class ClassUtilTest {

	@Test( expectedExceptions = InvalidActivityException.class )
	public void makeInstance() throws ClassNotFoundException, InvalidActivityException {

		ClassUtil classUtil = new ClassUtil();

		NLogger.debug( ClassUtil.getClass( "java.util.ArrayList<java.lang.String>" ) );
		NLogger.debug( ClassUtil.getClass( "java.util.ArrayList <java.lang.String" ) );
		NLogger.debug( ClassUtil.getClass( "java. util.ArrayList" ) );

		try {
			NLogger.debug( ClassUtil.getClass( "java.util.ArrayLis" ) );

		} catch( ClassNotFoundException e ) {
			throw new InvalidActivityException( e );
		}

	}

	@Test
	public void hasClassTest() {

		ClassUtil classUtil = new ClassUtil();

		assertEquals( true,   ClassUtil.isExtendedBy( Integer.class, Integer.class ) );
		assertEquals( true,   ClassUtil.isExtendedBy( ArrayList.class, List.class ) );
		assertEquals( true,   ClassUtil.isExtendedBy( NMap.class, Map.class ) );
		assertEquals( false,  ClassUtil.isExtendedBy( NMap.class, List.class ) );

	}

}

@@ -489,50 +489,8 @@
  %7B%0A%0A
-%09%09ClassUtil classUtil = new ClassUtil();%0A%0A
 %09%09NL
@@ -563,24 +563,24 @@
 ring%3E%22 ) );%0A
+
 %09%09NLogger.de
@@ -709,24 +709,88 @@
 ayList%22 ) );
+%0A%09%09NLogger.debug( ClassUtil.getClass( %22java.util.ArrayList%22 ) );
 %0A%0A%09%09try %7B%0A%09%09
@@ -851,17 +851,16 @@
 s%22 ) );%0A
-%0A
 %09%09%7D catc
@@ -985,51 +985,8 @@
 ) %7B%0A
-%0A%09%09ClassUtil classUtil = new ClassUtil();%0A%0A
 %09%09as
@@ -1211,32 +1211,32 @@
  Map.class ) );%0A
+
 %09%09assertEquals( 
@@ -1295,15 +1295,14 @@
 ss ) );%0A
-%0A
 %09%7D%0A%0A%7D%0A

add test case