From a7632f3931d319f1be3deaf288e90de42c2de755 Mon Sep 17 00:00:00 2001 From: Zed Date: Mon, 21 Dec 2020 17:19:00 +0800 Subject: [PATCH] =?UTF-8?q?DEC-15861=20feat:=20Fr/Bi=E8=9E=8D=E5=90=88?= =?UTF-8?q?=E4=B8=8E=E7=8B=AC=E7=AB=8B=E9=83=A8=E7=BD=B2V1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/decision/CommonKit.java | 12 ++++++++++++ .../com/fanruan/api/decision/CommonKitTest.java | 13 ++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fanruan/api/decision/CommonKit.java b/src/main/java/com/fanruan/api/decision/CommonKit.java index 61ef66f..119d7ae 100644 --- a/src/main/java/com/fanruan/api/decision/CommonKit.java +++ b/src/main/java/com/fanruan/api/decision/CommonKit.java @@ -5,8 +5,10 @@ import com.fanruan.api.util.StringKit; import com.fr.base.Base64; import com.fr.base.ServerConfig; import com.fr.decision.webservice.utils.DecisionServiceConstants; +import com.fr.decision.webservice.utils.WebServiceUtils; import com.fr.stable.StringUtils; +import javax.servlet.http.HttpServletRequest; import java.awt.Image; /** * @author richie @@ -63,4 +65,14 @@ public class CommonKit { public static String encode(Image im, String format) { return Base64.encode(im, format); } + + /** + * 是否是ajax请求 + * + * @param request http请求 + * @return 是否是ajax请求 + */ + public static boolean ajaxRequest(HttpServletRequest request) { + return WebServiceUtils.ajaxRequest(request); + } } diff --git a/src/test/java/com/fanruan/api/decision/CommonKitTest.java b/src/test/java/com/fanruan/api/decision/CommonKitTest.java index 52a7996..8b503d8 100644 --- a/src/test/java/com/fanruan/api/decision/CommonKitTest.java +++ b/src/test/java/com/fanruan/api/decision/CommonKitTest.java @@ -10,9 +10,11 @@ import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import java.awt.Image; +import javax.servlet.http.HttpServletRequest; +import java.awt.*; import java.awt.image.BufferedImage; import java.io.UnsupportedEncodingException; +import java.lang.reflect.Method; /** * @author Lucian.Chen @@ -56,4 +58,13 @@ public class CommonKitTest { String result = Base64.encode(im, ""); Assert.assertEquals(result, CommonKit.encode(im, "")); } + + @Test + public void ajaxRequest() throws Exception { + Class classBook = Class.forName("com.fanruan.api.decision.CommonKit"); + Assert.assertNotNull(classBook); + + Method method1 = classBook.getDeclaredMethod("ajaxRequest", HttpServletRequest.class); + Assert.assertNotNull(method1); + } }