diff --git a/group15/1515_337959725/.classpath b/group15/1515_337959725/.classpath index d171cd4c12..6a4228528e 100644 --- a/group15/1515_337959725/.classpath +++ b/group15/1515_337959725/.classpath @@ -1,6 +1,7 @@ - + + diff --git a/group15/1515_337959725/.project b/group15/1515_337959725/.project index 8c7c8dd0f7..6730933705 100644 --- a/group15/1515_337959725/.project +++ b/group15/1515_337959725/.project @@ -1,6 +1,6 @@ - BasicTest + coding0305 diff --git a/group15/1515_337959725/.settings/org.eclipse.jdt.core.prefs b/group15/1515_337959725/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..060c5ee3d2 --- /dev/null +++ b/group15/1515_337959725/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/group15/1515_337959725/src/com/coderising/array/ArrayUtil.java b/group15/1515_337959725/src/com/coderising/array/ArrayUtil.java new file mode 100644 index 0000000000..3273e77f7b --- /dev/null +++ b/group15/1515_337959725/src/com/coderising/array/ArrayUtil.java @@ -0,0 +1,184 @@ +package com.coderising.array; + +public class ArrayUtil { + + /** + * ����һ����������a , �Ը������ֵ�����û� + ���磺 a = [7, 9 , 30, 3] , �û���Ϊ [3, 30, 9,7] + ��� a = [7, 9, 30, 3, 4] , �û���Ϊ [4,3, 30 , 9,7] + * @param origin + * @return + */ + public void reverseArray(int[] origin){ + int a; + int length=origin.length; + for(int i=0;iarray2[j]){ + array3[k]=array1[j]; + j++; + k++; + } + } + return array3; + } + /** + * ��һ���Ѿ��������ݵ����� oldArray������������չ�� ��չ��������ݴ�СΪoldArray.length + size + * ע�⣬�������Ԫ��������������Ҫ���� + * ���� oldArray = [2,3,6] , size = 3,�򷵻ص�������Ϊ + * [2,3,6,0,0,0] + * @param oldArray + * @param size + * @return + */ + public int[] grow(int [] oldArray, int size){ + int[] newArray =new int[oldArray.length+size]; + int i; + for(i=0;i parameters) { + + /* + + 0. ��ȡ�����ļ�struts.xml + + 1. ����actionName�ҵ����Ӧ��class �� ����LoginAction, ͨ������ʵ�������������� + ��parameters�е����ݣ����ö����setter������ ����parameters�е������� + ("name"="test" , "password"="1234") , + �Ǿ�Ӧ�õ��� setName��setPassword���� + + 2. ͨ��������ö����exectue ������ ����÷���ֵ������"success" + + 3. ͨ�������ҵ����������getter���������� getMessage��, + ͨ�����������ã� ��ֵ�������γ�һ��HashMap , ���� {"message": "��¼�ɹ�"} , + �ŵ�View�����parameters + + 4. ����struts.xml�е� ����,�Լ�execute�ķ���ֵ�� ȷ����һ��jsp�� + �ŵ�View�����jsp�ֶ��С� + + */ + DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); + View view = null; + try { + DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder(); + File f = new File("E:/gitProject/coding2017/group15/1515_337959725/src/com/coderising/litestruts/struts.xml"); + Document document = documentBuilder.parse(f); + NodeList actionList = document.getElementsByTagName("action"); + Node node = null; + String className=""; + for(int i=0;i params = new HashMap(); + params.put("name","test"); + params.put("password","1234"); + + + View view = Struts.runAction(actionName,params); + + Assert.assertEquals("/jsp/homepage.jsp", view.getJsp()); + Assert.assertEquals("login successful", view.getParameters().get("message")); + } + + @Test + public void testLoginActionFailed() { + String actionName = "login"; + Map params = new HashMap(); + params.put("name","test"); + params.put("password","123456"); //�����Ԥ��IJ�һ�� + + View view = Struts.runAction(actionName,params); + + Assert.assertEquals("/jsp/showLogin.jsp", view.getJsp()); + Assert.assertEquals("login failed,please check your user/pwd", view.getParameters().get("message")); + } +} + diff --git a/group15/1515_337959725/src/com/coderising/litestruts/View.java b/group15/1515_337959725/src/com/coderising/litestruts/View.java new file mode 100644 index 0000000000..07df2a5dab --- /dev/null +++ b/group15/1515_337959725/src/com/coderising/litestruts/View.java @@ -0,0 +1,23 @@ +package com.coderising.litestruts; + +import java.util.Map; + +public class View { + private String jsp; + private Map parameters; + + public String getJsp() { + return jsp; + } + public View setJsp(String jsp) { + this.jsp = jsp; + return this; + } + public Map getParameters() { + return parameters; + } + public View setParameters(Map parameters) { + this.parameters = parameters; + return this; + } +} diff --git a/group15/1515_337959725/src/com/coderising/litestruts/struts.xml b/group15/1515_337959725/src/com/coderising/litestruts/struts.xml new file mode 100644 index 0000000000..6f23f0a83d --- /dev/null +++ b/group15/1515_337959725/src/com/coderising/litestruts/struts.xml @@ -0,0 +1,11 @@ + + + + /jsp/homepage.jsp + /jsp/showLogin.jsp + + + /jsp/welcome.jsp + /jsp/error.jsp + + \ No newline at end of file