From 04a854eddcb5a442c7e4932c0f7c26cf1c900c5a Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 23 Jun 2017 20:31:33 +0900 Subject: [PATCH] added test --- .../loafle/overflow/proxy/db/DBProxyTest.java | 15 ----- .../overflow/proxy/db/MethodSeekerTest.java | 67 +++++++++++++++++++ 2 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 src/test/java/com/loafle/overflow/proxy/db/MethodSeekerTest.java diff --git a/src/test/java/com/loafle/overflow/proxy/db/DBProxyTest.java b/src/test/java/com/loafle/overflow/proxy/db/DBProxyTest.java index 7e96561..fe4527c 100644 --- a/src/test/java/com/loafle/overflow/proxy/db/DBProxyTest.java +++ b/src/test/java/com/loafle/overflow/proxy/db/DBProxyTest.java @@ -34,22 +34,7 @@ public class DBProxyTest { @Autowired private NoAuthProbeDAO noAuthProbeDAO; - @Test - public void RelfetMehotds() { - JpaRepository jpa = this.noAuthProbeDAO; - - Method[] mArray = jpa.getClass().getMethods(); - - for (Method m : mArray) { - if( m.getName().equals("findOne")) { - - System.out.println(m.getParameterTypes()); - } - } - - - } @Test public void RelfectMethod() throws InvocationTargetException, IllegalAccessException { diff --git a/src/test/java/com/loafle/overflow/proxy/db/MethodSeekerTest.java b/src/test/java/com/loafle/overflow/proxy/db/MethodSeekerTest.java new file mode 100644 index 0000000..b4c8a1e --- /dev/null +++ b/src/test/java/com/loafle/overflow/proxy/db/MethodSeekerTest.java @@ -0,0 +1,67 @@ +package com.loafle.overflow.proxy.db; + +import com.loafle.overflow.AppConfig; +import com.loafle.overflow.JdbcConfiguration; +import com.loafle.overflow.module.domain.model.Domain; +import com.loafle.overflow.module.noauthprobe.dao.NoAuthProbeDAO; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.lang.reflect.Method; + +import static org.junit.Assert.*; + +/** + * Created by root on 17. 6. 23. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +public class MethodSeekerTest { + + @Autowired + private NoAuthProbeDAO noAuthProbeDAO; + + @Test + public void getMethod() throws Exception { + + JpaRepository jpa = this.noAuthProbeDAO; + + Method m = MethodSeeker.getMethod(jpa.getClass(), "findAllByDomain", null); + + Assert.assertNotEquals(m, null); + + } + + @Test + public void RelfetMehotds() { + + JpaRepository jpa = this.noAuthProbeDAO; + + Method[] mArray = jpa.getClass().getMethods(); + + for (Method m : mArray) { + if( m.getName().equals("findAllByDomain")) { + + System.out.println(m.getParameterTypes()); + } + } + + } + + @Test + public void RelfectMethodType() throws NoSuchMethodException { + + JpaRepository jpa = this.noAuthProbeDAO; + + Method m = jpa.getClass().getMethod("findAllByDomain", Domain.class); + + Assert.assertNotEquals(m, null); + + } + +} \ No newline at end of file