From 876cf64589f2c647c3314983fa4c445e49477370 Mon Sep 17 00:00:00 2001 From: lujiajia Date: Mon, 12 Jun 2017 23:45:33 +0800 Subject: [PATCH 01/81] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=87=86=E5=A4=87?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../250103158/data-structure/answer/pom.xml | 32 +++ .../coderising/download/DownloadThread.java | 20 ++ .../coderising/download/FileDownloader.java | 73 +++++++ .../download/FileDownloaderTest.java | 59 ++++++ .../coderising/download/api/Connection.java | 23 ++ .../download/api/ConnectionException.java | 5 + .../download/api/ConnectionManager.java | 10 + .../download/api/DownloadListener.java | 5 + .../download/impl/ConnectionImpl.java | 27 +++ .../download/impl/ConnectionManagerImpl.java | 15 ++ .../coderising/litestruts/LoginAction.java | 39 ++++ .../com/coderising/litestruts/Struts.java | 34 +++ .../com/coderising/litestruts/StrutsTest.java | 43 ++++ .../java/com/coderising/litestruts/View.java | 23 ++ .../java/com/coderising/litestruts/struts.xml | 11 + .../main/java/com/coding/basic/Iterator.java | 7 + .../src/main/java/com/coding/basic/List.java | 9 + .../com/coding/basic/array/ArrayList.java | 35 +++ .../com/coding/basic/array/ArrayUtil.java | 96 +++++++++ .../coding/basic/linklist/LRUPageFrame.java | 164 +++++++++++++++ .../basic/linklist/LRUPageFrameTest.java | 34 +++ .../com/coding/basic/linklist/LinkedList.java | 125 +++++++++++ .../com/coding/basic/queue/CircleQueue.java | 47 +++++ .../coding/basic/queue/CircleQueueTest.java | 44 ++++ .../java/com/coding/basic/queue/Josephus.java | 39 ++++ .../com/coding/basic/queue/JosephusTest.java | 27 +++ .../java/com/coding/basic/queue/Queue.java | 61 ++++++ .../basic/queue/QueueWithTwoStacks.java | 55 +++++ .../com/coding/basic/stack/QuickMinStack.java | 44 ++++ .../coding/basic/stack/QuickMinStackTest.java | 39 ++++ .../java/com/coding/basic/stack/Stack.java | 24 +++ .../com/coding/basic/stack/StackUtil.java | 168 +++++++++++++++ .../com/coding/basic/stack/StackUtilTest.java | 86 ++++++++ .../basic/stack/StackWithTwoQueues.java | 53 +++++ .../basic/stack/StackWithTwoQueuesTest.java | 36 ++++ .../java/com/coding/basic/stack/Tail.java | 5 + .../basic/stack/TwoStackInOneArray.java | 117 ++++++++++ .../basic/stack/TwoStackInOneArrayTest.java | 65 ++++++ .../coding/basic/stack/expr/InfixExpr.java | 72 +++++++ .../basic/stack/expr/InfixExprTest.java | 52 +++++ .../basic/stack/expr/InfixToPostfix.java | 43 ++++ .../basic/stack/expr/InfixToPostfixTest.java | 41 ++++ .../coding/basic/stack/expr/PostfixExpr.java | 46 ++++ .../basic/stack/expr/PostfixExprTest.java | 41 ++++ .../coding/basic/stack/expr/PrefixExpr.java | 52 +++++ .../basic/stack/expr/PrefixExprTest.java | 45 ++++ .../com/coding/basic/stack/expr/Token.java | 50 +++++ .../coding/basic/stack/expr/TokenParser.java | 57 +++++ .../basic/stack/expr/TokenParserTest.java | 41 ++++ .../coding/basic/tree/BinarySearchTree.java | 189 +++++++++++++++++ .../basic/tree/BinarySearchTreeTest.java | 108 ++++++++++ .../com/coding/basic/tree/BinaryTreeNode.java | 36 ++++ .../com/coding/basic/tree/BinaryTreeUtil.java | 116 ++++++++++ .../coding/basic/tree/BinaryTreeUtilTest.java | 75 +++++++ .../java/com/coding/basic/tree/FileList.java | 34 +++ .../data-structure/assignment/pom.xml | 32 +++ .../coderising/download/DownloadThread.java | 20 ++ .../coderising/download/FileDownloader.java | 73 +++++++ .../download/FileDownloaderTest.java | 59 ++++++ .../coderising/download/api/Connection.java | 23 ++ .../download/api/ConnectionException.java | 5 + .../download/api/ConnectionManager.java | 10 + .../download/api/DownloadListener.java | 5 + .../download/impl/ConnectionImpl.java | 27 +++ .../download/impl/ConnectionManagerImpl.java | 15 ++ .../coderising/litestruts/LoginAction.java | 39 ++++ .../com/coderising/litestruts/Struts.java | 34 +++ .../com/coderising/litestruts/StrutsTest.java | 43 ++++ .../java/com/coderising/litestruts/View.java | 23 ++ .../java/com/coderising/litestruts/struts.xml | 11 + .../com/coderising/ood/course/bad/Course.java | 24 +++ .../ood/course/bad/CourseOffering.java | 26 +++ .../ood/course/bad/CourseService.java | 16 ++ .../coderising/ood/course/bad/Student.java | 14 ++ .../coderising/ood/course/good/Course.java | 18 ++ .../ood/course/good/CourseOffering.java | 34 +++ .../ood/course/good/CourseService.java | 14 ++ .../coderising/ood/course/good/Student.java | 21 ++ .../java/com/coderising/ood/ocp/DateUtil.java | 10 + .../java/com/coderising/ood/ocp/Logger.java | 38 ++++ .../java/com/coderising/ood/ocp/MailUtil.java | 10 + .../java/com/coderising/ood/ocp/SMSUtil.java | 10 + .../com/coderising/ood/srp/Configuration.java | 23 ++ .../coderising/ood/srp/ConfigurationKeys.java | 9 + .../java/com/coderising/ood/srp/DBUtil.java | 25 +++ .../java/com/coderising/ood/srp/MailUtil.java | 18 ++ .../com/coderising/ood/srp/PromotionMail.java | 199 ++++++++++++++++++ .../coderising/ood/srp/product_promotion.txt | 4 + .../main/java/com/coding/basic/Iterator.java | 7 + .../src/main/java/com/coding/basic/List.java | 9 + .../com/coding/basic/array/ArrayList.java | 35 +++ .../com/coding/basic/array/ArrayUtil.java | 96 +++++++++ .../coding/basic/linklist/LRUPageFrame.java | 57 +++++ .../basic/linklist/LRUPageFrameTest.java | 34 +++ .../com/coding/basic/linklist/LinkedList.java | 125 +++++++++++ .../com/coding/basic/queue/CircleQueue.java | 39 ++++ .../java/com/coding/basic/queue/Josephus.java | 18 ++ .../com/coding/basic/queue/JosephusTest.java | 27 +++ .../java/com/coding/basic/queue/Queue.java | 61 ++++++ .../basic/queue/QueueWithTwoStacks.java | 47 +++++ .../com/coding/basic/stack/QuickMinStack.java | 19 ++ .../java/com/coding/basic/stack/Stack.java | 24 +++ .../com/coding/basic/stack/StackUtil.java | 48 +++++ .../com/coding/basic/stack/StackUtilTest.java | 65 ++++++ .../basic/stack/StackWithTwoQueues.java | 16 ++ .../basic/stack/TwoStackInOneArray.java | 57 +++++ .../coding/basic/stack/expr/InfixExpr.java | 15 ++ .../basic/stack/expr/InfixExprTest.java | 52 +++++ .../basic/stack/expr/InfixToPostfix.java | 14 ++ .../coding/basic/stack/expr/PostfixExpr.java | 18 ++ .../basic/stack/expr/PostfixExprTest.java | 41 ++++ .../coding/basic/stack/expr/PrefixExpr.java | 18 ++ .../basic/stack/expr/PrefixExprTest.java | 45 ++++ .../com/coding/basic/stack/expr/Token.java | 50 +++++ .../coding/basic/stack/expr/TokenParser.java | 57 +++++ .../basic/stack/expr/TokenParserTest.java | 41 ++++ .../coding/basic/tree/BinarySearchTree.java | 55 +++++ .../basic/tree/BinarySearchTreeTest.java | 109 ++++++++++ .../com/coding/basic/tree/BinaryTreeNode.java | 35 +++ .../com/coding/basic/tree/BinaryTreeUtil.java | 66 ++++++ .../coding/basic/tree/BinaryTreeUtilTest.java | 75 +++++++ .../java/com/coding/basic/tree/FileList.java | 10 + students/250103158/ood/ood-assignment/pom.xml | 32 +++ .../com/coderising/ood/srp/Configuration.java | 23 ++ .../coderising/ood/srp/ConfigurationKeys.java | 9 + .../java/com/coderising/ood/srp/DBUtil.java | 25 +++ .../java/com/coderising/ood/srp/MailUtil.java | 18 ++ .../com/coderising/ood/srp/PromotionMail.java | 199 ++++++++++++++++++ .../coderising/ood/srp/product_promotion.txt | 4 + 129 files changed, 5624 insertions(+) create mode 100644 students/250103158/data-structure/answer/pom.xml create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/download/DownloadThread.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/download/FileDownloader.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/download/FileDownloaderTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/Connection.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/ConnectionException.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/ConnectionManager.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/DownloadListener.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/download/impl/ConnectionImpl.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/download/impl/ConnectionManagerImpl.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/LoginAction.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/Struts.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/StrutsTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/View.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/struts.xml create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/Iterator.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/List.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/array/ArrayList.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/array/ArrayUtil.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LRUPageFrame.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LRUPageFrameTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LinkedList.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/CircleQueue.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/CircleQueueTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/Josephus.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/JosephusTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/Queue.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/QueueWithTwoStacks.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/QuickMinStack.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/QuickMinStackTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/Stack.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackUtil.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackUtilTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackWithTwoQueues.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackWithTwoQueuesTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/Tail.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/TwoStackInOneArray.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/TwoStackInOneArrayTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixExpr.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixExprTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixToPostfix.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixToPostfixTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PostfixExpr.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PostfixExprTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PrefixExpr.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PrefixExprTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/Token.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/TokenParser.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/TokenParserTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinarySearchTree.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinarySearchTreeTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeNode.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeUtil.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeUtilTest.java create mode 100644 students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/FileList.java create mode 100644 students/250103158/data-structure/assignment/pom.xml create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/download/DownloadThread.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/download/FileDownloader.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/download/FileDownloaderTest.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/Connection.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/ConnectionException.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/ConnectionManager.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/DownloadListener.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/download/impl/ConnectionImpl.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/download/impl/ConnectionManagerImpl.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/LoginAction.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/Struts.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/StrutsTest.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/View.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/struts.xml create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/Course.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/CourseOffering.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/CourseService.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/Student.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/Course.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/CourseOffering.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/CourseService.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/Student.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/DateUtil.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/Logger.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/MailUtil.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/SMSUtil.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/Configuration.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/ConfigurationKeys.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/DBUtil.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/MailUtil.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/PromotionMail.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/product_promotion.txt create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/Iterator.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/List.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/array/ArrayList.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/array/ArrayUtil.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LRUPageFrame.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LRUPageFrameTest.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LinkedList.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/CircleQueue.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/Josephus.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/JosephusTest.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/Queue.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/QueueWithTwoStacks.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/QuickMinStack.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/Stack.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackUtil.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackUtilTest.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackWithTwoQueues.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/TwoStackInOneArray.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixExpr.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixExprTest.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixToPostfix.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PostfixExpr.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PostfixExprTest.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PrefixExpr.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PrefixExprTest.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/Token.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/TokenParser.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/TokenParserTest.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinarySearchTree.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinarySearchTreeTest.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeNode.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeUtil.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeUtilTest.java create mode 100644 students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/FileList.java create mode 100644 students/250103158/ood/ood-assignment/pom.xml create mode 100644 students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/Configuration.java create mode 100644 students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/ConfigurationKeys.java create mode 100644 students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/DBUtil.java create mode 100644 students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/MailUtil.java create mode 100644 students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/PromotionMail.java create mode 100644 students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/product_promotion.txt diff --git a/students/250103158/data-structure/answer/pom.xml b/students/250103158/data-structure/answer/pom.xml new file mode 100644 index 0000000000..ac6ba882df --- /dev/null +++ b/students/250103158/data-structure/answer/pom.xml @@ -0,0 +1,32 @@ + + 4.0.0 + + com.coderising + ds-answer + 0.0.1-SNAPSHOT + jar + + ds-answer + http://maven.apache.org + + + UTF-8 + + + + + + junit + junit + 4.12 + + + + + + aliyunmaven + http://maven.aliyun.com/nexus/content/groups/public/ + + + diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/download/DownloadThread.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/DownloadThread.java new file mode 100644 index 0000000000..900a3ad358 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/DownloadThread.java @@ -0,0 +1,20 @@ +package com.coderising.download; + +import com.coderising.download.api.Connection; + +public class DownloadThread extends Thread{ + + Connection conn; + int startPos; + int endPos; + + public DownloadThread( Connection conn, int startPos, int endPos){ + + this.conn = conn; + this.startPos = startPos; + this.endPos = endPos; + } + public void run(){ + + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/download/FileDownloader.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/FileDownloader.java new file mode 100644 index 0000000000..c3c8a3f27d --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/FileDownloader.java @@ -0,0 +1,73 @@ +package com.coderising.download; + +import com.coderising.download.api.Connection; +import com.coderising.download.api.ConnectionException; +import com.coderising.download.api.ConnectionManager; +import com.coderising.download.api.DownloadListener; + + +public class FileDownloader { + + String url; + + DownloadListener listener; + + ConnectionManager cm; + + + public FileDownloader(String _url) { + this.url = _url; + + } + + public void execute(){ + // 在这里实现你的代码, 注意: 需要用多线程实现下载 + // 这个类依赖于其他几个接口, 你需要写这几个接口的实现代码 + // (1) ConnectionManager , 可以打开一个连接,通过Connection可以读取其中的一段(用startPos, endPos来指定) + // (2) DownloadListener, 由于是多线程下载, 调用这个类的客户端不知道什么时候结束,所以你需要实现当所有 + // 线程都执行完以后, 调用listener的notifiedFinished方法, 这样客户端就能收到通知。 + // 具体的实现思路: + // 1. 需要调用ConnectionManager的open方法打开连接, 然后通过Connection.getContentLength方法获得文件的长度 + // 2. 至少启动3个线程下载, 注意每个线程需要先调用ConnectionManager的open方法 + // 然后调用read方法, read方法中有读取文件的开始位置和结束位置的参数, 返回值是byte[]数组 + // 3. 把byte数组写入到文件中 + // 4. 所有的线程都下载完成以后, 需要调用listener的notifiedFinished方法 + + // 下面的代码是示例代码, 也就是说只有一个线程, 你需要改造成多线程的。 + Connection conn = null; + try { + + conn = cm.open(this.url); + + int length = conn.getContentLength(); + + new DownloadThread(conn,0,length-1).start(); + + } catch (ConnectionException e) { + e.printStackTrace(); + }finally{ + if(conn != null){ + conn.close(); + } + } + + + + + } + + public void setListener(DownloadListener listener) { + this.listener = listener; + } + + + + public void setConnectionManager(ConnectionManager ucm){ + this.cm = ucm; + } + + public DownloadListener getListener(){ + return this.listener; + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/download/FileDownloaderTest.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/FileDownloaderTest.java new file mode 100644 index 0000000000..4ff7f46ae0 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/FileDownloaderTest.java @@ -0,0 +1,59 @@ +package com.coderising.download; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.coderising.download.api.ConnectionManager; +import com.coderising.download.api.DownloadListener; +import com.coderising.download.impl.ConnectionManagerImpl; + +public class FileDownloaderTest { + boolean downloadFinished = false; + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testDownload() { + + String url = "http://localhost:8080/test.jpg"; + + FileDownloader downloader = new FileDownloader(url); + + + ConnectionManager cm = new ConnectionManagerImpl(); + downloader.setConnectionManager(cm); + + downloader.setListener(new DownloadListener() { + @Override + public void notifyFinished() { + downloadFinished = true; + } + + }); + + + downloader.execute(); + + // 等待多线程下载程序执行完毕 + while (!downloadFinished) { + try { + System.out.println("还没有下载完成,休眠五秒"); + //休眠5秒 + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + System.out.println("下载完成!"); + + + + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/Connection.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/Connection.java new file mode 100644 index 0000000000..0957eaf7f4 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/Connection.java @@ -0,0 +1,23 @@ +package com.coderising.download.api; + +import java.io.IOException; + +public interface Connection { + /** + * 给定开始和结束位置, 读取数据, 返回值是字节数组 + * @param startPos 开始位置, 从0开始 + * @param endPos 结束位置 + * @return + */ + public byte[] read(int startPos,int endPos) throws IOException; + /** + * 得到数据内容的长度 + * @return + */ + public int getContentLength(); + + /** + * 关闭连接 + */ + public void close(); +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/ConnectionException.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/ConnectionException.java new file mode 100644 index 0000000000..1551a80b3d --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/ConnectionException.java @@ -0,0 +1,5 @@ +package com.coderising.download.api; + +public class ConnectionException extends Exception { + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/ConnectionManager.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/ConnectionManager.java new file mode 100644 index 0000000000..ce045393b1 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/ConnectionManager.java @@ -0,0 +1,10 @@ +package com.coderising.download.api; + +public interface ConnectionManager { + /** + * 给定一个url , 打开一个连接 + * @param url + * @return + */ + public Connection open(String url) throws ConnectionException; +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/DownloadListener.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/DownloadListener.java new file mode 100644 index 0000000000..bf9807b307 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/api/DownloadListener.java @@ -0,0 +1,5 @@ +package com.coderising.download.api; + +public interface DownloadListener { + public void notifyFinished(); +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/download/impl/ConnectionImpl.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/impl/ConnectionImpl.java new file mode 100644 index 0000000000..36a9d2ce15 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/impl/ConnectionImpl.java @@ -0,0 +1,27 @@ +package com.coderising.download.impl; + +import java.io.IOException; + +import com.coderising.download.api.Connection; + +public class ConnectionImpl implements Connection{ + + @Override + public byte[] read(int startPos, int endPos) throws IOException { + + return null; + } + + @Override + public int getContentLength() { + + return 0; + } + + @Override + public void close() { + + + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/download/impl/ConnectionManagerImpl.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/impl/ConnectionManagerImpl.java new file mode 100644 index 0000000000..172371dd55 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/download/impl/ConnectionManagerImpl.java @@ -0,0 +1,15 @@ +package com.coderising.download.impl; + +import com.coderising.download.api.Connection; +import com.coderising.download.api.ConnectionException; +import com.coderising.download.api.ConnectionManager; + +public class ConnectionManagerImpl implements ConnectionManager { + + @Override + public Connection open(String url) throws ConnectionException { + + return null; + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/LoginAction.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/LoginAction.java new file mode 100644 index 0000000000..dcdbe226ed --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/LoginAction.java @@ -0,0 +1,39 @@ +package com.coderising.litestruts; + +/** + * 这是一个用来展示登录的业务类, 其中的用户名和密码都是硬编码的。 + * @author liuxin + * + */ +public class LoginAction{ + private String name ; + private String password; + private String message; + + public String getName() { + return name; + } + + public String getPassword() { + return password; + } + + public String execute(){ + if("test".equals(name) && "1234".equals(password)){ + this.message = "login successful"; + return "success"; + } + this.message = "login failed,please check your user/pwd"; + return "fail"; + } + + public void setName(String name){ + this.name = name; + } + public void setPassword(String password){ + this.password = password; + } + public String getMessage(){ + return this.message; + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/Struts.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/Struts.java new file mode 100644 index 0000000000..85e2e22de3 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/Struts.java @@ -0,0 +1,34 @@ +package com.coderising.litestruts; + +import java.util.Map; + + + +public class Struts { + + public static View runAction(String actionName, Map 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字段中。 + + */ + + return null; + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/StrutsTest.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/StrutsTest.java new file mode 100644 index 0000000000..b8c81faf3c --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/StrutsTest.java @@ -0,0 +1,43 @@ +package com.coderising.litestruts; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; + + + + + +public class StrutsTest { + + @Test + public void testLoginActionSuccess() { + + String actionName = "login"; + + Map 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"); //密码和预设的不一致 + + 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/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/View.java b/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/View.java new file mode 100644 index 0000000000..07df2a5dab --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/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/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/struts.xml b/students/250103158/data-structure/answer/src/main/java/com/coderising/litestruts/struts.xml new file mode 100644 index 0000000000..e5d9aebba8 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/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 diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/Iterator.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..06ef6311b2 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/List.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/List.java new file mode 100644 index 0000000000..10d13b5832 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/List.java @@ -0,0 +1,9 @@ +package com.coding.basic; + +public interface List { + public void add(Object o); + public void add(int index, Object o); + public Object get(int index); + public Object remove(int index); + public int size(); +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/array/ArrayList.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/array/ArrayList.java new file mode 100644 index 0000000000..4576c016af --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/array/ArrayList.java @@ -0,0 +1,35 @@ +package com.coding.basic.array; + +import com.coding.basic.Iterator; +import com.coding.basic.List; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + public void add(Object o){ + + } + public void add(int index, Object o){ + + } + + public Object get(int index){ + return null; + } + + public Object remove(int index){ + return null; + } + + public int size(){ + return -1; + } + + public Iterator iterator(){ + return null; + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/array/ArrayUtil.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/array/ArrayUtil.java new file mode 100644 index 0000000000..45740e6d57 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/array/ArrayUtil.java @@ -0,0 +1,96 @@ +package com.coding.basic.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 oldArr[]={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5} + * 要求将以上数组中值为0的项去掉,将不为0的值存入一个新的数组,生成的新数组为: + * {1,3,4,5,6,6,5,4,7,6,7,5} + * @param oldArray + * @return + */ + + public int[] removeZero(int[] oldArray){ + return null; + } + + /** + * 给定两个已经排序好的整形数组, a1和a2 , 创建一个新的数组a3, 使得a3 包含a1和a2 的所有元素, 并且仍然是有序的 + * 例如 a1 = [3, 5, 7,8] a2 = [4, 5, 6,7] 则 a3 为[3,4,5,6,7,8] , 注意: 已经消除了重复 + * @param array1 + * @param array2 + * @return + */ + + public int[] merge(int[] array1, int[] array2){ + return null; + } + /** + * 把一个已经存满数据的数组 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){ + return null; + } + + /** + * 斐波那契数列为:1,1,2,3,5,8,13,21...... ,给定一个最大值, 返回小于该值的数列 + * 例如, max = 15 , 则返回的数组应该为 [1,1,2,3,5,8,13] + * max = 1, 则返回空数组 [] + * @param max + * @return + */ + public int[] fibonacci(int max){ + return null; + } + + /** + * 返回小于给定最大值max的所有素数数组 + * 例如max = 23, 返回的数组为[2,3,5,7,11,13,17,19] + * @param max + * @return + */ + public int[] getPrimes(int max){ + return null; + } + + /** + * 所谓“完数”, 是指这个数恰好等于它的因子之和,例如6=1+2+3 + * 给定一个最大值max, 返回一个数组, 数组中是小于max 的所有完数 + * @param max + * @return + */ + public int[] getPerfectNumbers(int max){ + return null; + } + + /** + * 用seperator 把数组 array给连接起来 + * 例如array= [3,8,9], seperator = "-" + * 则返回值为"3-8-9" + * @param array + * @param s + * @return + */ + public String join(int[] array, String seperator){ + return null; + } + + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LRUPageFrame.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LRUPageFrame.java new file mode 100644 index 0000000000..24b9d8b155 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LRUPageFrame.java @@ -0,0 +1,164 @@ +package com.coding.basic.linklist; + + +public class LRUPageFrame { + + private static class Node { + + Node prev; + Node next; + int pageNum; + + Node() { + } + } + + private int capacity; + + private int currentSize; + private Node first;// 链表头 + private Node last;// 链表尾 + + + public LRUPageFrame(int capacity) { + this.currentSize = 0; + this.capacity = capacity; + + } + + /** + * 获取缓存中对象 + * + * @param key + * @return + */ + public void access(int pageNum) { + + Node node = find(pageNum); + //在该队列中存在, 则提到队列头 + if (node != null) { + + moveExistingNodeToHead(node); + + } else{ + + node = new Node(); + node.pageNum = pageNum; + + // 缓存容器是否已经超过大小. + if (currentSize >= capacity) { + removeLast(); + + } + + addNewNodetoHead(node); + + + + + } + } + + private void addNewNodetoHead(Node node) { + + if(isEmpty()){ + + node.prev = null; + node.next = null; + first = node; + last = node; + + } else{ + node.prev = null; + node.next = first; + first.prev = node; + first = node; + } + this.currentSize ++; + } + + private Node find(int data){ + + Node node = first; + while(node != null){ + if(node.pageNum == data){ + return node; + } + node = node.next; + } + return null; + + } + + + + + + + /** + * 删除链表尾部节点 表示 删除最少使用的缓存对象 + */ + private void removeLast() { + Node prev = last.prev; + prev.next = null; + last.prev = null; + last = prev; + this.currentSize --; + } + + /** + * 移动到链表头,表示这个节点是最新使用过的 + * + * @param node + */ + private void moveExistingNodeToHead(Node node) { + + if (node == first) { + + return; + } + else if(node == last){ + //当前节点是链表尾, 需要放到链表头 + Node prevNode = node.prev; + prevNode.next = null; + last.prev = null; + last = prevNode; + + } else{ + //node 在链表的中间, 把node 的前后节点连接起来 + Node prevNode = node.prev; + prevNode.next = node.next; + + Node nextNode = node.next; + nextNode.prev = prevNode; + + + } + + node.prev = null; + node.next = first; + first.prev = node; + first = node; + + } + private boolean isEmpty(){ + return (first == null) && (last == null); + } + + public String toString(){ + StringBuilder buffer = new StringBuilder(); + Node node = first; + while(node != null){ + buffer.append(node.pageNum); + + node = node.next; + if(node != null){ + buffer.append(","); + } + } + return buffer.toString(); + } + + + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LRUPageFrameTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LRUPageFrameTest.java new file mode 100644 index 0000000000..7fd72fc2b4 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LRUPageFrameTest.java @@ -0,0 +1,34 @@ +package com.coding.basic.linklist; + +import org.junit.Assert; + +import org.junit.Test; + + +public class LRUPageFrameTest { + + @Test + public void testAccess() { + LRUPageFrame frame = new LRUPageFrame(3); + frame.access(7); + frame.access(0); + frame.access(1); + Assert.assertEquals("1,0,7", frame.toString()); + frame.access(2); + Assert.assertEquals("2,1,0", frame.toString()); + frame.access(0); + Assert.assertEquals("0,2,1", frame.toString()); + frame.access(0); + Assert.assertEquals("0,2,1", frame.toString()); + frame.access(3); + Assert.assertEquals("3,0,2", frame.toString()); + frame.access(0); + Assert.assertEquals("0,3,2", frame.toString()); + frame.access(4); + Assert.assertEquals("4,0,3", frame.toString()); + frame.access(5); + Assert.assertEquals("5,4,0", frame.toString()); + + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LinkedList.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LinkedList.java new file mode 100644 index 0000000000..f4c7556a2e --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/linklist/LinkedList.java @@ -0,0 +1,125 @@ +package com.coding.basic.linklist; + +import com.coding.basic.Iterator; +import com.coding.basic.List; + +public class LinkedList implements List { + + private Node head; + + public void add(Object o){ + + } + public void add(int index , Object o){ + + } + public Object get(int index){ + return null; + } + public Object remove(int index){ + return null; + } + + public int size(){ + return -1; + } + + public void addFirst(Object o){ + + } + public void addLast(Object o){ + + } + public Object removeFirst(){ + return null; + } + public Object removeLast(){ + return null; + } + public Iterator iterator(){ + return null; + } + + + private static class Node{ + Object data; + Node next; + + } + + /** + * 把该链表逆置 + * 例如链表为 3->7->10 , 逆置后变为 10->7->3 + */ + public void reverse(){ + + } + + /** + * 删除一个单链表的前半部分 + * 例如:list = 2->5->7->8 , 删除以后的值为 7->8 + * 如果list = 2->5->7->8->10 ,删除以后的值为7,8,10 + + */ + public void removeFirstHalf(){ + + } + + /** + * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 + * @param i + * @param length + */ + public void remove(int i, int length){ + + } + /** + * 假定当前链表和listB均包含已升序排列的整数 + * 从当前链表中取出那些listB所指定的元素 + * 例如当前链表 = 11->101->201->301->401->501->601->701 + * listB = 1->3->4->6 + * 返回的结果应该是[101,301,401,601] + * @param list + */ + public int[] getElements(LinkedList list){ + return null; + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 从当前链表中中删除在listB中出现的元素 + + * @param list + */ + + public void subtract(LinkedList list){ + + } + + /** + * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) + */ + public void removeDuplicateValues(){ + + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * @param min + * @param max + */ + public void removeRange(int min, int max){ + + } + + /** + * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) + * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 + * @param list + */ + public LinkedList intersection( LinkedList list){ + return null; + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/CircleQueue.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/CircleQueue.java new file mode 100644 index 0000000000..f169d5f8e4 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/CircleQueue.java @@ -0,0 +1,47 @@ +package com.coding.basic.queue; + +public class CircleQueue { + + //用数组来保存循环队列的元素 + private Object[] elementData ; + int size = 0; + //队头 + private int front = 0; + //队尾 + private int rear = 0; + + public CircleQueue(int capacity){ + elementData = new Object[capacity]; + } + public boolean isEmpty() { + return (front == rear) && !isFull(); + + } + + public boolean isFull(){ + return size == elementData.length; + } + public int size() { + return size; + } + + public void enQueue(E data) { + if(isFull()){ + throw new RuntimeException("The queue is full"); + } + rear = (rear+1) % elementData.length; + elementData[rear++] = data; + size++; + } + + public E deQueue() { + if(isEmpty()){ + throw new RuntimeException("The queue is empty"); + } + E data = (E)elementData[front]; + elementData[front] = null; + front = (front+1) % elementData.length; + size --; + return data; + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/CircleQueueTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/CircleQueueTest.java new file mode 100644 index 0000000000..7307eb77d4 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/CircleQueueTest.java @@ -0,0 +1,44 @@ +package com.coding.basic.queue; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class CircleQueueTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void test() { + CircleQueue queue = new CircleQueue(5); + Assert.assertTrue(queue.isEmpty()); + Assert.assertFalse(queue.isFull()); + + queue.enQueue("a"); + queue.enQueue("b"); + queue.enQueue("c"); + queue.enQueue("d"); + queue.enQueue("e"); + + Assert.assertTrue(queue.isFull()); + Assert.assertFalse(queue.isEmpty()); + Assert.assertEquals(5, queue.size()); + + Assert.assertEquals("a", queue.deQueue()); + Assert.assertEquals("b", queue.deQueue()); + Assert.assertEquals("c", queue.deQueue()); + Assert.assertEquals("d", queue.deQueue()); + Assert.assertEquals("e", queue.deQueue()); + + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/Josephus.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/Josephus.java new file mode 100644 index 0000000000..36ec615d36 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/Josephus.java @@ -0,0 +1,39 @@ +package com.coding.basic.queue; + +import java.util.ArrayList; +import java.util.List; + +/** + * 用Queue来实现Josephus问题 + * 在这个古老的问题当中, N个深陷绝境的人一致同意用这种方式减少生存人数: N个人围成一圈(位置记为0到N-1), 并且从第一个人报数, 报到M的人会被杀死, 直到最后一个人留下来 + * @author liuxin + * + */ +public class Josephus { + + public static List execute(int n, int m){ + + Queue queue = new Queue(); + for (int i = 0; i < n; i++){ + queue.enQueue(i); + } + + List result = new ArrayList(); + int i = 0; + + while (!queue.isEmpty()) { + + int x = queue.deQueue(); + + if (++i % m == 0){ + result.add(x); + } else{ + queue.enQueue(x); + } + } + + + return result; + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/JosephusTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/JosephusTest.java new file mode 100644 index 0000000000..7d90318b51 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/JosephusTest.java @@ -0,0 +1,27 @@ +package com.coding.basic.queue; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class JosephusTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testExecute() { + + Assert.assertEquals("[1, 3, 5, 0, 4, 2, 6]", Josephus.execute(7, 2).toString()); + + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/Queue.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/Queue.java new file mode 100644 index 0000000000..c4c4b7325e --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/Queue.java @@ -0,0 +1,61 @@ +package com.coding.basic.queue; + +import java.util.NoSuchElementException; + +public class Queue { + private Node first; + private Node last; + private int size; + + + private static class Node { + private E item; + private Node next; + } + + + public Queue() { + first = null; + last = null; + size = 0; + } + + + public boolean isEmpty() { + return first == null; + } + + public int size() { + return size; + } + + + + public void enQueue(E data) { + Node oldlast = last; + last = new Node(); + last.item = data; + last.next = null; + if (isEmpty()) { + first = last; + } + else{ + oldlast.next = last; + } + size++; + } + + public E deQueue() { + if (isEmpty()) { + throw new NoSuchElementException("Queue underflow"); + } + E item = first.item; + first = first.next; + size--; + if (isEmpty()) { + last = null; + } + return item; + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/QueueWithTwoStacks.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/QueueWithTwoStacks.java new file mode 100644 index 0000000000..bc97df0800 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/queue/QueueWithTwoStacks.java @@ -0,0 +1,55 @@ +package com.coding.basic.queue; + +import java.util.NoSuchElementException; +import java.util.Stack; + +public class QueueWithTwoStacks { + private Stack stack1; + private Stack stack2; + + + public QueueWithTwoStacks() { + stack1 = new Stack(); + stack2 = new Stack(); + } + + + private void moveStack1ToStack2() { + while (!stack1.isEmpty()){ + stack2.push(stack1.pop()); + } + + } + + + public boolean isEmpty() { + return stack1.isEmpty() && stack2.isEmpty(); + } + + + + public int size() { + return stack1.size() + stack2.size(); + } + + + + public void enQueue(E item) { + stack1.push(item); + } + + public E deQueue() { + if (isEmpty()) { + throw new NoSuchElementException("Queue is empty"); + } + if (stack2.isEmpty()) { + moveStack1ToStack2(); + } + + return stack2.pop(); + } + + + + } + diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/QuickMinStack.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/QuickMinStack.java new file mode 100644 index 0000000000..faf2644ab1 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/QuickMinStack.java @@ -0,0 +1,44 @@ +package com.coding.basic.stack; + +import java.util.Stack; +/** + * 设计一个栈,支持栈的push和pop操作,以及第三种操作findMin, 它返回改数据结构中的最小元素 + * finMin操作最坏的情形下时间复杂度应该是O(1) , 简单来讲,操作一次就可以得到最小值 + * @author liuxin + * + */ +public class QuickMinStack { + + private Stack normalStack = new Stack(); + private Stack minNumStack = new Stack(); + + public void push(int data){ + + normalStack.push(data); + + if(minNumStack.isEmpty()){ + minNumStack.push(data); + } else{ + if(minNumStack.peek() >= data) { + minNumStack.push(data); + } + } + + } + public int pop(){ + if(normalStack.isEmpty()){ + throw new RuntimeException("the stack is empty"); + } + int value = normalStack.pop(); + if(value == minNumStack.peek()){ + minNumStack.pop(); + } + return value; + } + public int findMin(){ + if(minNumStack.isEmpty()){ + throw new RuntimeException("the stack is empty"); + } + return minNumStack.peek(); + } +} \ No newline at end of file diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/QuickMinStackTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/QuickMinStackTest.java new file mode 100644 index 0000000000..efe41a9f8f --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/QuickMinStackTest.java @@ -0,0 +1,39 @@ +package com.coding.basic.stack; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + +public class QuickMinStackTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void test() { + QuickMinStack stack = new QuickMinStack(); + stack.push(5); + Assert.assertEquals(5, stack.findMin()); + stack.push(6); + Assert.assertEquals(5, stack.findMin()); + stack.push(4); + Assert.assertEquals(4, stack.findMin()); + stack.push(4); + Assert.assertEquals(4, stack.findMin()); + + stack.pop(); + Assert.assertEquals(4, stack.findMin()); + stack.pop(); + Assert.assertEquals(5, stack.findMin()); + stack.pop(); + Assert.assertEquals(5, stack.findMin()); + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/Stack.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/Stack.java new file mode 100644 index 0000000000..fedb243604 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/Stack.java @@ -0,0 +1,24 @@ +package com.coding.basic.stack; + +import com.coding.basic.array.ArrayList; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o){ + } + + public Object pop(){ + return null; + } + + public Object peek(){ + return null; + } + public boolean isEmpty(){ + return false; + } + public int size(){ + return -1; + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackUtil.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackUtil.java new file mode 100644 index 0000000000..7c86d22fe7 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackUtil.java @@ -0,0 +1,168 @@ +package com.coding.basic.stack; +import java.util.Stack; +public class StackUtil { + + public static void bad_reverse(Stack s) { + if(s == null || s.isEmpty()){ + return; + } + Stack tmpStack = new Stack(); + while(!s.isEmpty()){ + tmpStack.push(s.pop()); + } + + s = tmpStack; + + } + + + + public static void reverse_247565311(Stack s){ + if(s == null || s.isEmpty()) { + return; + } + + int size = s.size(); + Stack tmpStack = new Stack(); + + for(int i=0;ii){ + tmpStack.push(s.pop()); + } + s.push(top); + while(tmpStack.size()>0){ + s.push(tmpStack.pop()); + } + } + } + + + + /** + * 假设栈中的元素是Integer, 从栈顶到栈底是 : 5,4,3,2,1 调用该方法后, 元素次序变为: 1,2,3,4,5 + * 注意:只能使用Stack的基本操作,即push,pop,peek,isEmpty, 可以使用另外一个栈来辅助 + */ + public static void reverse(Stack s) { + if(s == null || s.isEmpty()){ + return; + } + + Stack tmp = new Stack(); + while(!s.isEmpty()){ + tmp.push(s.pop()); + } + while(!tmp.isEmpty()){ + Integer top = tmp.pop(); + addToBottom(s,top); + } + + + } + public static void addToBottom(Stack s, Integer value){ + if(s.isEmpty()){ + s.push(value); + } else{ + Integer top = s.pop(); + addToBottom(s,value); + s.push(top); + } + + } + /** + * 删除栈中的某个元素 注意:只能使用Stack的基本操作,即push,pop,peek,isEmpty, 可以使用另外一个栈来辅助 + * + * @param o + */ + public static void remove(Stack s,Object o) { + if(s == null || s.isEmpty()){ + return; + } + Stack tmpStack = new Stack(); + + while(!s.isEmpty()){ + Object value = s.pop(); + if(!value.equals(o)){ + tmpStack.push(value); + } + } + + while(!tmpStack.isEmpty()){ + s.push(tmpStack.pop()); + } + } + + /** + * 从栈顶取得len个元素, 原来的栈中元素保持不变 + * 注意:只能使用Stack的基本操作,即push,pop,peek,isEmpty, 可以使用另外一个栈来辅助 + * @param len + * @return + */ + public static Object[] getTop(Stack s,int len) { + + if(s == null || s.isEmpty() || s.size() stack = new Stack(); + for(int i=0;i s = new Stack(); + s.push(1); + s.push(2); + s.push(3); + + StackUtil.addToBottom(s, 0); + + Assert.assertEquals("[0, 1, 2, 3]", s.toString()); + + } + @Test + public void testReverse() { + Stack s = new Stack(); + s.push(1); + s.push(2); + s.push(3); + s.push(4); + s.push(5); + Assert.assertEquals("[1, 2, 3, 4, 5]", s.toString()); + StackUtil.reverse(s); + Assert.assertEquals("[5, 4, 3, 2, 1]", s.toString()); + } + @Test + public void testReverse_247565311() { + Stack s = new Stack(); + s.push(1); + s.push(2); + s.push(3); + + Assert.assertEquals("[1, 2, 3]", s.toString()); + StackUtil.reverse_247565311(s); + Assert.assertEquals("[3, 2, 1]", s.toString()); + } + @Test + public void testRemove() { + Stack s = new Stack(); + s.push(1); + s.push(2); + s.push(3); + StackUtil.remove(s, 2); + Assert.assertEquals("[1, 3]", s.toString()); + } + + @Test + public void testGetTop() { + Stack s = new Stack(); + s.push(1); + s.push(2); + s.push(3); + s.push(4); + s.push(5); + { + Object[] values = StackUtil.getTop(s, 3); + Assert.assertEquals(5, values[0]); + Assert.assertEquals(4, values[1]); + Assert.assertEquals(3, values[2]); + } + } + + @Test + public void testIsValidPairs() { + Assert.assertTrue(StackUtil.isValidPairs("([e{d}f])")); + Assert.assertFalse(StackUtil.isValidPairs("([b{x]y})")); + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackWithTwoQueues.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackWithTwoQueues.java new file mode 100644 index 0000000000..7a58fbff56 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackWithTwoQueues.java @@ -0,0 +1,53 @@ +package com.coding.basic.stack; + +import java.util.ArrayDeque; +import java.util.Queue; + +public class StackWithTwoQueues { + Queue queue1 = new ArrayDeque<>(); + Queue queue2 = new ArrayDeque<>(); + + public void push(int data) { + //两个栈都为空时,优先考虑queue1 + if (queue1.isEmpty()&&queue2.isEmpty()) { + queue1.add(data); + return; + } + + if (queue1.isEmpty()) { + queue2.add(data); + return; + } + + if (queue2.isEmpty()) { + queue1.add(data); + return; + } + + } + + public int pop() { + + if (queue1.isEmpty()&&queue2.isEmpty()) { + throw new RuntimeException("stack is empty"); + } + + if (queue1.isEmpty()) { + while (queue2.size()>1) { + queue1.add(queue2.poll()); + } + return queue2.poll(); + } + + if (queue2.isEmpty()) { + while (queue1.size()>1) { + queue2.add(queue1.poll()); + } + return queue1.poll(); + } + + throw new RuntimeException("no queue is empty, this is not allowed"); + + + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackWithTwoQueuesTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackWithTwoQueuesTest.java new file mode 100644 index 0000000000..4541b1f040 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/StackWithTwoQueuesTest.java @@ -0,0 +1,36 @@ +package com.coding.basic.stack; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class StackWithTwoQueuesTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void test() { + StackWithTwoQueues stack = new StackWithTwoQueues(); + stack.push(1); + stack.push(2); + stack.push(3); + stack.push(4); + Assert.assertEquals(4, stack.pop()); + Assert.assertEquals(3, stack.pop()); + + stack.push(5); + Assert.assertEquals(5, stack.pop()); + Assert.assertEquals(2, stack.pop()); + Assert.assertEquals(1, stack.pop()); + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/Tail.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/Tail.java new file mode 100644 index 0000000000..7f30ce55c8 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/Tail.java @@ -0,0 +1,5 @@ +package com.coding.basic.stack; + +public class Tail { + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/TwoStackInOneArray.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/TwoStackInOneArray.java new file mode 100644 index 0000000000..a532fd6e6c --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/TwoStackInOneArray.java @@ -0,0 +1,117 @@ +package com.coding.basic.stack; + +import java.util.Arrays; + +/** + * 用一个数组实现两个栈 + * 将数组的起始位置看作是第一个栈的栈底,将数组的尾部看作第二个栈的栈底,压栈时,栈顶指针分别向中间移动,直到两栈顶指针相遇,则扩容。 + * @author liuxin + * + */ +public class TwoStackInOneArray { + private Object[] data = new Object[10]; + private int size; + private int top1, top2; + + public TwoStackInOneArray(int n){ + data = new Object[n]; + size = n; + top1 = -1; + top2 = data.length; + } + /** + * 向第一个栈中压入元素 + * @param o + */ + public void push1(Object o){ + ensureCapacity(); + data[++top1] = o; + } + /* + * 向第二个栈压入元素 + */ + public void push2(Object o){ + ensureCapacity(); + data[--top2] = o; + } + public void ensureCapacity(){ + if(top2-top1>1){ + return; + } else{ + + Object[] newArray = new Object[data.length*2]; + System.arraycopy(data, 0, newArray, 0, top1+1); + + int stack2Size = data.length-top2; + int newTop2 = newArray.length-stack2Size; + System.arraycopy(data, top2, newArray, newTop2, stack2Size); + + top2 = newTop2; + data = newArray; + } + } + /** + * 从第一个栈中弹出元素 + * @return + */ + public Object pop1(){ + if(top1 == -1){ + throw new RuntimeException("Stack1 is empty"); + } + Object o = data[top1]; + data[top1] = null; + top1--; + return o; + + } + /** + * 从第二个栈弹出元素 + * @return + */ + public Object pop2(){ + if(top2 == data.length){ + throw new RuntimeException("Stack2 is empty"); + } + Object o = data[top2]; + data[top2] = null; + top2++; + return o; + } + /** + * 获取第一个栈的栈顶元素 + * @return + */ + + public Object peek1(){ + if(top1 == -1){ + throw new RuntimeException("Stack1 is empty"); + } + return data[top1]; + } + + + /** + * 获取第二个栈的栈顶元素 + * @return + */ + + public Object peek2(){ + if(top2 == data.length){ + throw new RuntimeException("Stack2 is empty"); + } + return data[top2]; + } + + public Object[] stack1ToArray(){ + return Arrays.copyOf(data, top1+1); + } + public Object[] stack2ToArray(){ + int size = data.length-top2; + Object [] stack2Data = new Object[size]; + int j=0; + for(int i=data.length-1; i>=top2 ;i--){ + stack2Data[j++] = data[i]; + } + return stack2Data; + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/TwoStackInOneArrayTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/TwoStackInOneArrayTest.java new file mode 100644 index 0000000000..b743d422c6 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/TwoStackInOneArrayTest.java @@ -0,0 +1,65 @@ +package com.coding.basic.stack; + +import java.util.Arrays; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class TwoStackInOneArrayTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void test1() { + TwoStackInOneArray stack = new TwoStackInOneArray(10); + stack.push1(1); + stack.push1(2); + stack.push1(3); + stack.push1(4); + stack.push1(5); + + stack.push2(1); + stack.push2(2); + stack.push2(3); + stack.push2(4); + stack.push2(5); + + for(int i=1;i<=5;i++){ + Assert.assertEquals(stack.peek1(), stack.peek2()); + Assert.assertEquals(stack.pop1(), stack.pop2()); + } + + + } + @Test + public void test2() { + TwoStackInOneArray stack = new TwoStackInOneArray(5); + stack.push1(1); + stack.push1(2); + stack.push1(3); + stack.push1(4); + stack.push1(5); + stack.push1(6); + stack.push1(7); + + stack.push2(1); + stack.push2(2); + stack.push2(3); + stack.push2(4); + + + Assert.assertEquals("[1, 2, 3, 4, 5, 6, 7]",Arrays.toString(stack.stack1ToArray())); + Assert.assertEquals("[1, 2, 3, 4]",Arrays.toString(stack.stack2ToArray())); + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixExpr.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixExpr.java new file mode 100644 index 0000000000..cebef21fa3 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixExpr.java @@ -0,0 +1,72 @@ +package com.coding.basic.stack.expr; + +import java.util.List; +import java.util.Stack; + + +public class InfixExpr { + String expr = null; + + public InfixExpr(String expr) { + this.expr = expr; + } + + public float evaluate() { + + + TokenParser parser = new TokenParser(); + List tokens = parser.parse(this.expr); + + + Stack opStack = new Stack<>(); + Stack numStack = new Stack<>(); + + for(Token token : tokens){ + + if (token.isOperator()){ + + while(!opStack.isEmpty() + && !token.hasHigherPriority(opStack.peek())){ + Token prevOperator = opStack.pop(); + Float f2 = numStack.pop(); + Float f1 = numStack.pop(); + Float result = calculate(prevOperator.toString(), f1,f2); + numStack.push(result); + + } + opStack.push(token); + } + if(token.isNumber()){ + numStack.push(new Float(token.getIntValue())); + } + } + + while(!opStack.isEmpty()){ + Token token = opStack.pop(); + Float f2 = numStack.pop(); + Float f1 = numStack.pop(); + numStack.push(calculate(token.toString(), f1,f2)); + } + + + return numStack.pop().floatValue(); + } + private Float calculate(String op, Float f1, Float f2){ + if(op.equals("+")){ + return f1+f2; + } + if(op.equals("-")){ + return f1-f2; + } + if(op.equals("*")){ + return f1*f2; + } + if(op.equals("/")){ + return f1/f2; + } + throw new RuntimeException(op + " is not supported"); + } + + + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixExprTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixExprTest.java new file mode 100644 index 0000000000..20e34e8852 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixExprTest.java @@ -0,0 +1,52 @@ +package com.coding.basic.stack.expr; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + +public class InfixExprTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEvaluate() { + //InfixExpr expr = new InfixExpr("300*20+12*5-20/4"); + { + InfixExpr expr = new InfixExpr("2+3*4+5"); + Assert.assertEquals(19.0, expr.evaluate(), 0.001f); + } + { + InfixExpr expr = new InfixExpr("3*20+12*5-40/2"); + Assert.assertEquals(100.0, expr.evaluate(), 0.001f); + } + + { + InfixExpr expr = new InfixExpr("3*20/2"); + Assert.assertEquals(30, expr.evaluate(), 0.001f); + } + + { + InfixExpr expr = new InfixExpr("20/2*3"); + Assert.assertEquals(30, expr.evaluate(), 0.001f); + } + + { + InfixExpr expr = new InfixExpr("10-30+50"); + Assert.assertEquals(30, expr.evaluate(), 0.001f); + } + { + InfixExpr expr = new InfixExpr("10-2*3+50"); + Assert.assertEquals(54, expr.evaluate(), 0.001f); + } + + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixToPostfix.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixToPostfix.java new file mode 100644 index 0000000000..9e501eda20 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixToPostfix.java @@ -0,0 +1,43 @@ +package com.coding.basic.stack.expr; + +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +public class InfixToPostfix { + + public static List convert(String expr) { + List inFixTokens = new TokenParser().parse(expr); + + List postFixTokens = new ArrayList<>(); + + Stack opStack = new Stack(); + for(Token token : inFixTokens){ + + if(token.isOperator()){ + + while(!opStack.isEmpty() + && !token.hasHigherPriority(opStack.peek())){ + postFixTokens.add(opStack.pop()); + + } + opStack.push(token); + + } + if(token.isNumber()){ + + postFixTokens.add(token); + + } + } + + while(!opStack.isEmpty()){ + postFixTokens.add(opStack.pop()); + } + + return postFixTokens; + } + + + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixToPostfixTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixToPostfixTest.java new file mode 100644 index 0000000000..f879f55f14 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/InfixToPostfixTest.java @@ -0,0 +1,41 @@ +package com.coding.basic.stack.expr; + +import java.util.List; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class InfixToPostfixTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testConvert() { + { + List tokens = InfixToPostfix.convert("2+3"); + Assert.assertEquals("[2, 3, +]", tokens.toString()); + } + { + + List tokens = InfixToPostfix.convert("2+3*4"); + Assert.assertEquals("[2, 3, 4, *, +]", tokens.toString()); + } + + { + + List tokens = InfixToPostfix.convert("2-3*4+5"); + Assert.assertEquals("[2, 3, 4, *, -, 5, +]", tokens.toString()); + } + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PostfixExpr.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PostfixExpr.java new file mode 100644 index 0000000000..c54eb69e2a --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PostfixExpr.java @@ -0,0 +1,46 @@ +package com.coding.basic.stack.expr; + +import java.util.List; +import java.util.Stack; + +public class PostfixExpr { +String expr = null; + + public PostfixExpr(String expr) { + this.expr = expr; + } + + public float evaluate() { + TokenParser parser = new TokenParser(); + List tokens = parser.parse(this.expr); + + + Stack numStack = new Stack<>(); + for(Token token : tokens){ + if(token.isNumber()){ + numStack.push(new Float(token.getIntValue())); + } else{ + Float f2 = numStack.pop(); + Float f1 = numStack.pop(); + numStack.push(calculate(token.toString(),f1,f2)); + } + } + return numStack.pop().floatValue(); + } + + private Float calculate(String op, Float f1, Float f2){ + if(op.equals("+")){ + return f1+f2; + } + if(op.equals("-")){ + return f1-f2; + } + if(op.equals("*")){ + return f1*f2; + } + if(op.equals("/")){ + return f1/f2; + } + throw new RuntimeException(op + " is not supported"); + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PostfixExprTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PostfixExprTest.java new file mode 100644 index 0000000000..c0435a2db5 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PostfixExprTest.java @@ -0,0 +1,41 @@ +package com.coding.basic.stack.expr; + + + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class PostfixExprTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEvaluate() { + { + PostfixExpr expr = new PostfixExpr("6 5 2 3 + 8 * + 3 + *"); + Assert.assertEquals(288, expr.evaluate(),0.0f); + } + { + //9+(3-1)*3+10/2 + PostfixExpr expr = new PostfixExpr("9 3 1-3*+ 10 2/+"); + Assert.assertEquals(20, expr.evaluate(),0.0f); + } + + { + //10-2*3+50 + PostfixExpr expr = new PostfixExpr("10 2 3 * - 50 +"); + Assert.assertEquals(54, expr.evaluate(),0.0f); + } + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PrefixExpr.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PrefixExpr.java new file mode 100644 index 0000000000..f811fd6d9a --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PrefixExpr.java @@ -0,0 +1,52 @@ +package com.coding.basic.stack.expr; + +import java.util.List; +import java.util.Stack; + +public class PrefixExpr { + String expr = null; + + public PrefixExpr(String expr) { + this.expr = expr; + } + + public float evaluate() { + TokenParser parser = new TokenParser(); + List tokens = parser.parse(this.expr); + + Stack exprStack = new Stack<>(); + Stack numStack = new Stack<>(); + for(Token token : tokens){ + exprStack.push(token); + } + + while(!exprStack.isEmpty()){ + Token t = exprStack.pop(); + if(t.isNumber()){ + numStack.push(new Float(t.getIntValue())); + }else{ + Float f1 = numStack.pop(); + Float f2 = numStack.pop(); + numStack.push(calculate(t.toString(),f1,f2)); + + } + } + return numStack.pop().floatValue(); + } + + private Float calculate(String op, Float f1, Float f2){ + if(op.equals("+")){ + return f1+f2; + } + if(op.equals("-")){ + return f1-f2; + } + if(op.equals("*")){ + return f1*f2; + } + if(op.equals("/")){ + return f1/f2; + } + throw new RuntimeException(op + " is not supported"); + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PrefixExprTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PrefixExprTest.java new file mode 100644 index 0000000000..5cec210e75 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/PrefixExprTest.java @@ -0,0 +1,45 @@ +package com.coding.basic.stack.expr; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + +public class PrefixExprTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEvaluate() { + { + // 2*3+4*5 + PrefixExpr expr = new PrefixExpr("+ * 2 3* 4 5"); + Assert.assertEquals(26, expr.evaluate(),0.001f); + } + { + // 4*2 + 6+9*2/3 -8 + PrefixExpr expr = new PrefixExpr("-++6/*2 9 3 * 4 2 8"); + Assert.assertEquals(12, expr.evaluate(),0.001f); + } + { + //(3+4)*5-6 + PrefixExpr expr = new PrefixExpr("- * + 3 4 5 6"); + Assert.assertEquals(29, expr.evaluate(),0.001f); + } + { + //1+((2+3)*4)-5 + PrefixExpr expr = new PrefixExpr("- + 1 * + 2 3 4 5"); + Assert.assertEquals(16, expr.evaluate(),0.001f); + } + + + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/Token.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/Token.java new file mode 100644 index 0000000000..8579743fe9 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/Token.java @@ -0,0 +1,50 @@ +package com.coding.basic.stack.expr; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +class Token { + public static final List OPERATORS = Arrays.asList("+", "-", "*", "/"); + private static final Map priorities = new HashMap<>(); + static { + priorities.put("+", 1); + priorities.put("-", 1); + priorities.put("*", 2); + priorities.put("/", 2); + } + static final int OPERATOR = 1; + static final int NUMBER = 2; + String value; + int type; + public Token(int type, String value){ + this.type = type; + this.value = value; + } + + public boolean isNumber() { + return type == NUMBER; + } + + public boolean isOperator() { + return type == OPERATOR; + } + + public int getIntValue() { + return Integer.valueOf(value).intValue(); + } + public String toString(){ + return value; + } + + public boolean hasHigherPriority(Token t){ + if(!this.isOperator() && !t.isOperator()){ + throw new RuntimeException("numbers can't compare priority"); + } + return priorities.get(this.value) - priorities.get(t.value) > 0; + } + + + +} \ No newline at end of file diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/TokenParser.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/TokenParser.java new file mode 100644 index 0000000000..d3b0f167e1 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/TokenParser.java @@ -0,0 +1,57 @@ +package com.coding.basic.stack.expr; + +import java.util.ArrayList; +import java.util.List; + +public class TokenParser { + + + public List parse(String expr) { + List tokens = new ArrayList<>(); + + int i = 0; + + while (i < expr.length()) { + + char c = expr.charAt(i); + + if (isOperator(c)) { + + Token t = new Token(Token.OPERATOR, String.valueOf(c)); + tokens.add(t); + i++; + + } else if (Character.isDigit(c)) { + + int nextOperatorIndex = indexOfNextOperator(i, expr); + String value = expr.substring(i, nextOperatorIndex); + Token t = new Token(Token.NUMBER, value); + tokens.add(t); + i = nextOperatorIndex; + + } else{ + System.out.println("char :["+c+"] is not number or operator,ignore"); + i++; + } + + } + return tokens; + } + + private int indexOfNextOperator(int i, String expr) { + + while (Character.isDigit(expr.charAt(i))) { + i++; + if (i == expr.length()) { + break; + } + } + return i; + + } + + private boolean isOperator(char c) { + String sc = String.valueOf(c); + return Token.OPERATORS.contains(sc); + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/TokenParserTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/TokenParserTest.java new file mode 100644 index 0000000000..399d3e857e --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/stack/expr/TokenParserTest.java @@ -0,0 +1,41 @@ +package com.coding.basic.stack.expr; + +import static org.junit.Assert.*; + +import java.util.List; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class TokenParserTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void test() { + + TokenParser parser = new TokenParser(); + List tokens = parser.parse("300*20+12*5-20/4"); + + Assert.assertEquals(300, tokens.get(0).getIntValue()); + Assert.assertEquals("*", tokens.get(1).toString()); + Assert.assertEquals(20, tokens.get(2).getIntValue()); + Assert.assertEquals("+", tokens.get(3).toString()); + Assert.assertEquals(12, tokens.get(4).getIntValue()); + Assert.assertEquals("*", tokens.get(5).toString()); + Assert.assertEquals(5, tokens.get(6).getIntValue()); + Assert.assertEquals("-", tokens.get(7).toString()); + Assert.assertEquals(20, tokens.get(8).getIntValue()); + Assert.assertEquals("/", tokens.get(9).toString()); + Assert.assertEquals(4, tokens.get(10).getIntValue()); + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinarySearchTree.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinarySearchTree.java new file mode 100644 index 0000000000..284e5b0011 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinarySearchTree.java @@ -0,0 +1,189 @@ +package com.coding.basic.tree; + +import java.util.ArrayList; +import java.util.List; + +import com.coding.basic.queue.Queue; + + +public class BinarySearchTree { + + BinaryTreeNode root; + public BinarySearchTree(BinaryTreeNode root){ + this.root = root; + } + public BinaryTreeNode getRoot(){ + return root; + } + public T findMin(){ + if(root == null){ + return null; + } + return findMin(root).data; + } + public T findMax(){ + if(root == null){ + return null; + } + return findMax(root).data; + } + public int height() { + return height(root); + } + public int size() { + return size(root); + } + public void remove(T e){ + remove(e, root); + } + + private BinaryTreeNode remove(T x, BinaryTreeNode t){ + if(t == null){ + return t; + } + int compareResult = x.compareTo(t.data); + + if(compareResult< 0 ){ + t.left = remove(x,t.left); + + } else if(compareResult > 0){ + t.right = remove(x, t.right); + + } else { + if(t.left != null && t.right != null){ + + t.data = findMin(t.right).data; + t.right = remove(t.data,t.right); + + } else{ + t = (t.left != null) ? t.left : t.right; + } + } + return t; + } + + private BinaryTreeNode findMin(BinaryTreeNode p){ + if (p==null){ + return null; + } else if (p.left == null){ + return p; + } else{ + return findMin(p.left); + } + } + private BinaryTreeNode findMax(BinaryTreeNode p){ + if (p==null){ + return null; + }else if (p.right==null){ + return p; + } else{ + return findMax(p.right); + } + } + private int height(BinaryTreeNode t){ + if (t==null){ + return 0; + }else { + int leftChildHeight=height(t.left); + int rightChildHeight=height(t.right); + if(leftChildHeight > rightChildHeight){ + return leftChildHeight+1; + } else{ + return rightChildHeight+1; + } + } + } + private int size(BinaryTreeNode t){ + if (t == null){ + return 0; + } + return size(t.left) + 1 + size(t.right); + + } + + public List levelVisit(){ + List result = new ArrayList(); + if(root == null){ + return result; + } + Queue> queue = new Queue>(); + BinaryTreeNode node = root; + queue.enQueue(node); + while (!queue.isEmpty()) { + node = queue.deQueue(); + result.add(node.data); + if (node.left != null){ + queue.enQueue(node.left); + } + if (node.right != null){ + queue.enQueue(node.right); + } + } + return result; + } + public boolean isValid(){ + return isValid(root); + } + public T getLowestCommonAncestor(T n1, T n2){ + if (root == null){ + return null; + } + return lowestCommonAncestor(root,n1,n2); + + } + public List getNodesBetween(T n1, T n2){ + List elements = new ArrayList<>(); + getNodesBetween(elements,root,n1,n2); + return elements; + } + + public void getNodesBetween(List elements ,BinaryTreeNode node, T n1, T n2){ + + if (node == null) { + return; + } + + if (n1.compareTo(node.data) < 0) { + getNodesBetween(elements,node.left, n1, n2); + } + + if ((n1.compareTo(node.data) <= 0 ) + && (n2.compareTo(node.data) >= 0 )) { + elements.add(node.data); + } + if (n2.compareTo(node.data)>0) { + getNodesBetween(elements,node.right, n1, n2); + } + } + private T lowestCommonAncestor(BinaryTreeNode node,T n1, T n2){ + if(node == null){ + return null; + } + // 如果n1和n2都比 node的值小, LCA在左孩子 + if (node.data.compareTo(n1) > 0 && node.data.compareTo(n2) >0){ + return lowestCommonAncestor(node.left, n1, n2); + } + + // 如果n1和n2都比 node的值小, LCA在右孩子 + if (node.data.compareTo(n1) < 0 && node.data.compareTo(n2) <0) + return lowestCommonAncestor(node.right, n1, n2); + + return node.data; + } + private boolean isValid(BinaryTreeNode t){ + if(t == null){ + return true; + } + if(t.left != null && findMax(t.left).data.compareTo(t.data) >0){ + return false; + } + if(t.right !=null && findMin(t.right).data.compareTo(t.data) <0){ + return false; + } + if(!isValid(t.left) || !isValid(t.right)){ + return false; + } + return true; + } +} + diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinarySearchTreeTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinarySearchTreeTest.java new file mode 100644 index 0000000000..590e60306c --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinarySearchTreeTest.java @@ -0,0 +1,108 @@ +package com.coding.basic.tree; + +import java.util.List; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class BinarySearchTreeTest { + + BinarySearchTree tree = null; + + @Before + public void setUp() throws Exception { + BinaryTreeNode root = new BinaryTreeNode(6); + root.left = new BinaryTreeNode(2); + root.right = new BinaryTreeNode(8); + root.left.left = new BinaryTreeNode(1); + root.left.right = new BinaryTreeNode(4); + root.left.right.left = new BinaryTreeNode(3); + root.left.right.right = new BinaryTreeNode(5); + tree = new BinarySearchTree(root); + } + + @After + public void tearDown() throws Exception { + tree = null; + } + + @Test + public void testFindMin() { + Assert.assertEquals(1, tree.findMin().intValue()); + + } + + @Test + public void testFindMax() { + Assert.assertEquals(8, tree.findMax().intValue()); + } + + @Test + public void testHeight() { + Assert.assertEquals(4, tree.height()); + } + + @Test + public void testSize() { + Assert.assertEquals(7, tree.size()); + } + + @Test + public void testRemoveLeaf() { + tree.remove(3); + BinaryTreeNode root= tree.getRoot(); + Assert.assertEquals(4, root.left.right.data.intValue()); + + } + @Test + public void testRemoveMiddleNode1() { + tree.remove(4); + BinaryTreeNode root= tree.getRoot(); + Assert.assertEquals(5, root.left.right.data.intValue()); + Assert.assertEquals(3, root.left.right.left.data.intValue()); + } + @Test + public void testRemoveMiddleNode2() { + tree.remove(2); + BinaryTreeNode root= tree.getRoot(); + Assert.assertEquals(3, root.left.data.intValue()); + Assert.assertEquals(4, root.left.right.data.intValue()); + } + + @Test + public void testLevelVisit() { + List values = tree.levelVisit(); + Assert.assertEquals("[6, 2, 8, 1, 4, 3, 5]", values.toString()); + + } + @Test + public void testLCA(){ + Assert.assertEquals(2,tree.getLowestCommonAncestor(1, 5).intValue()); + Assert.assertEquals(2,tree.getLowestCommonAncestor(1, 4).intValue()); + Assert.assertEquals(6,tree.getLowestCommonAncestor(3, 8).intValue()); + } + @Test + public void testIsValid() { + + Assert.assertTrue(tree.isValid()); + + BinaryTreeNode root = new BinaryTreeNode(6); + root.left = new BinaryTreeNode(2); + root.right = new BinaryTreeNode(8); + root.left.left = new BinaryTreeNode(4); + root.left.right = new BinaryTreeNode(1); + root.left.right.left = new BinaryTreeNode(3); + tree = new BinarySearchTree(root); + + Assert.assertFalse(tree.isValid()); + } + @Test + public void testGetNodesBetween(){ + List numbers = this.tree.getNodesBetween(3, 8); + Assert.assertEquals("[3, 4, 5, 6, 8]",numbers.toString()); + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeNode.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeNode.java new file mode 100644 index 0000000000..3f6f4d2b44 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeNode.java @@ -0,0 +1,36 @@ +package com.coding.basic.tree; + +public class BinaryTreeNode { + + public T data; + public BinaryTreeNode left; + public BinaryTreeNode right; + + public BinaryTreeNode(T data){ + this.data=data; + } + public T getData() { + return data; + } + public void setData(T data) { + this.data = data; + } + public BinaryTreeNode getLeft() { + return left; + } + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + public BinaryTreeNode getRight() { + return right; + } + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Object o){ + return null; + } + + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeUtil.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeUtil.java new file mode 100644 index 0000000000..f2a6515fa6 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeUtil.java @@ -0,0 +1,116 @@ +package com.coding.basic.tree; + +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +public class BinaryTreeUtil { + /** + * 用递归的方式实现对二叉树的前序遍历, 需要通过BinaryTreeUtilTest测试 + * + * @param root + * @return + */ + public static List preOrderVisit(BinaryTreeNode root) { + List result = new ArrayList(); + preOrderVisit(root, result); + return result; + } + + /** + * 用递归的方式实现对二叉树的中遍历 + * + * @param root + * @return + */ + public static List inOrderVisit(BinaryTreeNode root) { + List result = new ArrayList(); + inOrderVisit(root, result); + return result; + } + + /** + * 用递归的方式实现对二叉树的后遍历 + * + * @param root + * @return + */ + public static List postOrderVisit(BinaryTreeNode root) { + List result = new ArrayList(); + postOrderVisit(root, result); + return result; + } + + public static List preOrderWithoutRecursion(BinaryTreeNode root) { + + List result = new ArrayList(); + Stack> stack = new Stack>(); + + BinaryTreeNode node = root; + + if(node != null){ + stack.push(node); + } + + while(!stack.isEmpty()){ + node = stack.pop(); + result.add(node.data); + + if(node.right != null){ + stack.push(node.right); + } + + if(node.left != null){ + stack.push(node.right); + } + } + return result; + } + + public static List inOrderWithoutRecursion(BinaryTreeNode root) { + + List result = new ArrayList(); + BinaryTreeNode node = root; + Stack> stack = new Stack>(); + + while (node != null || !stack.isEmpty()) { + + while (node != null) { + stack.push(node); + node = node.left; + } + BinaryTreeNode currentNode = stack.pop(); + result.add(currentNode.data); + node = currentNode.right; + } + return result; + } + + private static void preOrderVisit(BinaryTreeNode node, List result) { + if (node == null) { + return; + } + result.add(node.getData()); + preOrderVisit(node.getLeft(), result); + preOrderVisit(node.getRight(), result); + } + + private static void inOrderVisit(BinaryTreeNode node, List result) { + if (node == null) { + return; + } + inOrderVisit(node.getLeft(), result); + result.add(node.getData()); + inOrderVisit(node.getRight(), result); + } + + private static void postOrderVisit(BinaryTreeNode node, List result) { + if (node == null) { + return; + } + postOrderVisit(node.getLeft(), result); + postOrderVisit(node.getRight(), result); + result.add(node.getData()); + } + +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeUtilTest.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeUtilTest.java new file mode 100644 index 0000000000..41857e137d --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/BinaryTreeUtilTest.java @@ -0,0 +1,75 @@ +package com.coding.basic.tree; + +import java.util.List; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class BinaryTreeUtilTest { + + BinaryTreeNode root = null; + @Before + public void setUp() throws Exception { + root = new BinaryTreeNode(1); + root.setLeft(new BinaryTreeNode(2)); + root.setRight(new BinaryTreeNode(5)); + root.getLeft().setLeft(new BinaryTreeNode(3)); + root.getLeft().setRight(new BinaryTreeNode(4)); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testPreOrderVisit() { + + List result = BinaryTreeUtil.preOrderVisit(root); + Assert.assertEquals("[1, 2, 3, 4, 5]", result.toString()); + + + } + @Test + public void testInOrderVisit() { + + + List result = BinaryTreeUtil.inOrderVisit(root); + Assert.assertEquals("[3, 2, 4, 1, 5]", result.toString()); + + } + + @Test + public void testPostOrderVisit() { + + + List result = BinaryTreeUtil.postOrderVisit(root); + Assert.assertEquals("[3, 4, 2, 5, 1]", result.toString()); + + } + + + @Test + public void testInOrderVisitWithoutRecursion() { + BinaryTreeNode node = root.getLeft().getRight(); + node.setLeft(new BinaryTreeNode(6)); + node.setRight(new BinaryTreeNode(7)); + + List result = BinaryTreeUtil.inOrderWithoutRecursion(root); + Assert.assertEquals("[3, 2, 6, 4, 7, 1, 5]", result.toString()); + + } + @Test + public void testPreOrderVisitWithoutRecursion() { + BinaryTreeNode node = root.getLeft().getRight(); + node.setLeft(new BinaryTreeNode(6)); + node.setRight(new BinaryTreeNode(7)); + + List result = BinaryTreeUtil.preOrderWithoutRecursion(root); + Assert.assertEquals("[1, 2, 3, 4, 6, 7, 5]", result.toString()); + + } +} diff --git a/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/FileList.java b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/FileList.java new file mode 100644 index 0000000000..85fb8ab2a4 --- /dev/null +++ b/students/250103158/data-structure/answer/src/main/java/com/coding/basic/tree/FileList.java @@ -0,0 +1,34 @@ +package com.coding.basic.tree; + +import java.io.File; + +public class FileList { + public void list(File f) { + list(f, 0); + } + + public void list(File f, int depth) { + printName(f, depth); + if (f.isDirectory()) { + File[] files = f.listFiles(); + for (File i : files) + list(i, depth + 1); + } + } + + void printName(File f, int depth) { + String name = f.getName(); + for (int i = 0; i < depth; i++) + System.out.print("+"); + if (f.isDirectory()) + System.out.println("Dir: " + name); + else + System.out.println(f.getName() + " " + f.length()); + } + + public static void main(String args[]) { + FileList L = new FileList(); + File f = new File("C:\\coderising\\tmp"); + L.list(f); + } +} diff --git a/students/250103158/data-structure/assignment/pom.xml b/students/250103158/data-structure/assignment/pom.xml new file mode 100644 index 0000000000..5024466d17 --- /dev/null +++ b/students/250103158/data-structure/assignment/pom.xml @@ -0,0 +1,32 @@ + + 4.0.0 + + com.coderising + ds-assignment + 0.0.1-SNAPSHOT + jar + + ds-assignment + http://maven.apache.org + + + UTF-8 + + + + + + junit + junit + 4.12 + + + + + + aliyunmaven + http://maven.aliyun.com/nexus/content/groups/public/ + + + diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/DownloadThread.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/DownloadThread.java new file mode 100644 index 0000000000..900a3ad358 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/DownloadThread.java @@ -0,0 +1,20 @@ +package com.coderising.download; + +import com.coderising.download.api.Connection; + +public class DownloadThread extends Thread{ + + Connection conn; + int startPos; + int endPos; + + public DownloadThread( Connection conn, int startPos, int endPos){ + + this.conn = conn; + this.startPos = startPos; + this.endPos = endPos; + } + public void run(){ + + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/FileDownloader.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/FileDownloader.java new file mode 100644 index 0000000000..c3c8a3f27d --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/FileDownloader.java @@ -0,0 +1,73 @@ +package com.coderising.download; + +import com.coderising.download.api.Connection; +import com.coderising.download.api.ConnectionException; +import com.coderising.download.api.ConnectionManager; +import com.coderising.download.api.DownloadListener; + + +public class FileDownloader { + + String url; + + DownloadListener listener; + + ConnectionManager cm; + + + public FileDownloader(String _url) { + this.url = _url; + + } + + public void execute(){ + // 在这里实现你的代码, 注意: 需要用多线程实现下载 + // 这个类依赖于其他几个接口, 你需要写这几个接口的实现代码 + // (1) ConnectionManager , 可以打开一个连接,通过Connection可以读取其中的一段(用startPos, endPos来指定) + // (2) DownloadListener, 由于是多线程下载, 调用这个类的客户端不知道什么时候结束,所以你需要实现当所有 + // 线程都执行完以后, 调用listener的notifiedFinished方法, 这样客户端就能收到通知。 + // 具体的实现思路: + // 1. 需要调用ConnectionManager的open方法打开连接, 然后通过Connection.getContentLength方法获得文件的长度 + // 2. 至少启动3个线程下载, 注意每个线程需要先调用ConnectionManager的open方法 + // 然后调用read方法, read方法中有读取文件的开始位置和结束位置的参数, 返回值是byte[]数组 + // 3. 把byte数组写入到文件中 + // 4. 所有的线程都下载完成以后, 需要调用listener的notifiedFinished方法 + + // 下面的代码是示例代码, 也就是说只有一个线程, 你需要改造成多线程的。 + Connection conn = null; + try { + + conn = cm.open(this.url); + + int length = conn.getContentLength(); + + new DownloadThread(conn,0,length-1).start(); + + } catch (ConnectionException e) { + e.printStackTrace(); + }finally{ + if(conn != null){ + conn.close(); + } + } + + + + + } + + public void setListener(DownloadListener listener) { + this.listener = listener; + } + + + + public void setConnectionManager(ConnectionManager ucm){ + this.cm = ucm; + } + + public DownloadListener getListener(){ + return this.listener; + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/FileDownloaderTest.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/FileDownloaderTest.java new file mode 100644 index 0000000000..4ff7f46ae0 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/FileDownloaderTest.java @@ -0,0 +1,59 @@ +package com.coderising.download; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.coderising.download.api.ConnectionManager; +import com.coderising.download.api.DownloadListener; +import com.coderising.download.impl.ConnectionManagerImpl; + +public class FileDownloaderTest { + boolean downloadFinished = false; + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testDownload() { + + String url = "http://localhost:8080/test.jpg"; + + FileDownloader downloader = new FileDownloader(url); + + + ConnectionManager cm = new ConnectionManagerImpl(); + downloader.setConnectionManager(cm); + + downloader.setListener(new DownloadListener() { + @Override + public void notifyFinished() { + downloadFinished = true; + } + + }); + + + downloader.execute(); + + // 等待多线程下载程序执行完毕 + while (!downloadFinished) { + try { + System.out.println("还没有下载完成,休眠五秒"); + //休眠5秒 + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + System.out.println("下载完成!"); + + + + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/Connection.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/Connection.java new file mode 100644 index 0000000000..0957eaf7f4 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/Connection.java @@ -0,0 +1,23 @@ +package com.coderising.download.api; + +import java.io.IOException; + +public interface Connection { + /** + * 给定开始和结束位置, 读取数据, 返回值是字节数组 + * @param startPos 开始位置, 从0开始 + * @param endPos 结束位置 + * @return + */ + public byte[] read(int startPos,int endPos) throws IOException; + /** + * 得到数据内容的长度 + * @return + */ + public int getContentLength(); + + /** + * 关闭连接 + */ + public void close(); +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/ConnectionException.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/ConnectionException.java new file mode 100644 index 0000000000..1551a80b3d --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/ConnectionException.java @@ -0,0 +1,5 @@ +package com.coderising.download.api; + +public class ConnectionException extends Exception { + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/ConnectionManager.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/ConnectionManager.java new file mode 100644 index 0000000000..ce045393b1 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/ConnectionManager.java @@ -0,0 +1,10 @@ +package com.coderising.download.api; + +public interface ConnectionManager { + /** + * 给定一个url , 打开一个连接 + * @param url + * @return + */ + public Connection open(String url) throws ConnectionException; +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/DownloadListener.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/DownloadListener.java new file mode 100644 index 0000000000..bf9807b307 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/api/DownloadListener.java @@ -0,0 +1,5 @@ +package com.coderising.download.api; + +public interface DownloadListener { + public void notifyFinished(); +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/impl/ConnectionImpl.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/impl/ConnectionImpl.java new file mode 100644 index 0000000000..36a9d2ce15 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/impl/ConnectionImpl.java @@ -0,0 +1,27 @@ +package com.coderising.download.impl; + +import java.io.IOException; + +import com.coderising.download.api.Connection; + +public class ConnectionImpl implements Connection{ + + @Override + public byte[] read(int startPos, int endPos) throws IOException { + + return null; + } + + @Override + public int getContentLength() { + + return 0; + } + + @Override + public void close() { + + + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/impl/ConnectionManagerImpl.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/impl/ConnectionManagerImpl.java new file mode 100644 index 0000000000..172371dd55 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/download/impl/ConnectionManagerImpl.java @@ -0,0 +1,15 @@ +package com.coderising.download.impl; + +import com.coderising.download.api.Connection; +import com.coderising.download.api.ConnectionException; +import com.coderising.download.api.ConnectionManager; + +public class ConnectionManagerImpl implements ConnectionManager { + + @Override + public Connection open(String url) throws ConnectionException { + + return null; + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/LoginAction.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/LoginAction.java new file mode 100644 index 0000000000..dcdbe226ed --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/LoginAction.java @@ -0,0 +1,39 @@ +package com.coderising.litestruts; + +/** + * 这是一个用来展示登录的业务类, 其中的用户名和密码都是硬编码的。 + * @author liuxin + * + */ +public class LoginAction{ + private String name ; + private String password; + private String message; + + public String getName() { + return name; + } + + public String getPassword() { + return password; + } + + public String execute(){ + if("test".equals(name) && "1234".equals(password)){ + this.message = "login successful"; + return "success"; + } + this.message = "login failed,please check your user/pwd"; + return "fail"; + } + + public void setName(String name){ + this.name = name; + } + public void setPassword(String password){ + this.password = password; + } + public String getMessage(){ + return this.message; + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/Struts.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/Struts.java new file mode 100644 index 0000000000..85e2e22de3 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/Struts.java @@ -0,0 +1,34 @@ +package com.coderising.litestruts; + +import java.util.Map; + + + +public class Struts { + + public static View runAction(String actionName, Map 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字段中。 + + */ + + return null; + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/StrutsTest.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/StrutsTest.java new file mode 100644 index 0000000000..b8c81faf3c --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/StrutsTest.java @@ -0,0 +1,43 @@ +package com.coderising.litestruts; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Test; + + + + + +public class StrutsTest { + + @Test + public void testLoginActionSuccess() { + + String actionName = "login"; + + Map 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"); //密码和预设的不一致 + + 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/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/View.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/View.java new file mode 100644 index 0000000000..07df2a5dab --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/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/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/struts.xml b/students/250103158/data-structure/assignment/src/main/java/com/coderising/litestruts/struts.xml new file mode 100644 index 0000000000..e5d9aebba8 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/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 diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/Course.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/Course.java new file mode 100644 index 0000000000..436d092f58 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/Course.java @@ -0,0 +1,24 @@ +package com.coderising.ood.course.bad; + +import java.util.List; + +public class Course { + private String id; + private String desc; + private int duration ; + + List prerequisites; + + public List getPrerequisites() { + return prerequisites; + } + + + public boolean equals(Object o){ + if(o == null || !(o instanceof Course)){ + return false; + } + Course c = (Course)o; + return (c != null) && c.id.equals(id); + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/CourseOffering.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/CourseOffering.java new file mode 100644 index 0000000000..ab8c764584 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/CourseOffering.java @@ -0,0 +1,26 @@ +package com.coderising.ood.course.bad; + +import java.util.ArrayList; +import java.util.List; + + +public class CourseOffering { + private Course course; + private String location; + private String teacher; + private int maxStudents; + + List students = new ArrayList(); + + public int getMaxStudents() { + return maxStudents; + } + + public List getStudents() { + return students; + } + + public Course getCourse() { + return course; + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/CourseService.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/CourseService.java new file mode 100644 index 0000000000..8c34bad0c3 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/CourseService.java @@ -0,0 +1,16 @@ +package com.coderising.ood.course.bad; + + + +public class CourseService { + + public void chooseCourse(Student student, CourseOffering sc){ + //如果学生上过该科目的先修科目,并且该课程还未满, 则学生可以加入该课程 + if(student.getCoursesAlreadyTaken().containsAll( + sc.getCourse().getPrerequisites()) + && sc.getMaxStudents() > sc.getStudents().size()){ + sc.getStudents().add(student); + } + + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/Student.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/Student.java new file mode 100644 index 0000000000..a651923ef5 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/bad/Student.java @@ -0,0 +1,14 @@ +package com.coderising.ood.course.bad; + +import java.util.ArrayList; +import java.util.List; + +public class Student { + private String id; + private String name; + private List coursesAlreadyTaken = new ArrayList(); + + public List getCoursesAlreadyTaken() { + return coursesAlreadyTaken; + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/Course.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/Course.java new file mode 100644 index 0000000000..aefc9692bb --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/Course.java @@ -0,0 +1,18 @@ +package com.coderising.ood.course.good; + +import java.util.List; + +public class Course { + private String id; + private String desc; + private int duration ; + + List prerequisites; + + public List getPrerequisites() { + return prerequisites; + } + +} + + diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/CourseOffering.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/CourseOffering.java new file mode 100644 index 0000000000..8660ec8109 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/CourseOffering.java @@ -0,0 +1,34 @@ +package com.coderising.ood.course.good; + +import java.util.ArrayList; +import java.util.List; + +public class CourseOffering { + private Course course; + private String location; + private String teacher; + private int maxStudents; + + List students = new ArrayList(); + + public List getStudents() { + return students; + } + public int getMaxStudents() { + return maxStudents; + } + public Course getCourse() { + return course; + } + + + // 第二步: 把主要逻辑移动到CourseOffering 中 + public void addStudent(Student student){ + + if(student.canAttend(course) + && this.maxStudents > students.size()){ + students.add(student); + } + } + // 第三步: 重构CourseService +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/CourseService.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/CourseService.java new file mode 100644 index 0000000000..22ba4a5450 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/CourseService.java @@ -0,0 +1,14 @@ +package com.coderising.ood.course.good; + + + +public class CourseService { + + public void chooseCourse(Student student, CourseOffering sc){ + //第一步:重构: canAttend , 但是还有问题 + if(student.canAttend(sc.getCourse()) + && sc.getMaxStudents() > sc.getStudents().size()){ + sc.getStudents().add(student); + } + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/Student.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/Student.java new file mode 100644 index 0000000000..2c7e128b2a --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/course/good/Student.java @@ -0,0 +1,21 @@ +package com.coderising.ood.course.good; + +import java.util.ArrayList; +import java.util.List; + +public class Student { + private String id; + private String name; + private List coursesAlreadyTaken = new ArrayList(); + + public List getCoursesAlreadyTaken() { + return coursesAlreadyTaken; + } + + public boolean canAttend(Course course){ + return this.coursesAlreadyTaken.containsAll( + course.getPrerequisites()); + } +} + + diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/DateUtil.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/DateUtil.java new file mode 100644 index 0000000000..b6cf28c096 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/DateUtil.java @@ -0,0 +1,10 @@ +package com.coderising.ood.ocp; + +public class DateUtil { + + public static String getCurrentDateAsString() { + + return null; + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/Logger.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/Logger.java new file mode 100644 index 0000000000..0357c4d912 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/Logger.java @@ -0,0 +1,38 @@ +package com.coderising.ood.ocp; + +public class Logger { + + public final int RAW_LOG = 1; + public final int RAW_LOG_WITH_DATE = 2; + public final int EMAIL_LOG = 1; + public final int SMS_LOG = 2; + public final int PRINT_LOG = 3; + + int type = 0; + int method = 0; + + public Logger(int logType, int logMethod){ + this.type = logType; + this.method = logMethod; + } + public void log(String msg){ + + String logMsg = msg; + + if(this.type == RAW_LOG){ + logMsg = msg; + } else if(this.type == RAW_LOG_WITH_DATE){ + String txtDate = DateUtil.getCurrentDateAsString(); + logMsg = txtDate + ": " + msg; + } + + if(this.method == EMAIL_LOG){ + MailUtil.send(logMsg); + } else if(this.method == SMS_LOG){ + SMSUtil.send(logMsg); + } else if(this.method == PRINT_LOG){ + System.out.println(logMsg); + } + } +} + diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/MailUtil.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/MailUtil.java new file mode 100644 index 0000000000..ec54b839c5 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/MailUtil.java @@ -0,0 +1,10 @@ +package com.coderising.ood.ocp; + +public class MailUtil { + + public static void send(String logMsg) { + // TODO Auto-generated method stub + + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/SMSUtil.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/SMSUtil.java new file mode 100644 index 0000000000..13cf802418 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/ocp/SMSUtil.java @@ -0,0 +1,10 @@ +package com.coderising.ood.ocp; + +public class SMSUtil { + + public static void send(String logMsg) { + // TODO Auto-generated method stub + + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/Configuration.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/Configuration.java new file mode 100644 index 0000000000..f328c1816a --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/Configuration.java @@ -0,0 +1,23 @@ +package com.coderising.ood.srp; +import java.util.HashMap; +import java.util.Map; + +public class Configuration { + + static Map configurations = new HashMap<>(); + static{ + configurations.put(ConfigurationKeys.SMTP_SERVER, "smtp.163.com"); + configurations.put(ConfigurationKeys.ALT_SMTP_SERVER, "smtp1.163.com"); + configurations.put(ConfigurationKeys.EMAIL_ADMIN, "admin@company.com"); + } + /** + * 应该从配置文件读, 但是这里简化为直接从一个map 中去读 + * @param key + * @return + */ + public String getProperty(String key) { + + return configurations.get(key); + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/ConfigurationKeys.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/ConfigurationKeys.java new file mode 100644 index 0000000000..8695aed644 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/ConfigurationKeys.java @@ -0,0 +1,9 @@ +package com.coderising.ood.srp; + +public class ConfigurationKeys { + + public static final String SMTP_SERVER = "smtp.server"; + public static final String ALT_SMTP_SERVER = "alt.smtp.server"; + public static final String EMAIL_ADMIN = "email.admin"; + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/DBUtil.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/DBUtil.java new file mode 100644 index 0000000000..82e9261d18 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/DBUtil.java @@ -0,0 +1,25 @@ +package com.coderising.ood.srp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class DBUtil { + + /** + * 应该从数据库读, 但是简化为直接生成。 + * @param sql + * @return + */ + public static List query(String sql){ + + List userList = new ArrayList(); + for (int i = 1; i <= 3; i++) { + HashMap userInfo = new HashMap(); + userInfo.put("NAME", "User" + i); + userInfo.put("EMAIL", "aa@bb.com"); + userList.add(userInfo); + } + + return userList; + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/MailUtil.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/MailUtil.java new file mode 100644 index 0000000000..9f9e749af7 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/MailUtil.java @@ -0,0 +1,18 @@ +package com.coderising.ood.srp; + +public class MailUtil { + + public static void sendEmail(String toAddress, String fromAddress, String subject, String message, String smtpHost, + boolean debug) { + //假装发了一封邮件 + StringBuilder buffer = new StringBuilder(); + buffer.append("From:").append(fromAddress).append("\n"); + buffer.append("To:").append(toAddress).append("\n"); + buffer.append("Subject:").append(subject).append("\n"); + buffer.append("Content:").append(message).append("\n"); + System.out.println(buffer.toString()); + + } + + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/PromotionMail.java b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/PromotionMail.java new file mode 100644 index 0000000000..781587a846 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/PromotionMail.java @@ -0,0 +1,199 @@ +package com.coderising.ood.srp; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +public class PromotionMail { + + + protected String sendMailQuery = null; + + + protected String smtpHost = null; + protected String altSmtpHost = null; + protected String fromAddress = null; + protected String toAddress = null; + protected String subject = null; + protected String message = null; + + protected String productID = null; + protected String productDesc = null; + + private static Configuration config; + + + + private static final String NAME_KEY = "NAME"; + private static final String EMAIL_KEY = "EMAIL"; + + + public static void main(String[] args) throws Exception { + + File f = new File("C:\\coderising\\workspace_ds\\ood-example\\src\\product_promotion.txt"); + boolean emailDebug = false; + + PromotionMail pe = new PromotionMail(f, emailDebug); + + } + + + public PromotionMail(File file, boolean mailDebug) throws Exception { + + //读取配置文件, 文件中只有一行用空格隔开, 例如 P8756 iPhone8 + readFile(file); + + + config = new Configuration(); + + setSMTPHost(); + setAltSMTPHost(); + + + setFromAddress(); + + + setLoadQuery(); + + sendEMails(mailDebug, loadMailingList()); + + + } + + + + + protected void setProductID(String productID) + { + this.productID = productID; + + } + + protected String getproductID() + { + return productID; + } + + protected void setLoadQuery() throws Exception { + + sendMailQuery = "Select name from subscriptions " + + "where product_id= '" + productID +"' " + + "and send_mail=1 "; + + + System.out.println("loadQuery set"); + } + + + protected void setSMTPHost() + { + smtpHost = config.getProperty(ConfigurationKeys.SMTP_SERVER); + } + + + protected void setAltSMTPHost() + { + altSmtpHost = config.getProperty(ConfigurationKeys.ALT_SMTP_SERVER); + + } + + + protected void setFromAddress() + { + fromAddress = config.getProperty(ConfigurationKeys.EMAIL_ADMIN); + } + + protected void setMessage(HashMap userInfo) throws IOException + { + + String name = (String) userInfo.get(NAME_KEY); + + subject = "您关注的产品降价了"; + message = "尊敬的 "+name+", 您关注的产品 " + productDesc + " 降价了,欢迎购买!" ; + + + + } + + + protected void readFile(File file) throws IOException // @02C + { + BufferedReader br = null; + try { + br = new BufferedReader(new FileReader(file)); + String temp = br.readLine(); + String[] data = temp.split(" "); + + setProductID(data[0]); + setProductDesc(data[1]); + + System.out.println("产品ID = " + productID + "\n"); + System.out.println("产品描述 = " + productDesc + "\n"); + + } catch (IOException e) { + throw new IOException(e.getMessage()); + } finally { + br.close(); + } + } + + private void setProductDesc(String desc) { + this.productDesc = desc; + } + + + protected void configureEMail(HashMap userInfo) throws IOException + { + toAddress = (String) userInfo.get(EMAIL_KEY); + if (toAddress.length() > 0) + setMessage(userInfo); + } + + protected List loadMailingList() throws Exception { + return DBUtil.query(this.sendMailQuery); + } + + + protected void sendEMails(boolean debug, List mailingList) throws IOException + { + + System.out.println("开始发送邮件"); + + + if (mailingList != null) { + Iterator iter = mailingList.iterator(); + while (iter.hasNext()) { + configureEMail((HashMap) iter.next()); + try + { + if (toAddress.length() > 0) + MailUtil.sendEmail(toAddress, fromAddress, subject, message, smtpHost, debug); + } + catch (Exception e) + { + + try { + MailUtil.sendEmail(toAddress, fromAddress, subject, message, altSmtpHost, debug); + + } catch (Exception e2) + { + System.out.println("通过备用 SMTP服务器发送邮件失败: " + e2.getMessage()); + } + } + } + + + } + + else { + System.out.println("没有邮件发送"); + + } + + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/product_promotion.txt b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/product_promotion.txt new file mode 100644 index 0000000000..a98917f829 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coderising/ood/srp/product_promotion.txt @@ -0,0 +1,4 @@ +P8756 iPhone8 +P3946 XiaoMi10 +P8904 Oppo R15 +P4955 Vivo X20 \ No newline at end of file diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/Iterator.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/Iterator.java new file mode 100644 index 0000000000..06ef6311b2 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/Iterator.java @@ -0,0 +1,7 @@ +package com.coding.basic; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/List.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/List.java new file mode 100644 index 0000000000..10d13b5832 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/List.java @@ -0,0 +1,9 @@ +package com.coding.basic; + +public interface List { + public void add(Object o); + public void add(int index, Object o); + public Object get(int index); + public Object remove(int index); + public int size(); +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/array/ArrayList.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/array/ArrayList.java new file mode 100644 index 0000000000..4576c016af --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/array/ArrayList.java @@ -0,0 +1,35 @@ +package com.coding.basic.array; + +import com.coding.basic.Iterator; +import com.coding.basic.List; + +public class ArrayList implements List { + + private int size = 0; + + private Object[] elementData = new Object[100]; + + public void add(Object o){ + + } + public void add(int index, Object o){ + + } + + public Object get(int index){ + return null; + } + + public Object remove(int index){ + return null; + } + + public int size(){ + return -1; + } + + public Iterator iterator(){ + return null; + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/array/ArrayUtil.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/array/ArrayUtil.java new file mode 100644 index 0000000000..45740e6d57 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/array/ArrayUtil.java @@ -0,0 +1,96 @@ +package com.coding.basic.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 oldArr[]={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5} + * 要求将以上数组中值为0的项去掉,将不为0的值存入一个新的数组,生成的新数组为: + * {1,3,4,5,6,6,5,4,7,6,7,5} + * @param oldArray + * @return + */ + + public int[] removeZero(int[] oldArray){ + return null; + } + + /** + * 给定两个已经排序好的整形数组, a1和a2 , 创建一个新的数组a3, 使得a3 包含a1和a2 的所有元素, 并且仍然是有序的 + * 例如 a1 = [3, 5, 7,8] a2 = [4, 5, 6,7] 则 a3 为[3,4,5,6,7,8] , 注意: 已经消除了重复 + * @param array1 + * @param array2 + * @return + */ + + public int[] merge(int[] array1, int[] array2){ + return null; + } + /** + * 把一个已经存满数据的数组 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){ + return null; + } + + /** + * 斐波那契数列为:1,1,2,3,5,8,13,21...... ,给定一个最大值, 返回小于该值的数列 + * 例如, max = 15 , 则返回的数组应该为 [1,1,2,3,5,8,13] + * max = 1, 则返回空数组 [] + * @param max + * @return + */ + public int[] fibonacci(int max){ + return null; + } + + /** + * 返回小于给定最大值max的所有素数数组 + * 例如max = 23, 返回的数组为[2,3,5,7,11,13,17,19] + * @param max + * @return + */ + public int[] getPrimes(int max){ + return null; + } + + /** + * 所谓“完数”, 是指这个数恰好等于它的因子之和,例如6=1+2+3 + * 给定一个最大值max, 返回一个数组, 数组中是小于max 的所有完数 + * @param max + * @return + */ + public int[] getPerfectNumbers(int max){ + return null; + } + + /** + * 用seperator 把数组 array给连接起来 + * 例如array= [3,8,9], seperator = "-" + * 则返回值为"3-8-9" + * @param array + * @param s + * @return + */ + public String join(int[] array, String seperator){ + return null; + } + + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LRUPageFrame.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LRUPageFrame.java new file mode 100644 index 0000000000..994a241a3d --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LRUPageFrame.java @@ -0,0 +1,57 @@ +package com.coding.basic.linklist; + + +public class LRUPageFrame { + + private static class Node { + + Node prev; + Node next; + int pageNum; + + Node() { + } + } + + private int capacity; + + private int currentSize; + private Node first;// 链表头 + private Node last;// 链表尾 + + + public LRUPageFrame(int capacity) { + this.currentSize = 0; + this.capacity = capacity; + + } + + /** + * 获取缓存中对象 + * + * @param key + * @return + */ + public void access(int pageNum) { + + + } + + + public String toString(){ + StringBuilder buffer = new StringBuilder(); + Node node = first; + while(node != null){ + buffer.append(node.pageNum); + + node = node.next; + if(node != null){ + buffer.append(","); + } + } + return buffer.toString(); + } + + + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LRUPageFrameTest.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LRUPageFrameTest.java new file mode 100644 index 0000000000..7fd72fc2b4 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LRUPageFrameTest.java @@ -0,0 +1,34 @@ +package com.coding.basic.linklist; + +import org.junit.Assert; + +import org.junit.Test; + + +public class LRUPageFrameTest { + + @Test + public void testAccess() { + LRUPageFrame frame = new LRUPageFrame(3); + frame.access(7); + frame.access(0); + frame.access(1); + Assert.assertEquals("1,0,7", frame.toString()); + frame.access(2); + Assert.assertEquals("2,1,0", frame.toString()); + frame.access(0); + Assert.assertEquals("0,2,1", frame.toString()); + frame.access(0); + Assert.assertEquals("0,2,1", frame.toString()); + frame.access(3); + Assert.assertEquals("3,0,2", frame.toString()); + frame.access(0); + Assert.assertEquals("0,3,2", frame.toString()); + frame.access(4); + Assert.assertEquals("4,0,3", frame.toString()); + frame.access(5); + Assert.assertEquals("5,4,0", frame.toString()); + + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LinkedList.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LinkedList.java new file mode 100644 index 0000000000..f4c7556a2e --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/linklist/LinkedList.java @@ -0,0 +1,125 @@ +package com.coding.basic.linklist; + +import com.coding.basic.Iterator; +import com.coding.basic.List; + +public class LinkedList implements List { + + private Node head; + + public void add(Object o){ + + } + public void add(int index , Object o){ + + } + public Object get(int index){ + return null; + } + public Object remove(int index){ + return null; + } + + public int size(){ + return -1; + } + + public void addFirst(Object o){ + + } + public void addLast(Object o){ + + } + public Object removeFirst(){ + return null; + } + public Object removeLast(){ + return null; + } + public Iterator iterator(){ + return null; + } + + + private static class Node{ + Object data; + Node next; + + } + + /** + * 把该链表逆置 + * 例如链表为 3->7->10 , 逆置后变为 10->7->3 + */ + public void reverse(){ + + } + + /** + * 删除一个单链表的前半部分 + * 例如:list = 2->5->7->8 , 删除以后的值为 7->8 + * 如果list = 2->5->7->8->10 ,删除以后的值为7,8,10 + + */ + public void removeFirstHalf(){ + + } + + /** + * 从第i个元素开始, 删除length 个元素 , 注意i从0开始 + * @param i + * @param length + */ + public void remove(int i, int length){ + + } + /** + * 假定当前链表和listB均包含已升序排列的整数 + * 从当前链表中取出那些listB所指定的元素 + * 例如当前链表 = 11->101->201->301->401->501->601->701 + * listB = 1->3->4->6 + * 返回的结果应该是[101,301,401,601] + * @param list + */ + public int[] getElements(LinkedList list){ + return null; + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 从当前链表中中删除在listB中出现的元素 + + * @param list + */ + + public void subtract(LinkedList list){ + + } + + /** + * 已知当前链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 删除表中所有值相同的多余元素(使得操作后的线性表中所有元素的值均不相同) + */ + public void removeDuplicateValues(){ + + } + + /** + * 已知链表中的元素以值递增有序排列,并以单链表作存储结构。 + * 试写一高效的算法,删除表中所有值大于min且小于max的元素(若表中存在这样的元素) + * @param min + * @param max + */ + public void removeRange(int min, int max){ + + } + + /** + * 假设当前链表和参数list指定的链表均以元素依值递增有序排列(同一表中的元素值各不相同) + * 现要求生成新链表C,其元素为当前链表和list中元素的交集,且表C中的元素有依值递增有序排列 + * @param list + */ + public LinkedList intersection( LinkedList list){ + return null; + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/CircleQueue.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/CircleQueue.java new file mode 100644 index 0000000000..2e0550c67e --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/CircleQueue.java @@ -0,0 +1,39 @@ +package com.coding.basic.queue; + +/** + * 用数组实现循环队列 + * @author liuxin + * + * @param + */ +public class CircleQueue { + + private final static int DEFAULT_SIZE = 10; + + //用数组来保存循环队列的元素 + private Object[] elementData = new Object[DEFAULT_SIZE] ; + + //队头 + private int front = 0; + //队尾 + private int rear = 0; + + public boolean isEmpty() { + return false; + + } + + public int size() { + return -1; + } + + + + public void enQueue(E data) { + + } + + public E deQueue() { + return null; + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/Josephus.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/Josephus.java new file mode 100644 index 0000000000..6a3ea639b9 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/Josephus.java @@ -0,0 +1,18 @@ +package com.coding.basic.queue; + +import java.util.List; + +/** + * 用Queue来实现Josephus问题 + * 在这个古老的问题当中, N个深陷绝境的人一致同意用这种方式减少生存人数: N个人围成一圈(位置记为0到N-1), 并且从第一个人报数, 报到M的人会被杀死, 直到最后一个人留下来 + * 该方法返回一个List, 包含了被杀死人的次序 + * @author liuxin + * + */ +public class Josephus { + + public static List execute(int n, int m){ + return null; + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/JosephusTest.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/JosephusTest.java new file mode 100644 index 0000000000..7d90318b51 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/JosephusTest.java @@ -0,0 +1,27 @@ +package com.coding.basic.queue; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class JosephusTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testExecute() { + + Assert.assertEquals("[1, 3, 5, 0, 4, 2, 6]", Josephus.execute(7, 2).toString()); + + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/Queue.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/Queue.java new file mode 100644 index 0000000000..c4c4b7325e --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/Queue.java @@ -0,0 +1,61 @@ +package com.coding.basic.queue; + +import java.util.NoSuchElementException; + +public class Queue { + private Node first; + private Node last; + private int size; + + + private static class Node { + private E item; + private Node next; + } + + + public Queue() { + first = null; + last = null; + size = 0; + } + + + public boolean isEmpty() { + return first == null; + } + + public int size() { + return size; + } + + + + public void enQueue(E data) { + Node oldlast = last; + last = new Node(); + last.item = data; + last.next = null; + if (isEmpty()) { + first = last; + } + else{ + oldlast.next = last; + } + size++; + } + + public E deQueue() { + if (isEmpty()) { + throw new NoSuchElementException("Queue underflow"); + } + E item = first.item; + first = first.next; + size--; + if (isEmpty()) { + last = null; + } + return item; + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/QueueWithTwoStacks.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/QueueWithTwoStacks.java new file mode 100644 index 0000000000..cef19a8b59 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/queue/QueueWithTwoStacks.java @@ -0,0 +1,47 @@ +package com.coding.basic.queue; + +import java.util.Stack; + +/** + * 用两个栈来实现一个队列 + * @author liuxin + * + * @param + */ +public class QueueWithTwoStacks { + private Stack stack1; + private Stack stack2; + + + public QueueWithTwoStacks() { + stack1 = new Stack(); + stack2 = new Stack(); + } + + + + + public boolean isEmpty() { + return false; + } + + + + public int size() { + return -1; + } + + + + public void enQueue(E item) { + + } + + public E deQueue() { + return null; + } + + + + } + diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/QuickMinStack.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/QuickMinStack.java new file mode 100644 index 0000000000..f391d92b8f --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/QuickMinStack.java @@ -0,0 +1,19 @@ +package com.coding.basic.stack; + +/** + * 设计一个栈,支持栈的push和pop操作,以及第三种操作findMin, 它返回改数据结构中的最小元素 + * finMin操作最坏的情形下时间复杂度应该是O(1) , 简单来讲,操作一次就可以得到最小值 + * @author liuxin + * + */ +public class QuickMinStack { + public void push(int data){ + + } + public int pop(){ + return -1; + } + public int findMin(){ + return -1; + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/Stack.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/Stack.java new file mode 100644 index 0000000000..fedb243604 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/Stack.java @@ -0,0 +1,24 @@ +package com.coding.basic.stack; + +import com.coding.basic.array.ArrayList; + +public class Stack { + private ArrayList elementData = new ArrayList(); + + public void push(Object o){ + } + + public Object pop(){ + return null; + } + + public Object peek(){ + return null; + } + public boolean isEmpty(){ + return false; + } + public int size(){ + return -1; + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackUtil.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackUtil.java new file mode 100644 index 0000000000..b0ec38161d --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackUtil.java @@ -0,0 +1,48 @@ +package com.coding.basic.stack; +import java.util.Stack; +public class StackUtil { + + + + /** + * 假设栈中的元素是Integer, 从栈顶到栈底是 : 5,4,3,2,1 调用该方法后, 元素次序变为: 1,2,3,4,5 + * 注意:只能使用Stack的基本操作,即push,pop,peek,isEmpty, 可以使用另外一个栈来辅助 + */ + public static void reverse(Stack s) { + + + + } + + /** + * 删除栈中的某个元素 注意:只能使用Stack的基本操作,即push,pop,peek,isEmpty, 可以使用另外一个栈来辅助 + * + * @param o + */ + public static void remove(Stack s,Object o) { + + } + + /** + * 从栈顶取得len个元素, 原来的栈中元素保持不变 + * 注意:只能使用Stack的基本操作,即push,pop,peek,isEmpty, 可以使用另外一个栈来辅助 + * @param len + * @return + */ + public static Object[] getTop(Stack s,int len) { + return null; + } + /** + * 字符串s 可能包含这些字符: ( ) [ ] { }, a,b,c... x,yz + * 使用堆栈检查字符串s中的括号是不是成对出现的。 + * 例如s = "([e{d}f])" , 则该字符串中的括号是成对出现, 该方法返回true + * 如果 s = "([b{x]y})", 则该字符串中的括号不是成对出现的, 该方法返回false; + * @param s + * @return + */ + public static boolean isValidPairs(String s){ + return false; + } + + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackUtilTest.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackUtilTest.java new file mode 100644 index 0000000000..76f2cb7668 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackUtilTest.java @@ -0,0 +1,65 @@ +package com.coding.basic.stack; + +import java.util.Stack; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +public class StackUtilTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + + @Test + public void testReverse() { + Stack s = new Stack(); + s.push(1); + s.push(2); + s.push(3); + s.push(4); + s.push(5); + Assert.assertEquals("[1, 2, 3, 4, 5]", s.toString()); + StackUtil.reverse(s); + Assert.assertEquals("[5, 4, 3, 2, 1]", s.toString()); + } + + @Test + public void testRemove() { + Stack s = new Stack(); + s.push(1); + s.push(2); + s.push(3); + StackUtil.remove(s, 2); + Assert.assertEquals("[1, 3]", s.toString()); + } + + @Test + public void testGetTop() { + Stack s = new Stack(); + s.push(1); + s.push(2); + s.push(3); + s.push(4); + s.push(5); + { + Object[] values = StackUtil.getTop(s, 3); + Assert.assertEquals(5, values[0]); + Assert.assertEquals(4, values[1]); + Assert.assertEquals(3, values[2]); + } + } + + @Test + public void testIsValidPairs() { + Assert.assertTrue(StackUtil.isValidPairs("([e{d}f])")); + Assert.assertFalse(StackUtil.isValidPairs("([b{x]y})")); + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackWithTwoQueues.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackWithTwoQueues.java new file mode 100644 index 0000000000..d0ab4387d2 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/StackWithTwoQueues.java @@ -0,0 +1,16 @@ +package com.coding.basic.stack; + + +public class StackWithTwoQueues { + + + public void push(int data) { + + } + + public int pop() { + return -1; + } + + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/TwoStackInOneArray.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/TwoStackInOneArray.java new file mode 100644 index 0000000000..e86d056a24 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/TwoStackInOneArray.java @@ -0,0 +1,57 @@ +package com.coding.basic.stack; + +/** + * 用一个数组实现两个栈 + * 将数组的起始位置看作是第一个栈的栈底,将数组的尾部看作第二个栈的栈底,压栈时,栈顶指针分别向中间移动,直到两栈顶指针相遇,则扩容。 + * @author liuxin + * + */ +public class TwoStackInOneArray { + Object[] data = new Object[10]; + + /** + * 向第一个栈中压入元素 + * @param o + */ + public void push1(Object o){ + + } + /** + * 从第一个栈中弹出元素 + * @return + */ + public Object pop1(){ + return null; + } + + /** + * 获取第一个栈的栈顶元素 + * @return + */ + + public Object peek1(){ + return null; + } + /* + * 向第二个栈压入元素 + */ + public void push2(Object o){ + + } + /** + * 从第二个栈弹出元素 + * @return + */ + public Object pop2(){ + return null; + } + /** + * 获取第二个栈的栈顶元素 + * @return + */ + + public Object peek2(){ + return null; + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixExpr.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixExpr.java new file mode 100644 index 0000000000..ef85ff007f --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixExpr.java @@ -0,0 +1,15 @@ +package com.coding.basic.stack.expr; + +public class InfixExpr { + String expr = null; + + public InfixExpr(String expr) { + this.expr = expr; + } + + public float evaluate() { + return 0.0f; + } + + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixExprTest.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixExprTest.java new file mode 100644 index 0000000000..20e34e8852 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixExprTest.java @@ -0,0 +1,52 @@ +package com.coding.basic.stack.expr; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + +public class InfixExprTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEvaluate() { + //InfixExpr expr = new InfixExpr("300*20+12*5-20/4"); + { + InfixExpr expr = new InfixExpr("2+3*4+5"); + Assert.assertEquals(19.0, expr.evaluate(), 0.001f); + } + { + InfixExpr expr = new InfixExpr("3*20+12*5-40/2"); + Assert.assertEquals(100.0, expr.evaluate(), 0.001f); + } + + { + InfixExpr expr = new InfixExpr("3*20/2"); + Assert.assertEquals(30, expr.evaluate(), 0.001f); + } + + { + InfixExpr expr = new InfixExpr("20/2*3"); + Assert.assertEquals(30, expr.evaluate(), 0.001f); + } + + { + InfixExpr expr = new InfixExpr("10-30+50"); + Assert.assertEquals(30, expr.evaluate(), 0.001f); + } + { + InfixExpr expr = new InfixExpr("10-2*3+50"); + Assert.assertEquals(54, expr.evaluate(), 0.001f); + } + + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixToPostfix.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixToPostfix.java new file mode 100644 index 0000000000..96a2194a67 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/InfixToPostfix.java @@ -0,0 +1,14 @@ +package com.coding.basic.stack.expr; + +import java.util.List; + +public class InfixToPostfix { + + public static List convert(String expr) { + + return null; + } + + + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PostfixExpr.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PostfixExpr.java new file mode 100644 index 0000000000..dcbb18be4b --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PostfixExpr.java @@ -0,0 +1,18 @@ +package com.coding.basic.stack.expr; + +import java.util.List; +import java.util.Stack; + +public class PostfixExpr { +String expr = null; + + public PostfixExpr(String expr) { + this.expr = expr; + } + + public float evaluate() { + return 0.0f; + } + + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PostfixExprTest.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PostfixExprTest.java new file mode 100644 index 0000000000..c0435a2db5 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PostfixExprTest.java @@ -0,0 +1,41 @@ +package com.coding.basic.stack.expr; + + + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class PostfixExprTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEvaluate() { + { + PostfixExpr expr = new PostfixExpr("6 5 2 3 + 8 * + 3 + *"); + Assert.assertEquals(288, expr.evaluate(),0.0f); + } + { + //9+(3-1)*3+10/2 + PostfixExpr expr = new PostfixExpr("9 3 1-3*+ 10 2/+"); + Assert.assertEquals(20, expr.evaluate(),0.0f); + } + + { + //10-2*3+50 + PostfixExpr expr = new PostfixExpr("10 2 3 * - 50 +"); + Assert.assertEquals(54, expr.evaluate(),0.0f); + } + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PrefixExpr.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PrefixExpr.java new file mode 100644 index 0000000000..956927e2df --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PrefixExpr.java @@ -0,0 +1,18 @@ +package com.coding.basic.stack.expr; + +import java.util.List; +import java.util.Stack; + +public class PrefixExpr { + String expr = null; + + public PrefixExpr(String expr) { + this.expr = expr; + } + + public float evaluate() { + return 0.0f; + } + + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PrefixExprTest.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PrefixExprTest.java new file mode 100644 index 0000000000..5cec210e75 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/PrefixExprTest.java @@ -0,0 +1,45 @@ +package com.coding.basic.stack.expr; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + +public class PrefixExprTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEvaluate() { + { + // 2*3+4*5 + PrefixExpr expr = new PrefixExpr("+ * 2 3* 4 5"); + Assert.assertEquals(26, expr.evaluate(),0.001f); + } + { + // 4*2 + 6+9*2/3 -8 + PrefixExpr expr = new PrefixExpr("-++6/*2 9 3 * 4 2 8"); + Assert.assertEquals(12, expr.evaluate(),0.001f); + } + { + //(3+4)*5-6 + PrefixExpr expr = new PrefixExpr("- * + 3 4 5 6"); + Assert.assertEquals(29, expr.evaluate(),0.001f); + } + { + //1+((2+3)*4)-5 + PrefixExpr expr = new PrefixExpr("- + 1 * + 2 3 4 5"); + Assert.assertEquals(16, expr.evaluate(),0.001f); + } + + + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/Token.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/Token.java new file mode 100644 index 0000000000..8579743fe9 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/Token.java @@ -0,0 +1,50 @@ +package com.coding.basic.stack.expr; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +class Token { + public static final List OPERATORS = Arrays.asList("+", "-", "*", "/"); + private static final Map priorities = new HashMap<>(); + static { + priorities.put("+", 1); + priorities.put("-", 1); + priorities.put("*", 2); + priorities.put("/", 2); + } + static final int OPERATOR = 1; + static final int NUMBER = 2; + String value; + int type; + public Token(int type, String value){ + this.type = type; + this.value = value; + } + + public boolean isNumber() { + return type == NUMBER; + } + + public boolean isOperator() { + return type == OPERATOR; + } + + public int getIntValue() { + return Integer.valueOf(value).intValue(); + } + public String toString(){ + return value; + } + + public boolean hasHigherPriority(Token t){ + if(!this.isOperator() && !t.isOperator()){ + throw new RuntimeException("numbers can't compare priority"); + } + return priorities.get(this.value) - priorities.get(t.value) > 0; + } + + + +} \ No newline at end of file diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/TokenParser.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/TokenParser.java new file mode 100644 index 0000000000..d3b0f167e1 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/TokenParser.java @@ -0,0 +1,57 @@ +package com.coding.basic.stack.expr; + +import java.util.ArrayList; +import java.util.List; + +public class TokenParser { + + + public List parse(String expr) { + List tokens = new ArrayList<>(); + + int i = 0; + + while (i < expr.length()) { + + char c = expr.charAt(i); + + if (isOperator(c)) { + + Token t = new Token(Token.OPERATOR, String.valueOf(c)); + tokens.add(t); + i++; + + } else if (Character.isDigit(c)) { + + int nextOperatorIndex = indexOfNextOperator(i, expr); + String value = expr.substring(i, nextOperatorIndex); + Token t = new Token(Token.NUMBER, value); + tokens.add(t); + i = nextOperatorIndex; + + } else{ + System.out.println("char :["+c+"] is not number or operator,ignore"); + i++; + } + + } + return tokens; + } + + private int indexOfNextOperator(int i, String expr) { + + while (Character.isDigit(expr.charAt(i))) { + i++; + if (i == expr.length()) { + break; + } + } + return i; + + } + + private boolean isOperator(char c) { + String sc = String.valueOf(c); + return Token.OPERATORS.contains(sc); + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/TokenParserTest.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/TokenParserTest.java new file mode 100644 index 0000000000..399d3e857e --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/stack/expr/TokenParserTest.java @@ -0,0 +1,41 @@ +package com.coding.basic.stack.expr; + +import static org.junit.Assert.*; + +import java.util.List; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class TokenParserTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void test() { + + TokenParser parser = new TokenParser(); + List tokens = parser.parse("300*20+12*5-20/4"); + + Assert.assertEquals(300, tokens.get(0).getIntValue()); + Assert.assertEquals("*", tokens.get(1).toString()); + Assert.assertEquals(20, tokens.get(2).getIntValue()); + Assert.assertEquals("+", tokens.get(3).toString()); + Assert.assertEquals(12, tokens.get(4).getIntValue()); + Assert.assertEquals("*", tokens.get(5).toString()); + Assert.assertEquals(5, tokens.get(6).getIntValue()); + Assert.assertEquals("-", tokens.get(7).toString()); + Assert.assertEquals(20, tokens.get(8).getIntValue()); + Assert.assertEquals("/", tokens.get(9).toString()); + Assert.assertEquals(4, tokens.get(10).getIntValue()); + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinarySearchTree.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinarySearchTree.java new file mode 100644 index 0000000000..4536ee7a2b --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinarySearchTree.java @@ -0,0 +1,55 @@ +package com.coding.basic.tree; + +import java.util.ArrayList; +import java.util.List; + +import com.coding.basic.queue.Queue; + +public class BinarySearchTree { + + BinaryTreeNode root; + public BinarySearchTree(BinaryTreeNode root){ + this.root = root; + } + public BinaryTreeNode getRoot(){ + return root; + } + public T findMin(){ + return null; + } + public T findMax(){ + return null; + } + public int height() { + return -1; + } + public int size() { + return -1; + } + public void remove(T e){ + + } + public List levelVisit(){ + + return null; + } + public boolean isValid(){ + return false; + } + public T getLowestCommonAncestor(T n1, T n2){ + return null; + + } + /** + * 返回所有满足下列条件的节点的值: n1 <= n <= n2 , n 为 + * 该二叉查找树中的某一节点 + * @param n1 + * @param n2 + * @return + */ + public List getNodesBetween(T n1, T n2){ + return null; + } + +} + diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinarySearchTreeTest.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinarySearchTreeTest.java new file mode 100644 index 0000000000..4a53dbe2f1 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinarySearchTreeTest.java @@ -0,0 +1,109 @@ +package com.coding.basic.tree; + +import java.util.List; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class BinarySearchTreeTest { + + BinarySearchTree tree = null; + + @Before + public void setUp() throws Exception { + BinaryTreeNode root = new BinaryTreeNode(6); + root.left = new BinaryTreeNode(2); + root.right = new BinaryTreeNode(8); + root.left.left = new BinaryTreeNode(1); + root.left.right = new BinaryTreeNode(4); + root.left.right.left = new BinaryTreeNode(3); + root.left.right.right = new BinaryTreeNode(5); + tree = new BinarySearchTree(root); + } + + @After + public void tearDown() throws Exception { + tree = null; + } + + @Test + public void testFindMin() { + Assert.assertEquals(1, tree.findMin().intValue()); + + } + + @Test + public void testFindMax() { + Assert.assertEquals(8, tree.findMax().intValue()); + } + + @Test + public void testHeight() { + Assert.assertEquals(4, tree.height()); + } + + @Test + public void testSize() { + Assert.assertEquals(7, tree.size()); + } + + @Test + public void testRemoveLeaf() { + tree.remove(3); + BinaryTreeNode root= tree.getRoot(); + Assert.assertEquals(4, root.left.right.data.intValue()); + + } + @Test + public void testRemoveMiddleNode1() { + tree.remove(4); + BinaryTreeNode root= tree.getRoot(); + Assert.assertEquals(5, root.left.right.data.intValue()); + Assert.assertEquals(3, root.left.right.left.data.intValue()); + } + @Test + public void testRemoveMiddleNode2() { + tree.remove(2); + BinaryTreeNode root= tree.getRoot(); + Assert.assertEquals(3, root.left.data.intValue()); + Assert.assertEquals(4, root.left.right.data.intValue()); + } + + @Test + public void testLevelVisit() { + List values = tree.levelVisit(); + Assert.assertEquals("[6, 2, 8, 1, 4, 3, 5]", values.toString()); + + } + @Test + public void testLCA(){ + Assert.assertEquals(2,tree.getLowestCommonAncestor(1, 5).intValue()); + Assert.assertEquals(2,tree.getLowestCommonAncestor(1, 4).intValue()); + Assert.assertEquals(6,tree.getLowestCommonAncestor(3, 8).intValue()); + } + @Test + public void testIsValid() { + + Assert.assertTrue(tree.isValid()); + + BinaryTreeNode root = new BinaryTreeNode(6); + root.left = new BinaryTreeNode(2); + root.right = new BinaryTreeNode(8); + root.left.left = new BinaryTreeNode(4); + root.left.right = new BinaryTreeNode(1); + root.left.right.left = new BinaryTreeNode(3); + tree = new BinarySearchTree(root); + + Assert.assertFalse(tree.isValid()); + } + @Test + public void testGetNodesBetween(){ + List numbers = this.tree.getNodesBetween(3, 8); + System.out.println(numbers.toString()); + + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeNode.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeNode.java new file mode 100644 index 0000000000..c1421cd398 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeNode.java @@ -0,0 +1,35 @@ +package com.coding.basic.tree; + +public class BinaryTreeNode { + + public T data; + public BinaryTreeNode left; + public BinaryTreeNode right; + + public BinaryTreeNode(T data){ + this.data=data; + } + public T getData() { + return data; + } + public void setData(T data) { + this.data = data; + } + public BinaryTreeNode getLeft() { + return left; + } + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + public BinaryTreeNode getRight() { + return right; + } + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Object o){ + return null; + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeUtil.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeUtil.java new file mode 100644 index 0000000000..b033cbe1d5 --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeUtil.java @@ -0,0 +1,66 @@ +package com.coding.basic.tree; + +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +public class BinaryTreeUtil { + /** + * 用递归的方式实现对二叉树的前序遍历, 需要通过BinaryTreeUtilTest测试 + * + * @param root + * @return + */ + public static List preOrderVisit(BinaryTreeNode root) { + List result = new ArrayList(); + + return result; + } + + /** + * 用递归的方式实现对二叉树的中遍历 + * + * @param root + * @return + */ + public static List inOrderVisit(BinaryTreeNode root) { + List result = new ArrayList(); + + return result; + } + + /** + * 用递归的方式实现对二叉树的后遍历 + * + * @param root + * @return + */ + public static List postOrderVisit(BinaryTreeNode root) { + List result = new ArrayList(); + + return result; + } + /** + * 用非递归的方式实现对二叉树的前序遍历 + * @param root + * @return + */ + public static List preOrderWithoutRecursion(BinaryTreeNode root) { + + List result = new ArrayList(); + + return result; + } + /** + * 用非递归的方式实现对二叉树的中序遍历 + * @param root + * @return + */ + public static List inOrderWithoutRecursion(BinaryTreeNode root) { + + List result = new ArrayList(); + + return result; + } + +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeUtilTest.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeUtilTest.java new file mode 100644 index 0000000000..41857e137d --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/BinaryTreeUtilTest.java @@ -0,0 +1,75 @@ +package com.coding.basic.tree; + +import java.util.List; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + +public class BinaryTreeUtilTest { + + BinaryTreeNode root = null; + @Before + public void setUp() throws Exception { + root = new BinaryTreeNode(1); + root.setLeft(new BinaryTreeNode(2)); + root.setRight(new BinaryTreeNode(5)); + root.getLeft().setLeft(new BinaryTreeNode(3)); + root.getLeft().setRight(new BinaryTreeNode(4)); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testPreOrderVisit() { + + List result = BinaryTreeUtil.preOrderVisit(root); + Assert.assertEquals("[1, 2, 3, 4, 5]", result.toString()); + + + } + @Test + public void testInOrderVisit() { + + + List result = BinaryTreeUtil.inOrderVisit(root); + Assert.assertEquals("[3, 2, 4, 1, 5]", result.toString()); + + } + + @Test + public void testPostOrderVisit() { + + + List result = BinaryTreeUtil.postOrderVisit(root); + Assert.assertEquals("[3, 4, 2, 5, 1]", result.toString()); + + } + + + @Test + public void testInOrderVisitWithoutRecursion() { + BinaryTreeNode node = root.getLeft().getRight(); + node.setLeft(new BinaryTreeNode(6)); + node.setRight(new BinaryTreeNode(7)); + + List result = BinaryTreeUtil.inOrderWithoutRecursion(root); + Assert.assertEquals("[3, 2, 6, 4, 7, 1, 5]", result.toString()); + + } + @Test + public void testPreOrderVisitWithoutRecursion() { + BinaryTreeNode node = root.getLeft().getRight(); + node.setLeft(new BinaryTreeNode(6)); + node.setRight(new BinaryTreeNode(7)); + + List result = BinaryTreeUtil.preOrderWithoutRecursion(root); + Assert.assertEquals("[1, 2, 3, 4, 6, 7, 5]", result.toString()); + + } +} diff --git a/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/FileList.java b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/FileList.java new file mode 100644 index 0000000000..6e65192e4a --- /dev/null +++ b/students/250103158/data-structure/assignment/src/main/java/com/coding/basic/tree/FileList.java @@ -0,0 +1,10 @@ +package com.coding.basic.tree; + +import java.io.File; + +public class FileList { + public void list(File f) { + } + + +} diff --git a/students/250103158/ood/ood-assignment/pom.xml b/students/250103158/ood/ood-assignment/pom.xml new file mode 100644 index 0000000000..cac49a5328 --- /dev/null +++ b/students/250103158/ood/ood-assignment/pom.xml @@ -0,0 +1,32 @@ + + 4.0.0 + + com.coderising + ood-assignment + 0.0.1-SNAPSHOT + jar + + ood-assignment + http://maven.apache.org + + + UTF-8 + + + + + + junit + junit + 4.12 + + + + + + aliyunmaven + http://maven.aliyun.com/nexus/content/groups/public/ + + + diff --git a/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/Configuration.java b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/Configuration.java new file mode 100644 index 0000000000..f328c1816a --- /dev/null +++ b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/Configuration.java @@ -0,0 +1,23 @@ +package com.coderising.ood.srp; +import java.util.HashMap; +import java.util.Map; + +public class Configuration { + + static Map configurations = new HashMap<>(); + static{ + configurations.put(ConfigurationKeys.SMTP_SERVER, "smtp.163.com"); + configurations.put(ConfigurationKeys.ALT_SMTP_SERVER, "smtp1.163.com"); + configurations.put(ConfigurationKeys.EMAIL_ADMIN, "admin@company.com"); + } + /** + * 应该从配置文件读, 但是这里简化为直接从一个map 中去读 + * @param key + * @return + */ + public String getProperty(String key) { + + return configurations.get(key); + } + +} diff --git a/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/ConfigurationKeys.java b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/ConfigurationKeys.java new file mode 100644 index 0000000000..8695aed644 --- /dev/null +++ b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/ConfigurationKeys.java @@ -0,0 +1,9 @@ +package com.coderising.ood.srp; + +public class ConfigurationKeys { + + public static final String SMTP_SERVER = "smtp.server"; + public static final String ALT_SMTP_SERVER = "alt.smtp.server"; + public static final String EMAIL_ADMIN = "email.admin"; + +} diff --git a/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/DBUtil.java b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/DBUtil.java new file mode 100644 index 0000000000..82e9261d18 --- /dev/null +++ b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/DBUtil.java @@ -0,0 +1,25 @@ +package com.coderising.ood.srp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class DBUtil { + + /** + * 应该从数据库读, 但是简化为直接生成。 + * @param sql + * @return + */ + public static List query(String sql){ + + List userList = new ArrayList(); + for (int i = 1; i <= 3; i++) { + HashMap userInfo = new HashMap(); + userInfo.put("NAME", "User" + i); + userInfo.put("EMAIL", "aa@bb.com"); + userList.add(userInfo); + } + + return userList; + } +} diff --git a/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/MailUtil.java b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/MailUtil.java new file mode 100644 index 0000000000..9f9e749af7 --- /dev/null +++ b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/MailUtil.java @@ -0,0 +1,18 @@ +package com.coderising.ood.srp; + +public class MailUtil { + + public static void sendEmail(String toAddress, String fromAddress, String subject, String message, String smtpHost, + boolean debug) { + //假装发了一封邮件 + StringBuilder buffer = new StringBuilder(); + buffer.append("From:").append(fromAddress).append("\n"); + buffer.append("To:").append(toAddress).append("\n"); + buffer.append("Subject:").append(subject).append("\n"); + buffer.append("Content:").append(message).append("\n"); + System.out.println(buffer.toString()); + + } + + +} diff --git a/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/PromotionMail.java b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/PromotionMail.java new file mode 100644 index 0000000000..781587a846 --- /dev/null +++ b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/PromotionMail.java @@ -0,0 +1,199 @@ +package com.coderising.ood.srp; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +public class PromotionMail { + + + protected String sendMailQuery = null; + + + protected String smtpHost = null; + protected String altSmtpHost = null; + protected String fromAddress = null; + protected String toAddress = null; + protected String subject = null; + protected String message = null; + + protected String productID = null; + protected String productDesc = null; + + private static Configuration config; + + + + private static final String NAME_KEY = "NAME"; + private static final String EMAIL_KEY = "EMAIL"; + + + public static void main(String[] args) throws Exception { + + File f = new File("C:\\coderising\\workspace_ds\\ood-example\\src\\product_promotion.txt"); + boolean emailDebug = false; + + PromotionMail pe = new PromotionMail(f, emailDebug); + + } + + + public PromotionMail(File file, boolean mailDebug) throws Exception { + + //读取配置文件, 文件中只有一行用空格隔开, 例如 P8756 iPhone8 + readFile(file); + + + config = new Configuration(); + + setSMTPHost(); + setAltSMTPHost(); + + + setFromAddress(); + + + setLoadQuery(); + + sendEMails(mailDebug, loadMailingList()); + + + } + + + + + protected void setProductID(String productID) + { + this.productID = productID; + + } + + protected String getproductID() + { + return productID; + } + + protected void setLoadQuery() throws Exception { + + sendMailQuery = "Select name from subscriptions " + + "where product_id= '" + productID +"' " + + "and send_mail=1 "; + + + System.out.println("loadQuery set"); + } + + + protected void setSMTPHost() + { + smtpHost = config.getProperty(ConfigurationKeys.SMTP_SERVER); + } + + + protected void setAltSMTPHost() + { + altSmtpHost = config.getProperty(ConfigurationKeys.ALT_SMTP_SERVER); + + } + + + protected void setFromAddress() + { + fromAddress = config.getProperty(ConfigurationKeys.EMAIL_ADMIN); + } + + protected void setMessage(HashMap userInfo) throws IOException + { + + String name = (String) userInfo.get(NAME_KEY); + + subject = "您关注的产品降价了"; + message = "尊敬的 "+name+", 您关注的产品 " + productDesc + " 降价了,欢迎购买!" ; + + + + } + + + protected void readFile(File file) throws IOException // @02C + { + BufferedReader br = null; + try { + br = new BufferedReader(new FileReader(file)); + String temp = br.readLine(); + String[] data = temp.split(" "); + + setProductID(data[0]); + setProductDesc(data[1]); + + System.out.println("产品ID = " + productID + "\n"); + System.out.println("产品描述 = " + productDesc + "\n"); + + } catch (IOException e) { + throw new IOException(e.getMessage()); + } finally { + br.close(); + } + } + + private void setProductDesc(String desc) { + this.productDesc = desc; + } + + + protected void configureEMail(HashMap userInfo) throws IOException + { + toAddress = (String) userInfo.get(EMAIL_KEY); + if (toAddress.length() > 0) + setMessage(userInfo); + } + + protected List loadMailingList() throws Exception { + return DBUtil.query(this.sendMailQuery); + } + + + protected void sendEMails(boolean debug, List mailingList) throws IOException + { + + System.out.println("开始发送邮件"); + + + if (mailingList != null) { + Iterator iter = mailingList.iterator(); + while (iter.hasNext()) { + configureEMail((HashMap) iter.next()); + try + { + if (toAddress.length() > 0) + MailUtil.sendEmail(toAddress, fromAddress, subject, message, smtpHost, debug); + } + catch (Exception e) + { + + try { + MailUtil.sendEmail(toAddress, fromAddress, subject, message, altSmtpHost, debug); + + } catch (Exception e2) + { + System.out.println("通过备用 SMTP服务器发送邮件失败: " + e2.getMessage()); + } + } + } + + + } + + else { + System.out.println("没有邮件发送"); + + } + + } +} diff --git a/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/product_promotion.txt b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/product_promotion.txt new file mode 100644 index 0000000000..0c0124cc61 --- /dev/null +++ b/students/250103158/ood/ood-assignment/src/main/java/com/coderising/ood/srp/product_promotion.txt @@ -0,0 +1,4 @@ +P8756 iPhone8 +P3946 XiaoMi10 +P8904 Oppo_R15 +P4955 Vivo_X20 \ No newline at end of file From 9d5a9944152ba1d60b54e7742567265cd09819af Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sun, 9 Jul 2017 15:33:31 +0800 Subject: [PATCH 02/81] =?UTF-8?q?2017=E5=B9=B47=E6=9C=889=E6=97=A5=2015:33?= =?UTF-8?q?:22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../740707954/src/ood/newSrp/MailSender.java | 73 ------- .../src/ood/newSrp/PromotionMail.java | 32 ---- .../src/ood/newSrp/conf/Configuration.java | 26 --- .../src/ood/newSrp/entity/Email.java | 57 ------ .../src/ood/newSrp/entity/Product.java | 35 ---- .../src/ood/newSrp/product_promotion.txt | 4 - .../ood/newSrp/server/MainSmtpFactory.java | 11 -- .../src/ood/newSrp/server/MainSmtpServer.java | 30 --- .../src/ood/newSrp/server/ProductServer.java | 55 ------ .../src/ood/newSrp/server/SmtpFactory.java | 8 - .../src/ood/newSrp/server/SmtpServer.java | 19 -- .../ood/newSrp/server/TempSmtpFactory.java | 11 -- .../src/ood/newSrp/server/TempSmtpServer.java | 29 --- .../src/ood/newSrp/server/UserServer.java | 19 -- .../740707954/src/ood/newSrp/util/DBUtil.java | 25 --- .../src/ood/oldSrp/Configuration.java | 23 --- .../src/ood/oldSrp/ConfigurationKeys.java | 9 - students/740707954/src/ood/oldSrp/DBUtil.java | 25 --- .../740707954/src/ood/oldSrp/MailUtil.java | 18 -- .../src/ood/oldSrp/PromotionMail.java | 180 ------------------ .../src/ood/oldSrp/product_promotion.txt | 4 - 21 files changed, 693 deletions(-) delete mode 100644 students/740707954/src/ood/newSrp/MailSender.java delete mode 100644 students/740707954/src/ood/newSrp/PromotionMail.java delete mode 100644 students/740707954/src/ood/newSrp/conf/Configuration.java delete mode 100644 students/740707954/src/ood/newSrp/entity/Email.java delete mode 100644 students/740707954/src/ood/newSrp/entity/Product.java delete mode 100644 students/740707954/src/ood/newSrp/product_promotion.txt delete mode 100644 students/740707954/src/ood/newSrp/server/MainSmtpFactory.java delete mode 100644 students/740707954/src/ood/newSrp/server/MainSmtpServer.java delete mode 100644 students/740707954/src/ood/newSrp/server/ProductServer.java delete mode 100644 students/740707954/src/ood/newSrp/server/SmtpFactory.java delete mode 100644 students/740707954/src/ood/newSrp/server/SmtpServer.java delete mode 100644 students/740707954/src/ood/newSrp/server/TempSmtpFactory.java delete mode 100644 students/740707954/src/ood/newSrp/server/TempSmtpServer.java delete mode 100644 students/740707954/src/ood/newSrp/server/UserServer.java delete mode 100644 students/740707954/src/ood/newSrp/util/DBUtil.java delete mode 100644 students/740707954/src/ood/oldSrp/Configuration.java delete mode 100644 students/740707954/src/ood/oldSrp/ConfigurationKeys.java delete mode 100644 students/740707954/src/ood/oldSrp/DBUtil.java delete mode 100644 students/740707954/src/ood/oldSrp/MailUtil.java delete mode 100644 students/740707954/src/ood/oldSrp/PromotionMail.java delete mode 100644 students/740707954/src/ood/oldSrp/product_promotion.txt diff --git a/students/740707954/src/ood/newSrp/MailSender.java b/students/740707954/src/ood/newSrp/MailSender.java deleted file mode 100644 index 14604b2c14..0000000000 --- a/students/740707954/src/ood/newSrp/MailSender.java +++ /dev/null @@ -1,73 +0,0 @@ -package ood.newSrp; - -import ood.newSrp.entity.Email; -import ood.newSrp.entity.Product; -import ood.newSrp.server.MainSmtpFactory; -import ood.newSrp.server.SmtpServer; -import ood.newSrp.server.TempSmtpFactory; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -/** - * 邮件发送器 - * Created by lx on 2017/6/17. - */ -public class MailSender { - - protected SmtpServer mainServer = new MainSmtpFactory().createSmtp(); - protected SmtpServer tempServer = new TempSmtpFactory().createSmtp(); - public static final String NAME_KEY = "NAME"; - - /** - * 批量发送邮件 - * @param p 产品信息 - * @param sendUserList 用户信息 - * @param d - * @throws IOException - */ - public void batchSendEMail(Product p, List sendUserList, boolean d) throws IOException { - System.out.println("--------开始发送邮件-------"); - if (null == sendUserList || sendUserList.size() == 0) { - System.out.println("没有邮件发送"); - return; - } - - for (Map userInfo : sendUserList) { - Email email = new Email(); - String toAddr = userInfo.get("EMAIL").toString(); - email.setToAddress(toAddr); - email.setFromAddress(mainServer.address); - email.setSubject("您关注的产品降价了"); - email.setMessage("尊敬的 " + userInfo.get(NAME_KEY).toString() + ", 您关注的产品 " + p.getProductDesc() + " 降价了,欢迎购买!"); - try { - sendEmail(email, d); - } catch (Exception e) { - try { - email.setFromAddress(tempServer.address); - sendEmail(email, d); - } catch (Exception e2) { - System.out.println("通过备用 SMTP服务器发送邮件失败: " + e2.getMessage()); - } - } - } - - } - - /** - * 发送邮件 - * @param n - * @param debug - */ - public static void sendEmail(Email n, boolean debug) { - //假装发了一封邮件 - StringBuilder buffer = new StringBuilder(); - buffer.append("From:").append(n.getFromAddress()).append("\n"); - buffer.append("To:").append(n.getToAddress()).append("\n"); - buffer.append("Subject:").append(n.getSubject()).append("\n"); - buffer.append("Content:").append(n.getMessage()).append("\n"); - System.out.println(buffer.toString()); - - } -} diff --git a/students/740707954/src/ood/newSrp/PromotionMail.java b/students/740707954/src/ood/newSrp/PromotionMail.java deleted file mode 100644 index 74cb9741da..0000000000 --- a/students/740707954/src/ood/newSrp/PromotionMail.java +++ /dev/null @@ -1,32 +0,0 @@ -package ood.newSrp; - -import ood.newSrp.entity.Product; -import ood.newSrp.server.UserServer; -import ood.newSrp.server.ProductServer; - -import java.util.List; -import java.util.Map; - -/** - * promotion 提升 - */ -public class PromotionMail { - // 用户信息 - private static UserServer ms = new UserServer(); - // 邮件发送器 - private static MailSender mSend = new MailSender(); - - public static void main(String[] args) throws Exception { - // 获取产品信息 - List pList = ProductServer.getUserProduct(); - - for (Product p : pList) { - System.out.println("产品ID: " + p.getProductId() + "\n" + "产品描述:" + p.getProductDesc()); - // 获取接收产品用户列表 - List sendUserList = ms.querySendUser(p.getProductId()); - // 发送邮件 - mSend.batchSendEMail(p, sendUserList, false); - } - - } -} diff --git a/students/740707954/src/ood/newSrp/conf/Configuration.java b/students/740707954/src/ood/newSrp/conf/Configuration.java deleted file mode 100644 index 37bf3f3a58..0000000000 --- a/students/740707954/src/ood/newSrp/conf/Configuration.java +++ /dev/null @@ -1,26 +0,0 @@ -package ood.newSrp.conf; - -import ood.oldSrp.ConfigurationKeys; -import java.util.HashMap; -import java.util.Map; - -public class Configuration { - - static Map configurations = new HashMap<>(); - - static{ - configurations.put(ConfigurationKeys.SMTP_SERVER, "smtp.163.com"); - configurations.put(ConfigurationKeys.ALT_SMTP_SERVER, "smtp1.163.com"); - configurations.put(ConfigurationKeys.EMAIL_ADMIN, "admin@company.com"); - } - - /** - * 应该从配置文件读, 但是这里简化为直接从一个map 中去读 - * @param key - * @return - */ - public static String getProperty(String key) { - return configurations.get(key); - } - -} diff --git a/students/740707954/src/ood/newSrp/entity/Email.java b/students/740707954/src/ood/newSrp/entity/Email.java deleted file mode 100644 index 17159b916b..0000000000 --- a/students/740707954/src/ood/newSrp/entity/Email.java +++ /dev/null @@ -1,57 +0,0 @@ -package ood.newSrp.entity; - -/** - * 邮件 - * Created by Administrator on 2017/6/15 0015. - */ -public class Email { - private String subject; - private String message; - private String toAddress; - private String fromAddress; - private String smtpHost; - - public Email() { - - } - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getToAddress() { - return toAddress; - } - - public void setToAddress(String toAddress) { - this.toAddress = toAddress; - } - - public String getFromAddress() { - return fromAddress; - } - - public void setFromAddress(String fromAddress) { - this.fromAddress = fromAddress; - } - - public String getSmtpHost() { - return smtpHost; - } - - public void setSmtpHost(String smtpHost) { - this.smtpHost = smtpHost; - } -} diff --git a/students/740707954/src/ood/newSrp/entity/Product.java b/students/740707954/src/ood/newSrp/entity/Product.java deleted file mode 100644 index 4fc38aacb4..0000000000 --- a/students/740707954/src/ood/newSrp/entity/Product.java +++ /dev/null @@ -1,35 +0,0 @@ -package ood.newSrp.entity; - -/** - * 产品信息 - * Created by Administrator on 2017/6/15 0015. - */ -public class Product { - private String productId = null; - private String productDesc = null; - - public Product() { - - } - - public Product(String productId, String productDesc) { - this.productId = productId; - this.productDesc = productDesc; - } - - public void setProductId(String productId) { - this.productId = productId; - } - - public String getProductId() { - return productId; - } - - public String getProductDesc() { - return productDesc; - } - - public void setProductDesc(String productDesc) { - this.productDesc = productDesc; - } -} diff --git a/students/740707954/src/ood/newSrp/product_promotion.txt b/students/740707954/src/ood/newSrp/product_promotion.txt deleted file mode 100644 index b7a974adb3..0000000000 --- a/students/740707954/src/ood/newSrp/product_promotion.txt +++ /dev/null @@ -1,4 +0,0 @@ -P8756 iPhone8 -P3946 XiaoMi10 -P8904 Oppo_R15 -P4955 Vivo_X20 \ No newline at end of file diff --git a/students/740707954/src/ood/newSrp/server/MainSmtpFactory.java b/students/740707954/src/ood/newSrp/server/MainSmtpFactory.java deleted file mode 100644 index 5dcfdc5a5b..0000000000 --- a/students/740707954/src/ood/newSrp/server/MainSmtpFactory.java +++ /dev/null @@ -1,11 +0,0 @@ -package ood.newSrp.server; - -/** - * Created by lx on 2017/6/17. - */ -public class MainSmtpFactory implements SmtpFactory { - @Override - public SmtpServer createSmtp() { - return new MainSmtpServer(); - } -} diff --git a/students/740707954/src/ood/newSrp/server/MainSmtpServer.java b/students/740707954/src/ood/newSrp/server/MainSmtpServer.java deleted file mode 100644 index 6e9be0a9ab..0000000000 --- a/students/740707954/src/ood/newSrp/server/MainSmtpServer.java +++ /dev/null @@ -1,30 +0,0 @@ -package ood.newSrp.server; - -import ood.newSrp.conf.Configuration; -import ood.oldSrp.ConfigurationKeys; - -/** - * 主要服务器 - * Created by Administrator on 2017/6/15 0015. - */ -public class MainSmtpServer extends SmtpServer { - - public MainSmtpServer() { - address = Configuration.getProperty(ConfigurationKeys.EMAIL_ADMIN); - host = Configuration.getProperty(ConfigurationKeys.SMTP_SERVER); - } - - /** - * 设置服务器地址 - */ - public void setServerAddr() { - address = Configuration.getProperty(ConfigurationKeys.EMAIL_ADMIN); - } - - /** - * 设置服务器host - */ - public void setServerHost() { - host = Configuration.getProperty(ConfigurationKeys.SMTP_SERVER); - } -} diff --git a/students/740707954/src/ood/newSrp/server/ProductServer.java b/students/740707954/src/ood/newSrp/server/ProductServer.java deleted file mode 100644 index db8efa8bc3..0000000000 --- a/students/740707954/src/ood/newSrp/server/ProductServer.java +++ /dev/null @@ -1,55 +0,0 @@ -package ood.newSrp.server; - -import ood.newSrp.entity.Product; -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - *产品服务 - * Created by lx on 2017/6/17. - */ -public class ProductServer { - private static List pList = new ArrayList<>(); - static { - try { - initSpecialProductList(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * 生成优惠产品信息 - * @return - * @throws IOException - */ - private static void initSpecialProductList() throws IOException { - String filePath = System.getProperty("user.dir") + "/src/ood/oldSrp/product_promotion.txt"; - BufferedReader br = null; - try { - br = new BufferedReader(new FileReader(filePath)); - String pInfo; - while ((pInfo = br.readLine()) != null) { - String[] data = pInfo.split(" "); - pList.add(new Product(data[0], data[1])); - } - } catch (IOException e) { - throw new IOException( "读取文件内容失败 " + e.getMessage()); - } finally { - if (br != null) { - br.close(); - } - } - } - - /** - * 获取用户的产品 - * @return - */ - public static List getUserProduct() { - return pList; - } -} diff --git a/students/740707954/src/ood/newSrp/server/SmtpFactory.java b/students/740707954/src/ood/newSrp/server/SmtpFactory.java deleted file mode 100644 index efdf3ec25b..0000000000 --- a/students/740707954/src/ood/newSrp/server/SmtpFactory.java +++ /dev/null @@ -1,8 +0,0 @@ -package ood.newSrp.server; - -/** - * Created by lx on 2017/6/17. - */ -public interface SmtpFactory { - public SmtpServer createSmtp(); -} \ No newline at end of file diff --git a/students/740707954/src/ood/newSrp/server/SmtpServer.java b/students/740707954/src/ood/newSrp/server/SmtpServer.java deleted file mode 100644 index ff35288d1f..0000000000 --- a/students/740707954/src/ood/newSrp/server/SmtpServer.java +++ /dev/null @@ -1,19 +0,0 @@ -package ood.newSrp.server; - -/** - * Created by Administrator on 2017/6/15 0015. - */ -public abstract class SmtpServer { - public String address = ""; - public String host = ""; - - /** - * 设置服务器地址 - */ - abstract void setServerAddr(); - - /** - * 设置服务器host - */ - abstract void setServerHost(); -} diff --git a/students/740707954/src/ood/newSrp/server/TempSmtpFactory.java b/students/740707954/src/ood/newSrp/server/TempSmtpFactory.java deleted file mode 100644 index ae16252fd0..0000000000 --- a/students/740707954/src/ood/newSrp/server/TempSmtpFactory.java +++ /dev/null @@ -1,11 +0,0 @@ -package ood.newSrp.server; - -/** - * Created by lx on 2017/6/17. - */ -public class TempSmtpFactory implements SmtpFactory { - @Override - public SmtpServer createSmtp() { - return new TempSmtpServer(); - } -} diff --git a/students/740707954/src/ood/newSrp/server/TempSmtpServer.java b/students/740707954/src/ood/newSrp/server/TempSmtpServer.java deleted file mode 100644 index 417cd8acd0..0000000000 --- a/students/740707954/src/ood/newSrp/server/TempSmtpServer.java +++ /dev/null @@ -1,29 +0,0 @@ -package ood.newSrp.server; - -import ood.newSrp.conf.Configuration; -import ood.oldSrp.ConfigurationKeys; - -/** - * 备用服务器 - * Created by Administrator on 2017/6/15 0015. - */ -public class TempSmtpServer extends SmtpServer { - - public TempSmtpServer() { - address = Configuration.getProperty(ConfigurationKeys.EMAIL_ADMIN); - host = Configuration.getProperty(ConfigurationKeys.ALT_SMTP_SERVER); - } - /** - * 设置服务器地址 - */ - public void setServerAddr() { - address = Configuration.getProperty(ConfigurationKeys.EMAIL_ADMIN); - } - - /** - * 设置服务器host - */ - public void setServerHost() { - host = Configuration.getProperty(ConfigurationKeys.ALT_SMTP_SERVER); - } -} diff --git a/students/740707954/src/ood/newSrp/server/UserServer.java b/students/740707954/src/ood/newSrp/server/UserServer.java deleted file mode 100644 index 0c9864eab7..0000000000 --- a/students/740707954/src/ood/newSrp/server/UserServer.java +++ /dev/null @@ -1,19 +0,0 @@ -package ood.newSrp.server; - -import ood.newSrp.util.DBUtil; -import java.util.List; -import java.util.Map; - -/** - * Created by lx on 2017/6/17. - */ -public class UserServer { - - /** - * 查询发送人 - * @return - */ - public List querySendUser(String productId){ - return DBUtil.query("Select name from subscriptions where product_id= '" + productId + "' and send_mail=1 "); - } -} diff --git a/students/740707954/src/ood/newSrp/util/DBUtil.java b/students/740707954/src/ood/newSrp/util/DBUtil.java deleted file mode 100644 index c1866fd925..0000000000 --- a/students/740707954/src/ood/newSrp/util/DBUtil.java +++ /dev/null @@ -1,25 +0,0 @@ -package ood.newSrp.util; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class DBUtil { - - /** - * 应该从数据库读, 但是简化为直接生成。 - * @param sql - * @return - */ - public static List query(String sql){ - - List userList = new ArrayList(); - for (int i = 1; i <= 3; i++) { - HashMap userInfo = new HashMap(); - userInfo.put("NAME", "User" + i); - userInfo.put("EMAIL", "aa@bb.com"); - userList.add(userInfo); - } - - return userList; - } -} diff --git a/students/740707954/src/ood/oldSrp/Configuration.java b/students/740707954/src/ood/oldSrp/Configuration.java deleted file mode 100644 index 9a1a4d075c..0000000000 --- a/students/740707954/src/ood/oldSrp/Configuration.java +++ /dev/null @@ -1,23 +0,0 @@ -package ood.oldSrp; -import java.util.HashMap; -import java.util.Map; - -public class Configuration { - - static Map configurations = new HashMap<>(); - static{ - configurations.put(ConfigurationKeys.SMTP_SERVER, "smtp.163.com"); - configurations.put(ConfigurationKeys.ALT_SMTP_SERVER, "smtp1.163.com"); - configurations.put(ConfigurationKeys.EMAIL_ADMIN, "admin@company.com"); - } - /** - * 应该从配置文件读, 但是这里简化为直接从一个map 中去读 - * @param key - * @return - */ - public String getProperty(String key) { - - return configurations.get(key); - } - -} diff --git a/students/740707954/src/ood/oldSrp/ConfigurationKeys.java b/students/740707954/src/ood/oldSrp/ConfigurationKeys.java deleted file mode 100644 index 154ea2c77c..0000000000 --- a/students/740707954/src/ood/oldSrp/ConfigurationKeys.java +++ /dev/null @@ -1,9 +0,0 @@ -package ood.oldSrp; - -public class ConfigurationKeys { - - public static final String SMTP_SERVER = "smtp.server"; - public static final String ALT_SMTP_SERVER = "alt.smtp.server"; - public static final String EMAIL_ADMIN = "email.admin"; - -} diff --git a/students/740707954/src/ood/oldSrp/DBUtil.java b/students/740707954/src/ood/oldSrp/DBUtil.java deleted file mode 100644 index 2397e15ad1..0000000000 --- a/students/740707954/src/ood/oldSrp/DBUtil.java +++ /dev/null @@ -1,25 +0,0 @@ -package ood.oldSrp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class DBUtil { - - /** - * 应该从数据库读, 但是简化为直接生成。 - * @param sql - * @return - */ - public static List query(String sql){ - - List userList = new ArrayList(); - for (int i = 1; i <= 3; i++) { - HashMap userInfo = new HashMap(); - userInfo.put("NAME", "User" + i); - userInfo.put("EMAIL", "aa@bb.com"); - userList.add(userInfo); - } - - return userList; - } -} diff --git a/students/740707954/src/ood/oldSrp/MailUtil.java b/students/740707954/src/ood/oldSrp/MailUtil.java deleted file mode 100644 index 71c229b37d..0000000000 --- a/students/740707954/src/ood/oldSrp/MailUtil.java +++ /dev/null @@ -1,18 +0,0 @@ -package ood.oldSrp; - -public class MailUtil { - - public static void sendEmail(String toAddress, String fromAddress, String subject, String message, String smtpHost, - boolean debug) { - //假装发了一封邮件 - StringBuilder buffer = new StringBuilder(); - buffer.append("From:").append(fromAddress).append("\n"); - buffer.append("To:").append(toAddress).append("\n"); - buffer.append("Subject:").append(subject).append("\n"); - buffer.append("Content:").append(message).append("\n"); - System.out.println(buffer.toString()); - - } - - -} diff --git a/students/740707954/src/ood/oldSrp/PromotionMail.java b/students/740707954/src/ood/oldSrp/PromotionMail.java deleted file mode 100644 index 2edbd5bf46..0000000000 --- a/students/740707954/src/ood/oldSrp/PromotionMail.java +++ /dev/null @@ -1,180 +0,0 @@ -package ood.oldSrp; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -public class PromotionMail { - - - protected String sendMailQuery = null; - - - protected String smtpHost = null; - protected String altSmtpHost = null; - protected String fromAddress = null; - protected String toAddress = null; - protected String subject = null; - protected String message = null; - - protected String productID = null; - protected String productDesc = null; - - private static Configuration config; - - - private static final String NAME_KEY = "NAME"; - private static final String EMAIL_KEY = "EMAIL"; - - - public static void main(String[] args) throws Exception { - - File f = new File(System.getProperty("user.dir") + "/src/ood/oldSrp/product_promotion.txt"); - boolean emailDebug = false; - - PromotionMail pe = new PromotionMail(f, emailDebug); - - } - - - public PromotionMail(File file, boolean mailDebug) throws Exception { - - //读取配置文件, 文件中只有一行用空格隔开, 例如 P8756 iPhone8 - readFile(file); - - - config = new Configuration(); - - setSMTPHost(); - setAltSMTPHost(); - - - setFromAddress(); - - - setLoadQuery(); - - sendEMails(mailDebug, loadMailingList()); - - - } - - - protected void setProductID(String productID) { - this.productID = productID; - - } - - protected String getproductID() { - return productID; - } - - protected void setLoadQuery() throws Exception { - - sendMailQuery = "Select name from subscriptions " - + "where product_id= '" + productID + "' " - + "and send_mail=1 "; - - - System.out.println("loadQuery set"); - } - - - protected void setSMTPHost() { - smtpHost = config.getProperty(ConfigurationKeys.SMTP_SERVER); - } - - - protected void setAltSMTPHost() { - altSmtpHost = config.getProperty(ConfigurationKeys.ALT_SMTP_SERVER); - - } - - - protected void setFromAddress() { - fromAddress = config.getProperty(ConfigurationKeys.EMAIL_ADMIN); - } - - protected void setMessage(HashMap userInfo) throws IOException { - - String name = (String) userInfo.get(NAME_KEY); - - subject = "您关注的产品降价了"; - message = "尊敬的 " + name + ", 您关注的产品 " + productDesc + " 降价了,欢迎购买!"; - - - } - - - protected void readFile(File file) throws IOException // @02C - { - BufferedReader br = null; - try { - br = new BufferedReader(new FileReader(file)); - String temp = br.readLine(); - String[] data = temp.split(" "); - - setProductID(data[0]); - setProductDesc(data[1]); - - System.out.println("产品ID = " + productID + "\n"); - System.out.println("产品描述 = " + productDesc + "\n"); - - } catch (IOException e) { - throw new IOException(e.getMessage()); - } finally { - br.close(); - } - } - - private void setProductDesc(String desc) { - this.productDesc = desc; - } - - - protected void configureEMail(HashMap userInfo) throws IOException { - toAddress = (String) userInfo.get(EMAIL_KEY); - if (toAddress.length() > 0) - setMessage(userInfo); - } - - protected List loadMailingList() throws Exception { - return DBUtil.query(this.sendMailQuery); - } - - - protected void sendEMails(boolean debug, List mailingList) throws IOException { - - System.out.println("开始发送邮件"); - - - if (mailingList != null) { - Iterator iter = mailingList.iterator(); - while (iter.hasNext()) { - configureEMail((HashMap) iter.next()); - try { - if (toAddress.length() > 0) - MailUtil.sendEmail(toAddress, fromAddress, subject, message, smtpHost, debug); - } catch (Exception e) { - - try { - MailUtil.sendEmail(toAddress, fromAddress, subject, message, altSmtpHost, debug); - - } catch (Exception e2) { - System.out.println("通过备用 SMTP服务器发送邮件失败: " + e2.getMessage()); - } - } - } - - - } else { - System.out.println("没有邮件发送"); - - } - - } -} diff --git a/students/740707954/src/ood/oldSrp/product_promotion.txt b/students/740707954/src/ood/oldSrp/product_promotion.txt deleted file mode 100644 index b7a974adb3..0000000000 --- a/students/740707954/src/ood/oldSrp/product_promotion.txt +++ /dev/null @@ -1,4 +0,0 @@ -P8756 iPhone8 -P3946 XiaoMi10 -P8904 Oppo_R15 -P4955 Vivo_X20 \ No newline at end of file From fc4528948efa80357d647cd1ca32dc7a4070eee5 Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 15 Jul 2017 10:16:39 +0800 Subject: [PATCH 03/81] 20170715 --- students/740707954/740707954.iml | 214 +++++++++++++++++ students/740707954/code/code.iml | 217 ++++++++++++++++++ students/740707954/code/pom.xml | 21 ++ .../code/src/main/webapp/WEB-INF/web.xml | 7 + .../740707954/code/src/main/webapp/index.jsp | 5 + 5 files changed, 464 insertions(+) create mode 100644 students/740707954/740707954.iml create mode 100644 students/740707954/code/code.iml create mode 100644 students/740707954/code/pom.xml create mode 100644 students/740707954/code/src/main/webapp/WEB-INF/web.xml create mode 100644 students/740707954/code/src/main/webapp/index.jsp diff --git a/students/740707954/740707954.iml b/students/740707954/740707954.iml new file mode 100644 index 0000000000..70dcb0034d --- /dev/null +++ b/students/740707954/740707954.iml @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/students/740707954/code/code.iml b/students/740707954/code/code.iml new file mode 100644 index 0000000000..618afa2ab2 --- /dev/null +++ b/students/740707954/code/code.iml @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/students/740707954/code/pom.xml b/students/740707954/code/pom.xml new file mode 100644 index 0000000000..7ed87ba94b --- /dev/null +++ b/students/740707954/code/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + 740707954 + 740707954 + war + 1.0-SNAPSHOT + 740707954 Maven Webapp + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + + 740707954 + + diff --git a/students/740707954/code/src/main/webapp/WEB-INF/web.xml b/students/740707954/code/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..9f88c1f963 --- /dev/null +++ b/students/740707954/code/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ + + + + Archetype Created Web Application + diff --git a/students/740707954/code/src/main/webapp/index.jsp b/students/740707954/code/src/main/webapp/index.jsp new file mode 100644 index 0000000000..c38169bb95 --- /dev/null +++ b/students/740707954/code/src/main/webapp/index.jsp @@ -0,0 +1,5 @@ + + +

Hello World!

+ + From 8aff298d5d2d3280568d59a3832256b15b1d8045 Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 15 Jul 2017 10:24:56 +0800 Subject: [PATCH 04/81] =?UTF-8?q?2017=E5=B9=B47=E6=9C=8815=E6=97=A5=2010:2?= =?UTF-8?q?4:52?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- students/740707954/740707954.iml | 214 ------------------------------- students/740707954/code/code.iml | 12 ++ 2 files changed, 12 insertions(+), 214 deletions(-) delete mode 100644 students/740707954/740707954.iml diff --git a/students/740707954/740707954.iml b/students/740707954/740707954.iml deleted file mode 100644 index 70dcb0034d..0000000000 --- a/students/740707954/740707954.iml +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/students/740707954/code/code.iml b/students/740707954/code/code.iml index 618afa2ab2..777f244f53 100644 --- a/students/740707954/code/code.iml +++ b/students/740707954/code/code.iml @@ -1,5 +1,17 @@ + + + + + + + + + + + + From 868e836737cf3479ad7cf802a3de0325909d6502 Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 15 Jul 2017 12:43:23 +0800 Subject: [PATCH 05/81] =?UTF-8?q?=E8=A7=A3=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解锁 --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index fa9bcb8820..a4f6f3d915 100644 --- a/.gitignore +++ b/.gitignore @@ -291,7 +291,6 @@ students/406400373/* students/549739951/* students/582161208/* students/592146505/* -students/740707954/* students/844620174/* students/87049319/* students/183549495/* From 7dc43e65ee8fc01d644e9b1ed5dad9415e685cb9 Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 15 Jul 2017 12:44:46 +0800 Subject: [PATCH 06/81] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改结构目录 --- students/740707954/code/code.iml | 229 ------------------ students/740707954/code/pom.xml | 21 -- .../code/src/main/webapp/WEB-INF/web.xml | 7 - .../740707954/code/src/main/webapp/index.jsp | 5 - 4 files changed, 262 deletions(-) delete mode 100644 students/740707954/code/code.iml delete mode 100644 students/740707954/code/pom.xml delete mode 100644 students/740707954/code/src/main/webapp/WEB-INF/web.xml delete mode 100644 students/740707954/code/src/main/webapp/index.jsp diff --git a/students/740707954/code/code.iml b/students/740707954/code/code.iml deleted file mode 100644 index 777f244f53..0000000000 --- a/students/740707954/code/code.iml +++ /dev/null @@ -1,229 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/students/740707954/code/pom.xml b/students/740707954/code/pom.xml deleted file mode 100644 index 7ed87ba94b..0000000000 --- a/students/740707954/code/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - 4.0.0 - 740707954 - 740707954 - war - 1.0-SNAPSHOT - 740707954 Maven Webapp - http://maven.apache.org - - - junit - junit - 3.8.1 - test - - - - 740707954 - - diff --git a/students/740707954/code/src/main/webapp/WEB-INF/web.xml b/students/740707954/code/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 9f88c1f963..0000000000 --- a/students/740707954/code/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - Archetype Created Web Application - diff --git a/students/740707954/code/src/main/webapp/index.jsp b/students/740707954/code/src/main/webapp/index.jsp deleted file mode 100644 index c38169bb95..0000000000 --- a/students/740707954/code/src/main/webapp/index.jsp +++ /dev/null @@ -1,5 +0,0 @@ - - -

Hello World!

- - From e976ae32574869f7d1636139367d087f9da234a4 Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 15 Jul 2017 12:50:48 +0800 Subject: [PATCH 07/81] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BAmaven=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改为maven项目 --- students/740707954/pom.xml | 25 ++++++++++++ students/740707954/readMe | 2 - .../src/main/java/740707954/App.java | 13 +++++++ .../src/test/java/740707954/AppTest.java | 38 +++++++++++++++++++ 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 students/740707954/pom.xml delete mode 100644 students/740707954/readMe create mode 100644 students/740707954/src/main/java/740707954/App.java create mode 100644 students/740707954/src/test/java/740707954/AppTest.java diff --git a/students/740707954/pom.xml b/students/740707954/pom.xml new file mode 100644 index 0000000000..3c385fa294 --- /dev/null +++ b/students/740707954/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + 740707954 + 740707954 + 1.0-SNAPSHOT + jar + + 740707954 + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/students/740707954/readMe b/students/740707954/readMe deleted file mode 100644 index f831579269..0000000000 --- a/students/740707954/readMe +++ /dev/null @@ -1,2 +0,0 @@ -TEST1 -2017.06.17 \ No newline at end of file diff --git a/students/740707954/src/main/java/740707954/App.java b/students/740707954/src/main/java/740707954/App.java new file mode 100644 index 0000000000..11a9e6c3df --- /dev/null +++ b/students/740707954/src/main/java/740707954/App.java @@ -0,0 +1,13 @@ +package 740707954; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/students/740707954/src/test/java/740707954/AppTest.java b/students/740707954/src/test/java/740707954/AppTest.java new file mode 100644 index 0000000000..17c3a5e1bc --- /dev/null +++ b/students/740707954/src/test/java/740707954/AppTest.java @@ -0,0 +1,38 @@ +package 740707954; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} From e4d6ff460d5068b303b77c5c973fc98656bd56b7 Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 15 Jul 2017 12:52:27 +0800 Subject: [PATCH 08/81] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 提交 --- .../src/main/java/740707954/App.java | 13 ------- .../src/test/java/740707954/AppTest.java | 38 ------------------- 2 files changed, 51 deletions(-) delete mode 100644 students/740707954/src/main/java/740707954/App.java delete mode 100644 students/740707954/src/test/java/740707954/AppTest.java diff --git a/students/740707954/src/main/java/740707954/App.java b/students/740707954/src/main/java/740707954/App.java deleted file mode 100644 index 11a9e6c3df..0000000000 --- a/students/740707954/src/main/java/740707954/App.java +++ /dev/null @@ -1,13 +0,0 @@ -package 740707954; - -/** - * Hello world! - * - */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); - } -} diff --git a/students/740707954/src/test/java/740707954/AppTest.java b/students/740707954/src/test/java/740707954/AppTest.java deleted file mode 100644 index 17c3a5e1bc..0000000000 --- a/students/740707954/src/test/java/740707954/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package 740707954; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} From 63b24012d3a6235d28ba16b241b286435642f5c4 Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 15 Jul 2017 13:01:26 +0800 Subject: [PATCH 09/81] =?UTF-8?q?2017=E5=B9=B47=E6=9C=8815=E6=97=A5=2013:0?= =?UTF-8?q?1:19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ood/srp1/ConfigurationKeys.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 students/740707954/src/main/java/ood/srp1/ConfigurationKeys.java diff --git a/students/740707954/src/main/java/ood/srp1/ConfigurationKeys.java b/students/740707954/src/main/java/ood/srp1/ConfigurationKeys.java new file mode 100644 index 0000000000..65f5e77dc4 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/ConfigurationKeys.java @@ -0,0 +1,9 @@ +package ood.srp1; + +public class ConfigurationKeys { + + public static final String SMTP_SERVER = "smtp.server"; + public static final String ALT_SMTP_SERVER = "alt.smtp.server"; + public static final String EMAIL_ADMIN = "email.admin"; + +} From dfca1942a780535ede48f86f552c7891e79720dc Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 15 Jul 2017 13:02:34 +0800 Subject: [PATCH 10/81] =?UTF-8?q?2017=E5=B9=B47=E6=9C=8815=E6=97=A5=2013:0?= =?UTF-8?q?1:19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ood/srp1/MailSender.java | 73 +++++++++++++++++++ .../src/main/java/ood/srp1/PromotionMail.java | 32 ++++++++ .../java/ood/srp1/conf/Configuration.java | 27 +++++++ .../src/main/java/ood/srp1/entity/Email.java | 57 +++++++++++++++ .../main/java/ood/srp1/entity/Product.java | 35 +++++++++ .../main/java/ood/srp1/product_promotion.txt | 4 + .../java/ood/srp1/server/MainSmtpFactory.java | 11 +++ .../java/ood/srp1/server/MainSmtpServer.java | 30 ++++++++ .../java/ood/srp1/server/ProductServer.java | 55 ++++++++++++++ .../java/ood/srp1/server/SmtpFactory.java | 8 ++ .../main/java/ood/srp1/server/SmtpServer.java | 19 +++++ .../java/ood/srp1/server/TempSmtpFactory.java | 11 +++ .../java/ood/srp1/server/TempSmtpServer.java | 29 ++++++++ .../main/java/ood/srp1/server/UserServer.java | 19 +++++ .../src/main/java/ood/srp1/util/DBUtil.java | 25 +++++++ 15 files changed, 435 insertions(+) create mode 100644 students/740707954/src/main/java/ood/srp1/MailSender.java create mode 100644 students/740707954/src/main/java/ood/srp1/PromotionMail.java create mode 100644 students/740707954/src/main/java/ood/srp1/conf/Configuration.java create mode 100644 students/740707954/src/main/java/ood/srp1/entity/Email.java create mode 100644 students/740707954/src/main/java/ood/srp1/entity/Product.java create mode 100644 students/740707954/src/main/java/ood/srp1/product_promotion.txt create mode 100644 students/740707954/src/main/java/ood/srp1/server/MainSmtpFactory.java create mode 100644 students/740707954/src/main/java/ood/srp1/server/MainSmtpServer.java create mode 100644 students/740707954/src/main/java/ood/srp1/server/ProductServer.java create mode 100644 students/740707954/src/main/java/ood/srp1/server/SmtpFactory.java create mode 100644 students/740707954/src/main/java/ood/srp1/server/SmtpServer.java create mode 100644 students/740707954/src/main/java/ood/srp1/server/TempSmtpFactory.java create mode 100644 students/740707954/src/main/java/ood/srp1/server/TempSmtpServer.java create mode 100644 students/740707954/src/main/java/ood/srp1/server/UserServer.java create mode 100644 students/740707954/src/main/java/ood/srp1/util/DBUtil.java diff --git a/students/740707954/src/main/java/ood/srp1/MailSender.java b/students/740707954/src/main/java/ood/srp1/MailSender.java new file mode 100644 index 0000000000..410c9ab27f --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/MailSender.java @@ -0,0 +1,73 @@ +package ood.srp1; + +import ood.srp1.entity.Email; +import ood.srp1.entity.Product; +import ood.srp1.server.MainSmtpFactory; +import ood.srp1.server.SmtpServer; +import ood.srp1.server.TempSmtpFactory; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * 邮件发送器 + * Created by lx on 2017/6/17. + */ +public class MailSender { + + protected SmtpServer mainServer = new MainSmtpFactory().createSmtp(); + protected SmtpServer tempServer = new TempSmtpFactory().createSmtp(); + public static final String NAME_KEY = "NAME"; + + /** + * 批量发送邮件 + * @param p 产品信息 + * @param sendUserList 用户信息 + * @param d + * @throws java.io.IOException + */ + public void batchSendEMail(Product p, List sendUserList, boolean d) throws IOException { + System.out.println("--------开始发送邮件-------"); + if (null == sendUserList || sendUserList.size() == 0) { + System.out.println("没有邮件发送"); + return; + } + + for (Map userInfo : sendUserList) { + Email email = new Email(); + String toAddr = userInfo.get("EMAIL").toString(); + email.setToAddress(toAddr); + email.setFromAddress(mainServer.address); + email.setSubject("您关注的产品降价了"); + email.setMessage("尊敬的 " + userInfo.get(NAME_KEY).toString() + ", 您关注的产品 " + p.getProductDesc() + " 降价了,欢迎购买!"); + try { + sendEmail(email, d); + } catch (Exception e) { + try { + email.setFromAddress(tempServer.address); + sendEmail(email, d); + } catch (Exception e2) { + System.out.println("通过备用 SMTP服务器发送邮件失败: " + e2.getMessage()); + } + } + } + + } + + /** + * 发送邮件 + * @param n + * @param debug + */ + public static void sendEmail(Email n, boolean debug) { + //假装发了一封邮件 + StringBuilder buffer = new StringBuilder(); + buffer.append("From:").append(n.getFromAddress()).append("\n"); + buffer.append("To:").append(n.getToAddress()).append("\n"); + buffer.append("Subject:").append(n.getSubject()).append("\n"); + buffer.append("Content:").append(n.getMessage()).append("\n"); + System.out.println(buffer.toString()); + + } +} diff --git a/students/740707954/src/main/java/ood/srp1/PromotionMail.java b/students/740707954/src/main/java/ood/srp1/PromotionMail.java new file mode 100644 index 0000000000..865ae00896 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/PromotionMail.java @@ -0,0 +1,32 @@ +package ood.srp1; + +import ood.srp1.entity.Product; +import ood.srp1.server.UserServer; +import ood.srp1.server.ProductServer; + +import java.util.List; +import java.util.Map; + +/** + * promotion 提升 + */ +public class PromotionMail { + // 用户信息 + private static UserServer ms = new UserServer(); + // 邮件发送器 + private static MailSender mSend = new MailSender(); + + public static void main(String[] args) throws Exception { + // 获取产品信息 + List pList = ProductServer.getUserProduct(); + + for (Product p : pList) { + System.out.println("产品ID: " + p.getProductId() + "\n" + "产品描述:" + p.getProductDesc()); + // 获取接收产品用户列表 + List sendUserList = ms.querySendUser(p.getProductId()); + // 发送邮件 + mSend.batchSendEMail(p, sendUserList, false); + } + + } +} diff --git a/students/740707954/src/main/java/ood/srp1/conf/Configuration.java b/students/740707954/src/main/java/ood/srp1/conf/Configuration.java new file mode 100644 index 0000000000..d1fa32b6bf --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/conf/Configuration.java @@ -0,0 +1,27 @@ +package ood.srp1.conf; + +import ood.srp1.ConfigurationKeys; + +import java.util.HashMap; +import java.util.Map; + +public class Configuration { + + static Map configurations = new HashMap<>(); + + static{ + configurations.put(ConfigurationKeys.SMTP_SERVER, "smtp.163.com"); + configurations.put(ConfigurationKeys.ALT_SMTP_SERVER, "smtp1.163.com"); + configurations.put(ConfigurationKeys.EMAIL_ADMIN, "admin@company.com"); + } + + /** + * 应该从配置文件读, 但是这里简化为直接从一个map 中去读 + * @param key + * @return + */ + public static String getProperty(String key) { + return configurations.get(key); + } + +} diff --git a/students/740707954/src/main/java/ood/srp1/entity/Email.java b/students/740707954/src/main/java/ood/srp1/entity/Email.java new file mode 100644 index 0000000000..57103bb760 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/entity/Email.java @@ -0,0 +1,57 @@ +package ood.srp1.entity; + +/** + * 邮件 + * Created by Administrator on 2017/6/15 0015. + */ +public class Email { + private String subject; + private String message; + private String toAddress; + private String fromAddress; + private String smtpHost; + + public Email() { + + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getToAddress() { + return toAddress; + } + + public void setToAddress(String toAddress) { + this.toAddress = toAddress; + } + + public String getFromAddress() { + return fromAddress; + } + + public void setFromAddress(String fromAddress) { + this.fromAddress = fromAddress; + } + + public String getSmtpHost() { + return smtpHost; + } + + public void setSmtpHost(String smtpHost) { + this.smtpHost = smtpHost; + } +} diff --git a/students/740707954/src/main/java/ood/srp1/entity/Product.java b/students/740707954/src/main/java/ood/srp1/entity/Product.java new file mode 100644 index 0000000000..0eed36cb74 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/entity/Product.java @@ -0,0 +1,35 @@ +package ood.srp1.entity; + +/** + * 产品信息 + * Created by Administrator on 2017/6/15 0015. + */ +public class Product { + private String productId = null; + private String productDesc = null; + + public Product() { + + } + + public Product(String productId, String productDesc) { + this.productId = productId; + this.productDesc = productDesc; + } + + public void setProductId(String productId) { + this.productId = productId; + } + + public String getProductId() { + return productId; + } + + public String getProductDesc() { + return productDesc; + } + + public void setProductDesc(String productDesc) { + this.productDesc = productDesc; + } +} diff --git a/students/740707954/src/main/java/ood/srp1/product_promotion.txt b/students/740707954/src/main/java/ood/srp1/product_promotion.txt new file mode 100644 index 0000000000..b7a974adb3 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/product_promotion.txt @@ -0,0 +1,4 @@ +P8756 iPhone8 +P3946 XiaoMi10 +P8904 Oppo_R15 +P4955 Vivo_X20 \ No newline at end of file diff --git a/students/740707954/src/main/java/ood/srp1/server/MainSmtpFactory.java b/students/740707954/src/main/java/ood/srp1/server/MainSmtpFactory.java new file mode 100644 index 0000000000..644ef5988e --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/server/MainSmtpFactory.java @@ -0,0 +1,11 @@ +package ood.srp1.server; + +/** + * Created by lx on 2017/6/17. + */ +public class MainSmtpFactory implements SmtpFactory { + @Override + public SmtpServer createSmtp() { + return new MainSmtpServer(); + } +} diff --git a/students/740707954/src/main/java/ood/srp1/server/MainSmtpServer.java b/students/740707954/src/main/java/ood/srp1/server/MainSmtpServer.java new file mode 100644 index 0000000000..127d0fbef9 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/server/MainSmtpServer.java @@ -0,0 +1,30 @@ +package ood.srp1.server; + +import ood.srp1.ConfigurationKeys; +import ood.srp1.conf.Configuration; + +/** + * 主要服务器 + * Created by Administrator on 2017/6/15 0015. + */ +public class MainSmtpServer extends SmtpServer { + + public MainSmtpServer() { + address = Configuration.getProperty(ConfigurationKeys.EMAIL_ADMIN); + host = Configuration.getProperty(ConfigurationKeys.SMTP_SERVER); + } + + /** + * 设置服务器地址 + */ + public void setServerAddr() { + address = Configuration.getProperty(ConfigurationKeys.EMAIL_ADMIN); + } + + /** + * 设置服务器host + */ + public void setServerHost() { + host = Configuration.getProperty(ConfigurationKeys.SMTP_SERVER); + } +} diff --git a/students/740707954/src/main/java/ood/srp1/server/ProductServer.java b/students/740707954/src/main/java/ood/srp1/server/ProductServer.java new file mode 100644 index 0000000000..3078468128 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/server/ProductServer.java @@ -0,0 +1,55 @@ +package ood.srp1.server; + +import ood.srp1.entity.Product; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + *产品服务 + * Created by lx on 2017/6/17. + */ +public class ProductServer { + private static List pList = new ArrayList<>(); + static { + try { + initSpecialProductList(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * 生成优惠产品信息 + * @return + * @throws java.io.IOException + */ + private static void initSpecialProductList() throws IOException { + String filePath = System.getProperty("user.dir") + "/src/ood/oldSrp/product_promotion.txt"; + BufferedReader br = null; + try { + br = new BufferedReader(new FileReader(filePath)); + String pInfo; + while ((pInfo = br.readLine()) != null) { + String[] data = pInfo.split(" "); + pList.add(new Product(data[0], data[1])); + } + } catch (IOException e) { + throw new IOException( "读取文件内容失败 " + e.getMessage()); + } finally { + if (br != null) { + br.close(); + } + } + } + + /** + * 获取用户的产品 + * @return + */ + public static List getUserProduct() { + return pList; + } +} diff --git a/students/740707954/src/main/java/ood/srp1/server/SmtpFactory.java b/students/740707954/src/main/java/ood/srp1/server/SmtpFactory.java new file mode 100644 index 0000000000..07606ca9c2 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/server/SmtpFactory.java @@ -0,0 +1,8 @@ +package ood.srp1.server; + +/** + * Created by lx on 2017/6/17. + */ +public interface SmtpFactory { + public SmtpServer createSmtp(); +} \ No newline at end of file diff --git a/students/740707954/src/main/java/ood/srp1/server/SmtpServer.java b/students/740707954/src/main/java/ood/srp1/server/SmtpServer.java new file mode 100644 index 0000000000..7bc254ede3 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/server/SmtpServer.java @@ -0,0 +1,19 @@ +package ood.srp1.server; + +/** + * Created by Administrator on 2017/6/15 0015. + */ +public abstract class SmtpServer { + public String address = ""; + public String host = ""; + + /** + * 设置服务器地址 + */ + abstract void setServerAddr(); + + /** + * 设置服务器host + */ + abstract void setServerHost(); +} diff --git a/students/740707954/src/main/java/ood/srp1/server/TempSmtpFactory.java b/students/740707954/src/main/java/ood/srp1/server/TempSmtpFactory.java new file mode 100644 index 0000000000..1360c42c84 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/server/TempSmtpFactory.java @@ -0,0 +1,11 @@ +package ood.srp1.server; + +/** + * Created by lx on 2017/6/17. + */ +public class TempSmtpFactory implements SmtpFactory { + @Override + public SmtpServer createSmtp() { + return new TempSmtpServer(); + } +} diff --git a/students/740707954/src/main/java/ood/srp1/server/TempSmtpServer.java b/students/740707954/src/main/java/ood/srp1/server/TempSmtpServer.java new file mode 100644 index 0000000000..9c2ffebac1 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/server/TempSmtpServer.java @@ -0,0 +1,29 @@ +package ood.srp1.server; + +import ood.srp1.ConfigurationKeys; +import ood.srp1.conf.Configuration; + +/** + * 备用服务器 + * Created by Administrator on 2017/6/15 0015. + */ +public class TempSmtpServer extends SmtpServer { + + public TempSmtpServer() { + address = Configuration.getProperty(ConfigurationKeys.EMAIL_ADMIN); + host = Configuration.getProperty(ConfigurationKeys.ALT_SMTP_SERVER); + } + /** + * 设置服务器地址 + */ + public void setServerAddr() { + address = Configuration.getProperty(ConfigurationKeys.EMAIL_ADMIN); + } + + /** + * 设置服务器host + */ + public void setServerHost() { + host = Configuration.getProperty(ConfigurationKeys.ALT_SMTP_SERVER); + } +} diff --git a/students/740707954/src/main/java/ood/srp1/server/UserServer.java b/students/740707954/src/main/java/ood/srp1/server/UserServer.java new file mode 100644 index 0000000000..952aca1d60 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/server/UserServer.java @@ -0,0 +1,19 @@ +package ood.srp1.server; + +import ood.srp1.util.DBUtil; +import java.util.List; +import java.util.Map; + +/** + * Created by lx on 2017/6/17. + */ +public class UserServer { + + /** + * 查询发送人 + * @return + */ + public List querySendUser(String productId){ + return DBUtil.query("Select name from subscriptions where product_id= '" + productId + "' and send_mail=1 "); + } +} diff --git a/students/740707954/src/main/java/ood/srp1/util/DBUtil.java b/students/740707954/src/main/java/ood/srp1/util/DBUtil.java new file mode 100644 index 0000000000..715051d3c0 --- /dev/null +++ b/students/740707954/src/main/java/ood/srp1/util/DBUtil.java @@ -0,0 +1,25 @@ +package ood.srp1.util; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class DBUtil { + + /** + * 应该从数据库读, 但是简化为直接生成。 + * @param sql + * @return + */ + public static List query(String sql){ + + List userList = new ArrayList(); + for (int i = 1; i <= 3; i++) { + HashMap userInfo = new HashMap(); + userInfo.put("NAME", "User" + i); + userInfo.put("EMAIL", "aa@bb.com"); + userList.add(userInfo); + } + + return userList; + } +} From c70aaf7577eec3bd9524a0f714c24aeac58b9fad Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 15 Jul 2017 13:04:09 +0800 Subject: [PATCH 11/81] =?UTF-8?q?2017=E5=B9=B47=E6=9C=8815=E6=97=A5=2013:0?= =?UTF-8?q?1:19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../740707954/src/main/java/ood/srp1/server/ProductServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/students/740707954/src/main/java/ood/srp1/server/ProductServer.java b/students/740707954/src/main/java/ood/srp1/server/ProductServer.java index 3078468128..94dbea20e4 100644 --- a/students/740707954/src/main/java/ood/srp1/server/ProductServer.java +++ b/students/740707954/src/main/java/ood/srp1/server/ProductServer.java @@ -27,7 +27,7 @@ public class ProductServer { * @throws java.io.IOException */ private static void initSpecialProductList() throws IOException { - String filePath = System.getProperty("user.dir") + "/src/ood/oldSrp/product_promotion.txt"; + String filePath = System.getProperty("user.dir") + "/src/main/java/ood/srp1/product_promotion.txt"; BufferedReader br = null; try { br = new BufferedReader(new FileReader(filePath)); From ede72d47263cd8afda79aea6c13afdf08874ecf7 Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 15 Jul 2017 13:09:13 +0800 Subject: [PATCH 12/81] =?UTF-8?q?2017=E5=B9=B47=E6=9C=8815=E6=97=A5=2013:0?= =?UTF-8?q?1:19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/payroll/Employee.java | 72 +++++++++++++++++ .../src/main/java/payroll/PayCheck.java | 40 ++++++++++ .../src/main/java/payroll/PaySystem.java | 30 +++++++ .../src/main/java/payroll/TimeCard.java | 19 +++++ .../java/payroll/affiliation/Affiliation.java | 17 ++++ .../payroll/affiliation/NonAffiliation.java | 14 ++++ .../payroll/affiliation/ServiceCharge.java | 28 +++++++ .../payroll/affiliation/UnionAffiliation.java | 40 ++++++++++ .../classify/CommissionClassification.java | 36 +++++++++ .../classify/HourlyClassification.java | 50 ++++++++++++ .../classify/PaymentClassification.java | 11 +++ .../classify/SalariedClassification.java | 21 +++++ .../java/payroll/classify/SalesReceipt.java | 28 +++++++ .../main/java/payroll/classify/TimeCard.java | 28 +++++++ .../main/java/payroll/method/BankMethod.java | 14 ++++ .../main/java/payroll/method/HoldMethod.java | 14 ++++ .../main/java/payroll/method/MailMethod.java | 14 ++++ .../java/payroll/method/PaymentMethod.java | 11 +++ .../payroll/schedule/BiWeeklySchedule.java | 35 ++++++++ .../java/payroll/schedule/MonthSchedule.java | 31 +++++++ .../payroll/schedule/PaymentSchedule.java | 11 +++ .../java/payroll/schedule/WeeklySchedule.java | 32 ++++++++ .../java/payroll/service/IPayrollService.java | 14 ++++ .../payroll/service/PayrollServiceImpl.java | 31 +++++++ .../src/main/java/payroll/util/DateUtil.java | 80 +++++++++++++++++++ .../java/payroll/\351\234\200\346\261\202" | 16 ++++ students/740707954/src/test/java/test | 1 + 27 files changed, 738 insertions(+) create mode 100644 students/740707954/src/main/java/payroll/Employee.java create mode 100644 students/740707954/src/main/java/payroll/PayCheck.java create mode 100644 students/740707954/src/main/java/payroll/PaySystem.java create mode 100644 students/740707954/src/main/java/payroll/TimeCard.java create mode 100644 students/740707954/src/main/java/payroll/affiliation/Affiliation.java create mode 100644 students/740707954/src/main/java/payroll/affiliation/NonAffiliation.java create mode 100644 students/740707954/src/main/java/payroll/affiliation/ServiceCharge.java create mode 100644 students/740707954/src/main/java/payroll/affiliation/UnionAffiliation.java create mode 100644 students/740707954/src/main/java/payroll/classify/CommissionClassification.java create mode 100644 students/740707954/src/main/java/payroll/classify/HourlyClassification.java create mode 100644 students/740707954/src/main/java/payroll/classify/PaymentClassification.java create mode 100644 students/740707954/src/main/java/payroll/classify/SalariedClassification.java create mode 100644 students/740707954/src/main/java/payroll/classify/SalesReceipt.java create mode 100644 students/740707954/src/main/java/payroll/classify/TimeCard.java create mode 100644 students/740707954/src/main/java/payroll/method/BankMethod.java create mode 100644 students/740707954/src/main/java/payroll/method/HoldMethod.java create mode 100644 students/740707954/src/main/java/payroll/method/MailMethod.java create mode 100644 students/740707954/src/main/java/payroll/method/PaymentMethod.java create mode 100644 students/740707954/src/main/java/payroll/schedule/BiWeeklySchedule.java create mode 100644 students/740707954/src/main/java/payroll/schedule/MonthSchedule.java create mode 100644 students/740707954/src/main/java/payroll/schedule/PaymentSchedule.java create mode 100644 students/740707954/src/main/java/payroll/schedule/WeeklySchedule.java create mode 100644 students/740707954/src/main/java/payroll/service/IPayrollService.java create mode 100644 students/740707954/src/main/java/payroll/service/PayrollServiceImpl.java create mode 100644 students/740707954/src/main/java/payroll/util/DateUtil.java create mode 100644 "students/740707954/src/main/java/payroll/\351\234\200\346\261\202" create mode 100644 students/740707954/src/test/java/test diff --git a/students/740707954/src/main/java/payroll/Employee.java b/students/740707954/src/main/java/payroll/Employee.java new file mode 100644 index 0000000000..65ac530d81 --- /dev/null +++ b/students/740707954/src/main/java/payroll/Employee.java @@ -0,0 +1,72 @@ +package payroll; + +import payroll.affiliation.Affiliation; +import payroll.classify.PaymentClassification; +import payroll.method.PaymentMethod; +import payroll.schedule.PaymentSchedule; + +import java.util.Date; + +/** + * 员工 + * Created by lx on 2017/7/8. + */ +public class Employee { + private String id; + private String name; + private String address; + private Affiliation affiliation; + + private PaymentClassification classification; + private PaymentSchedule schedule; + private PaymentMethod paymentMethod; + + public Employee(String name, String address) { + this.name = name; + this.address = address; + } + + /** + * 计算员工薪水 + * @param pc + */ + public void calculatePay(PayCheck pc) { + double grossPay = classification.calculdatePay(pc); + double deductions = affiliation.calculateDeductions(pc); + double netPay = grossPay - deductions; + pc.setGrossPay(grossPay); + pc.setDeductions(deductions); + pc.setNetPay(netPay); + paymentMethod.pay(pc); + } + + /** + * 是否为支付日 + * @param d + * @return + */ + public boolean isPayDay(Date d) { + return schedule.isPayDate(d); + } + + /** + * 获取支付的起始时间 + * @param d + * @return + */ + public Date getPayPeriodStartDate(Date d) { + return schedule.getPayPeriodStartDate(d); + } + + public void setClassifcation(PaymentClassification classifcation) { + this.classification = classifcation; + } + + public void setSchedule(PaymentSchedule schedule) { + this.schedule = schedule; + } + + public void setPaymentMethod(PaymentMethod paymentMethod) { + this.paymentMethod = paymentMethod; + } +} diff --git a/students/740707954/src/main/java/payroll/PayCheck.java b/students/740707954/src/main/java/payroll/PayCheck.java new file mode 100644 index 0000000000..b469890593 --- /dev/null +++ b/students/740707954/src/main/java/payroll/PayCheck.java @@ -0,0 +1,40 @@ +package payroll; + +import java.util.Date; + +/** + * 可以检查是否重复执行 + * Created by lx on 2017/7/8. + */ +public class PayCheck { + private Date payPeriodStart; + private Date payPeriodEnd; + private double grossPay;// 应付 + private double netPay;// 实付 + private double deductions;// 扣除 + + public PayCheck(Date payPeriodStart, Date payPeriodEnd) { + this.payPeriodStart = payPeriodStart; + this.payPeriodEnd = payPeriodEnd; + } + + public Date getPayPeriodEnd() { + return payPeriodEnd; + } + + public Date getPayPeriodStart() { + return payPeriodStart; + } + + public void setGrossPay(double grossPay) { + this.grossPay = grossPay; + } + + public void setNetPay(double netPay) { + this.netPay = netPay; + } + + public void setDeductions(double deductions) { + this.deductions = deductions; + } +} diff --git a/students/740707954/src/main/java/payroll/PaySystem.java b/students/740707954/src/main/java/payroll/PaySystem.java new file mode 100644 index 0000000000..ac81d79d22 --- /dev/null +++ b/students/740707954/src/main/java/payroll/PaySystem.java @@ -0,0 +1,30 @@ +package payroll; + +import payroll.service.IPayrollService; +import payroll.service.PayrollServiceImpl; +import java.util.Date; +import java.util.List; + +/** + * 薪水支付系统 + * Created by lx on 2017/7/8. + */ +public class PaySystem { + private static IPayrollService payrollService; + + static { + payrollService = new PayrollServiceImpl(); + } + + public static void main(String[] args) { + Date date = new Date(); + List employees = payrollService.getAllEmployees(); + for (Employee e : employees) { + if (e.isPayDay(date)) { + PayCheck pc = new PayCheck(e.getPayPeriodStartDate(date), date); + e.calculatePay(pc); + payrollService.savePaycheck(pc); + } + } + } +} diff --git a/students/740707954/src/main/java/payroll/TimeCard.java b/students/740707954/src/main/java/payroll/TimeCard.java new file mode 100644 index 0000000000..db41ff2da3 --- /dev/null +++ b/students/740707954/src/main/java/payroll/TimeCard.java @@ -0,0 +1,19 @@ +package payroll; + +import java.util.Date; + +/** + * Created by lx on 2017/7/8. + */ +public class TimeCard { + private Date date; + private int hours; + + public Date getDate(){ + return date; + } + + public int getHours() { + return hours; + } +} diff --git a/students/740707954/src/main/java/payroll/affiliation/Affiliation.java b/students/740707954/src/main/java/payroll/affiliation/Affiliation.java new file mode 100644 index 0000000000..15b2a4b41b --- /dev/null +++ b/students/740707954/src/main/java/payroll/affiliation/Affiliation.java @@ -0,0 +1,17 @@ +package payroll.affiliation; + +import payroll.PayCheck; + +/** + * Affiliation 会员 + * Created by lx on 2017/7/8. + */ +public interface Affiliation { + + /** + * 计算服务费 + * @param pc + * @return + */ + double calculateDeductions(PayCheck pc); +} diff --git a/students/740707954/src/main/java/payroll/affiliation/NonAffiliation.java b/students/740707954/src/main/java/payroll/affiliation/NonAffiliation.java new file mode 100644 index 0000000000..0bd2232001 --- /dev/null +++ b/students/740707954/src/main/java/payroll/affiliation/NonAffiliation.java @@ -0,0 +1,14 @@ +package payroll.affiliation; + +import payroll.PayCheck; + +/** + * 非会员 + * Created by lx on 2017/7/8. + */ +public class NonAffiliation implements Affiliation { + @Override + public double calculateDeductions(PayCheck pc) { + return 0; + } +} diff --git a/students/740707954/src/main/java/payroll/affiliation/ServiceCharge.java b/students/740707954/src/main/java/payroll/affiliation/ServiceCharge.java new file mode 100644 index 0000000000..7d89f17e27 --- /dev/null +++ b/students/740707954/src/main/java/payroll/affiliation/ServiceCharge.java @@ -0,0 +1,28 @@ +package payroll.affiliation; + +import java.util.Date; + +/** + * 服务费用 + * Created by lx on 2017/7/8. + */ +public class ServiceCharge { + private Date date; + private double amount; + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public double getAmount() { + return amount; + } + + public void setAmount(double amount) { + this.amount = amount; + } +} diff --git a/students/740707954/src/main/java/payroll/affiliation/UnionAffiliation.java b/students/740707954/src/main/java/payroll/affiliation/UnionAffiliation.java new file mode 100644 index 0000000000..44f482dda8 --- /dev/null +++ b/students/740707954/src/main/java/payroll/affiliation/UnionAffiliation.java @@ -0,0 +1,40 @@ +package payroll.affiliation; + +import payroll.PayCheck; +import payroll.util.DateUtil; +import java.util.Date; +import java.util.Map; + +/** + * 会员 + * Created by lx on 2017/7/8. + */ +public class UnionAffiliation implements Affiliation { + private int memeberId = 0; + private double weekDue = 0; + private Map charege; + + /** + * 计算服务费用 + * @param pc + * @return + */ + @Override + public double calculateDeductions(PayCheck pc) { + int fridays = DateUtil.getFridaysBetween(pc.getPayPeriodStart(), pc.getPayPeriodEnd()); + double totalDue = fridays * weekDue; + double totalCharge = 0.0d; + for (Map.Entry entry : charege.entrySet()) { + ServiceCharge sc = entry.getValue(); + totalCharge += sc.getAmount(); +// calculateCharge(sc); + } + return totalCharge + totalDue; + } + +// private double calculateCharge(ServiceCharge sc) { +// return sc.getAmount(); +// } + + +} diff --git a/students/740707954/src/main/java/payroll/classify/CommissionClassification.java b/students/740707954/src/main/java/payroll/classify/CommissionClassification.java new file mode 100644 index 0000000000..6fa1705c03 --- /dev/null +++ b/students/740707954/src/main/java/payroll/classify/CommissionClassification.java @@ -0,0 +1,36 @@ +package payroll.classify; + +import payroll.PayCheck; +import payroll.util.DateUtil; + +import java.util.Date; +import java.util.Map; + +/** + * 佣金雇员 + * Created by lx on 2017/7/8. + */ +public class CommissionClassification implements PaymentClassification { + private Map salesReceipt;// 销售凭条 + private double salary;//薪水 + private double rate;//单价 + + /** + * 计算薪水 + * @param pc + * @return + */ + @Override + public double calculdatePay(PayCheck pc) { + //1 统计销售凭条在pc.getStartDate 和 pc.getEndDate之间 + //2 加上基本工资,计算薪水 + double commission = 0.0d; + for (Map.Entry entry : salesReceipt.entrySet()) { + SalesReceipt receipt = entry.getValue(); + if (DateUtil.between(receipt.getDate(), pc.getPayPeriodStart(), pc.getPayPeriodEnd())) { + commission = receipt.getAmount() * rate; + } + } + return commission + salary; + } +} diff --git a/students/740707954/src/main/java/payroll/classify/HourlyClassification.java b/students/740707954/src/main/java/payroll/classify/HourlyClassification.java new file mode 100644 index 0000000000..30e4f5c59f --- /dev/null +++ b/students/740707954/src/main/java/payroll/classify/HourlyClassification.java @@ -0,0 +1,50 @@ +package payroll.classify; + +import payroll.PayCheck; +import payroll.util.DateUtil; + +import java.util.Date; +import java.util.Map; + +/** + * 小时工 + * Created by lx on 2017/7/8. + */ +public class HourlyClassification implements PaymentClassification { + private Map timeCards; + private double rate;// 价格 + + /** + * 统计时间卡在pc.getStartDate 和 pc.getEndDate之间 + * 并计算薪水 + * + * @param pc + * @return + */ + @Override + public double calculdatePay(PayCheck pc) { + double totalPay = 0.0d; + for (Map.Entry entry : timeCards.entrySet()) { + TimeCard tc = entry.getValue(); + if (DateUtil.between(tc.getDate(), pc.getPayPeriodStart(), pc.getPayPeriodEnd())) { + totalPay += calculatePayForTimeCard(tc); + } + } + return totalPay; + } + + /** + * 计算每个时间卡的薪水 + * + * @param tc + * @return + */ + public double calculatePayForTimeCard(TimeCard tc) { + int hours = tc.getHours(); + if (tc.getHours() > 8) { + return 8 * rate + (hours - 8) * 1.5 * rate; + } else { + return 8 * rate; + } + } +} diff --git a/students/740707954/src/main/java/payroll/classify/PaymentClassification.java b/students/740707954/src/main/java/payroll/classify/PaymentClassification.java new file mode 100644 index 0000000000..6cb2dafeee --- /dev/null +++ b/students/740707954/src/main/java/payroll/classify/PaymentClassification.java @@ -0,0 +1,11 @@ +package payroll.classify; + +import payroll.PayCheck; + +/** + * 分类 + * Created by lx on 2017/7/8. + */ +public interface PaymentClassification { + public double calculdatePay(PayCheck pc); +} diff --git a/students/740707954/src/main/java/payroll/classify/SalariedClassification.java b/students/740707954/src/main/java/payroll/classify/SalariedClassification.java new file mode 100644 index 0000000000..863d42e381 --- /dev/null +++ b/students/740707954/src/main/java/payroll/classify/SalariedClassification.java @@ -0,0 +1,21 @@ +package payroll.classify; + +import payroll.PayCheck; + +/** + * 月薪雇员 + * Created by lx on 2017/7/8. + */ +public class SalariedClassification implements PaymentClassification { + private double salary; + + /** + * 计算支付 + * @param pc + * @return + */ + @Override + public double calculdatePay(PayCheck pc) { + return salary; + } +} diff --git a/students/740707954/src/main/java/payroll/classify/SalesReceipt.java b/students/740707954/src/main/java/payroll/classify/SalesReceipt.java new file mode 100644 index 0000000000..2eae0fe092 --- /dev/null +++ b/students/740707954/src/main/java/payroll/classify/SalesReceipt.java @@ -0,0 +1,28 @@ +package payroll.classify; + +import java.util.Date; + +/** + * 销售凭条 + * Created by lx on 2017/7/8. + */ +public class SalesReceipt { + private Date date; + private double amount; + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public double getAmount() { + return amount; + } + + public void setAmount(double amount) { + this.amount = amount; + } +} diff --git a/students/740707954/src/main/java/payroll/classify/TimeCard.java b/students/740707954/src/main/java/payroll/classify/TimeCard.java new file mode 100644 index 0000000000..86b760083f --- /dev/null +++ b/students/740707954/src/main/java/payroll/classify/TimeCard.java @@ -0,0 +1,28 @@ +package payroll.classify; + +import java.util.Date; + +/** + * 时间卡 + * Created by lx on 2017/7/8. + */ +public class TimeCard { + private int hours;// 上班时间 + private Date date;// 那天上班 + + public int getHours() { + return hours; + } + + public void setHours(int hours) { + this.hours = hours; + } + + public void setDate(Date date) { + this.date = date; + } + + public Date getDate() { + return date; + } +} diff --git a/students/740707954/src/main/java/payroll/method/BankMethod.java b/students/740707954/src/main/java/payroll/method/BankMethod.java new file mode 100644 index 0000000000..4009040157 --- /dev/null +++ b/students/740707954/src/main/java/payroll/method/BankMethod.java @@ -0,0 +1,14 @@ +package payroll.method; + +import payroll.PayCheck; + +/** + * 银行卡支付 + * Created by lx on 2017/7/8. + */ +public class BankMethod implements PaymentMethod { + @Override + public void pay(PayCheck pc) { + + } +} diff --git a/students/740707954/src/main/java/payroll/method/HoldMethod.java b/students/740707954/src/main/java/payroll/method/HoldMethod.java new file mode 100644 index 0000000000..2261593191 --- /dev/null +++ b/students/740707954/src/main/java/payroll/method/HoldMethod.java @@ -0,0 +1,14 @@ +package payroll.method; + +import payroll.PayCheck; + +/** + * 从财务那里支付 + * Created by lx on 2017/7/8. + */ +public class HoldMethod implements PaymentMethod { + @Override + public void pay(PayCheck pc) { + + } +} diff --git a/students/740707954/src/main/java/payroll/method/MailMethod.java b/students/740707954/src/main/java/payroll/method/MailMethod.java new file mode 100644 index 0000000000..41ae0ff02e --- /dev/null +++ b/students/740707954/src/main/java/payroll/method/MailMethod.java @@ -0,0 +1,14 @@ +package payroll.method; + +import payroll.PayCheck; + +/** + * 邮递支付 + * Created by lx on 2017/7/8. + */ +public class MailMethod implements PaymentMethod{ + @Override + public void pay(PayCheck pc) { + + } +} diff --git a/students/740707954/src/main/java/payroll/method/PaymentMethod.java b/students/740707954/src/main/java/payroll/method/PaymentMethod.java new file mode 100644 index 0000000000..23ca7f954a --- /dev/null +++ b/students/740707954/src/main/java/payroll/method/PaymentMethod.java @@ -0,0 +1,11 @@ +package payroll.method; + +import payroll.PayCheck; + +/** + * 支付方式 + * Created by lx on 2017/7/8. + */ +public interface PaymentMethod { + public void pay(PayCheck pc); +} diff --git a/students/740707954/src/main/java/payroll/schedule/BiWeeklySchedule.java b/students/740707954/src/main/java/payroll/schedule/BiWeeklySchedule.java new file mode 100644 index 0000000000..6bb0dd22f6 --- /dev/null +++ b/students/740707954/src/main/java/payroll/schedule/BiWeeklySchedule.java @@ -0,0 +1,35 @@ +package payroll.schedule; + +import payroll.util.DateUtil; + +import java.util.Date; + +/** + * 每隔一周支付 + * Created by lx on 2017/7/8. + */ +public class BiWeeklySchedule implements PaymentSchedule { + Date firstPayFriday = DateUtil.parse("2017-07-07"); + + /** + * 是否为支付日 + * @param date + * @return + */ + @Override + public boolean isPayDate(Date date) { +// return DateUtil.add(date, -13) == firstPayFriday; + int interval = DateUtil.getDaysBetween(firstPayFriday, date); + return interval % 14 == 0; + } + + /** + * 获取支付薪水日期的起始时间 + * @param payPeriodEndDate + * @return + */ + @Override + public Date getPayPeriodStartDate(Date payPeriodEndDate) { + return DateUtil.add(payPeriodEndDate, -13); + } +} diff --git a/students/740707954/src/main/java/payroll/schedule/MonthSchedule.java b/students/740707954/src/main/java/payroll/schedule/MonthSchedule.java new file mode 100644 index 0000000000..b229cb7e2f --- /dev/null +++ b/students/740707954/src/main/java/payroll/schedule/MonthSchedule.java @@ -0,0 +1,31 @@ +package payroll.schedule; + +import payroll.util.DateUtil; + +import java.util.Date; + +/** + * 每月月底支付 + * Created by lx on 2017/7/8. + */ +public class MonthSchedule implements PaymentSchedule { + /** + * 是否为支付日 + * @param date + * @return + */ + @Override + public boolean isPayDate(Date date) { + return DateUtil.isLastDayOfMonth(date); + } + + /** + * 获取支付薪水日期的起始时间 + * @param payPeriodEndDate + * @return + */ + @Override + public Date getPayPeriodStartDate(Date payPeriodEndDate) { + return DateUtil.getFirstDayOfMonth(payPeriodEndDate); + } +} diff --git a/students/740707954/src/main/java/payroll/schedule/PaymentSchedule.java b/students/740707954/src/main/java/payroll/schedule/PaymentSchedule.java new file mode 100644 index 0000000000..f7445d2d3d --- /dev/null +++ b/students/740707954/src/main/java/payroll/schedule/PaymentSchedule.java @@ -0,0 +1,11 @@ +package payroll.schedule; + +import java.util.Date; + +/** + * Created by lx on 2017/7/8. + */ +public interface PaymentSchedule { + public boolean isPayDate(Date date); + public Date getPayPeriodStartDate(Date payPeriodEndDate); +} diff --git a/students/740707954/src/main/java/payroll/schedule/WeeklySchedule.java b/students/740707954/src/main/java/payroll/schedule/WeeklySchedule.java new file mode 100644 index 0000000000..8bf4fed61a --- /dev/null +++ b/students/740707954/src/main/java/payroll/schedule/WeeklySchedule.java @@ -0,0 +1,32 @@ +package payroll.schedule; + +import payroll.util.DateUtil; + +import java.util.Date; + +/** + * 每周五支付 + * Created by lx on 2017/7/8. + */ +public class WeeklySchedule implements PaymentSchedule{ + + /** + * 是否为支付日 + * @param date + * @return + */ + @Override + public boolean isPayDate(Date date) { + return DateUtil.isFriday(date); + } + + /** + * 获取支付薪水日期的起始时间 + * @param payPeriodEndDate + * @return + */ + @Override + public Date getPayPeriodStartDate(Date payPeriodEndDate) { + return DateUtil.add(payPeriodEndDate, -6); + } +} diff --git a/students/740707954/src/main/java/payroll/service/IPayrollService.java b/students/740707954/src/main/java/payroll/service/IPayrollService.java new file mode 100644 index 0000000000..ea0bf8f78f --- /dev/null +++ b/students/740707954/src/main/java/payroll/service/IPayrollService.java @@ -0,0 +1,14 @@ +package payroll.service; + +import payroll.Employee; +import payroll.PayCheck; +import java.util.List; + +/** + * Created by lx on 2017/7/8. + */ +public interface IPayrollService { + List getAllEmployees(); + + boolean savePaycheck(PayCheck pc); +} diff --git a/students/740707954/src/main/java/payroll/service/PayrollServiceImpl.java b/students/740707954/src/main/java/payroll/service/PayrollServiceImpl.java new file mode 100644 index 0000000000..1df829008d --- /dev/null +++ b/students/740707954/src/main/java/payroll/service/PayrollServiceImpl.java @@ -0,0 +1,31 @@ +package payroll.service; + +import payroll.Employee; +import payroll.PayCheck; +import java.util.List; + +/** + * Created by lx on 2017/7/8. + */ +public class PayrollServiceImpl implements IPayrollService { + + /** + * 获取所有员工信息 + * @return + */ + @Override + public List getAllEmployees() { + return null; + } + + /** + * 保存paycheck + * @param pc + * @return + */ + @Override + public boolean savePaycheck(PayCheck pc) { + System.out.println("保存。。。。。"); + return true; + } +} diff --git a/students/740707954/src/main/java/payroll/util/DateUtil.java b/students/740707954/src/main/java/payroll/util/DateUtil.java new file mode 100644 index 0000000000..f3e7f02d6c --- /dev/null +++ b/students/740707954/src/main/java/payroll/util/DateUtil.java @@ -0,0 +1,80 @@ +package payroll.util; + +import java.util.Date; + +/** + * 日期工具类 + * Created by lx on 2017/7/8. + */ +public class DateUtil { + /** + * 是否为周五 + * @param date + * @return + */ + public static boolean isFriday(Date date) { + return false; + } + + /** + * 返回对指定日期+i的日期 + * @param payPeriodEndDate + * @param i + * @return + */ + public static Date add(Date payPeriodEndDate, int i) { + return null; + } + + /** + * 是否为本月的最后一天 + * @param date + * @return + */ + public static boolean isLastDayOfMonth(Date date) { + return false; + } + + /** + * 获取本月的第一天 + * @param payPeriodEndDate + * @return + */ + public static Date getFirstDayOfMonth(Date payPeriodEndDate) { + return null; + } + + /** + * 将字符串转换为日期 + * @param s + * @return + */ + public static Date parse(String s) { + return null; + } + + /** + * 计算两个日期之间相差的天数 + * @param firstPayFriday + * @param date + * @return + */ + public static int getDaysBetween(Date firstPayFriday, Date date) { + return 0; + } + + public static boolean between(Date date, Date payPeriodStart, Date payPeriodEnd) { + + return false; + } + + /** + * 获取两个时间段中有几个周五 + * @param payPeriodStart + * @param payPeriodEnd + * @return + */ + public static int getFridaysBetween(Date payPeriodStart, Date payPeriodEnd) { + return 0; + } +} diff --git "a/students/740707954/src/main/java/payroll/\351\234\200\346\261\202" "b/students/740707954/src/main/java/payroll/\351\234\200\346\261\202" new file mode 100644 index 0000000000..1e2abc7bc0 --- /dev/null +++ "b/students/740707954/src/main/java/payroll/\351\234\200\346\261\202" @@ -0,0 +1,16 @@ +该系统由一个公司数据库以及和雇员相关的数据(例如工作时间卡)组成,系统需要准时地按照规则给员工支付薪水, +同时,必须从薪水中扣除各种扣款有些雇员是钟点工, 会按照他们雇员记录中每小时的报酬字段的值对他们进行支付, +他们每天提交工作时间卡,其中记录了日期以及工作小时数,如果每天工作超过8小时,按1.5倍进行支付。 +每周五对他们进行支付。有些雇员完全以月薪进行支付,每个月的最后一个工作日对他们进行支付, +在他们的雇员记录中有个月薪字段 同时,对于一些带薪的雇员,会根据他们的销售情况,支付给他们一定数量的佣金, +他们会提交销售凭条,其中记录了销售的日期和数量。在他们的雇员记录中有一个酬金报酬字段。 +每隔一周的周五对他们进行支付。雇员可以选择支付方式,可以把支票邮寄到他们指定的邮政地址, +也可以保存在财务那里随时支取,或者要求直接存入他们指定的银行账户 一些雇员会加入协会,在他们的雇员记录中有一个每周应付款项字段, +这些应付款需要从他们的薪水中扣除。协会有时会针对单个会员征收服务费用。 +协会每周会提交这些服务费用,服务费用从相应雇员的薪水总额中扣除。薪水支付程序每个工作日运行一次, 并在当天对相应的雇员进行支付, +系统会被告知雇员的支付日期,这样它会计算从雇员上次支付日期到规定的支付日期间应付的数额。 + + +雇员类型:小时工、领月薪的、带薪的 +支付方式:打到银行卡、邮递、保存在财务那里 +支付时间:每周五、每隔一周、每个月 diff --git a/students/740707954/src/test/java/test b/students/740707954/src/test/java/test new file mode 100644 index 0000000000..30d74d2584 --- /dev/null +++ b/students/740707954/src/test/java/test @@ -0,0 +1 @@ +test \ No newline at end of file From 510dcfdd413c579376db5aa941cd5645845fd093 Mon Sep 17 00:00:00 2001 From: chasing <282692248@qq.com> Date: Sun, 16 Jul 2017 18:02:14 +0800 Subject: [PATCH 13/81] =?UTF-8?q?=E8=96=AA=E6=B0=B4=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/coderising/payroll/Affiliation.java | 5 + .../com/coderising/payroll/BankMethod.java | 8 ++ .../coderising/payroll/BiWeeklySchedule.java | 18 +++ .../payroll/ComissionClassification.java | 28 +++++ .../java/com/coderising/payroll/DateUtil.java | 99 +++++++++++++++ .../java/com/coderising/payroll/Employee.java | 56 +++++++++ .../com/coderising/payroll/HoldMethod.java | 7 ++ .../payroll/HourlyClassification.java | 40 ++++++ .../com/coderising/payroll/MailMethod.java | 8 ++ .../coderising/payroll/MonthlySchedule.java | 13 ++ .../coderising/payroll/NonAffiliation.java | 7 ++ .../java/com/coderising/payroll/Paycheck.java | 41 ++++++ .../payroll/PaymentClassification.java | 5 + .../com/coderising/payroll/PaymentMethod.java | 5 + .../coderising/payroll/PaymentSchedule.java | 8 ++ .../payroll/SalariedClassification.java | 14 +++ .../com/coderising/payroll/SalesReceipt.java | 21 ++++ .../java/com/coderising/payroll/TimeCard.java | 19 +++ .../coderising/payroll/UnionAffiliation.java | 17 +++ .../coderising/payroll/WeeklySchedule.java | 12 ++ .../src/main/resources/employees.txt | 9 ++ .../src/main/resources/salesreceipt.txt | 9 ++ .../src/main/resources/timecard.txt | 9 ++ .../src/main/resources/union.txt | 4 + .../com/coderising/payroll/EmployeeTest.java | 119 ++++++++++++++++++ 25 files changed, 581 insertions(+) create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Affiliation.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/BankMethod.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/BiWeeklySchedule.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/ComissionClassification.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/DateUtil.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Employee.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/HoldMethod.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/HourlyClassification.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/MailMethod.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/MonthlySchedule.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/NonAffiliation.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Paycheck.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentClassification.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentMethod.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentSchedule.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/SalariedClassification.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/SalesReceipt.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/TimeCard.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/UnionAffiliation.java create mode 100644 students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/WeeklySchedule.java create mode 100644 students/282692248/ood/ood-assignment/src/main/resources/employees.txt create mode 100644 students/282692248/ood/ood-assignment/src/main/resources/salesreceipt.txt create mode 100644 students/282692248/ood/ood-assignment/src/main/resources/timecard.txt create mode 100644 students/282692248/ood/ood-assignment/src/main/resources/union.txt create mode 100644 students/282692248/ood/ood-assignment/src/test/java/com/coderising/payroll/EmployeeTest.java diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Affiliation.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Affiliation.java new file mode 100644 index 0000000000..091165a2af --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Affiliation.java @@ -0,0 +1,5 @@ +package com.coderising.payroll; + +public interface Affiliation { + public double calculateDeductions(Paycheck pc); +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/BankMethod.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/BankMethod.java new file mode 100644 index 0000000000..a7b0dd9436 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/BankMethod.java @@ -0,0 +1,8 @@ +package com.coderising.payroll; + +public class BankMethod implements PaymentMethod{ + private String account; + public void pay(Paycheck pc){ + System.out.println("转到银行账号:"+account+"。备注:"+pc); + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/BiWeeklySchedule.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/BiWeeklySchedule.java new file mode 100644 index 0000000000..943b4ae757 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/BiWeeklySchedule.java @@ -0,0 +1,18 @@ +package com.coderising.payroll; + +import java.util.Date; + +public class BiWeeklySchedule implements PaymentSchedule{ + private Date firstPayDay; + public BiWeeklySchedule(String firstPayDay){ + this.firstPayDay = DateUtil.parseDate(firstPayDay); + } + + public boolean isPayDate(Date date){ + return DateUtil.getDaysBetween(firstPayDay, date)%14 == 0; + } + + public Date getPayPeriodStartDate( Date payPeriodEndDate){ + return DateUtil.add(payPeriodEndDate, -13); + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/ComissionClassification.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/ComissionClassification.java new file mode 100644 index 0000000000..e8ef651b11 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/ComissionClassification.java @@ -0,0 +1,28 @@ +package com.coderising.payroll; + +import java.util.ArrayList; +import java.util.List; + +public class ComissionClassification implements PaymentClassification { + private double salary; + private double rate; + List receipts = new ArrayList<>(); + + public ComissionClassification(double salary, double rate, List receipts) { + super(); + this.salary = salary; + this.rate = rate; + this.receipts = receipts; + } + + + public double calculatePay(Paycheck pc){ + double totalAmount = 0.0; + for(SalesReceipt sr:receipts){ + if(DateUtil.between(sr.getSaleDate(),pc.getPayPeriodStartDate(), pc.getPayPeriodEndDate())){ + totalAmount += sr.getAmount(); + } + } + return salary + totalAmount*rate; + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/DateUtil.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/DateUtil.java new file mode 100644 index 0000000000..0b2c6aad54 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/DateUtil.java @@ -0,0 +1,99 @@ +package com.coderising.payroll; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +public class DateUtil { + public static final long SECOND_IN_MS = 1000L; + public static final long MINUTE_IN_S = 60L; + public static final long HOUR_IN_MINUTE = 60L; + public static final long DAY_IN_HOUR = 24L; + public static final long DAY_IN_MS = DAY_IN_HOUR*HOUR_IN_MINUTE*MINUTE_IN_S*SECOND_IN_MS; + private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + public static boolean isFriday(Date date){ + Calendar calendar = new GregorianCalendar(); + calendar.setTime(date); + return calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY; + } + + public static int getDaysBetween(Date beginDate, Date endDate){ + assert(endDate.after(beginDate)); + return (int)((endDate.getTime() - beginDate.getTime())/DAY_IN_MS); + } + + public static Date parseDate(String strDate){ + try{ + return sdf.parse(strDate); + } + catch(ParseException e){ + throw new RuntimeException(e); + } + } + + public static Date add(Date date, int dayCount){ + Calendar calendar = new GregorianCalendar(); + calendar.setTime(date); + calendar.add(Calendar.DATE, dayCount); + return calendar.getTime(); + } + + /** + * 判断当前日期是否是当月最后一个工作日 + * true: 当前日期是工作日并且与下一工作日不同月 + * */ + public static boolean isLastWorkDayOfMonth(Date d){ + if(isWeekday(d)){ + Date nextWeekday = nextWeekday(d); + Calendar calendar = new GregorianCalendar(); + calendar.setTime(d); + int mouth = calendar.get(Calendar.MONTH); + calendar.setTime(nextWeekday); + return mouth != calendar.get(Calendar.MONTH); + } + return false; + } + + public static boolean isWeekday(Date d){ + Calendar calendar = new GregorianCalendar(); + calendar.setTime(d); + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); + return Calendar.MONDAY <= dayOfWeek && dayOfWeek <= Calendar.FRIDAY; + } + + public static Date nextWeekday(Date d){ + Calendar calendar = new GregorianCalendar(); + calendar.setTime(d); + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); + switch (dayOfWeek) { + case Calendar.FRIDAY: + calendar.add(Calendar.DATE, 3); + break; + case Calendar.SATURDAY: + calendar.add(Calendar.DATE, 2); + break; + default: + calendar.add(Calendar.DATE, 1); + break; + } + return calendar.getTime(); + } + + public static Date getFirstDayOfMonth(Date d){ + Calendar calendar = new GregorianCalendar(); + calendar.setTime(d); + calendar.set(Calendar.DAY_OF_MONTH, 1); + return calendar.getTime(); + } + + public static boolean between(Date d, Date startDate, Date endDate){ + return d.compareTo(startDate)>=0 && d.compareTo(endDate)<=0; + } + + public static String format(Date d){ + return sdf.format(d); + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Employee.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Employee.java new file mode 100644 index 0000000000..75fbc04ddf --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Employee.java @@ -0,0 +1,56 @@ +package com.coderising.payroll; + +import java.util.Date; + +public class Employee { + String id; + String name; + String address; + Affiliation affiliation = new NonAffiliation(); + + + PaymentClassification classification; + PaymentSchedule schedule; + PaymentMethod paymentMethod; + + public Employee(String id, String name, String address){ + this.id = id; + this.name = name; + this.address = address; + } + public boolean isPayDay(Date d) { + return schedule.isPayDate(d); + } + + public Date getPayPeriodStartDate(Date d) { + return schedule.getPayPeriodStartDate(d); + } + + public void payDay(Paycheck pc){ + double grossPay = classification.calculatePay(pc); + double deductions = affiliation.calculateDeductions(pc); + double netPay = grossPay - deductions; + pc.setGrossPay(grossPay); + pc.setDeductions(deductions); + pc.setNetPay(netPay); + this.paymentMethod.pay(pc); + } + + public void setClassification(PaymentClassification classification) { + this.classification = classification; + } + public void setSchedule(PaymentSchedule schedule) { + this.schedule = schedule; + } + public void setPaymentMethod(PaymentMethod paymentMethod) { + this.paymentMethod = paymentMethod; + } + public void setAffiliation(Affiliation affiliation) { + this.affiliation = affiliation; + } + @Override + public String toString() { + return "Employee [id=" + id + ", name=" + name + ", address=" + address + "]"; + } +} + diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/HoldMethod.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/HoldMethod.java new file mode 100644 index 0000000000..d1f4b48a4d --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/HoldMethod.java @@ -0,0 +1,7 @@ +package com.coderising.payroll; + +public class HoldMethod implements PaymentMethod{ + public void pay(Paycheck pc){ + System.out.println("转到财务处:"+pc); + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/HourlyClassification.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/HourlyClassification.java new file mode 100644 index 0000000000..9cdce41184 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/HourlyClassification.java @@ -0,0 +1,40 @@ +package com.coderising.payroll; + +import java.util.ArrayList; +import java.util.List; + +public class HourlyClassification implements PaymentClassification{ + private double hourlyRate; + private List timeCards = new ArrayList<>(); + + public HourlyClassification(double hourlyRate, List timeCards) { + super(); + this.hourlyRate = hourlyRate; + this.timeCards = timeCards; + } + + public double getHourlyRate() { + return hourlyRate; + } + + public void setHourlyRate(double hourlyRate) { + this.hourlyRate = hourlyRate; + } + + public double calculatePay(Paycheck pc){ + double salary = 0.0; + for(TimeCard tc:timeCards){ + if(DateUtil.between(tc.getDate(), pc.getPayPeriodStartDate(), pc.getPayPeriodEndDate())){ + salary += calculatePayForTimeCard(tc); + } + } + return salary; + } + + private double calculatePayForTimeCard(TimeCard tc){ + if(tc.getHours() > 8){ + return 8*hourlyRate + (tc.getHours()-8)*1.5*hourlyRate; + } + return tc.getHours()*hourlyRate; + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/MailMethod.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/MailMethod.java new file mode 100644 index 0000000000..19e59fa512 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/MailMethod.java @@ -0,0 +1,8 @@ +package com.coderising.payroll; + +public class MailMethod implements PaymentMethod{ + private String address; + public void pay(Paycheck pc){ + System.out.println("邮寄到:"+address+"。备注:"+pc); + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/MonthlySchedule.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/MonthlySchedule.java new file mode 100644 index 0000000000..86f9b7e21c --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/MonthlySchedule.java @@ -0,0 +1,13 @@ +package com.coderising.payroll; + +import java.util.Date; + +public class MonthlySchedule implements PaymentSchedule{ + public boolean isPayDate(Date date){ + return DateUtil.isLastWorkDayOfMonth(date); + } + + public Date getPayPeriodStartDate( Date payPeriodEndDate){ + return DateUtil.getFirstDayOfMonth(payPeriodEndDate); + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/NonAffiliation.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/NonAffiliation.java new file mode 100644 index 0000000000..31129fbab4 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/NonAffiliation.java @@ -0,0 +1,7 @@ +package com.coderising.payroll; + +public class NonAffiliation implements Affiliation{ + public double calculateDeductions(Paycheck pc){ + return 0.0; + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Paycheck.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Paycheck.java new file mode 100644 index 0000000000..81af0d4d66 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/Paycheck.java @@ -0,0 +1,41 @@ +package com.coderising.payroll; + +import java.util.Date; + +public class Paycheck { + private Date payPeriodStart; + private Date payPeriodEnd; + private double grossPay; + private double netPay; + private double deductions; + + public Paycheck(Date payPeriodStart, Date payPeriodEnd){ + this.payPeriodStart = payPeriodStart; + this.payPeriodEnd = payPeriodEnd; + } + public void setGrossPay(double grossPay) { + this.grossPay = grossPay; + + } + public void setDeductions(double deductions) { + this.deductions = deductions; + } + public void setNetPay(double netPay){ + this.netPay = netPay; + } + public Date getPayPeriodEndDate() { + + return this.payPeriodEnd; + } + public Date getPayPeriodStartDate() { + + return this.payPeriodStart; + } + @Override + public String toString() { + return "[开始时间=" + DateUtil.format(payPeriodStart) + ", 结束时间=" + DateUtil.format(payPeriodEnd) + ", 应发=" + + grossPay + ", 扣款=" + deductions + ", 实发=" + netPay + "]"; + } + + +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentClassification.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentClassification.java new file mode 100644 index 0000000000..f2bf2e26e9 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentClassification.java @@ -0,0 +1,5 @@ +package com.coderising.payroll; + +public interface PaymentClassification { + public double calculatePay(Paycheck pc); +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentMethod.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentMethod.java new file mode 100644 index 0000000000..5e549916b6 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentMethod.java @@ -0,0 +1,5 @@ +package com.coderising.payroll; + +public interface PaymentMethod { + public void pay(Paycheck pc); +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentSchedule.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentSchedule.java new file mode 100644 index 0000000000..500d72404d --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/PaymentSchedule.java @@ -0,0 +1,8 @@ +package com.coderising.payroll; + +import java.util.Date; + +public interface PaymentSchedule { + public boolean isPayDate(Date date); + public Date getPayPeriodStartDate( Date payPeriodEndDate); +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/SalariedClassification.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/SalariedClassification.java new file mode 100644 index 0000000000..d7c556405e --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/SalariedClassification.java @@ -0,0 +1,14 @@ +package com.coderising.payroll; + +public class SalariedClassification implements PaymentClassification { + private double salary; + + public SalariedClassification(double salary) { + super(); + this.salary = salary; + } + + public double calculatePay(Paycheck pc){ + return salary; + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/SalesReceipt.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/SalesReceipt.java new file mode 100644 index 0000000000..18297d3fc5 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/SalesReceipt.java @@ -0,0 +1,21 @@ +package com.coderising.payroll; + +import java.util.Date; + +public class SalesReceipt { + private Date saleDate; + private double amount; + + + public SalesReceipt(Date saleDate, double amount) { + super(); + this.saleDate = saleDate; + this.amount = amount; + } + public Date getSaleDate() { + return saleDate; + } + public double getAmount() { + return amount; + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/TimeCard.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/TimeCard.java new file mode 100644 index 0000000000..2aadeabb48 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/TimeCard.java @@ -0,0 +1,19 @@ +package com.coderising.payroll; + +import java.util.Date; + +public class TimeCard { + private Date date; + private int hours; + + public TimeCard(Date date, int hours){ + this.date = date; + this.hours = hours; + } + public Date getDate() { + return date; + } + public int getHours() { + return hours; + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/UnionAffiliation.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/UnionAffiliation.java new file mode 100644 index 0000000000..c9021baf0f --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/UnionAffiliation.java @@ -0,0 +1,17 @@ +package com.coderising.payroll; + +public class UnionAffiliation implements Affiliation{ + private String memberId; + private double weeklyDue; + + public UnionAffiliation(double weeklyDue) { + super(); + this.weeklyDue = weeklyDue; + } + + public double calculateDeductions(Paycheck pc){ + //简单实现 + int dayCount = DateUtil.getDaysBetween(pc.getPayPeriodStartDate(), pc.getPayPeriodEndDate()); + return (dayCount+1)/7 * weeklyDue; + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/WeeklySchedule.java b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/WeeklySchedule.java new file mode 100644 index 0000000000..b9788bd18a --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/java/com/coderising/payroll/WeeklySchedule.java @@ -0,0 +1,12 @@ +package com.coderising.payroll; + +import java.util.Date; + +public class WeeklySchedule implements PaymentSchedule{ + public boolean isPayDate(Date date){ + return DateUtil.isFriday(date); + } + public Date getPayPeriodStartDate( Date payPeriodEndDate){ + return DateUtil.add(payPeriodEndDate, -6); + } +} diff --git a/students/282692248/ood/ood-assignment/src/main/resources/employees.txt b/students/282692248/ood/ood-assignment/src/main/resources/employees.txt new file mode 100644 index 0000000000..6f2535dd25 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/resources/employees.txt @@ -0,0 +1,9 @@ +1 jerry china hourly 0.0 20.0 +2 tom usa hourly 0.0 30.0 +3 herry china hourly 0.0 25.0 +4 lily uk comission 1000.0 0.01 +5 merry china comission 1200.0 0.02 +6 lida japan comission 800.0 0.01 +7 kerry china salaried 5000.0 0.0 +8 jemmy japan salaried 8000.0 0.0 +9 jim usa salaried 7500.0 0.0 \ No newline at end of file diff --git a/students/282692248/ood/ood-assignment/src/main/resources/salesreceipt.txt b/students/282692248/ood/ood-assignment/src/main/resources/salesreceipt.txt new file mode 100644 index 0000000000..c9105f4a20 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/resources/salesreceipt.txt @@ -0,0 +1,9 @@ +2017-06-30 4 3000.0 +2017-07-11 4 5000.0 +2017-07-14 4 4000.0 +2017-06-29 5 2000.0 +2017-07-02 5 3000.0 +2017-07-15 5 3000.0 +2017-07-01 6 4000.0 +2017-07-08 6 3000.0 +2017-07-16 6 2000.0 \ No newline at end of file diff --git a/students/282692248/ood/ood-assignment/src/main/resources/timecard.txt b/students/282692248/ood/ood-assignment/src/main/resources/timecard.txt new file mode 100644 index 0000000000..995a2d20d5 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/resources/timecard.txt @@ -0,0 +1,9 @@ +2017-07-07 1 9 +2017-07-11 1 7 +2017-07-14 1 5 +2017-07-08 2 10 +2017-07-13 2 6 +2017-07-15 2 7 +2017-07-12 3 9 +2017-07-14 3 9 +2017-07-16 3 9 \ No newline at end of file diff --git a/students/282692248/ood/ood-assignment/src/main/resources/union.txt b/students/282692248/ood/ood-assignment/src/main/resources/union.txt new file mode 100644 index 0000000000..c15a30d749 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/main/resources/union.txt @@ -0,0 +1,4 @@ +1 +5 +7 +9 \ No newline at end of file diff --git a/students/282692248/ood/ood-assignment/src/test/java/com/coderising/payroll/EmployeeTest.java b/students/282692248/ood/ood-assignment/src/test/java/com/coderising/payroll/EmployeeTest.java new file mode 100644 index 0000000000..2bd6757ae2 --- /dev/null +++ b/students/282692248/ood/ood-assignment/src/test/java/com/coderising/payroll/EmployeeTest.java @@ -0,0 +1,119 @@ +package com.coderising.payroll; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.junit.Test; + +public class EmployeeTest { + + @Test + public void test() throws Exception{ + Date d = DateUtil.parseDate("2017-07-31"); + List employeeList = loadEmployees(); + for(Employee e:employeeList){ + if(e.isPayDay(d)){ + Paycheck pc = new Paycheck(e.getPayPeriodStartDate(d), d); + System.out.println("发工资--> "+e); + e.payDay(pc); + } + } + } + + private List loadEmployees()throws Exception{ + List employees = new ArrayList<>(); + Set unioners = loadUnionIds(); + UnionAffiliation ua = new UnionAffiliation(5.0); + Map> tcMap = loadTimeCard(); + Map> srMap = loadSalyReceipt(); + String employeesFileName = "D:\\coding2017\\students\\282692248\\ood\\ood-assignment\\src\\main\\resources\\employees.txt"; + BufferedReader br = new BufferedReader(new FileReader(employeesFileName)); + String line = null;//id name address type salary rate + while( (line = br.readLine()) != null ){ + String[] fileds = line.split("\t"); + String id = fileds[0]; + Employee employee = new Employee(id,fileds[1], fileds[2]); + switch (fileds[3]) { + case "hourly": + employee.setClassification(new HourlyClassification(Double.parseDouble(fileds[5]),tcMap.get(id))); + employee.setSchedule(new WeeklySchedule()); + break; + case "comission": + employee.setClassification(new ComissionClassification(Double.parseDouble(fileds[4]), + Double.parseDouble(fileds[5]), srMap.get(id))); + employee.setSchedule(new BiWeeklySchedule("2017-05-05")); + break; + case "salaried": + employee.setClassification(new SalariedClassification(Double.parseDouble(fileds[4]))); + employee.setSchedule(new MonthlySchedule()); + break; + default: + throw new RuntimeException("unkonwn type ["+fileds[3]+"]"); + } + employee.setPaymentMethod(new HoldMethod()); + if(unioners.contains(id)){ + employee.setAffiliation(ua); + } + employees.add(employee); + } + br.close(); + return employees; + } + + private Set loadUnionIds() throws Exception{ + Set unioners = new HashSet<>(); + String unionFileName = "D:\\coding2017\\students\\282692248\\ood\\ood-assignment\\src\\main\\resources\\union.txt"; + BufferedReader br = new BufferedReader(new FileReader(unionFileName)); + String line = null; + while( (line = br.readLine()) != null ){ + unioners.add(line); + } + br.close(); + return unioners; + } + + private Map> loadTimeCard() throws Exception{ + Map> result = new HashMap<>(); + String timecardFileName = "D:\\coding2017\\students\\282692248\\ood\\ood-assignment\\src\\main\\resources\\timecard.txt"; + BufferedReader br = new BufferedReader(new FileReader(timecardFileName)); + String line = null; + while( (line = br.readLine()) != null ){//date id hours + String[] fields = line.split("\t"); + TimeCard tc = new TimeCard(DateUtil.parseDate(fields[0]),Integer.parseInt(fields[2])); + List tcList = result.get(fields[1]); + if(tcList == null){ + tcList = new ArrayList<>(); + result.put(fields[1], tcList); + } + tcList.add(tc); + } + br.close(); + return result; + } + + private Map> loadSalyReceipt() throws Exception{ + Map> result = new HashMap<>(); + String receiptFileName = "D:\\coding2017\\students\\282692248\\ood\\ood-assignment\\src\\main\\resources\\salesreceipt.txt"; + BufferedReader br = new BufferedReader(new FileReader(receiptFileName)); + String line = null; + while( (line = br.readLine()) != null ){//date id amount + String[] fields = line.split("\t"); + SalesReceipt sr = new SalesReceipt(DateUtil.parseDate(fields[0]),Double.parseDouble(fields[2])); + List srList = result.get(fields[1]); + if(srList == null){ + srList = new ArrayList<>(); + result.put(fields[1], srList); + } + srList.add(sr); + } + br.close(); + return result; + } +} From 3c2f34231d780efb4dcdfd54915431d0e2687c33 Mon Sep 17 00:00:00 2001 From: yangzhm Date: Mon, 17 Jul 2017 11:08:56 +0800 Subject: [PATCH 14/81] add project of builder pattern --- students/495232796/OOD/builderpattern/pom.xml | 42 ++++++++++ .../com/coderising/dp/builder/TagBuilder.java | 41 ++++++++++ .../coderising/dp/builder/TagBuilderTest.java | 41 ++++++++++ .../com/coderising/dp/builder/TagNode.java | 82 +++++++++++++++++++ .../java/com/coderising/dp/main/TestAll.java | 17 ++++ 5 files changed, 223 insertions(+) create mode 100644 students/495232796/OOD/builderpattern/pom.xml create mode 100644 students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagBuilder.java create mode 100644 students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagBuilderTest.java create mode 100644 students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagNode.java create mode 100644 students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/main/TestAll.java diff --git a/students/495232796/OOD/builderpattern/pom.xml b/students/495232796/OOD/builderpattern/pom.xml new file mode 100644 index 0000000000..84bf4627e3 --- /dev/null +++ b/students/495232796/OOD/builderpattern/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + com.coderising + ood-assignment + 0.0.1-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + + + + jar + + ood-assignment + http://maven.apache.org + + + UTF-8 + + + + + + junit + junit + 4.12 + + + + + + aliyunmaven + http://maven.aliyun.com/nexus/content/groups/public/ + + + \ No newline at end of file diff --git a/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagBuilder.java b/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagBuilder.java new file mode 100644 index 0000000000..cf143e1ee6 --- /dev/null +++ b/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagBuilder.java @@ -0,0 +1,41 @@ +package com.coderising.dp.builder; + +public class TagBuilder { + private TagNode rootNode = null; + private TagNode curNode = null; + private TagNode parentNode = null; + + public TagBuilder(String rootTagName){ + rootNode = new TagNode(rootTagName); + curNode = rootNode; + } + + public TagBuilder addChild(String childTagName){ + TagNode tn = new TagNode(childTagName); + curNode.add(tn); + parentNode = curNode; + curNode = tn; + + return this; + } + public TagBuilder addSibling(String siblingTagName){ + TagNode tn = new TagNode(siblingTagName); + parentNode.add(tn); + curNode = tn; + + return this; + } + public TagBuilder setAttribute(String name, String value){ + curNode.setAttribute(name, value); + + return this; + } + public TagBuilder setText(String value){ + curNode.setValue(value); + + return this; + } + public String toXML(){ + return rootNode.toXML(); + } +} diff --git a/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagBuilderTest.java b/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagBuilderTest.java new file mode 100644 index 0000000000..e98cfae947 --- /dev/null +++ b/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagBuilderTest.java @@ -0,0 +1,41 @@ +package com.coderising.dp.builder; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class TagBuilderTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testToXML() { + + TagBuilder builder = new TagBuilder("order"); + + String xml = builder.addChild("line-items") + .addChild("line-item").setAttribute("pid", "P3677").setAttribute("qty", "3") + .addSibling("line-item").setAttribute("pid", "P9877").setAttribute("qty", "10") + .toXML(); + + String expected = "" + + "" + + "" + + "" + + "" + + ""; + + System.out.println(xml); + System.out.println(expected.equals(xml)); + assertEquals(expected, xml); + } + +} diff --git a/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagNode.java b/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagNode.java new file mode 100644 index 0000000000..6a31e04192 --- /dev/null +++ b/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/builder/TagNode.java @@ -0,0 +1,82 @@ +package com.coderising.dp.builder; + +import java.util.ArrayList; +import java.util.List; + +public class TagNode { + private String tagName; + private String tagValue; + private List children = new ArrayList<>(); + private List attributes = new ArrayList<>(); + + public TagNode(String name){ + this.tagName = name; + } + public void add(TagNode child){ + this.children.add(child); + } + public void setAttribute(String name, String value) { + Attribute attr = findAttribute(name); + if(attr != null){ + attr.value = value; + } else { + attributes.add(new Attribute(name,value)); + } + } + private Attribute findAttribute(String name){ + for(Attribute attr : attributes){ + if(attr.name.equals(name)){ + return attr; + } + } + return null; + } + public void setValue(String value) { + this.tagValue = value; + + } + public String getTagName() { + return tagName; + } + public List getChildren() { + return children; + } + + private static class Attribute{ + public Attribute(String name, String value) { + this.name = name; + this.value = value; + } + String name; + String value; + + } + public String toXML(){ + return toXML(this); + } + private String toXML(TagNode node){ + StringBuilder buffer = new StringBuilder(); + buffer.append("<").append(node.tagName); + if(node.attributes.size()> 0){ + for(int i=0;i"); + return buffer.toString(); + } + buffer.append(">"); + for(TagNode childNode : node.children){ + buffer.append(toXML(childNode)); + } + buffer.append(""); + + + return buffer.toString(); + } + private String toXML(Attribute attr){ + return attr.name+"=\""+attr.value + "\""; + } +} diff --git a/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/main/TestAll.java b/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/main/TestAll.java new file mode 100644 index 0000000000..d5ab3b0f05 --- /dev/null +++ b/students/495232796/OOD/builderpattern/src/main/java/com/coderising/dp/main/TestAll.java @@ -0,0 +1,17 @@ +package com.coderising.dp.main; + +import com.coderising.dp.builder.TagBuilderTest; + +public class TestAll { + + public void testTag() { + TagBuilderTest tt = new TagBuilderTest(); + tt.testToXML(); + } + + public static void main(String[] args) { + TestAll ta = new TestAll(); + ta.testTag(); + } + +} From d0385218c6252eafc8bc4c93d08c12ecb05dd5b5 Mon Sep 17 00:00:00 2001 From: Liu Zengzeng Date: Mon, 17 Jul 2017 11:51:30 +0800 Subject: [PATCH 15/81] atm homework --- .../coderising/ood/atmSimulation/atm/Atm.java | 166 ++++++++++++++++++ .../ood/atmSimulation/atm/Main.java | 97 ++++++++++ .../atmSimulation/atm/console/Display.java | 13 ++ .../atmSimulation/atm/console/KeyBoard.java | 26 +++ .../atm/console/SuperKeypad.java | 45 +++++ .../ood/atmSimulation/atm/print/Printer.java | 17 ++ .../atmSimulation/atm/proxy/BankProxy.java | 29 +++ .../ood/atmSimulation/atm/proxy/Network.java | 20 +++ .../atmSimulation/atm/reader/CardReader.java | 18 ++ .../atmSimulation/atm/slot/CashDepensier.java | 16 ++ .../atmSimulation/atm/slot/DepositSlot.java | 12 ++ .../ood/atmSimulation/atm/slot/MoneySlot.java | 28 +++ .../atm/transaction/DepositTx.java | 43 +++++ .../atm/transaction/QueryBalanceTx.java | 42 +++++ .../atm/transaction/TransferTx.java | 44 +++++ .../atm/transaction/Trasaction.java | 17 ++ .../atm/transaction/WithdrawTx.java | 42 +++++ .../ood/atmSimulation/bank/Bank.java | 97 ++++++++++ .../atmSimulation/bank/account/Account.java | 49 ++++++ .../atmSimulation/bank/proxy/ATMProxy.java | 34 ++++ .../bank/transaction/DepositTx.java | 38 ++++ .../bank/transaction/QueryBalanceTx.java | 38 ++++ .../bank/transaction/TransferTx.java | 42 +++++ .../bank/transaction/Trasaction.java | 16 ++ .../bank/transaction/WithdrawTx.java | 39 ++++ .../ood/atmSimulation/card/Card.java | 17 ++ .../serialization/JsonConvert.java | 19 ++ .../serialization/NetPackage.java | 76 ++++++++ 28 files changed, 1140 insertions(+) create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/Atm.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/Main.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/Display.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/KeyBoard.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/SuperKeypad.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/print/Printer.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/proxy/BankProxy.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/proxy/Network.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/reader/CardReader.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/CashDepensier.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/DepositSlot.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/MoneySlot.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/DepositTx.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/QueryBalanceTx.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/TransferTx.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/Trasaction.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/WithdrawTx.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/Bank.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/account/Account.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/proxy/ATMProxy.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/DepositTx.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/QueryBalanceTx.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/TransferTx.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/Trasaction.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/WithdrawTx.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/card/Card.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/serialization/JsonConvert.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/serialization/NetPackage.java diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/Atm.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/Atm.java new file mode 100644 index 0000000000..9728b39bfb --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/Atm.java @@ -0,0 +1,166 @@ +package com.coderising.ood.atmSimulation.atm; + +import com.coderising.ood.atmSimulation.atm.console.SuperKeypad; +import com.coderising.ood.atmSimulation.atm.print.Printer; +import com.coderising.ood.atmSimulation.atm.proxy.BankProxy; +import com.coderising.ood.atmSimulation.atm.reader.CardReader; +import com.coderising.ood.atmSimulation.atm.slot.CashDepensier; +import com.coderising.ood.atmSimulation.atm.slot.DepositSlot; +import com.coderising.ood.atmSimulation.atm.transaction.*; +import com.coderising.ood.atmSimulation.card.Card; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class Atm { + //存钱口 + private DepositSlot depositSlot; + //取钱口 + private CashDepensier cashDepensier; + //超级键盘 + private SuperKeypad superKeypad; + //读卡器 + private CardReader cardReader; + //bankProxy + private BankProxy bankProxy; + //打印器 + private Printer printer; + + public Atm(DepositSlot depositSlot, CashDepensier cashDepensier, + SuperKeypad superKeypad, CardReader cardReader, BankProxy bankProxy, Printer printer) { + this.depositSlot = depositSlot; + this.cashDepensier = cashDepensier; + this.superKeypad = superKeypad; + this.cardReader = cardReader; + this.bankProxy = bankProxy; + this.printer = printer; + } + + //账号|密码 + private String account; + private String password; + + private List list = new ArrayList<>(); + + public String getAccount() { + return account; + } + + public String getPassword() { + return password; + } + + public boolean hasEnoughMoney(int amount) { + return cashDepensier.hasEnoughMoney(amount); + } + + public boolean dipenseMoney(int amount) { + return cashDepensier.dispenseMoney(amount); + } + + public int retriveMoney() { + Random random = new Random(); + int money = random.nextInt(10000); + return depositSlot.retriveMoney(money); + } + + //插卡 + public void insertCard(Card card) { + account = cardReader.readCard(card); + } + + //输入密码 + public void writePassword() { + int count = 1; + while (count <= 3) { + count++; + password = superKeypad.inputPassword(); + if (bankProxy.verify(account, password)) { + return; + } + } + superKeypad.display("吞卡啦,到前台吧~"); + throw new RuntimeException("atm eat card"); + } + + //查询 + public void query() { + superKeypad.display("查询"); + QueryBalanceTx tx = new QueryBalanceTx(); + if (tx.preProcess(this)) { + String response = bankProxy.process(tx, this); + tx.setAmount(Integer.valueOf(response)); + superKeypad.display("查询操作余额为:" + response); + } + list.add(tx); + tx.postProcess(this); + } + + //转账 + public void transfer() { + superKeypad.display("转账"); + String toCard = superKeypad.inputCardNumber(); + int amount = superKeypad.inputAmount(); + TransferTx tx = new TransferTx(toCard, amount); + if (tx.preProcess(this)) { + String response = bankProxy.process(tx, this); + superKeypad.display("转账后,余额为:" + response); + } + list.add(tx); + tx.postProcess(this); + } + + //取款 + public void dependesier() { + superKeypad.display("取款"); + int amount = superKeypad.inputAmount(); + WithdrawTx tx = new WithdrawTx(amount); + if (tx.preProcess(this)) { + String response = bankProxy.process(tx, this); + superKeypad.display("取款后,余额为:" + response); + } + list.add(tx); + tx.postProcess(this); + } + + //存钱 + public void deposit() { + superKeypad.display("存款"); + DepositTx tx = new DepositTx(retriveMoney()); + if (tx.preProcess(this)) { + String response = bankProxy.process(tx, this); + superKeypad.display("存钱后,余额为:" + response); + } + list.add(tx); + tx.postProcess(this); + } + + //打印 + public void print() { + superKeypad.display("------打印操作-------"); + printer.print(list); + superKeypad.display("------打印完毕-------"); + } + + //退卡 + public void ejectCard(Card card) { + cardReader.ejectCard(card); + superKeypad.display("退卡成功"); + } + + //引导 + public void showGuide() { + superKeypad.display("请选择操作:"); + superKeypad.display("1:查询"); + superKeypad.display("2:存钱"); + superKeypad.display("3:取款"); + superKeypad.display("4:转账"); + superKeypad.display("5:退卡"); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/Main.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/Main.java new file mode 100644 index 0000000000..caf9ef2869 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/Main.java @@ -0,0 +1,97 @@ +package com.coderising.ood.atmSimulation.atm; + +import com.coderising.ood.atmSimulation.atm.console.Display; +import com.coderising.ood.atmSimulation.atm.console.KeyBoard; +import com.coderising.ood.atmSimulation.atm.console.SuperKeypad; +import com.coderising.ood.atmSimulation.atm.print.Printer; +import com.coderising.ood.atmSimulation.atm.proxy.BankProxy; +import com.coderising.ood.atmSimulation.atm.proxy.Network; +import com.coderising.ood.atmSimulation.atm.reader.CardReader; +import com.coderising.ood.atmSimulation.atm.slot.CashDepensier; +import com.coderising.ood.atmSimulation.atm.slot.DepositSlot; +import com.coderising.ood.atmSimulation.atm.slot.MoneySlot; +import com.coderising.ood.atmSimulation.bank.Bank; +import com.coderising.ood.atmSimulation.bank.account.Account; +import com.coderising.ood.atmSimulation.bank.proxy.ATMProxy; +import com.coderising.ood.atmSimulation.card.Card; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +/** + * @author nvarchar + * date 2017/7/16 + */ +public class Main { + + public static void main(String[] args) { + //mock bank + List accounts = new ArrayList<>(); + Account account = new Account("55005500", "123456", 10000); + accounts.add(account); + Bank bank = new Bank(accounts); + + //mock atmproxy + ATMProxy atmproxy = new ATMProxy(bank); + + //mock network + Network network = new Network(atmproxy); + + //mock bankProxy + BankProxy bankProxy = new BankProxy(network); + + //mock atm + DepositSlot depositSlot = new DepositSlot(); + CashDepensier cashDepensier = new CashDepensier(); + + Display display = new Display(); + KeyBoard keyBoard = new KeyBoard(); + SuperKeypad superKeypad = new SuperKeypad(display, keyBoard); + CardReader cardReader = new CardReader(); + Printer printer = new Printer(); + Atm atm = new Atm(depositSlot, cashDepensier, superKeypad, cardReader, bankProxy, printer); + + MoneySlot.setMoney(1000000); + + //mock card + Card card = new Card("55005500"); + + + atm.insertCard(card); + atm.writePassword(); + + atm.showGuide(); + + Scanner sca = new Scanner(System.in); + + boolean exit = false; + while (!exit) { + int ch = sca.nextInt(); + switch (ch) { + case 1: + atm.query(); + break; + case 2: + atm.deposit(); + break; + case 3: + atm.dependesier(); + break; + case 4: + atm.transfer(); + break; + case 5: + atm.ejectCard(card); + exit = true; + break; + default: + exit = true; + break; + } + } + + atm.print(); + + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/Display.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/Display.java new file mode 100644 index 0000000000..bae9135b4f --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/Display.java @@ -0,0 +1,13 @@ +package com.coderising.ood.atmSimulation.atm.console; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class Display { + + public void showMessage(String message) { + System.out.println(message); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/KeyBoard.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/KeyBoard.java new file mode 100644 index 0000000000..8cbfa6fd71 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/KeyBoard.java @@ -0,0 +1,26 @@ +package com.coderising.ood.atmSimulation.atm.console; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class KeyBoard { + + public String input() { + + BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); + String input = ""; + + try { + input = in.readLine(); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + return input; + } + +} \ No newline at end of file diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/SuperKeypad.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/SuperKeypad.java new file mode 100644 index 0000000000..97256872da --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/console/SuperKeypad.java @@ -0,0 +1,45 @@ +package com.coderising.ood.atmSimulation.atm.console; + +import com.coderising.ood.atmSimulation.atm.transaction.Trasaction; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class SuperKeypad { + private Display display; + private KeyBoard keyBoard; + + public SuperKeypad() { + } + + public SuperKeypad(Display display, KeyBoard keyBoard) { + this.display = display; + this.keyBoard = keyBoard; + } + + public void display(String message) { + display.showMessage(message); + } + + public String inputPassword() { + display("input your password: "); + String password = keyBoard.input(); + display(password.replaceAll("(?s).", "*")); + return password; + } + + public String inputCardNumber() { + display("input your transfer card number"); + return keyBoard.input(); + } + + public int inputAmount() { + display("input your amount"); + return Integer.valueOf(keyBoard.input()); + } + + public Trasaction getTrasaction() { + return null; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/print/Printer.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/print/Printer.java new file mode 100644 index 0000000000..41d492cc77 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/print/Printer.java @@ -0,0 +1,17 @@ +package com.coderising.ood.atmSimulation.atm.print; + +import com.coderising.ood.atmSimulation.atm.transaction.Trasaction; + +import java.util.List; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class Printer { + public void print(List list) { + for (Trasaction trasaction : list) { + System.out.println(trasaction.toPrint()); + } + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/proxy/BankProxy.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/proxy/BankProxy.java new file mode 100644 index 0000000000..4f227e8959 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/proxy/BankProxy.java @@ -0,0 +1,29 @@ +package com.coderising.ood.atmSimulation.atm.proxy; + +import com.coderising.ood.atmSimulation.atm.Atm; +import com.coderising.ood.atmSimulation.atm.transaction.Trasaction; +import com.coderising.ood.atmSimulation.serialization.JsonConvert; +import com.coderising.ood.atmSimulation.serialization.NetPackage; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class BankProxy { + private Network network; + + public BankProxy(Network network) { + this.network = network; + } + + public String process(Trasaction tx, Atm atm) { + String response = network.sendData(tx.toNetWorkPackage(atm)); + return response; + } + + public boolean verify(String account, String password) { + NetPackage netPackage = new NetPackage(account, password); + String response = network.sendData(JsonConvert.encode(netPackage)); + return "true".equals(response); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/proxy/Network.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/proxy/Network.java new file mode 100644 index 0000000000..a16917db06 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/proxy/Network.java @@ -0,0 +1,20 @@ +package com.coderising.ood.atmSimulation.atm.proxy; + +import com.coderising.ood.atmSimulation.bank.proxy.ATMProxy; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class Network { + + private ATMProxy atmProxy; + + public Network(ATMProxy atmProxy) { + this.atmProxy = atmProxy; + } + + public String sendData(String data) { + return atmProxy.getData(data); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/reader/CardReader.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/reader/CardReader.java new file mode 100644 index 0000000000..a347337548 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/reader/CardReader.java @@ -0,0 +1,18 @@ +package com.coderising.ood.atmSimulation.atm.reader; + +import com.coderising.ood.atmSimulation.card.Card; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class CardReader { + + public String readCard(Card card) { + return card.getAccount(); + } + + public void ejectCard(Card card){ + System.out.println("退卡"); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/CashDepensier.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/CashDepensier.java new file mode 100644 index 0000000000..256d4bb911 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/CashDepensier.java @@ -0,0 +1,16 @@ +package com.coderising.ood.atmSimulation.atm.slot; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class CashDepensier { + public boolean hasEnoughMoney(int amount) { + return MoneySlot.getMoney() - amount >= 0; + } + + public boolean dispenseMoney(int amount) { + MoneySlot.minusMoney(amount); + return true; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/DepositSlot.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/DepositSlot.java new file mode 100644 index 0000000000..2841e9f505 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/DepositSlot.java @@ -0,0 +1,12 @@ +package com.coderising.ood.atmSimulation.atm.slot; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class DepositSlot { + public int retriveMoney(int amount) { + //mock put money + return amount; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/MoneySlot.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/MoneySlot.java new file mode 100644 index 0000000000..171f9be15a --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/slot/MoneySlot.java @@ -0,0 +1,28 @@ +package com.coderising.ood.atmSimulation.atm.slot; + +/** + * manage atm money + * + * @author nvarchar + * date 2017/7/15 + */ +public class MoneySlot { + + private static long money; + + public static long getMoney() { + return money; + } + + public static void setMoney(long amount) { + MoneySlot.money = amount; + } + + public static void addMoney(long amount) { + money += amount; + } + + public static void minusMoney(long amount) { + money -= amount; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/DepositTx.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/DepositTx.java new file mode 100644 index 0000000000..770fe603ea --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/DepositTx.java @@ -0,0 +1,43 @@ +package com.coderising.ood.atmSimulation.atm.transaction; + +import com.coderising.ood.atmSimulation.atm.Atm; +import com.coderising.ood.atmSimulation.serialization.JsonConvert; +import com.coderising.ood.atmSimulation.serialization.NetPackage; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class DepositTx implements Trasaction { + + private int amount; + + public int getAmount() { + return amount; + } + + public DepositTx(int amount) { + this.amount = amount; + } + + @Override + public String toPrint() { + return "存款" + amount; + } + + @Override + public String toNetWorkPackage(Atm atm) { + NetPackage nt = new NetPackage(NetPackage.Type.DEPOSIT, atm, amount, null); + return JsonConvert.encode(nt); + } + + @Override + public boolean preProcess(Atm atm) { + return true; + } + + @Override + public boolean postProcess(Atm atm) { + return false; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/QueryBalanceTx.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/QueryBalanceTx.java new file mode 100644 index 0000000000..f0b8a54fb7 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/QueryBalanceTx.java @@ -0,0 +1,42 @@ +package com.coderising.ood.atmSimulation.atm.transaction; + +import com.coderising.ood.atmSimulation.atm.Atm; +import com.coderising.ood.atmSimulation.serialization.JsonConvert; +import com.coderising.ood.atmSimulation.serialization.NetPackage; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class QueryBalanceTx implements Trasaction { + + private int amount; + + public QueryBalanceTx() { + } + + public void setAmount(int amount) { + this.amount = amount; + } + + @Override + public String toPrint() { + return "查询账户,余额为:" + amount; + } + + @Override + public String toNetWorkPackage(Atm atm) { + NetPackage nt = new NetPackage(NetPackage.Type.QUERY, atm, null, null); + return JsonConvert.encode(nt); + } + + @Override + public boolean preProcess(Atm atm) { + return true; + } + + @Override + public boolean postProcess(Atm atm) { + return true; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/TransferTx.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/TransferTx.java new file mode 100644 index 0000000000..c3cb593ccd --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/TransferTx.java @@ -0,0 +1,44 @@ +package com.coderising.ood.atmSimulation.atm.transaction; + +import com.coderising.ood.atmSimulation.atm.Atm; +import com.coderising.ood.atmSimulation.serialization.JsonConvert; +import com.coderising.ood.atmSimulation.serialization.NetPackage; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class TransferTx implements Trasaction { + private String toCard; + private int amount; + + public TransferTx(String toCard, int amount) { + this.toCard = toCard; + this.amount = amount; + } + + public int getAmount() { + return amount; + } + + @Override + public String toPrint() { + return "转账" + amount + "元到" + toCard; + } + + @Override + public String toNetWorkPackage(Atm atm) { + NetPackage nt = new NetPackage(NetPackage.Type.TRANSFER, atm, amount, toCard); + return JsonConvert.encode(nt); + } + + @Override + public boolean preProcess(Atm atm) { + return atm.hasEnoughMoney(getAmount()); + } + + @Override + public boolean postProcess(Atm atm) { + return true; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/Trasaction.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/Trasaction.java new file mode 100644 index 0000000000..c3c58978ce --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/Trasaction.java @@ -0,0 +1,17 @@ +package com.coderising.ood.atmSimulation.atm.transaction; + +import com.coderising.ood.atmSimulation.atm.Atm; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public interface Trasaction { + public String toNetWorkPackage(Atm atm); + + public boolean preProcess(Atm atm); + + public boolean postProcess(Atm atm); + + public String toPrint(); +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/WithdrawTx.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/WithdrawTx.java new file mode 100644 index 0000000000..c783326e02 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/atm/transaction/WithdrawTx.java @@ -0,0 +1,42 @@ +package com.coderising.ood.atmSimulation.atm.transaction; + +import com.coderising.ood.atmSimulation.atm.Atm; +import com.coderising.ood.atmSimulation.serialization.JsonConvert; +import com.coderising.ood.atmSimulation.serialization.NetPackage; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class WithdrawTx implements Trasaction { + private int amount; + + public WithdrawTx(int amount) { + this.amount = amount; + } + + public int getAmount() { + return amount; + } + + @Override + public String toPrint() { + return "取款" + amount; + } + + @Override + public String toNetWorkPackage(Atm atm) { + NetPackage nt = new NetPackage(NetPackage.Type.WITHDRAW, atm, amount, null); + return JsonConvert.encode(nt); + } + + @Override + public boolean preProcess(Atm atm) { + return atm.hasEnoughMoney(getAmount()); + } + + @Override + public boolean postProcess(Atm atm) { + return atm.dipenseMoney(getAmount()); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/Bank.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/Bank.java new file mode 100644 index 0000000000..02550318bb --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/Bank.java @@ -0,0 +1,97 @@ +package com.coderising.ood.atmSimulation.bank; + +import com.coderising.ood.atmSimulation.bank.account.Account; +import com.coderising.ood.atmSimulation.bank.transaction.DepositTx; +import com.coderising.ood.atmSimulation.bank.transaction.QueryBalanceTx; +import com.coderising.ood.atmSimulation.bank.transaction.TransferTx; +import com.coderising.ood.atmSimulation.bank.transaction.WithdrawTx; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class Bank { + private List accounts = new ArrayList<>(); + + public Bank(List accounts) { + this.accounts = accounts; + } + + //查询 + public String query(String cardNumber, String password) { + QueryBalanceTx tx = new QueryBalanceTx(cardNumber, password); + if (tx.preProcess(this)) { + return tx.process(this); + } + tx.postProcess(this); + return null; + } + + //转账 + public String transfer(String cardNumber, String password, + String toCard, int amount) { + TransferTx tx = new TransferTx(cardNumber, password, + toCard, amount); + + if (tx.preProcess(this)) { + return tx.process(this); + } + tx.postProcess(this); + return null; + } + + //取款 + public String withDraw(String cardNumber, String password, + int amount) { + WithdrawTx tx = new WithdrawTx(cardNumber, password, amount); + + if (tx.preProcess(this)) { + return tx.process(this); + } + tx.postProcess(this); + return null; + } + + //存钱 + public String deposit(String cardNumber, String password, + int amount) { + DepositTx tx = new DepositTx(cardNumber, password, amount); + + if (tx.preProcess(this)) { + return tx.process(this); + } + tx.postProcess(this); + return null; + } + + //验证 + public boolean verify(String account, String password) { + return isExist(account, password); + } + + //查询是否 + private boolean isExist(String cardNumber, String password) { + for (Account account : accounts) { + if (cardNumber.equals(account.getCardNumber()) + && password.equals(account.getPassword())) { + return true; + } + } + return false; + } + + //获取账户 + public Account getAccount(String cardNumber, String password) { + for (Account account : accounts) { + if (cardNumber.equals(account.getCardNumber()) + && password.equals(account.getPassword())) { + return account; + } + } + return null; + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/account/Account.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/account/Account.java new file mode 100644 index 0000000000..3bbf50f600 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/account/Account.java @@ -0,0 +1,49 @@ +package com.coderising.ood.atmSimulation.bank.account; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class Account { + private String cardNumber; + private int money; + private String password; + + public Account() { + } + + public Account(String cardNumber, String password, int money) { + this.cardNumber = cardNumber; + this.money = money; + this.password = password; + } + + public String getCardNumber() { + return cardNumber; + } + + public int getMoney() { + return money; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public boolean hasEnoughMoney(int amount) { + return money >= amount; + } + + public boolean dipenseMoney(int amount) { + money -= amount; + return true; + } + + public void retriveMoney(int amount) { + money += amount; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/proxy/ATMProxy.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/proxy/ATMProxy.java new file mode 100644 index 0000000000..a4083ff454 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/proxy/ATMProxy.java @@ -0,0 +1,34 @@ +package com.coderising.ood.atmSimulation.bank.proxy; + +import com.coderising.ood.atmSimulation.bank.Bank; +import com.coderising.ood.atmSimulation.serialization.JsonConvert; +import com.coderising.ood.atmSimulation.serialization.NetPackage; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class ATMProxy { + private Bank bank; + + public ATMProxy(Bank bank) { + this.bank = bank; + } + + public String getData(String data) { + NetPackage np = JsonConvert.decode(data); + switch (np.getType()) { + case QUERY: + return bank.query(np.getAccount(), np.getPassword()); + case Verify: + return String.valueOf(bank.verify(np.getAccount(), np.getPassword())); + case DEPOSIT: + return bank.deposit(np.getAccount(), np.getPassword(), np.getAmount()); + case TRANSFER: + return bank.transfer(np.getAccount(), np.getPassword(), np.getToCard(), np.getAmount()); + case WITHDRAW: + return bank.withDraw(np.getAccount(), np.getPassword(), np.getAmount()); + } + return "no such method"; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/DepositTx.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/DepositTx.java new file mode 100644 index 0000000000..636df1e60d --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/DepositTx.java @@ -0,0 +1,38 @@ +package com.coderising.ood.atmSimulation.bank.transaction; + +import com.coderising.ood.atmSimulation.bank.Bank; +import com.coderising.ood.atmSimulation.bank.account.Account; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class DepositTx implements Trasaction { + + private String account; + private String password; + private int amount; + + public DepositTx(String account, String password, int amount) { + this.account = account; + this.password = password; + this.amount = amount; + } + + @Override + public boolean preProcess(Bank bank) { + return true; + } + + @Override + public boolean postProcess(Bank bank) { + return true; + } + + @Override + public String process(Bank bank) { + Account queryAccount = bank.getAccount(account, password); + queryAccount.retriveMoney(amount); + return String.valueOf(queryAccount.getMoney()); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/QueryBalanceTx.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/QueryBalanceTx.java new file mode 100644 index 0000000000..c14bac18e0 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/QueryBalanceTx.java @@ -0,0 +1,38 @@ +package com.coderising.ood.atmSimulation.bank.transaction; + +import com.coderising.ood.atmSimulation.bank.Bank; +import com.coderising.ood.atmSimulation.bank.account.Account; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class QueryBalanceTx implements Trasaction { + + private String account; + private String password; + + public QueryBalanceTx(String account, String password) { + this.account = account; + this.password = password; + } + + @Override + public boolean preProcess(Bank bank) { + return true; + } + + @Override + public boolean postProcess(Bank bank) { + return false; + } + + @Override + public String process(Bank bank) { + Account queryAccount = bank.getAccount(account, password); + if (account != null) { + return String.valueOf(queryAccount.getMoney()); + } + return null; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/TransferTx.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/TransferTx.java new file mode 100644 index 0000000000..91d0b82ed8 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/TransferTx.java @@ -0,0 +1,42 @@ +package com.coderising.ood.atmSimulation.bank.transaction; + +import com.coderising.ood.atmSimulation.bank.Bank; +import com.coderising.ood.atmSimulation.bank.account.Account; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class TransferTx implements Trasaction { + + private String account; + private String password; + private String toCard; + private int amount; + + public TransferTx(String account, String password, String toCard, int amount) { + this.account = account; + this.password = password; + this.toCard = toCard; + this.amount = amount; + } + + @Override + public boolean preProcess(Bank bank) { + Account queryAccount = bank.getAccount(account, password); + return queryAccount.hasEnoughMoney(amount); + } + + @Override + public boolean postProcess(Bank bank) { + return true; + } + + @Override + public String process(Bank bank) { + Account queryAccount = bank.getAccount(account, password); + queryAccount.dipenseMoney(amount); + //mock add money to toCard + return String.valueOf(queryAccount.getMoney()); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/Trasaction.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/Trasaction.java new file mode 100644 index 0000000000..cd09230fd3 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/Trasaction.java @@ -0,0 +1,16 @@ +package com.coderising.ood.atmSimulation.bank.transaction; + +import com.coderising.ood.atmSimulation.bank.Bank; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public interface Trasaction { + + public boolean preProcess(Bank bank); + + public boolean postProcess(Bank bank); + + public String process(Bank bank); +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/WithdrawTx.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/WithdrawTx.java new file mode 100644 index 0000000000..5ff8efec7a --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/bank/transaction/WithdrawTx.java @@ -0,0 +1,39 @@ +package com.coderising.ood.atmSimulation.bank.transaction; + +import com.coderising.ood.atmSimulation.bank.Bank; +import com.coderising.ood.atmSimulation.bank.account.Account; + +/** + * @author nvarchar + * date 2017/7/14 + */ +public class WithdrawTx implements Trasaction{ + + private String account; + private String password; + private int amount; + + public WithdrawTx(String account, String password, int amount) { + this.account = account; + this.password = password; + this.amount = amount; + } + + @Override + public boolean preProcess(Bank bank) { + Account queryAccount = bank.getAccount(account, password); + return queryAccount.hasEnoughMoney(amount); + } + + @Override + public boolean postProcess(Bank bank) { + return true; + } + + @Override + public String process(Bank bank) { + Account queryAccount = bank.getAccount(account, password); + queryAccount.dipenseMoney(amount); + return String.valueOf(queryAccount.getMoney()); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/card/Card.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/card/Card.java new file mode 100644 index 0000000000..e1103c02ef --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/card/Card.java @@ -0,0 +1,17 @@ +package com.coderising.ood.atmSimulation.card; + +/** + * @author nvarchar + * date 2017/7/15 + */ +public class Card { + private String account; + + public Card(String account) { + this.account = account; + } + + public String getAccount() { + return account; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/serialization/JsonConvert.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/serialization/JsonConvert.java new file mode 100644 index 0000000000..be1934944b --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/serialization/JsonConvert.java @@ -0,0 +1,19 @@ +package com.coderising.ood.atmSimulation.serialization; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +/** + * @author nvarchar + * date 2017/7/16 + */ +public class JsonConvert { + + public static String encode(NetPackage np) { + return JSON.toJSONString(np); + } + + public static NetPackage decode(String code) { + return JSONObject.parseObject(code, NetPackage.class); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/serialization/NetPackage.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/serialization/NetPackage.java new file mode 100644 index 0000000000..99246a3d41 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderising/ood/atmSimulation/serialization/NetPackage.java @@ -0,0 +1,76 @@ +package com.coderising.ood.atmSimulation.serialization; + +import com.coderising.ood.atmSimulation.atm.Atm; + +/** + * @author nvarchar + * date 2017/7/16 + */ +public class NetPackage { + + public enum Type {Verify, QUERY, TRANSFER, DEPOSIT, WITHDRAW} + + private String account; + private String password; + private Integer amount; + private Type type; + private String toCard; + + public void setAccount(String account) { + this.account = account; + } + + public void setPassword(String password) { + this.password = password; + } + + public void setAmount(Integer amount) { + this.amount = amount; + } + + public void setType(Type type) { + this.type = type; + } + + public void setToCard(String toCard) { + this.toCard = toCard; + } + + public String getAccount() { + return account; + } + + public String getPassword() { + return password; + } + + public Integer getAmount() { + return amount; + } + + public Type getType() { + return type; + } + + public String getToCard() { + return toCard; + } + + public NetPackage(Type type, Atm atm, Integer amount, String toCard) { + this.account = atm.getAccount(); + this.password = atm.getPassword(); + this.amount = amount; + this.type = type; + this.toCard = toCard; + } + + public NetPackage(String account, String password) { + this.type = Type.Verify; + this.account = account; + this.password = password; + } + + public NetPackage() { + } +} + From 0d0ebf008b1c39af64b5583995a79750b7a5f830 Mon Sep 17 00:00:00 2001 From: onlyliuxin <14703250@qq.com> Date: Mon, 17 Jul 2017 15:20:00 +0800 Subject: [PATCH 16/81] fix bug --- .../src/main/java/com/coderising/dp/builder/TagNode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/builder/TagNode.java b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/builder/TagNode.java index 7763ee9d0a..2ac26ad7b9 100644 --- a/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/builder/TagNode.java +++ b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/builder/TagNode.java @@ -19,6 +19,7 @@ public void setAttribute(String name, String value) { Attribute attr = findAttribute(name); if(attr != null){ attr.value = value; + return; } attributes.add(new Attribute(name,value)); From dbc9dd25e9da989526667681f54e6cfbef7241ad Mon Sep 17 00:00:00 2001 From: onlyliuxin <14703250@qq.com> Date: Mon, 17 Jul 2017 15:21:15 +0800 Subject: [PATCH 17/81] remove unused file --- dicegame.png | Bin 15130 -> 0 bytes shopping.png | Bin 12840 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 dicegame.png delete mode 100644 shopping.png diff --git a/dicegame.png b/dicegame.png deleted file mode 100644 index 1c1a40821ae9979ac0ab745a54fde3b2c9a462a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15130 zcma*OWn7d|*Eb5|paV#E2t#*=gmg=Hhk}$K-67rGAtfT+ARQ8t(%s$N&AE{Ke%|-P zdCu=}&6jJ~v-jG2ul%pIf)(T>kPz?@U|?X7q$EX^U|>KZFfg!U5D@ToV28FoLd=`(@!WtW6Nddtek*Dr&~{k6TvuC~KO5eym47;E88`y~CPqc?x&AkwWP zjNpDTBnk_KE;D{1x87}oM+f`VJ_dN27(1Fs+&A0IeS$NkK~Yq!yFBJRd+W%B;? z`r9%b2nzG``GbBXV8{`;^85yEg}0WzI6K2cc(II*$mQkx04L-o2s}gZMp=Au%=NfM z=zd->5a5F=3X>iBQWaYT4i*NODQBaID$6MCNKC7KrnTV6#b?bApvK?tly1u8WJ z^lv0{5Da~?P&}Nf5DZul1}qF|jqw*0Lj5<=O9)&`(f)v|`C$nL`9>XQ9~O9osG`;{ zyzY&DrwBuyM@fO1>rIs`h18!`hVh01(?c=-Lsyb0OhW&U8K078N`ydVMnaSj*yp8# zfu*IY;dGyu_5mC8_{gAw{vCw@I_#I8GAr>3+^22Ni~V=ob$kW_nq@!#&!{lQ6cz0u ztS8z9p^`8O^xa^R=d~!&t`ensDT{W$O6U05d0kCG+|vgQWB(mW0EQQZc3$h?X_x=t zRg@Iyks-}kiHRDxhB9IhuI?O)(;C7*I#6+d-PB47BmdiKt0%--I>3YN_CutO6PcGI z-L>}%uC2u%AAh~tqdJ{|DZXlbmmEmeuFftWfJKZ~LY(&!WQNhY^>L=du+M6WE?#bX z5dRM)y3Z4}t)jqTJtt{Y1C=}-h z)oP2;m)B2+w;CG_e~nHf^14Kv=x-@AMZfxRc9mPu9%8{YeGLR&@$TvOvVlqelFqZoSyo*w_X{7X0lFs%2HTm5y(b0|fg_ z@9-1t#_Bwc!-|X(kwhWHZse6XsGW$q)igZ}4Nx~@McVTa1a&lP*r&^wCWRp;E+2b! z?(KJ6<}vcUO{^-#frdeEy=+6e>lI4ieGLBNXPGGy<>UM4!`;SE%1=acxs|-e^R(Ld zq#-WZG3;a90w(Uq-KLoYOL^A%6SJOoR;^N9CeG^9*pwsQFpwjDO_odI4z0^ZV!I1L z4^|fRt>6fR%a5XZ!2`*o(<7E)Ot9gEYU%tzImC85dDjQMkN?66TlQcq&GkGqT;e8@&~Ke9aj@fqx>!aXySC zmf&D7ern{&hK*ISUfaHIt1Z^V9#ZD(Ob+N7YHHZCp2m>KZ21kT_V~zFTQ*9vQjEZl zA*Nfg*D$MO5X?lF8>7zR+t&$%^A)ev5L7_kdw}5edA<=6dDa!50Cr6n{>}IN_Md-R z=8+T|zvelNItajV6ttqo9)3~~&_X~N(QQ2Vs(cpJ!YOYn>v+8Vm6lT=oxrAT*BM9; znqlDD3dh^e>fVR_jMH=|?DH9?CnlNzxz0seuW~7!O+GfQ{A#{Wg*DwG9S}mLUd0yq1kJ$5V#^ zKIFG|PV-|uO%ix)N#$!vBCL?LbeMOLT#e4g4089^rEI-U?t-44RQ&rO?>Q0G%|NDv z8x2ppj;YAwU4gxD49@$D4i6+J{sbO5NJ}5GN(?5Wa5x^^&nS+HCo!e~#2B+M{zhu; zOEhKwjqa|@wb+~ku_&51`t7gy8K-$p)m(z~@WVwO1_{c}sM<`Pu9!It zhF)_AYr^z&n&~22`FgDIPU=*fT~mzFYw}Q$CY;~`D?=hXt8L^w4Iv)qz430ZU7mam zzNO7oD3_HM{f&kO)d~i{-hiz%06iH96td%#7-=@0u2Up!#?h-0Mrq>ff$IS~&yGrF z&MHC?`ou&QvKQ-hgYLs!iD;L<ajG)C3 zd$McZ!suQUbVk+LLr-KzkpW7cyFdmL?#V(SNWml&MU6)Y|I^hG5Nj*ds>h|ZHFAx- z@BXjgq2ztwkO_W8y=nZ(WkFu^iaGl%ZEEj9J5QBSp7TPg#N+aeenX#oBcf0X{SN|~ zzjjR?XOIlguxWuu#NPDoh|p866-*iUY?qkK;;o0@jnww0y3&f znTf8k|Jmqvq%4fLp+OHQw)oq_!^P8@(uf4I%?ceA%h`S2Gr7S1Q}UFzMk6t@hr3vAGL!R* zSUY*uB^!xsL@N`T`y0D?e_hWb(~f6TgSnK|DYDYPEi@sbb-z62e6y0ej&l+Fsm}4D zD3#st?CYQ_)D5_b9PrP@^lsB}ewFPpr_J>@4-e-*|NKeYT{z2}r*J#Vw)<-`Y!st* z*(gI<%uTM`HRw;wJ~h?6^;d^R9_I$;CqYV!Q-ADwshlDyz`k~nu>JQv8#}*B#P?tP zl>H{_mO-0Fj7VWNrfo5G7#VOuEO5A`wp#T2C*K!1%}vAn)s8nU5A6$~yT^)74-~6S z<^G^Aw}5i0p-8;8H`j@7OwQ6yxZd&c5u*_F^&U(7F3?aw7G*4RQT39+A=lOAG@*Ri z_q=5wY5dEBidye>?6v4PG99g136nvOt!@)FA;ilo8BAGP@RsxTdL=&V?%~HDjTU*2 zni}E-;-T=9RI(d^gFE@%0heP$TR3U8s1R`$K$Xgn4waSWQE~ocX$J(Y#QD0BuEDgp zWyV&mcsO0Y2%mt{j4b7<(CyU7wfCLA;r>Vd&+14F1uJkOV+=Z8f&-ACiHD?0;kwS` zV63nr4(F=zsqb!sbCd*%A&Fs+G;zg7V z1nwBA2`=zw+EiELaDuZQ3Ep7yN5~+h_kObzu5Q1v<(KU7oA!X+t~qg(AF$pY7^n<{ z9u*$y?UdJs0@IXLs5s9)sS~)&k%daNUhyqr-?5$2F7->`)}UTk#MfpJqy7_R+&J*l zzzIqi>0g`$77}xxU_bwoez`B$Y6Kd+b?w|R;fbAGOf9`rF-52|sL8f-ArDplH6*x6 zw4esKmMiAs;$4Cgf46pgPgpRZzKSgwf9UOlYfTDI&OVSv_@(OuJcxl;?aqHP{i{2# z7EKuNk--R09_Wd@phk82`ZqbVV2s4vCV7g@#$I{83g>rng9WEt6H&-7V{v?t=0^;b za8c0mv8UcN+3@JA&X%xp{*NPBOq8se1(@i#jM<7DbgR`uO z{4IT`Clo;ri@dbtNp*GGJmXv9`{-)Xk{*manmOFE;!$mT+vmbDlF6=<`k!y#=5$5RPYX;KY~m^@L~U$d?Q0jRRZ^aI4X=~fVVb&`gkP(E z58GSyRtP43o%T5CxDUSVIay>?5JsiO_ipv9Fex0{XHv?m#@|~XN-q6A5cRF$JED_T zs9fc@xe7$A5`Bf*kUyQAFYW%~GZ=RWAi3piL;-4NjA8Ut3B#CG;gf{acVSx|NH7re zsQIEk8L}aG70cYmwX?vy)y@XdW}LT%2UQcj$WdGB+;3{vjl*ossy0sx)xMGkFniQ7 z-g8|usE5*r`=!1JjWGMbO9x!NRh^#|<`g<;KUz z&Wuj2j!5Mf@RjexE1Muvoev7Xy6+uFVIrRQNVl@0)US>Ip`(@icO(kMszR`3NWR1z zMLeh1Od?>C{?Wr78_X=9a2fz3op6dEe%uBDZ}ha0;^BzLTB11ck0x|YMw}V}f?2MZ zDFf`mg@n0EE_L7|mX>;qJliif-QO|$1I(l7OSfdB<1f|)4Y0fe?zuKs)0`Q|0B#^k z+rMCO-kzuHjwT0u;<-cc*F|-=A%|9n3wVo3Ibh}c6#oEV-c+>i&3DtruV05Yt-ixk zTP9FjOf8Vs-d@qoSNpOaHVRDJ?)sS4I=Dgx4To?Sv3QDgvvf3^6a6*vk#SH1DC`~; zTggaSMt?1>ZyP{NGPz)2*;uyR*9GBa%~DS-rQCW85`##oZte0zzZ5>&O7V##D(x3B zJ&I+H!)r6X2U6%uUBPJy-&)cSi^}KO(l1JQyH=vM=06q3Wya?$q#kc&sd2M2t8l$R z;^ErS=`fuXsSIX7O`zwDLj?n#h6AWsqK@a%r8ULo;t!<#)FE(Q=jUqu!?cow?qF$z z{$p^F|H(D=8DaGhI9$L=V~KruCryyM5C{BkiM_N^J0d>kFi0o)Gv?KR?i#;iV-IW_unzw9h7Hd=IQyoY5q6 z0&WeOObF+RBU{3^m5%Ohc6jKyU$(NL_T_8xAn`SEc$uyMo8!;{=M9SeZ`|a(3H^Om z2VYO8Pv3fa(g^(tW=l=t3S=dO4c{;3xB{OE=BA%vAElvFAf@NG(Pd^ zdfnHls^nIhUL7FI>b&r6PUv=`Aed-#>mwFuP&DO95-k+sP#H_XQl3eGK?AFl3( ztiJV7HNWqpIQ5*WFSWi#%YWPJpJ3Kss&yaDT81Y4;&<#~#Pr2{*3qhO+}|n3MVv1^ za&mI+H+_+iLD*MX4MDE`LVQYS3X!wp*)rABUvmRH0C#JQtl7q_iM@g8?N{4uRemla zCT*nOUF!$w*O=N{bTXcj9YZ?Zs5cuu)S}^ZCkyesG6jF{{2`ORSM1B9HD2}ZVQ2Hi zt{s>qHJ>+eb!D>5qu>C8$qnw^oL^Pu0OeDLYt-FjU34rE2gRuD2dkETzg9Ncy+ z_i|@HIkXx*z4*xdh)E%U8w+PUd>cW_PjhiH%olXD|91`XP)w1rc+}Xe`<0^Enq6n% zf7G9Nq2`Lm#r{E;je3HU*iF-7KxAZ-IxHrj>4TC5N%{Frv3GW&EOd%61E4ie}KyUzk9Rdc^e2`~bG|N{@Xq zTyn|y;zcdR?3a7bGK(m(WTSAAvY!?CCKI(n8SYiFc^56pT>1!ya`fBjITM_I(GUJk zqc>ss-4 z>WwVF#DnMC>ye2`p&i!q#)*~*3X5zk2MhqKASOfjzI$h(8OG~8W~ZY+SeBGTg_!Nb z91b(VXwGa64`PIMMQHGJGn-D|g(fYYyImo7yi$QI$)#&*N?8Y*mM9iC0q zY9KiA*S9#b3wzgZf`j**p($iR*5cbCNpIg++xUQxtKT>uemTl;B%{i1FHMaTXw6)4|-mFytwQ2PDmtKC4NrBA(8g9iNDQmXd+ZxeF@5p2wGX$X(t%*wQLl4 z`9X8O%uZhNl<)t>2Jc4E*W#@b`AM9aUalxa{VmpD#__#A7_}8@ep=y!_xoa{E z^j|AUi>(sozGx9<*ekldLRNi|~(;)p?s11aK z2n6T=_pAkbeXCXSpr|Ru-WGDs+WY9IQ1=LB3c6A3dm{R=?XG0CUVSk1)>(%_RHjU9 zF!s3e@7}6x)pu4GM&BO4Tgqi>ay)@fMEaV0FaGIYYf;DmU)Y20R6Z@J8Wyo6HEhO; zxm@WUL1jz~3#!(tE~86@?d!Gf;-uGgYB`+GZt;IUB%d(pTC^Yn1BW%O|gaXBV|}?z?+Ch>zm1fE8hU8bj`e0SrFA*tLx~bRC1|zwncC{Sq$sd8t&&wGbI3GJiYN} zu?q93!Bi_;Xi*nl^nhvhrN~REH9TG3r)la`GL$c` zub_#)n;E{?n25bj9T=V;gV*Cqx9_?)Dl@W~RJ~aH9rLMFE>p1rJW*lPQvkD_iZ(SI z^P#iLxK=jo-UV6WigJR$ejx@Xxtu|nG`SpHw$eUT;JX4a55s#KYA0p$~w(S$_AulCBUClK)~h z==AoDxdA}vYp*3Th*xVmyd(iOp}<_FRyTh;Ks&1rH%mUHxKp^OC-=+A!oxnbFTN%rmfeBU&r<#|3lyuj}3vv&6Smwtw73w0=Yn zYJrE~wGlB$Ernrjd){gFUD7!p&(SHbG~C=Q$_^8|_NK6rgHMlC)SWk>{~oI z=AH%r`iwFqpRljx?+7*E_db(AqmckyvBG5ofn?3|>Q|PXHTa)#E(M#HG~d4vM^(8j zToP2cTZ0&+({ulddJPf-j!~^cYtbqBL(hfoi*91@iLl@d^I7YOQU+!Gi>K_xjGX#A z&0nhlDxc8>sVrm_f)WS;|8i|g7{KF_VP0#bf1a$W_#Kn1W;lcczL0GVQWVuftg({o z77zoSUf*H(53Ly)pVvoru#Rg4NC`V8AZ<$9Qkt)M=W z9zrhvMD%JbRXE{CGB18j3u+PwIE>OuE@^mN-Fp2)55fYB!rgZaFIYNP#BQfb3dlS*q;2DL*L0ip>yJ3r^Ei(H49M`Y*(xjYeZ|j*pi)RTqV*^@d9`D7 zGba~u_vFbD8aSvmVw2hOx55l_7_*f(vXl&o*RYtfIfAQCt1(!G>NTeYn{|*SkV0a8 zL5D=^E65IuTV~2x8>w<`4}({9G+@DqfA@|74S5A(O~{hiVfF1uBQS_I)9>XCW?Bt8VMmEXtM^d{y|}T z3GvcDA*^K=zc?RAzHq#JF+t9;MX^3A1`VyC10U{U1kK1(HfTz(DS+!kGuEV0m(@Nz z;k3J|`kr>8w1De>j2VyZ|N8Zzu}2d(rJa+$6><;dal~Zi?>`q}R-7*PLQ)Zn;2Z1p z)96vL+kcp}gFLeSiA6;HX;;r*?Fy~Gfjm+KRn$Yxl%d!O{<-KSj$~yKc&84Xj(w>4 zvJ}v-LrDc5A6*SQB|e&BV7zl*(#=u3)Ugjnp1FWMpLLcfI4vKuvDGbe*P;p&$2ap* zyf_ucEPA6hH#E~AFem-Me}93QAl53gV`km-(mS57I38`H8>}b@-2@L&^|`_U4m~NB zha-iGSuTJPYCBe+MAWP8t#5_}%i$jC1}EZ|*w^dG9cfuL(@(tjl^g~esay1TE%!o( zD{NkY5r8Zt{cJp6Q_I#}W^#eHWl5pUpG3>E(zTR7nuGNww&03W0hZGBxV*WCP!uFb z{+kK9UPTEsvy0PD^DDf*-$FHuQgMNZSdtFQu?t=s?}L=qTrZtBMT^^s)|x{vob)f` z9FLA|r)yz%t&}Wm9cl)AOKu=`4Luid?8aAw6x;sjVQ{)`)+o}iHp4Fdb0gb~+A^Jc zX0@oQ(cT<`U7}Lotjwye=VwyRibv{)q46bW>)-^kER2Q#5~J{{4izhQiF1<&o9?gl zemib(qaYQ9flY%sjHPHA6dXjE1Z;{e7HJv=C6oIj%{xrRkwxY1#3{A`Z=PN8t^65l zo_E7k%B?oAATv~eR}#b*y4&4BxQ@uhBK@)cABCV#fv}es3!u)!@@c96r9P8HkSt%6 z8U0f?!1Pdq*MLwO79fQ9{0p1?&?Seo$9W3FMI3~me=bN3TXY5KjLD?9efRbCUvzJ% zf)VJ-Uwv(6v1yN8{-q&yN4Eq{tllAUKNblvqtw?!sQxb&YibZ66YUsSU?mCwCdgkA zH|~6b$2#*&;?SRvu@h(21W1f6qK^BNnYs@frl!J?)6iZZg+!JYKFJRYQZC>HI zNT_6DmjoBRwL4jKB;o4wUg`;06afV{_UjT#$9 zD|hbpByL6{fvB6mrxi$yTD?CqZmJJCvY6)!HiUt}AAhO^=n;H>KuAfm5;UMZNUF%k z!#Eua4Wx51qM`jxD{9+o&azzO^dYi~GtH1@pfF4_)Zl6DsaLSIdaso>6X>_^u^)80 zS{CN{2R0+^k8E0c7^2+cXZ4+-C;~e=|0k}UvL3U#A7>QM2J)tOCbqUtB*v3Z$<-Y5 zw?8j&(z3m4dAT0=Y<`p+Z^%0jHCLP4E1llijPYxb@qPDdNgeS4P2{U!SZl-9mvfO-m!BR??pwuQ=juv{N6%_I)tFvy^{2^#Q%rsRLUdHVz8 zO#xQI*HyVM9$x=Y%Q+Xu=aCe|KiyHl9bI5jyxe|towdjnJ0WEs|E(l-@uRBc0!g93 z(XvEoAx`?d@YV!8&X1)RPh9vz5au(EZ*^J14O<3WoKWGhSHUD?6Fh^ z<<)=C9a3+PBHgu68Vf~neE2orkh^;K1wQ`xWp>c^MGtl3zqqpRy5JvxHW~vKy|2`E zp?F9{(E!l=_R`O9^(Bljdy?SvT@NsZgD`NZ5)GAYprUF&eEOl#y-sNo%*~lrpGBTSij{ zlDExlkU+-hK=ncLc>+nXjj??h>qR|+eu2mZJ)`~=zhZM_!I|PREr<~iC_$(+xGd1Z z#qtNgJhqBSdvax_S9jDJxrA{r!PA;i^sw`Xq&Frp=lnNDV-zuZUO85@rGcUcKiLP{ zXj69KoQDSw@d+|?dqUxtpak$Rc-OSYd}xmG>hh-Dt{j$Cp`J-Sal z5_^uWv*#gPh!?lls$v=r%kq#{zYBww|G{~t=W663~}Tb=SE@FOl=b{YNVUs6u<=HiH4{GFSG!N5wdi zpD*NYz^CTow85b*Q|>>dCf$SptQWJ8Sf*fl0C%;WdK8rBhOqH~mAvtWYm1(1Yco;) z2Lqp^vN55IM{)D+mIY zWzfUs!J*TryBHJ)miAtL=y9h7d}~ag9!4|TocE!kEykZ!)-0W#-3t7yZ7oCvi?61r zRS(E=s~lM_2^9qa)lvyj*!)B9?_i0fn%-Zg7lK>*q35F?ydrQeK<&%Buk2E~?G8CM z=WFlFa)-sV&Pe86_Ev17C!8#z-5XST#$m{xQ-yot222Ti)8-HL$?u+=o45PX`2S%_ zrA2x1?z+c_?6>CI?`UCx1g63DLlP9dBT;5$1(iH3iXFZ~HBw3Lrtqjo*1D$D>p1-5 zX3=H-$TdmZ!b11`hnoRrwA_9XP(v4^CvmKDAqxc(rG<5intc}rh45DP*V~j>wYo9e zA1p+t?d9`mJ0}cZgs8L&ptUgG=MV#|2iI@tkrWA)hUxS+1GK)P+MYMrp{l7bv2v(r zo$M8_D^gIN5(i;oE_iA(bD_tjPBn9Q$7=x&j0d?|Z9RWWe^x_#k)q9B5QX$a8r~uX zuY8TbUqk5d7vm`8iq<<6mTh_AvSzR&*9-i0=Ol$Q{Xl){{)iQe7Z`K|T8>au(c>WsyOMvAxP>g;h8x90AD z{6KTMGGkV;ywN@+`E(77ua$RV8R(3z8{OQsXr?g(-4Q~C8VmSv<7so>Bo`TrQ4-Ix zk|4d16ITrpkF`GU&7W$J-{ox+{>erXE^COI2e3#akhgg;D*6S`xK_q(GiS(^WW7 z9W-hSp+pDueLgClZUZ$^JfSW*`p)Wf5JB0*xR=8=A&Li0^{=fNvD}yjSWRd7s`W!4 z>xQqeJr*BR`O*)`;Lij!fcg(wkduIH*;N!%vZxINz0aWgY?EoE;Nl=MzFsk-U(;2# zuvFIBSbV(CaXI-gwzxw@1)?S6(cHVfS9E>rQ> z^O|1vbFkh5-1u^%hZHg5pVm~61l@m;x{0)=Pk5O%oQ{Gk8<0-{I^4f-x0U29)m)*% z9qmhIizN;@CQc~AJr7d?BpX-A>vepMq131b%4F#$%;xzEolxD{K8vC@CPGI{+Z6CdHd7(sZ^jxB*Kn;S|su<*otX7bP_t%Yt@mwzMf-e^| zcmcwjm;WUMkBSBECoh|CPBzdakzk#U6Nw@h9w9F?^I(VsEQ{I1n-dW1FL!k$OWT+* z{=rSJcxvyk11jmNemAV<#`VKIEuZXAUh{x8r~)de*HzIa9#+|#_6L-Ggq~8|b@WG? zsa}~;@QS}RY7lwZoEpsw%Iy5e=oM>2J5W;J;+>MpN~x64oGBI7x-m-vUXxk{)+bfiknZ_aVbbwT9A3ge(#8kP%~ zc%hlYSEn00tLH~^$Oa?f$&Gq?!Wq-29x7&&XgQ>-Ah4~7L8%988Y!PISzsqhiyl{AHpUJyc0Is!;y@xhCt!>X!WQR#{h-alg51Fn{?CnY<5S$(p%ny8mA`?4E6>`;Tp!hiycs zzTzHfikg3hlW&Tl4x3%pkLk7RN21)CRyqjctrF+2Xg7F#OB%ygl89{gisOT9J`No7 zeNf$_s}PI^6^5shV$p>B`F)FGrSCbQbM)XeJ*qYGH>PH*C9LkGC8TAotrX1f>vauO zbZIxs326M0U42F27Z`^U(Ui-;r`=$2L@hs8PB5sp?vyw%pViXS^Co;s#)N5PhrXA# zrlp(Q-C$Ge8z%q5`N4$^zv)@(q>Nrv(+`t8c_<&%bLyvwCpn~I6}~B}&g;(Cv1a&d zltfJA4N&Ew$0!A=6pWB3v)=qg-EDaY;d-HsA&4^IzqE%$3@056zTRL z8O|PkutQoBr6cmqO+M2r+U?DjyJdOX&w=hCZ7j}#)icX(Uw$HAx3h~vl~G*l4}X3y z+F`i391JeZ)%UEHK?CwqZ!9mFEz+v<5wX6T|E-VvlqEr)-HtQm6&60ffv1RK@P=yQ zx8J*RSDVJUqgh%}og=wai0v|0jT60pdhl3A=@;B%;q96=j>o@QsyQKL6(N1+Dw;H% z?l^SkKX_E6eAsCNs}rZ=>RO^y`dcp}=#l2hcZDCXJ zzL(Q+rDTwxdmoZ`Ha?oGe)cVKZX|nsooC@@J%K(R=drUlBj43B_%oB!LpN{Z89$R= zJ{||v)%AzF%bIPM2ALPUk(M+e59;asGDHB3ehjaV`A6Uyu41XbQ9!ZwZb!2a0M#o! zSHs>*D!IqxUaF@|ILJ@(6wz-5ue%_gCHY?_4)^IE3K*D(~4tqZ0% z!xtgOS5$=fipd4X<08*z(!3|kV(*AL$CsE4R9F5b(xbresLkq{|K(Fd(8}(%jO{7B zt_i35UnFJUAD;;^V^X0(ij<>hD0A}vQQ45*n10IuG>wAyNmW>Q4%Ya{oi>i+&RLd z&J}7jbcI~HYDA}hQ$Lc2PuDaMcj>160TsD_)yS3qRbeO*G!Y#Ol}cGV2(fX)7jCKF zl=ksuN>R%g!t^X1Yy7#1+me}tbm`>6%;LH3p-?k=${( z>(zNdQ=PjeCV%3i?baUt_XA8#e65uqd*Mu?oLH+GiYy3iMLpzaubAX_hOdhr z6=CBFbsjFtj~eyP+J?)82EylWMzkUi$j(c{JUf*Tv>tmBo0i1D-C-PG=Vcl-r4^qbc)*C-#aZDAai@e>5{aCLm9B=f?#3vAF0H^fMJmk$iPN~F93fO7m;s>8Qj6%d}xyPzYOF*v9itrVQ+K}v*fm@HveI4 z^11D|JKIBoo+D`$Vi^(@)D#3>eBImk~D`hV)d(f zI0q*<#%ZhWK#bD#T+1%kV~oy)`??bMju+naXhFNTaNHGYZ`TF$O?90Uv_#A8r>mM1 zy5v0s@QPQDTo~-;v1~H}(}-1)BT6eXzp@da9I@04iJuBkqpu-6n^%S#s>8opr5oqvsgY}ip5EySGc=8($Ikj_lsXz+pI(`hx z>-^%YAfyyv6!E1nKmSrX2WQz+Z3+x10G)X-W|))JQ?e?nF^ltgV{>37?FQVMm8e%w zLx7KuATm8(@$HhF;QO3TPZ6UIWl ze~+R&MF~7tzC{a|=kW!v?!C`hh!Q>87_a>1-Ju-%>UUO|m)BQgbjcgHSJxG~qBa^e zcr0tr>H-EujufAZf3>cWoJe4tQDfJkoNC%Pf zlKi%5lyiA4aX-^@ThT9TS1_Q=AXgjYr_5A$(qFQ@nCfCq<&LGwH0yupU~l94b(k9; z!ldTAx`?3_=e&DWfnWVtPJ40e#ao*)1YewBioL3T_{G1kP$+wGZ6o~l>Po?Z77f`S zDXUaYxBaR_IHp)jjk}cTVr3Bh7U|7 zg&6~S<`b5_t8^^_`3~YD=A=8h64?tMzdnAe2ti>YM7VuUEY^eD(iMwex^O3=kV?Gf zO93inVtj=$Cz6KPXrshdN9sv=?FnkLK;LqwKNLGsyQ-AL+F#O8rMtCIDPwm>r27p= zOpdcf{XyT{q^lDUrPR}Me9ebj<9`-f`w(rrE zEN4`xHTKN(-t2tj>f4_Yr^e0sKtC5X)VqL>Ye(hEH%}$nIKO~M_FWW{>L`(pduO1l zq87K1t*3PCz5Cks*~&TfU7lEcw@0t)fgI&s9Zo`8hzw5oyBAHbm>d|w+>=*@k~}|B zQ{CX3b74*xERDcCbx(Pw4IH|CExq!Hv;ulRFYw}ILMO<4gpFDi!{!|N1lEs_y8mi|6A*g zN{tO5hAX<0`t+XE3=j)x==R~8wZ4?#l`_jF65V&;?>nCwtoNuwbJd`5;0f}mt&$WD z2SIjHAcaBm767XF#c`BNWR0FR8!8)+FHZ6n1`4*H7U~7^EJ`mU_MWg<81P4+@)w&; zA?U?F10$IX(B9h`{pNXSKllNw@|`SUvC1(2^1pNl@QWA{=8VCXua9z%zD$17luylh zH81u_i1(KT!v1bXUP*_0!5nzRuG|w*RA*Mn@4Gc&czBPuS z(>L|`Etv|a7yZBgX)XP0-i2AH9H=_-dg_itu6p(KqzR($!_x8l_@Vtzhu{BK?;g;x znExx2?)em=fHR4L7k)l38B!SOr)2N{d%K~RHtU{KG{?)QLO7>kq9Ne12Wfr*N(8Wr zX#Ac{JTp?lS_(^J!6{wF1Qz|7*{q25YQ2V*N80gMnj)ONRcd z4i{`C2l)1XCmCqdY{t_xeBuPB|G#aT-jA<%!!KXqm{lag0Dn?qa-t=|20s4}bU^xH diff --git a/shopping.png b/shopping.png deleted file mode 100644 index 6ef672f5f9b500242c3cf915dafc8d3ba40e84ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12840 zcmeHuc{r49*!RtZWGg+9h>{_DQ6!?0FhgqWI~hs|S+W~SRMue-vOQU|hKKA^3S+X3 z7P4p0Hul|o*RAJy-}m{x<2&AezvKAcKQhOC-RE`Q*L7akd7i&>>G{nY>TCy&9e^N+ zO;h6<27(xFLJFgu*y|2msbe)Akjp3+2;=)?nV(gzz-YeIvoV1U7=S259c(7m>?*C zk$D?Dbesqj06)is{%6wvQ-U}{#>v}qLQpZ!54R!A)orrN1qd2C>^6E?D68m%2sp9< zjZ^G{Qt8`STD79OPAz&6WaYQ%v~Hm}Y$G$mpwJPd1+JgL>)GIz1cV*n9bJ$Mv6}t$oYnToJKJYNM#p+s|OiHDD(b^*E1&()yFVmJYXa) zts%G(skMgb4>L26)(1Ee5@lqT@g=Aavo{dQf9#QT z;5&`nla+4;kw7wxZ0BYyD9+Vh7b--+O(&i@*HP^B{DT^*l{9-q6zIm|t5 zxE8g#leL`0%LNlK`T>HHB3J>#I^`Rrkn8@I%dHQ{K<%6(vv?kf<{H9^D10~3IzHN) z0jR6h<9`q1IK3*ky=lAKYZGghat1L;@f&ntWyfV_bQb3ppRWzhr@sBDtk}e|ZR+MJ zrmli3WrK(n9cLSM3EPhdv!C<=RYVtt+UMubHVN#C$c$X@ip#_?Ml~GRmW7pn5Y@!G zrMuXBtDIYwbvrvvd1WCs=}9Q5Ri10T+NiE^(On(hNL?h6<2PA+l-|*ef;u8iZo`Ke zs7t`u{_SEFWc_hlpR*Oa8MMJ%O6$uV?w!!=Za#N%Ag#uGqI&-R&ZGJOoIlM%YRvw9 zV}vfvIn8_j6D5_Li4#Ds#P5gJt>aNarV7;WZjIzPS23?_cK4#(|m*WP$h+t94Bay9;Hj94V^nuiyr z^7A2{-TeHYnO(Q{gHxypCvsHl3HIG8w_IJDIJm!Ep|&kkRX;jR>gKmwWhHK(KU+6p z8)I4PCq(FX4ulPQ2z8!%4^N5HRzHfh?<7J)&l9`5J~5 zuJczgiY~kq5AjmbER}oZ{Oavp%4g#@yzQ%DL=~}^IN4fZzg1-^jh%gAyjbJR1_^Hc%8Xl%W?%V=$fQLCk<;})K`oxMxONg+O=`o?

xvJxqg))u90|)nJRBX0jeA^G$v)Sf=w{* z4zecRa{%Xy|Ee=Kk{S|!ZZMMLI%+Im%WSfpRISU0^|4hjMk2cGZrF@eO{|yk*(xZ^ zmAd=^4Q)*#tPWFN)}LUyXX3b`Dz7+E(?1s8!dfoYZeKpLYG0YyQ^E^TkNeJt^lLOI z3(F?Pnf8yijjR6FSxfrLEox43##20+ zFRfwBO(K*}#+bxcCr4>Qm&JWOLc&o9Ww%@P0}dF+B8}Wz@Ema-Da^gAj=Ax_uDW!b zO<3@Aq1nhFpl+4H@7AsqHxAqUW38)3nP)3&i%2IcoXUA?quwTyTbD6@+7a%^1|vb} zZsPo8vE%uqMSVEu3m zMcq*5jIgZmI5uCye!@jo4W%SLZIt1LY^c>!5#sJduViV>X13ffNd#^rAeq|At9)v9 z>1Jai_Bx&t%gQY}YvA}=<9V!YrBAK}iMrX2%$~};crwO2w z!dv@bQUF5tMOctRGNz&LIqp;L?~R7{)%FJK`>G`sDyVSH&{BXO%XPfan`Zp7VVGe z`P*5>7PPn~`eR^;ohrE_{Z%ki5c!SpmlTE`lKU+0U}Ro3f?^yeDYwsk)%@*mdrFna z>0#yxvfeJ{Gh#JY3~FHhVuJK81Jg3+=s;wnV?{O zh~`h@V_ye8rkttjy-%Y@Tis!G<#!&`;gqJHuBK!72HJM(>R{^hleR~Ff5me`#hP{c z4Pq1)4%?YSJxfmuFK+z<4C-_S0-9`TPu(g#4cP0#Iz0N4QWo&Kk=Ug|HzgzGV`r5p ze+JTq-g)33KvprndBIOJS->8jl(^z4;2xnEmBr#QB*;>t=mW3@uAEQiQD;(ae2MRi zZS-ZRj}-inh%>@Yq?ezKKDf)(@dO^On$I4MZU|Y5*s_>aP^7Niky6~=aP7Mb+g{9WpmWH`Ay*#ije!=20yl)@h)L_HR zi304)O|w^oyR?>R$Pc5V>!JTvD8QlsxA8O~!d;VN8ck zO6t}SQ-IUx);T2!ZAT=+Cr;5=`vyXO%)K&t*y4>Es=d1HEB9uzGACKxY~QZ2ah0M= z)}!yP2e$hc-tasjuWu+MXXL3IS#STY)cdf)0_fE0x-uJwhL0(*3ocI5FXJ^cQ1;uPIYc0OY14q7{jra?y}F~7;g->x6@I()r3Hm4exjJ zg!gB4LUJSJy}rrheyJ9<-K_MCW4WlebjxWpZ4KKFkmBAgR-}A2kb!C>QuSh4Kf{)4 zU`SBPQuKLs>N)B8$m2_Ytlyt-7>IPoQB>~9P_wD|F4TXt6JzotJ&X?BJfV-L096Nn z=AN#Vy55*uE_$?#KH}!Hu+yB-7Gwaw2AwtpqWIcQQu^#f$uUPM(8+rD?~cl z*OCNvl=*&$B!v|bknf_cAuF1%<%D=fcmWn#KejQN8l_o4?!VD21f?CRtL}PN_7*sb zK`~2~EL#h47sD{RUoBm$Cd<|gbkyCWb=9n;G!lu>Y~ z#Sy**8)aqySRbvW--=7Ah^7nRAaTDQ8+`{s9F*(DhW0@~^u=r&KlCyHGpS9ERgqfY zXQ1+vmPv5%_+kb71b7L^ zjRX2HE5^Ip-En1~|7N8R1YgW^?2mFmNmsB%-WX{N>~pp-jT}^5z&=PPvF>ws$T) zhW@CG$EFkeB~W~JhGCSR)61$-!pAgvECVdjOfT^Ge3 z7?~sj8ib-m;W4y6yr<)o76&yG^3&0@)R^g`f4_iNxRsH#@vy+iVr@;f8Hjh zRT`UDHJ?p*TlZ=ncn`?v4~sGF z){o>*8Mu6`)sjnPEUOvG8SJk&uE-dUc@wjyjIWzCTfC``M$c#dK>r0+`+)pCAKr^e z_Pm$=W)q6>(P{ac31aj!SL+=1ZVP)=YJA4inanEJ$^_XY0K4(1V8B=AiEZYH)Yyf{Z zUFv%7e4c^#T9?u|NjHTICDdJatkz(DCz^W3M#cuD7r@`+3hH=@cES&EwF0jCoHP6Z z0IzgRk~D_Ca5M(1WjBM8^3$@D5DQ6pNc{{aC<0R0?c>T~)KHe9=$je)mKQ4@A{!Lr zlYnPJjy{u(NbrJ1f0QE98l8nPwHLM0QWg)E`Sz-B;AW#m6yk_zI4KNX)Vn|RtE9DU z@f2?I)jvevbCX3HZZ-nwf4rp|Aeba3QW&h^S{-NlY4~P^9YHuZc^L**`WT>$v`+yIL>lc3X*$7Uw%ylaC;~8~B zf77JaY{s(s)=H=&5o_2-cnpjtK}O`tk{kM%mgM+LiSSRuNu!zbnJ6T>3r4`TiLdU# zZ0x$O_D9R1 zj!h~ts?{sPzDtb?M;S6fL(JZ}n)Y&kC3Tftj(e6hCOMzk!fIS%@g|maS+ys}%^iYL zUMD9K{B@fYBw4V}?;2Vx2qO6jW8!f5074b0=Cba2QS%9|t+sj<+RoaNJg)$Ofs)vj zQ!@wvJTlZMx^fh`{La+&wez_P?sy^DH|B4m520hb>Q_nAg{QN0}gn3c2L+QGlL*+8TEN z-GGQL%SI!VKu1yP;5P5>@Unc1jQuxzje#jaBv-WU@fcvWCDbF&OC8T4;&kFPOK*rT zUgZ{jnO$n4o~Bsm#XAE;Cu`7MqHL_Q1Fx z(jW>cRVXg+7DETU)TEu0>K}`vrNn}$BkPAl49E0WW$Mv!TjP)KG?slvfS}mX-prd6TSYRiFD}B_;#QV`W68W% z-BVf9q=w3uAe#e6MEtYNc!UyE_$Ana_F;F`X+4rx9`~N6U@W|IQ89k4J89d(*p18% z6|+D1ma&{J?)GO>4Q_#DD=Cm>gDb-6aA}mb?e2ZrkgFfWulcG;=SBS{eRL?|R+b;g| z{~(jZYzC!eC{bJ`?<71%>ZDW_DFx~_1LpouFW;)I@+7oy6&6~-SH@QBQ6yv;NPIMwmk#5K!?!wr_s+YUf{rV1*%_*(-^gbsMR$ zR#}N2Fn?L7!vE{~3w(}wgg(=*NG-Y;toYldF!Y z(?ca|5U%WrNV?$eKL#&l?19Co-&~37bBdp1A!>zsQ+}g8HM*v#iA+61rA_NlyB@@; z8u~oS{&m|Y!RrUIl6I~#$qVh??LMkhmjO1a{p38l>efz9W}1RmI=nnPk;r!D?dN?> z{Z+M6cZ70)xH-1_i`KSA?rfD=MtB-rZ?TRLNLD_o%SirI)4C9}clgg3@5i~l{>Ppx z#&df=H>@J}G+5?+KUu%Kp25nn!()`coyp@JvSRH=)8u0F5^vfBJ>_Jmq`ygEh=kz{osf zIYW7bL$2`khC-Z(laB4ym7NO}w3XdY?Af|{E7n8p&r1~es=u_F%MNlJZ~um7h60}6 zE#{9YFVmP}84WJN9(^Pwy&PKPrrF|mQ~BwyxhGODEOEX^27DS)83?2&J5q>^p;4y( zGR%eJztZ>${t#~K)u~t7^^Uj$hdr>><3PKbz~1>+kk;c%W8|sj*nVr+KDyLJ7xW zlV-xXII1qr=ndF7Es9{LB$XlJfn_5dR4Dk)t3C@n28oDeC9;npSC7^IhbdX9IR~Oa zHd6SWTeWyoEbsNCwqZV2tzrg(raSCvg=+6ff89$)CC7Pz`TnE*l9=1J#&d9To-4D} zTmJ`eeJ}5aFim>^Ab*bKt53wew zV$(wjz+EKXxPR8(T%4!7#tg)%I;4|gJXWQP0@2kw0?(@-P%UvjTDztX=eOpG{WlAR zFt-_uf5KljNb4~%^6o}4%8AAsk%(lMcNT9PVu+Ta+^&QNz|xmDLy&lvlcaR=Of0L@ zWvNM2Fn9D51DVTDjKK&I29mw00~Y*>L)7LFzWC!CiDF4zTGD-m++h{ zq!KPrlPEqW`MrwL9YG4KXch%2;6#@!6l3?Z_o>UN@{66FXTl8;Ot$&#+wsi1o2f^S z@@-tCW@D6AWP`qs&44tO1d9pm1`^%OouY+3OvWXJn1Cpq2!{=2h)ryqUiAyv>?;#W z%B)-Jz?NTZGnCocTo)j1E4WMRTSR3_fK-!}?Xe;cbc3Smqn9TYL0qdW#C?kdrJm z3jsnEI7yB4W49w#Z$6eVhT+VB8dJIX6#h;#yH8AB5jH?RNnl;pD08D;MIR%8-Sodv z-#$dm9^r`Wc1mWa$&Ho4*RWQvQZy8fMFQk0K?~NJV8AQ;;|xz={eejl!$2Bg{ScIW;O>5h+!*V)ETk`tO@Koks>S9RW$A>pXu5$BJP~(p|CqVo!S!i9 z+-dXUZ(Fuia9iO^3wgtTUR-J#i}udNkSNO-2Dol#qEbk_a#8O|2*tl|Xi}8TKuNTA*@uXG|NkPQysn6Xx*Fr4b zP~X+4s-eiFhaocGfG&ez6Y6H%;pvTK1?TfQW-Ti^Fmr5DmFNBqN03B?gFUJ60(1(f zD`$W4ig%oyzw0;zuO~U0xtKQ`YGg|cO()ve#v{iT3=E!3Q7)Kvx+44h>VtSwr zj#C-z;Q@KeTgR?QLZn)x6nyPuE1ys71q%Ae>ItV=kmM_MA;5Wb$R{h$rioKqjAw}D z+|tKt-k!&12O+4SWB9EPvv@3PM~>3CU}pK~fI%EUQXNv41j03*O=Y4?7u|qB=_`k` zM*+DnPxy&hjd!`&0O8Se0~snvRU06n0CDeYCNaxh=-3_dVM)wYV8N^s`SFZM2-t;I zlK31FK-(AmcsnE`7+@ojXIB{a1{#s9E10JSqphos2*_D2Qe!JR1ndad^4Wsl6i#@( zFX$t{ESDJ`+xt$P#^YN^gm2=Vg|azql$|HYXKM&$h&@=F@?AL_G)}mK^9oGB%8h>5Nk{Z|B}y$+M4H7H{siBsjKw0cjBJ zgw4dvh=$OrJKj;isZUNF8kQjCMhB{mbsUzlKdAr?)Z1(|^VpFKkv72nu4&ZaPp9~8Aea~>z%RFAiAl3<$u~n z78{aOjlC|d|F=a1d;O5HFBiqgkG~WmvwEwNkRH}g$nA=e?L)`9V`B?s_jc~A{uA)= zD$zkAlJMj=SgWhT{jcJ91Sd_g1qDEmKse5pocc(Fye)7J+AT-}8E0gJywk+$Y4R`r zrYisure&)KRYvED@qkd>;!RRKc{bC86yQ*a^b+C+{TYA*HQ*Y^35fAbW>y`poV0jT zt7l7YZC;{YgP^0YwSz*CHY*rO5Uu=3@4JkroG~4Ljgk+MC;u|VK~Uq}!^4`ICZF_d z>s@$1xsP3y4_qT7sQZ6Uoj^LozKf0Y?hi62C-)I@eKq)>FaZrZ`an?P)cd@>BE?~u z=aDT9R8Y%@KgJ;BegrO%oD-H^&rxEH1UL2Uk84JkF@~;{;vVN!9}U%(Y<>fERxs+R zFKCFzsJhrJVFd<|(~e^xRs}2!kuI%l<~W?p&S?Am;NV_NwRT~9eyu%q5NA8yX)Rlt zW%3@>&&eknnJ%oxnaa+^2qr={`UpvG3?@KyY7Ff zo)zG8m)-o(9LV)8dE!K`gX({>6T?sAJM`7o&KlC~E_19-SVGRun`>JIG~V4gC8i!b z*+na*W4}e9|J;ltxKL{8yZz2$`-)t?<3NXu>l~u-D-_f0#OGK>*jHMhp+G zMewf2O7`HmN2mZ8kT*ooXAkyd}WI_Z4wU zMcBwdVe?jbPqY%R4hTK}zB+i!VHdO-%0V+FJp1=&e&0Tti^}4t!PtW5Ww;+f_=5~* z%?rXKDS6$DkBy`MF?u_?7L1Bl+{*a4I?C*I{WoniXFV7NU@POJ@YqQ&5bnSnK136} zbLXx}RmF>$#!ifC(m`jgC+#Pr_fKb5c~$lSWMsr28^W-+)qFvP{OG`f7X4L>ZSP{4 zlJuUatkpDaVp$zD3-jZ}e4_4*=l*6fjXDA9EPLr7e%?6sG3(#M^HD}}gtrysDa$Ct zg1r}i3Q#=wA}cfBF_ft(dF23%qCjlO@I%lN0v0kK_e}0&OkB)JMCH-h@$Yc4&|(27 z#)1auM#!YTt5?wxNbg;#Pp$76$aG;*hb`URD&Ej*Ll2;SBL#@d!JCnS3v z-+oIKdRh1O=@Y$&WpY9JC15^{hKPvXA4*7B+&uI$*YwvD2T+oL@n>By*TH9_ACUC4 zE9J)8T;ATfvSu)tmhWVs$KO3obs~j-nh9nvxkT7&FRBZ>e(-{+n81OA&`ExEkxUdL z+&5pUypnwxUks#=Oh&K%#YQ`6*F^IVbX$LH;B2c`<-| z6#Pz7H8pc&ew`}8)`p_wL2FT2Fi`}Vv5FZ>$^Rb93cL%E!`JN3dq_kd;S-#Mh7Pa^ zQoWe-V_DBgik}DNd+6YL;H-unC#MQqYqpBJwz?0p3OVNr2}CLR0q`e!r)m%U zaa`gfZV6oiO%UxQcP%pTL~=UQj5CzF=sVo8*;vZz=%z3h9GYpS4dRh#y6e(gSwjV3 z+0_$jBhkY6c{4rFU)V6)9XQke&`^iVO| zrmR&H=Q#inqs%_uY&0P#?sdGSX2~K}B}Gf)fAx+ngM4a8A6yxMd?Qj=?_R--hq&0a zf!;THQt}?^4!PSL@Tf)w`-oH?7YL*PcV`AvbiJTc5`A7CFJ=JRRCt%Ip>~b9*-Vu5 zG(fg{0S29=_51Fg;o+=^=5Uhjp(MTnQF$w8$tpZ*S%2EuH2^N{nSy zI<2?{AC(~-;22~r(ATN`v_m46u&H~XQ5+7)w5z0ss+G7eRM%bcKVmqR*F5T)3FGSYld<9pfPJR7cS5V`ysPmlr)ht8V!8Jy!fDxVKh zxf?#?cz(7EBWTBgdA(d+W&qt`PEO_6o(R7pj8mefjz3D8;PG$ZfI2P~93dKCoe-v{ zHJ5`nLZYvUctB}TTLH)uSUUjH!IOY>8G4VkamMnEQ-QcizI6`fdiLp40K`>H7w`zU z*KEUSts1TS3}>SHD#wVHtRm)&yN*6_Y}?T)hJwJFOQ1Z!yU9utad2WMkD2FPY=5{Q@0}0Zy;0>5pnGOJHtm8&AVW z9hX)Oj(S-X_wS=F(|8VW{$A$g86%6;HJO}0s!H-p+!;YXDnEF>eHYIOYSVjZ557xW z#CJlsjNQ%~TZ*&732N{h)G3IJi;3O4rni1b1Za{#=1=0}{k2s9D5oARMPXZ%zbJ7EZa<2p^KGkxrsK>W`CDbfZA7d_|qv# zY=C;5m~kRp2C4~VXC2aHE~(XfD+3CwX&eYo3rKWDkqHMrZv)z5c#*6^-RT%f&L~Cl`$B*YDkVj-`jWVMf@C!?tg49$0R Date: Mon, 17 Jul 2017 23:37:15 +0800 Subject: [PATCH 18/81] =?UTF-8?q?Builder=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coderising/myood/builder/TagBuilder.java | 37 +++++++++ .../myood/builder/TagBuilderTest.java | 45 ++++++++++ .../com/coderising/myood/builder/TagNode.java | 83 +++++++++++++++++++ .../coderising/myood/builder/tagExample.xml | 9 ++ 4 files changed, 174 insertions(+) create mode 100644 students/812350401/src/main/java/com/coderising/myood/builder/TagBuilder.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/builder/TagBuilderTest.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/builder/TagNode.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/builder/tagExample.xml diff --git a/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilder.java b/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilder.java new file mode 100644 index 0000000000..11c5792908 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilder.java @@ -0,0 +1,37 @@ +package com.coderising.myood.builder; + +public class TagBuilder { + private TagNode rootNode; + private TagNode tagNode; + private TagNode parentTagNode; + public TagBuilder(String rootTagName){ + tagNode = new TagNode(rootTagName); + rootNode = tagNode; + } + + public TagBuilder addChild(String childTagName){ + TagNode newTagNode = new TagNode(childTagName); + tagNode.add(newTagNode); + parentTagNode = tagNode; + tagNode = newTagNode; + return this; + } + public TagBuilder addSibling(String siblingTagName){ + TagNode newTagNode = new TagNode(siblingTagName); + parentTagNode.add(newTagNode); + tagNode = newTagNode; + return this; + + } + public TagBuilder setAttribute(String name, String value){ + tagNode.setAttribute(name, value); + return this; + } + public TagBuilder setText(String value){ + tagNode.setValue(value); + return this; + } + public String toXML(){ + return rootNode.toXML(); + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilderTest.java b/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilderTest.java new file mode 100644 index 0000000000..cb80841992 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilderTest.java @@ -0,0 +1,45 @@ +package com.coderising.myood.builder; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class TagBuilderTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testToXML() { + + TagBuilder builder = new TagBuilder("order"); + + String xml = builder.addChild("line-items") + .addChild("line-item").setAttribute("pid", "P3677").setAttribute("qty", "3") + .addSibling("line-item").setAttribute("pid", "P9877").setAttribute("qty", "10") + .addSibling("line-item").setAttribute("pid", "P4455").setAttribute("qty", "12") + .addChild("child-line-item").setAttribute("pid", "P3333").setAttribute("qty", "15") + .toXML(); + + String expected = "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""; + + System.out.println(xml); + assertEquals(expected, xml); + } + +} diff --git a/students/812350401/src/main/java/com/coderising/myood/builder/TagNode.java b/students/812350401/src/main/java/com/coderising/myood/builder/TagNode.java new file mode 100644 index 0000000000..a9bb180a30 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/builder/TagNode.java @@ -0,0 +1,83 @@ +package com.coderising.myood.builder; + +import java.util.ArrayList; +import java.util.List; + +public class TagNode { + private String tagName; + private String tagValue; + private List children = new ArrayList<>(); + private List attributes = new ArrayList<>(); + + public TagNode(String name){ + this.tagName = name; + } + public void add(TagNode child){ + this.children.add(child); + } + public void setAttribute(String name, String value) { + Attribute attr = findAttribute(name); + if(attr != null){ + attr.value = value; + return; + } + + attributes.add(new Attribute(name,value)); + } + private Attribute findAttribute(String name){ + for(Attribute attr : attributes){ + if(attr.name.equals(name)){ + return attr; + } + } + return null; + } + public void setValue(String value) { + this.tagValue = value; + + } + public String getTagName() { + return tagName; + } + public List getChildren() { + return children; + } + + private static class Attribute{ + public Attribute(String name, String value) { + this.name = name; + this.value = value; + } + String name; + String value; + + } + public String toXML(){ + return toXML(this); + } + private String toXML(TagNode node){ + StringBuilder buffer = new StringBuilder(); + buffer.append("<").append(node.tagName); + if(node.attributes.size()> 0){ + for(int i=0;i"); + return buffer.toString(); + } + buffer.append(">"); + for(TagNode childNode : node.children){ + buffer.append(toXML(childNode)); // 递归 + } + buffer.append(""); + + + return buffer.toString(); + } + private String toXML(Attribute attr){ + return attr.name+"=\""+attr.value + "\""; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/builder/tagExample.xml b/students/812350401/src/main/java/com/coderising/myood/builder/tagExample.xml new file mode 100644 index 0000000000..839e62ddee --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/builder/tagExample.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file From d20ea1984670ad243c0cea82be024162f6ebac28 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Tue, 18 Jul 2017 22:34:24 +0800 Subject: [PATCH 19/81] =?UTF-8?q?=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE?= =?UTF-8?q?=E5=BC=8Finit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myknowledgepoint/regex/Utils.java | 27 ++ .../myknowledgepoint/regex/UtilsTest.java | 316 ++++++++++++++++++ .../coderising/myood/builder/TagBuilder.java | 2 +- students/812350401/src/main/resource/01.txt | 2 + students/812350401/src/main/resource/07.txt | 5 + 5 files changed, 351 insertions(+), 1 deletion(-) create mode 100644 students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/Utils.java create mode 100644 students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java create mode 100644 students/812350401/src/main/resource/01.txt create mode 100644 students/812350401/src/main/resource/07.txt diff --git a/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/Utils.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/Utils.java new file mode 100644 index 0000000000..b4c8bbddfc --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/Utils.java @@ -0,0 +1,27 @@ +package com.coderising.myknowledgepoint.regex; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class Utils { + + public static String readAllFromResouce(String resourceName) { + byte[] fileContentBytes; + try { + Path path = Paths.get(ClassLoader.getSystemResource(resourceName).toURI()); + fileContentBytes = Files.readAllBytes(path); + String fileContentStr = new String(fileContentBytes, StandardCharsets.UTF_8); + + return fileContentStr; + } catch (IOException | URISyntaxException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return ""; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java new file mode 100644 index 0000000000..4b5c53b5a9 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java @@ -0,0 +1,316 @@ +package com.coderising.myknowledgepoint.regex; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.Test; + +// http://www.cnblogs.com/playing/archive/2011/03/15/1984943.html + +public class UtilsTest { + + /** + * 多行模式-1 + */ + @Test + public void test01_01() { + String t1 = Utils.readAllFromResouce("01.txt"); + + // 默认 单行模式 + Pattern p1 = Pattern.compile("^def$"); + Matcher m1 = p1.matcher(t1); + + if (m1.find()) { + System.out.println("found!"); + } else { + System.out.println("not found!"); + } + } + + /** + *

+	 * 多行模式-2 
+	 *  (?m)		Pattern.MULTILINE
+	 * 
+ */ + @Test + public void test01_02() { + String t1 = Utils.readAllFromResouce("01.txt"); + + // 多行模式 写法一 + // Pattern p1 = Pattern.compile("(?m)^def$"); + // 多行模式 写法二 + Pattern p1 = Pattern.compile("^def$", Pattern.MULTILINE); + + Matcher m1 = p1.matcher(t1); + + if (m1.find()) { + System.out.println("found!"); + } else { + System.out.println("not found!"); + } + } + + /** + * flag设定和(?X)的等价关系 + * + *
+	 *  (?m)		Pattern.MULTILINE
+	 *  (?i)		Pattern.CASE_INSENSITIVE
+	 *  (?u)		Pattern.UNICODE_CASE
+	 *  (?s)		Pattern.DOTALL
+	 *  (?d)		Pattern.UNIX_LINES
+	 *  (?x)		Pattern.COMMENTS
+	 * 
+ */ + + /** + *
+	 * ascii大小写
+	 *  (?i)		Pattern.CASE_INSENSITIVE
+	 * 
+ */ + @Test + public void test02_01() { + String t1 = "abc AbC aCd abc ABc 2343"; + String r1 = "abc"; + + // 默认 区分大小写 + // Pattern p1 = Pattern.compile(r1); + + // 忽略ascii大小,写法一 + Pattern p1 = Pattern.compile("(?i)abc"); + + // 忽略ascii大小,写法而 + // Pattern p1 = Pattern.compile(r1, Pattern.CASE_INSENSITIVE ); + + Matcher m1 = p1.matcher(t1); + + while (m1.find()) { + System.out.println(m1.group()); + } + } + + /** + *
+	 * unicode大小写
+	 *  (?u)		Pattern.UNICODE_CASE
+	 * 
+ */ + @Test + public void test03_01() { + String t1 = "abc AbC aCd abc ABc 2343"; + String r1 = "abc";// 日文输入法下,全角abc,也就是宽字体 + + // 默认 区分大小写只适用于ascii + // Pattern p1 = Pattern.compile((?i)abc); + + // 忽略ascii大小,写法一 + Pattern p1 = Pattern.compile("(?iu)abc"); + + // 忽略ascii大小,写法而 + // Pattern p1 = Pattern.compile(r1, Pattern.UNICODE_CASE); + + Matcher m1 = p1.matcher(t1); + + while (m1.find()) { + System.out.println(m1.group()); + } + } + + /** 通过设定标志位忽略大小写 */ + @Test + public void test03_02() { + String t1 = "abc AbC aCd\nABCD 2343"; + String r1 = "(?i)(?m)abc"; + Pattern p1 = Pattern.compile(r1); + Matcher m1 = p1.matcher(t1); + + while (m1.find()) { + System.out.println(m1.group()); + } + } + + @Test + public void test04_01_dotall() { + Pattern p = null; + Matcher m = null; + + String text1 = "width height"; + String text2 = "width\nheight"; + // Pattern p = Pattern.compile("(?s)width.height"); + p = Pattern.compile("width.height", Pattern.DOTALL); + + m = p.matcher(text1); + boolean result1 = m.find(); + if (result1) { + System.out.println("text1 found"); + } else { + System.out.println("text1 not found"); + } + + m = p.matcher(text2); + boolean result2 = m.find(); + if (result2) { + System.out.println("text2 found"); + } else { + System.out.println("text2 not found"); + } + } + + /** + * group + * + *
+	 * group(0):正则表达式的匹配值 
+	 * group(1):第一个子串
+	 * 
+ */ + @Test + public void test05_01() { + Pattern p = Pattern.compile("([a-z]+)-(\\d+)"); + Matcher m = p.matcher("type x-235, type y-3, type zw-465"); + + while (m.find()) { + for (int i = 0; i < m.groupCount() + 1; i++) { + System.out.println("group(" + i + ")=" + m.group(i)); + } + System.out.println("---------------------"); + } + } + + /** + * 字符串分割的例子 + */ + @Test + public void test05_02() { + String abc = "a///b/c"; + + // 分割后的数组中包含空字符 + String[] array1 = abc.split("/"); + for (String str : array1) { + System.out.println(str); + } + + System.out.println("---------------------"); + + // 分割后的数组中取出了空字符 + String[] array2 = abc.split("/+"); + for (String str : array2) { + System.out.println(str); + } + } + + /** + * 替换 + */ + @Test + public void test06_01() { + String str = "Orange is 100yuan, Banana is 180 yuan."; + String regex = "\\d+\\s*yuan"; + Pattern p = Pattern.compile(regex); + + Matcher m = p.matcher(str); + System.out.println(m.find()); + String result = m.replaceFirst("_$0_"); + + System.out.println(result); + } + + /** + * 替换 + */ + @Test + public void test06_02() { + String str = "Orange is 100yuan, Banana is 180 yuan."; + String regex = "(\\d)\\s*(yuan)"; + + Pattern p = Pattern.compile(regex); + Matcher m = p.matcher(str); + + String result = m.replaceAll("$2_$1"); + + System.out.println(result); + } + + /** + * 命名分组,替换 + */ + @Test + public void test06_03() { + String pathfFilename = "aa/notepad.exe"; + + String regex = "^.+/(?.+)$"; + String replacement = "${filename}"; + + String filename = pathfFilename.replaceFirst(regex, replacement); + System.out.println(filename); + } + + /** + * 从文本中读取多行数据后,建议先把回车符删掉 + */ + @Test + public void test07_01() { + String t1 = Utils.readAllFromResouce("07.txt"); + System.out.println("--orignal text start--"); + System.out.print(t1); + System.out.println("--orignal text end --"); + + // 统一换行符 + String ret1 = t1.replaceAll("(\r\n)|\r", "\n"); + System.out.println("--统一换行符 start--"); + System.out.print(ret1); + System.out.println("--统一换行符 end --"); + + // 行单位前后trim + String ret2 = ret1.replaceAll("(?m)^\\s*(.*?)\\s*$", "$1"); + System.out.println("--行单位前后trim start--"); + System.out.println(ret2); + System.out.println("--行单位前后trim end --"); + + assertFalse(ret2.equals(t1)); + } + + @Test + public void test01_04_Zz() { + Pattern p = null; + Matcher m = null; + boolean result1 = false; + boolean result2 = false; + boolean result3 = false; + + String text1 = "abc def"; + String text2 = "def abc"; + String text3 = "def abc\n"; + + p = Pattern.compile("abc\\z"); + + m = p.matcher(text1); + result1 = m.find(); + + m = p.matcher(text2); + result2 = m.find(); + + m = p.matcher(text3); + result3 = m.find(); + + p = Pattern.compile("abc\\Z"); + + m = p.matcher(text1); + result1 = m.find(); + + m = p.matcher(text2); + result2 = m.find(); + + m = p.matcher(text3); + result3 = m.find(); + + assertFalse(result1); + assertTrue(result2); + assertTrue(result3); + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilder.java b/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilder.java index 11c5792908..ebfe9fe12b 100644 --- a/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilder.java +++ b/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilder.java @@ -12,7 +12,7 @@ public TagBuilder(String rootTagName){ public TagBuilder addChild(String childTagName){ TagNode newTagNode = new TagNode(childTagName); tagNode.add(newTagNode); - parentTagNode = tagNode; + parentTagNode = tagNode; tagNode = newTagNode; return this; } diff --git a/students/812350401/src/main/resource/01.txt b/students/812350401/src/main/resource/01.txt new file mode 100644 index 0000000000..5f5521fae2 --- /dev/null +++ b/students/812350401/src/main/resource/01.txt @@ -0,0 +1,2 @@ +abc +def diff --git a/students/812350401/src/main/resource/07.txt b/students/812350401/src/main/resource/07.txt new file mode 100644 index 0000000000..be72da22ea --- /dev/null +++ b/students/812350401/src/main/resource/07.txt @@ -0,0 +1,5 @@ + abc +def + +gh + From 27b07bef810972637d484d60817b15bc6f1c317c Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Tue, 18 Jul 2017 23:42:39 +0800 Subject: [PATCH 20/81] =?UTF-8?q?regex=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myknowledgepoint/regex/UtilsTest.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java index 4b5c53b5a9..7fc9d6de0b 100644 --- a/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java @@ -111,7 +111,7 @@ public void test03_01() { // 忽略ascii大小,写法一 Pattern p1 = Pattern.compile("(?iu)abc"); - // 忽略ascii大小,写法而 + // 忽略ascii大小,写法二 // Pattern p1 = Pattern.compile(r1, Pattern.UNICODE_CASE); Matcher m1 = p1.matcher(t1); @@ -142,7 +142,7 @@ public void test04_01_dotall() { String text1 = "width height"; String text2 = "width\nheight"; // Pattern p = Pattern.compile("(?s)width.height"); - p = Pattern.compile("width.height", Pattern.DOTALL); + p = Pattern.compile("width.height", Pattern.DOTALL); // 让.也能匹配换行符 m = p.matcher(text1); boolean result1 = m.find(); @@ -190,7 +190,7 @@ public void test05_02() { String abc = "a///b/c"; // 分割后的数组中包含空字符 - String[] array1 = abc.split("/"); + String[] array1 = abc.split("/"); // 可以直接写正则 for (String str : array1) { System.out.println(str); } @@ -198,7 +198,7 @@ public void test05_02() { System.out.println("---------------------"); // 分割后的数组中取出了空字符 - String[] array2 = abc.split("/+"); + String[] array2 = abc.split("/+"); // 贪婪匹配斜杠"///" for (String str : array2) { System.out.println(str); } @@ -226,7 +226,7 @@ public void test06_01() { @Test public void test06_02() { String str = "Orange is 100yuan, Banana is 180 yuan."; - String regex = "(\\d)\\s*(yuan)"; + String regex = "(\\d+)\\s*(yuan)"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(str); @@ -248,6 +248,15 @@ public void test06_03() { String filename = pathfFilename.replaceFirst(regex, replacement); System.out.println(filename); + + // 法2 + Pattern p = Pattern.compile(regex); + Matcher m = p.matcher(pathfFilename); + + String result = m.replaceFirst(replacement); + + System.out.println(result); + } /** @@ -287,18 +296,21 @@ public void test01_04_Zz() { String text2 = "def abc"; String text3 = "def abc\n"; - p = Pattern.compile("abc\\z"); + p = Pattern.compile("abc\\z"); // \z: asserts position at the end of the string m = p.matcher(text1); result1 = m.find(); + assertFalse(result1); m = p.matcher(text2); result2 = m.find(); + assertTrue(result2); m = p.matcher(text3); result3 = m.find(); + assertFalse(result3); - p = Pattern.compile("abc\\Z"); + p = Pattern.compile("abc\\Z"); // \Z: asserts position at the end of the string, or before the line terminator right at the end of the string (if any) m = p.matcher(text1); result1 = m.find(); From 9f32ea3b6d60a82bdd3c35cc03ed6120ba90bc9e Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Wed, 19 Jul 2017 01:14:31 +0800 Subject: [PATCH 21/81] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myknowledgepoint/regex/UtilsTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java index 7fc9d6de0b..ca61d7ae71 100644 --- a/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java @@ -3,6 +3,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.util.HashMap; +import java.util.Map; +import java.util.StringJoiner; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -325,4 +328,32 @@ public void test01_04_Zz() { assertTrue(result2); assertTrue(result3); } + + @Test + public void testTemplate() { + String origin = "【工银信用卡】于${startTime}至${endTime}申办奋斗卡,无年费,赢郎平签名排球!详情${link}"; + Map map = new HashMap() { + { + put("startTime", "昨天"); + put("endTime", "今天"); + put("link", "没有"); + } + }; + String newStr = renderTemplate(origin, map); + assertTrue(newStr.equals("【工银信用卡】于昨天至今天申办奋斗卡,无年费,赢郎平签名排球!详情没有")); + } + + private String renderTemplate(String origin, Map map) { + Pattern p = Pattern.compile("\\$\\{(.*?)\\}"); + Matcher m = p.matcher(origin); + String newStr = origin; + Matcher newM; + String match; + while (m.find()) { + match = m.group(1); + newM = p.matcher(newStr); + newStr = newM.replaceFirst(map.get(match)); + } + return newStr; + } } From b9815bb4b92013370be733556dea67a4b417060b Mon Sep 17 00:00:00 2001 From: jy <977996067@qq.com> Date: Wed, 19 Jul 2017 23:06:38 +0800 Subject: [PATCH 22/81] Add Builder homework --- students/977996067/pom.xml | 24 +++++ .../com/coderising/dp/week1/TagBuilder.java | 63 +++++++++++++ .../java/com/coderising/dp/week1/TagNode.java | 91 +++++++++++++++++++ .../com/coderising/dp/week1/TagNodeTest.java | 20 ++++ 4 files changed, 198 insertions(+) create mode 100644 students/977996067/pom.xml create mode 100644 students/977996067/src/main/java/com/coderising/dp/week1/TagBuilder.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week1/TagNode.java create mode 100644 students/977996067/src/test/java/com/coderising/dp/week1/TagNodeTest.java diff --git a/students/977996067/pom.xml b/students/977996067/pom.xml new file mode 100644 index 0000000000..2c2630e332 --- /dev/null +++ b/students/977996067/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + cc.javaone.coding2017 + ood-assignment + 1.0-SNAPSHOT + + + junit + junit + 4.12 + + + org.projectlombok + lombok + 1.16.18 + + + + + \ No newline at end of file diff --git a/students/977996067/src/main/java/com/coderising/dp/week1/TagBuilder.java b/students/977996067/src/main/java/com/coderising/dp/week1/TagBuilder.java new file mode 100644 index 0000000000..a31514a6fe --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week1/TagBuilder.java @@ -0,0 +1,63 @@ +package com.coderising.dp.week1; + +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; + +public class TagBuilder { + + private TagNode rootTag; + + private AtomicReference tempParentNode = new AtomicReference<>(); + + private AtomicReference currentNode = new AtomicReference<>(); + + public TagBuilder(String rootTagName) { + this.rootTag = new TagNode(); + rootTag.setTagName(rootTagName); + tempParentNode.set(rootTag); + currentNode.set(rootTag); + } + + public TagBuilder addChild(String childTagName) { + TagNode node = currentNode.get(); + tempParentNode.set(node); + currentNode.set(doAddChildren(node, childTagName)); + return this; + } + + private TagNode doAddChildren(TagNode node, String childTagName) { + List children = node.getChildren(); + TagNode childTag = new TagNode(); + childTag.setTagName(childTagName); + children.add(childTag); + return childTag; + } + + public TagBuilder addSibling(String childTagName) { + TagNode tagNode = tempParentNode.get(); + TagNode childTag = doAddChildren(tagNode, childTagName); + currentNode.set(childTag); + return this; + } + + public TagBuilder setAttribute(String key, String value) { + TagNode tagNode = currentNode.get(); + List attributes = tagNode.getAttributes(); + + TagNode.Attribute attribute = new TagNode.Attribute(); + attribute.setName(key); + attribute.setValue(value); + attributes.add(attribute); + return this; + } + + public String toXML() { + return rootTag.toString(); + } +} + + +// ~ HomeWork2 +// ======================================================================================================== + +// 单例的类: java.lang.Runtime \ No newline at end of file diff --git a/students/977996067/src/main/java/com/coderising/dp/week1/TagNode.java b/students/977996067/src/main/java/com/coderising/dp/week1/TagNode.java new file mode 100644 index 0000000000..6fa56abfdf --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week1/TagNode.java @@ -0,0 +1,91 @@ +package com.coderising.dp.week1; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class TagNode { + private String tagName; + private String tagValue; + private List children = new ArrayList<>(); + private List attributes = new ArrayList<>(); + + public String getTagName() { + return tagName; + } + + public void setTagName(String tagName) { + this.tagName = tagName; + } + + public String getTagValue() { + return tagValue; + } + + public void setTagValue(String tagValue) { + this.tagValue = tagValue; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public List getAttributes() { + return attributes; + } + + public void setAttributes(List attributes) { + this.attributes = attributes; + } + + public static class Attribute { + String name; + String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + } + + @Override + public String toString() { + String lineBreaker = System.getProperty("line.separator"); + StringBuilder sb = new StringBuilder(); + sb.append("<").append(this.tagName); + if (!isEmpty(this.attributes)) { + attributes.forEach(attribute -> sb.append(" ") + .append(attribute.getName()) + .append("=\"") + .append(attribute.getValue()) + .append("\"")); + } + sb.append(">"); + if (!isEmpty(this.children)) { + sb.append(lineBreaker); + children.forEach(child -> sb.append(child.toString())); + } + sb.append(lineBreaker).append("").append(lineBreaker); + return sb.toString(); + + } + + private boolean isEmpty(Collection c) { + return c == null || c.size() == 0; + } +} diff --git a/students/977996067/src/test/java/com/coderising/dp/week1/TagNodeTest.java b/students/977996067/src/test/java/com/coderising/dp/week1/TagNodeTest.java new file mode 100644 index 0000000000..554ae1fda4 --- /dev/null +++ b/students/977996067/src/test/java/com/coderising/dp/week1/TagNodeTest.java @@ -0,0 +1,20 @@ +package com.coderising.dp.week1; + +import org.junit.Test; + +public class TagNodeTest { + + @Test + public void testBuilder() { + + TagBuilder builder = new TagBuilder("order"); + + + String xml = builder.addChild("line-items") + .addChild("line-item").setAttribute("pid", "p3333").setAttribute("qty", "3") + .addSibling("line-item").setAttribute("pid", "p9876").setAttribute("qty", "10") + .toXML(); + + System.out.println(xml); + } +} \ No newline at end of file From 10cd690743cd09bc97b5dc3d230a06736dfb6ff1 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Thu, 20 Jul 2017 00:35:00 +0800 Subject: [PATCH 23/81] =?UTF-8?q?=E6=AD=A3=E5=88=992?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myknowledgepoint/regex/UtilsTest.java | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java index ca61d7ae71..7fa02e77a6 100644 --- a/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java @@ -1,11 +1,13 @@ package com.coderising.myknowledgepoint.regex; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; -import java.util.StringJoiner; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -356,4 +358,44 @@ private String renderTemplate(String origin, Map map) { } return newStr; } + + @Test + public void testReverseTemplate() { + String origin = "【工银信用卡】于${startTime}至${endTime}申办奋斗卡,\n" + + "无年费,赢郎平签名排球!详情${link}."; + String newStr = "【工银信用卡】于昨天至今天申办奋斗卡,\n" + + "无年费,赢郎平签名排球!详情没有."; + Map map = extractTemplateMap(origin, newStr); + Map map2 = new HashMap() { + { + put("startTime", "昨天"); + put("endTime", "今天"); + put("link", "没有"); + } + }; + assertEquals( map, map2 ); + } + + private Map extractTemplateMap(String origin, String newStr) { + Map map = new HashMap<>(10); + List keys = new LinkedList<>(); + Pattern p1 = Pattern.compile("\\$\\{(\\w+)\\}"); + Matcher m1 = p1.matcher(origin); + while (m1.find()) { + keys.add(m1.group(1)); + } + String newRegex = m1.replaceAll("(.*)"); // newRegex = "【工银信用卡】于(.*)至(.*)申办奋斗卡,无年费,赢郎平签名排球!详情(.*)." + Pattern p2 = Pattern.compile(newRegex); + Matcher m2 = p2.matcher(newStr); + int index = 0; + while (m2.find()) { + for (int i = 1; i <= m2.groupCount(); i++) { + map.put(keys.get(index), m2.group(i)); + index++; + } + } + return map; + } + + } From 27d3f8644bb4c6e68db40396d00c6c07cb9f6627 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Thu, 20 Jul 2017 01:27:43 +0800 Subject: [PATCH 24/81] Little fix --- .../streams/EntrySetTest.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 students/812350401/src/main/java/com/coderising/myknowledgepoint/streams/EntrySetTest.java diff --git a/students/812350401/src/main/java/com/coderising/myknowledgepoint/streams/EntrySetTest.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/streams/EntrySetTest.java new file mode 100644 index 0000000000..6287afea7e --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/streams/EntrySetTest.java @@ -0,0 +1,35 @@ +package com.coderising.myknowledgepoint.streams; + +import org.junit.Test; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Created by thomas_young on 20/7/2017. + */ +public class EntrySetTest { + @Test + public void test1() { + System.out.println("----test1----"); + Map map = new HashMap<>(); + map.put("01", "zhangsan"); + map.put("02", "lisi"); + map.put("03", "wangwu"); + Collection collection = map.keySet(); // 返回值是个值的Collection集合 + collection.stream().forEach(key -> System.out.println(key + ": " + map.get(key))); + } + + @Test + public void test2() { + System.out.println("----test2----"); + Map map = new HashMap<>(); + map.put("01", "zhangsan"); + map.put("02", "lisi"); + map.put("03", "wangwu"); + Set> entrySet = map.entrySet(); + entrySet.stream().forEach(entry -> System.out.println(entry.getKey() + ": " + entry.getValue())); + } +} From 8b1df6c06d485c27e6e7cf4433cf064eed4e5a5a Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Thu, 20 Jul 2017 02:11:09 +0800 Subject: [PATCH 25/81] =?UTF-8?q?=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE?= =?UTF-8?q?=E5=BC=8F3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myknowledgepoint/regex/UtilsTest.java | 94 +++++++++++++++++-- 1 file changed, 86 insertions(+), 8 deletions(-) diff --git a/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java index 7fa02e77a6..6f8a39a806 100644 --- a/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/regex/UtilsTest.java @@ -4,13 +4,11 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.junit.Ignore; import org.junit.Test; // http://www.cnblogs.com/playing/archive/2011/03/15/1984943.html @@ -362,9 +360,9 @@ private String renderTemplate(String origin, Map map) { @Test public void testReverseTemplate() { String origin = "【工银信用卡】于${startTime}至${endTime}申办奋斗卡,\n" + - "无年费,赢郎平签名排球!详情${link}."; + "无年费,赢郎平签名排球!详情${link}"; String newStr = "【工银信用卡】于昨天至今天申办奋斗卡,\n" + - "无年费,赢郎平签名排球!详情没有."; + "无年费,赢郎平签名排球!详情没有"; Map map = extractTemplateMap(origin, newStr); Map map2 = new HashMap() { { @@ -374,17 +372,23 @@ public void testReverseTemplate() { } }; assertEquals( map, map2 ); + + // 我的方法无法用于下面的代码 +// origin = "(【工银信用卡】于${startTime}至${endTime}申办奋斗卡,无年费,赢郎平签名排球!详情${link}."; +// newStr = "(【工银信用卡】于昨天至今天申办奋斗卡,无年费,赢郎平签名排球!详情没有."; +// map = extractTemplateMap(origin, newStr); +// System.out.println(map); } private Map extractTemplateMap(String origin, String newStr) { Map map = new HashMap<>(10); List keys = new LinkedList<>(); - Pattern p1 = Pattern.compile("\\$\\{(\\w+)\\}"); + Pattern p1 = Pattern.compile("\\$\\{(.+?)\\}"); Matcher m1 = p1.matcher(origin); while (m1.find()) { keys.add(m1.group(1)); } - String newRegex = m1.replaceAll("(.*)"); // newRegex = "【工银信用卡】于(.*)至(.*)申办奋斗卡,无年费,赢郎平签名排球!详情(.*)." + String newRegex = "^" + m1.replaceAll("(.*?)") + "$"; // newRegex = "【工银信用卡】于(.*?)至(.*?)申办奋斗卡,无年费,赢郎平签名排球!详情(.*?)." Pattern p2 = Pattern.compile(newRegex); Matcher m2 = p2.matcher(newStr); int index = 0; @@ -397,5 +401,79 @@ private Map extractTemplateMap(String origin, String newStr) { return map; } + @Test + public void test_template_string() { + String tmpl = null; + String text = null; + + // test data 1 + tmpl = "【工银信用卡】于${startTime}至${endTime}申办奋斗卡,无年费,赢郎平签名排球!详情${link}."; + text = "【工银信用卡】于昨天至今天申办奋斗卡,无年费,赢郎平签名排球!详情没有."; + + // test data 2 + tmpl = "a${startTime}b${endTime}"; + text = "abbc"; + + // test data 3 + tmpl = "(${startTime}至)${endTime}."; + text = "(昨天至)今天."; + + System.out.println("模板字符串:" + tmpl); + System.out.println("文本字符串:" + text); + System.out.println(); + + // 模板字符串中变量的正则表达式 + String keyRegex = "\\$\\{.*?\\}"; + + // 找出模板字符串中变量 + List keyList = new ArrayList<>(); + { + Pattern p = Pattern.compile(keyRegex); + Matcher m = p.matcher(tmpl); + + while (m.find()) { + keyList.add(m.group()); + } + } + + // 找出文本字符串中替换值集合 + List valueList = new ArrayList<>(); + { + // **关键想法** 把模板字符串改装成正则表达式 + + // ** 难点** + // 如果字符串中有元字符,改装后的正则表达式会有语法错误。 + // 例子:如果模板字符串中仅存在一个(,该装后的正则表达式会有语法错误。 + // 所以在每一个字符前都加\,这样(就变成\(,变成匹配(,符合原意。 + // 但是如果模板字符串中仅存在一个t,变成了\t,变成了匹配tab键,又出现了错误。 + // 结合以上的说明,我们要有选择的在字符前加\, 我们在非数字字母的字符前加\ + String tmplEscape = tmpl.replaceAll("([^\\w])", "\\\\$1"); + + // 在原始模板字符串中的占位符中的非数字字母的字符前, + // 已经被加\,所以占位符的正则表达式也要做相应的编辑 + String keyRegexEscape = "\\\\\\$\\\\\\{.*?\\\\\\}"; + + String tmplRegex = "^" + tmplEscape.replaceAll(keyRegexEscape, "(.*?)") + "$"; + System.out.println("模板字符串改装后的正则表达式:" + tmplRegex); + System.out.println(); + // 注: "\至" 也匹配 "至" + Pattern p = Pattern.compile(tmplRegex); + Matcher m = p.matcher(text); + if (m.find()) { + for (int i = 1; i <= m.groupCount(); i++) { + valueList.add(m.group(i)); + } + } + } + + // 输出结果 + if (valueList.isEmpty()) { + System.out.println("the text file format is not correct"); + } else { + for (int i = 0; i < keyList.size(); i++) { + System.out.println(keyList.get(i) + "\t\t" + valueList.get(i)); + } + } + } } From 57a340647fe796ca8a6d9a1fea84205ed9c788bc Mon Sep 17 00:00:00 2001 From: GordenChow <513274874@qq.com> Date: Fri, 21 Jul 2017 09:05:05 +0800 Subject: [PATCH 26/81] =?UTF-8?q?=E6=8F=90=E4=BA=A4builder=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/coderising/ood/builder/Attribute.java | 11 +++ .../coderising/ood/builder/TagBuilder.java | 46 +++++++++++ .../ood/builder/TagBuilderTest.java | 40 ++++++++++ .../com/coderising/ood/builder/TagNode.java | 78 +++++++++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/Attribute.java create mode 100644 students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagBuilder.java create mode 100644 students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagBuilderTest.java create mode 100644 students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagNode.java diff --git a/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/Attribute.java b/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/Attribute.java new file mode 100644 index 0000000000..6ee7739309 --- /dev/null +++ b/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/Attribute.java @@ -0,0 +1,11 @@ +package com.coderising.dp.builder; + +public class Attribute{ + public Attribute(String name, String value) { + this.name = name; + this.value = value; + } + String name; + String value; + + } \ No newline at end of file diff --git a/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagBuilder.java b/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagBuilder.java new file mode 100644 index 0000000000..59c9dd8066 --- /dev/null +++ b/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagBuilder.java @@ -0,0 +1,46 @@ +package com.coderising.dp.builder; + +public class TagBuilder { + TagNode root; + TagNode parNode; + TagNode curNode; + + + public TagBuilder(String rootTagName) { + root = new TagNode(rootTagName); + curNode = root; + parNode = root; + } + + public TagBuilder addChild(String childTagName) { + TagNode node = new TagNode(childTagName); + curNode.add(node); + parNode = curNode; + curNode = node; + return this; + } + + public TagBuilder addSibling(String siblingTagName) { + TagNode node = new TagNode(siblingTagName); + parNode.add(node); + parNode = curNode; + curNode = node; + return this; + + } + + public TagBuilder setAttribute(String name, String value) { + curNode.setAttribute(name, value); + return this; + } + + public TagBuilder setText(String value) { + curNode.setValue(value); + return this; + } + + public String toXML() { + return root.toXML(); + } + +} diff --git a/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagBuilderTest.java b/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagBuilderTest.java new file mode 100644 index 0000000000..e30d20285b --- /dev/null +++ b/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagBuilderTest.java @@ -0,0 +1,40 @@ +package com.coderising.dp.builder; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class TagBuilderTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testToXML() { + + TagBuilder builder = new TagBuilder("order"); + + String xml = builder.addChild("line-items") + .addChild("line-item").setAttribute("pid", "P3677").setAttribute("qty", "3") + .addSibling("line-item").setAttribute("pid", "P9877").setAttribute("qty", "10") + .toXML(); + + String expected = "" + + "" + + "" + + "" + + "" + + ""; + + System.out.println(xml); + assertEquals(expected, xml); + } + +} diff --git a/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagNode.java b/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagNode.java new file mode 100644 index 0000000000..0a28545af0 --- /dev/null +++ b/students/513274874/ood/ood-assignment/src/main/java/com/coderising/ood/builder/TagNode.java @@ -0,0 +1,78 @@ +package com.coderising.dp.builder; + +import java.util.ArrayList; +import java.util.List; + +public class TagNode { + private String tagName; + private String tagValue; + private List children = new ArrayList<>(); + private List attributes = new ArrayList<>(); + + public TagNode(String name){ + this.tagName = name; + } + public void add(TagNode child){ + this.children.add(child); + } + public void setAttribute(String name, String value) { + Attribute attr = findAttribute(name); + if(attr != null){ + attr.value = value; + return; + } + + attributes.add(new Attribute(name,value)); + } + private Attribute findAttribute(String name){ + for(Attribute attr : attributes){ + if(attr.name.equals(name)){ + return attr; + } + } + return null; + } + public void setValue(String value) { + this.tagValue = value; + } + public String getTagName() { + return tagName; + } + public List getChildren() { + return children; + } + + public String toXML(){ + return toXML(this); + } + private String toXML(TagNode node){ + StringBuilder buffer = new StringBuilder(); + buffer.append("<").append(node.tagName); + if(node.attributes.size()> 0){ + for(int i=0;i"); + return buffer.toString(); + } + buffer.append(">"); + for(TagNode childNode : node.children){ + buffer.append(toXML(childNode)); + } + buffer.append(""); + + + return buffer.toString(); + } + private String toXML(Attribute attr){ + return attr.name+"=\""+attr.value + "\""; + } + + public TagNode(TagBuilder builder){ + + + } +} From 892f1bc2c80ca44f782e10de82733050b1a542e7 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Fri, 21 Jul 2017 13:41:44 +0800 Subject: [PATCH 27/81] =?UTF-8?q?=E5=88=86=E5=88=AB=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E4=BA=86=E4=B8=A4=E5=B1=82=E5=B5=8C=E5=A5=97=E5=92=8C=E5=A4=9A?= =?UTF-8?q?=E5=B1=82=E5=B5=8C=E5=A5=97=E7=9A=84XML=E7=BB=93=E7=82=B9?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DoubleLevelNesting/TagBuilder.java" | 71 ++++++++++++++ .../DoubleLevelNesting/TagNode.java" | 94 +++++++++++++++++++ .../MultiLevelNesting/TagBuilder.java" | 73 ++++++++++++++ .../MultiLevelNesting/TagNode.java" | 93 ++++++++++++++++++ ...4\232\345\261\202\345\265\214\345\245\227" | 0 5 files changed, 331 insertions(+) create mode 100644 "students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/DoubleLevelNesting/TagBuilder.java" create mode 100644 "students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/DoubleLevelNesting/TagNode.java" create mode 100644 "students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/MultiLevelNesting/TagBuilder.java" create mode 100644 "students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/MultiLevelNesting/TagNode.java" create mode 100644 "students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/\345\210\206\345\210\253\345\256\236\347\216\260\344\272\206\344\270\244\345\261\202\345\265\214\345\245\227\345\222\214\345\244\232\345\261\202\345\265\214\345\245\227" diff --git "a/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/DoubleLevelNesting/TagBuilder.java" "b/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/DoubleLevelNesting/TagBuilder.java" new file mode 100644 index 0000000000..be8b594844 --- /dev/null +++ "b/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/DoubleLevelNesting/TagBuilder.java" @@ -0,0 +1,71 @@ +package DoubleLevelNesting; + +import java.util.ArrayList; + +/** + * Tag构造器 + * + * @author LanyuanXiaoyao + * @create 2017-07-18 + */ +public class TagBuilder { + + private TagNode root; + private TagBuilder rootBuilder; + + public TagBuilder(String rootName) { + this.root = new TagNode(rootName); + this.root.setChildren(new ArrayList<>()); + this.root.setAttributes(new ArrayList<>()); + } + + public TagBuilder(String rootName, TagBuilder tagBuilder) { + this.root = new TagNode(rootName); + this.root.setChildren(new ArrayList<>()); + this.root.setAttributes(new ArrayList<>()); + this.rootBuilder = tagBuilder; + } + + public TagBuilder addChild(String childName) { + TagBuilder childBuilder = new TagBuilder(childName, this); + if (rootBuilder == null) + root.getChildren().add(childBuilder.build()); + else + rootBuilder.build().getChildren().add(childBuilder.build()); + return childBuilder; + } + + public TagBuilder setAttribute(String name, String value) { + TagNode.Attribute attribute = new TagNode.Attribute(name, value); + root.getAttributes().add(attribute); + return this; + } + + public TagBuilder end() { + return rootBuilder; + } + + public void toXML() { + if (rootBuilder == null) + System.out.println(root.toXML()); + else + rootBuilder.toXML(); + } + + public TagNode build() { + return root; + } + + public static void main(String[] args) { + new TagBuilder("root") + .setAttribute("attr3", "value") + .setAttribute("attr4", "value") + .addChild("child") + .setAttribute("attr1", "value") + .setAttribute("attr2", "value") + .addChild("child2") + .setAttribute("attr5", "value") + .setAttribute("attr6", "value") + .toXML(); + } +} diff --git "a/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/DoubleLevelNesting/TagNode.java" "b/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/DoubleLevelNesting/TagNode.java" new file mode 100644 index 0000000000..45fc5ac9b6 --- /dev/null +++ "b/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/DoubleLevelNesting/TagNode.java" @@ -0,0 +1,94 @@ +package DoubleLevelNesting; + +import java.util.ArrayList; +import java.util.List; + +/** + * Tag节点 + * + * @author LanyuanXiaoyao + * @create 2017-07-18 + */ +public class TagNode { + private String tagName; + private String tagValue; + private List children = new ArrayList<>(); + private List attributes = new ArrayList<>(); + + public TagNode(String tagName) { + this.tagName = tagName; + } + + public String getTagName() { + return tagName; + } + + public void setTagName(String tagName) { + this.tagName = tagName; + } + + public String getTagValue() { + return tagValue; + } + + public void setTagValue(String tagValue) { + this.tagValue = tagValue; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public List getAttributes() { + return attributes; + } + + public void setAttributes(List attributes) { + this.attributes = attributes; + } + + public static class Attribute { + public Attribute(String name, String value) { + this.name = name; + this.value = value; + } + + String name; + String value; + } + + public String toXML() { + return toXML(this); + } + + private String toXML(TagNode node) { + StringBuilder buffer = new StringBuilder(); + buffer.append("<").append(node.tagName); + if (node.attributes.size() > 0) { + for (int i = 0; i < node.attributes.size(); i++) { + Attribute attr = node.attributes.get(i); + buffer.append(" ").append(toXML(attr)); + } + } + if (node.children.size() == 0) { + buffer.append("/>"); + return buffer.toString(); + } + System.out.println(node.children.size()); + buffer.append(">"); + for (TagNode childNode : node.children) { + buffer.append(toXML(childNode)); + } + buffer.append(""); + + return buffer.toString(); + } + + private String toXML(Attribute attr) { + return attr.name + "=\"" + attr.value + "\""; + } +} diff --git "a/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/MultiLevelNesting/TagBuilder.java" "b/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/MultiLevelNesting/TagBuilder.java" new file mode 100644 index 0000000000..64b3a3d51a --- /dev/null +++ "b/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/MultiLevelNesting/TagBuilder.java" @@ -0,0 +1,73 @@ +package MultiLevelNesting; + +import java.util.ArrayList; + +/** + * Tag构造器 + * + * @author LanyuanXiaoyao + * @create 2017-07-18 + */ +public class TagBuilder { + + private TagNode root; + private TagBuilder rootBuilder; + + public TagBuilder(String rootName) { + this.root = new TagNode(rootName); + this.root.setChildren(new ArrayList<>()); + this.root.setAttributes(new ArrayList<>()); + } + + public TagBuilder(String rootName, TagBuilder tagBuilder) { + this.root = new TagNode(rootName); + this.root.setChildren(new ArrayList<>()); + this.root.setAttributes(new ArrayList<>()); + this.rootBuilder = tagBuilder; + } + + public TagBuilder addChild(String childName) { + TagBuilder childBuilder = new TagBuilder(childName, this); + root.getChildren().add(childBuilder.toTagTreeNode()); + return childBuilder; + } + + public TagBuilder setAttribute(String name, String value) { + TagNode.Attribute attribute = new TagNode.Attribute(name, value); + root.getAttributes().add(attribute); + return this; + } + + public TagBuilder and() { + return rootBuilder; + } + + public void toXML() { + if (rootBuilder == null) + System.out.println(root.toXML()); + else + rootBuilder.toXML(); + } + + public TagNode toTagTreeNode() { + return root; + } + + public static void main(String[] args) { + new TagBuilder("root") + .setAttribute("attr0","0") + .addChild("child") + .setAttribute("attr1","1") + .setAttribute("attr1","1") + .setAttribute("attr1","1") + .addChild("child2") + .setAttribute("attr2","2") + .setAttribute("attr2","2") + .setAttribute("attr2","2") + .and() + .and() + .addChild("child3") + .setAttribute("attr3","3") + .toXML(); + } +} diff --git "a/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/MultiLevelNesting/TagNode.java" "b/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/MultiLevelNesting/TagNode.java" new file mode 100644 index 0000000000..421ca50850 --- /dev/null +++ "b/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/MultiLevelNesting/TagNode.java" @@ -0,0 +1,93 @@ +package MultiLevelNesting; + +import java.util.ArrayList; +import java.util.List; + +/** + * Tag节点 + * + * @author LanyuanXiaoyao + * @create 2017-07-18 + */ +public class TagNode { + private String tagName; + private String tagValue; + private List children = new ArrayList<>(); + private List attributes = new ArrayList<>(); + + public TagNode(String tagName) { + this.tagName = tagName; + } + + public String getTagName() { + return tagName; + } + + public void setTagName(String tagName) { + this.tagName = tagName; + } + + public String getTagValue() { + return tagValue; + } + + public void setTagValue(String tagValue) { + this.tagValue = tagValue; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public List getAttributes() { + return attributes; + } + + public void setAttributes(List attributes) { + this.attributes = attributes; + } + + public static class Attribute { + public Attribute(String name, String value) { + this.name = name; + this.value = value; + } + + String name; + String value; + } + + public String toXML() { + return toXML(this); + } + + private String toXML(TagNode node) { + StringBuilder buffer = new StringBuilder(); + buffer.append("<").append(node.tagName); + if (node.attributes.size() > 0) { + for (int i = 0; i < node.attributes.size(); i++) { + Attribute attr = node.attributes.get(i); + buffer.append(" ").append(toXML(attr)); + } + } + if (node.children.size() == 0) { + buffer.append("/>"); + return buffer.toString(); + } + buffer.append(">"); + for (TagNode childNode : node.children) { + buffer.append(toXML(childNode)); + } + buffer.append(""); + + return buffer.toString(); + } + + private String toXML(Attribute attr) { + return attr.name + "=\"" + attr.value + "\""; + } +} diff --git "a/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/\345\210\206\345\210\253\345\256\236\347\216\260\344\272\206\344\270\244\345\261\202\345\265\214\345\245\227\345\222\214\345\244\232\345\261\202\345\265\214\345\245\227" "b/students/949603184/homework06-XML\347\273\223\347\202\271\347\224\237\346\210\220\345\231\250/\345\210\206\345\210\253\345\256\236\347\216\260\344\272\206\344\270\244\345\261\202\345\265\214\345\245\227\345\222\214\345\244\232\345\261\202\345\265\214\345\245\227" new file mode 100644 index 0000000000..e69de29bb2 From bc2ecb5b57152868c6462082614cf4d17a8e6879 Mon Sep 17 00:00:00 2001 From: Liu Zengzeng Date: Fri, 21 Jul 2017 20:57:14 +0800 Subject: [PATCH 28/81] tagBuilder and singleton --- .../com/coderings/dp/builder/TagBuilder.java | 49 +++++++++++ .../coderings/dp/builder/TagBuilderTest.java | 40 +++++++++ .../com/coderings/dp/builder/TagNode.java | 83 +++++++++++++++++++ .../coderings/dp/singleton/jdk_singleton.md | 38 +++++++++ 4 files changed, 210 insertions(+) create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagBuilder.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagBuilderTest.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagNode.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/singleton/jdk_singleton.md diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagBuilder.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagBuilder.java new file mode 100644 index 0000000000..becc6a3d37 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagBuilder.java @@ -0,0 +1,49 @@ +package com.coderings.dp.builder; + +public class TagBuilder { + + final TagNode rootNode; + + TagNode iteratorNode; + + TagNode prevIteratorNode; + + public TagBuilder(String rootTagName) { + rootNode = new TagNode(rootTagName); + iteratorNode = rootNode; + prevIteratorNode = rootNode; + } + + public TagBuilder addChild(String childTagName) { + TagNode tagNode = new TagNode(childTagName); + iteratorNode.add(tagNode); + + prevIteratorNode = iteratorNode; + iteratorNode = tagNode; + + return this; + } + + public TagBuilder addSibling(String siblingTagName) { + TagNode tagNode = new TagNode(siblingTagName); + prevIteratorNode.add(tagNode); + + iteratorNode = tagNode; + + return this; + } + + public TagBuilder setAttribute(String name, String value) { + iteratorNode.setAttribute(name, value); + return this; + } + + public TagBuilder setText(String value) { + iteratorNode.setValue(value); + return this; + } + + public String toXML() { + return rootNode.toXML(); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagBuilderTest.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagBuilderTest.java new file mode 100644 index 0000000000..2d6dae918b --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagBuilderTest.java @@ -0,0 +1,40 @@ +package com.coderings.dp.builder; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class TagBuilderTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testToXML() { + + TagBuilder builder = new TagBuilder("order"); + + String xml = builder.addChild("line-items") + .addChild("line-item").setAttribute("pid", "P3677").setAttribute("qty", "3") + .addSibling("line-item").setAttribute("pid", "P9877").setAttribute("qty", "10") + .toXML(); + + String expected = "" + + "" + + "" + + "" + + "" + + ""; + + System.out.println(xml); + assertEquals(expected, xml); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagNode.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagNode.java new file mode 100644 index 0000000000..28fb0f54b8 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/builder/TagNode.java @@ -0,0 +1,83 @@ +package com.coderings.dp.builder; + +import java.util.ArrayList; +import java.util.List; + +public class TagNode { + private String tagName; + private String tagValue; + private List children = new ArrayList<>(); + private List attributes = new ArrayList<>(); + + public TagNode(String name){ + this.tagName = name; + } + public void add(TagNode child){ + this.children.add(child); + } + public void setAttribute(String name, String value) { + Attribute attr = findAttribute(name); + if(attr != null){ + attr.value = value; + return; + } + + attributes.add(new Attribute(name,value)); + } + private Attribute findAttribute(String name){ + for(Attribute attr : attributes){ + if(attr.name.equals(name)){ + return attr; + } + } + return null; + } + public void setValue(String value) { + this.tagValue = value; + + } + public String getTagName() { + return tagName; + } + public List getChildren() { + return children; + } + + private static class Attribute{ + public Attribute(String name, String value) { + this.name = name; + this.value = value; + } + String name; + String value; + + } + public String toXML(){ + return toXML(this); + } + private String toXML(TagNode node){ + StringBuilder buffer = new StringBuilder(); + buffer.append("<").append(node.tagName); + if(node.attributes.size()> 0){ + for(int i=0;i"); + return buffer.toString(); + } + buffer.append(">"); + for(TagNode childNode : node.children){ + buffer.append(toXML(childNode)); + } + buffer.append(""); + + + return buffer.toString(); + } + private String toXML(Attribute attr){ + return attr.name+"=\""+attr.value + "\""; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/singleton/jdk_singleton.md b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/singleton/jdk_singleton.md new file mode 100644 index 0000000000..69df72e73d --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/singleton/jdk_singleton.md @@ -0,0 +1,38 @@ +#Singleton in JDK + +## java.lang.Runtime + + private static Runtime currentRuntime = new Runtime(); + + public static Runtime getRuntime() { + return currentRuntime; + } + +## java.awt.Desktop + + private DesktopPeer peer; + + private Desktop() { + peer = Toolkit.getDefaultToolkit().createDesktopPeer(this); + } + + + public static synchronized Desktop getDesktop(){ + Desktop desktop = (Desktop)context.get(Desktop.class); + + if (desktop == null) { + desktop = new Desktop(); + context.put(Desktop.class, desktop); + } + + return desktop; + } + +## java.lang.System + + private static volatile SecurityManager security = null; + + public static SecurityManager getSecurityManager() { + return security; + } + \ No newline at end of file From b757eef66f5640477539c22d549ab77a8a43faa5 Mon Sep 17 00:00:00 2001 From: sheng <1158154002@qq.com> Date: Sun, 23 Jul 2017 07:01:30 +0800 Subject: [PATCH 29/81] builder --- .../com/coderising/dp/builder/TagBuilder.java | 43 ++++++++++ .../coderising/dp/builder/TagBuilderTest.java | 45 ++++++++++ .../com/coderising/dp/builder/TagNode.java | 83 +++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilder.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilderTest.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/builder/TagNode.java diff --git a/students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilder.java b/students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilder.java new file mode 100644 index 0000000000..c4efe3eaf3 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilder.java @@ -0,0 +1,43 @@ +package com.coderising.dp.builder; + +import java.util.List; + +public class TagBuilder { + private TagNode root; + private TagNode now; + private TagNode prev; + public TagBuilder(String rootTagName) { + root=new TagNode(rootTagName); + now=root; + } + + public TagBuilder addChild(String childTagName) { + prev=now; + TagNode temp=new TagNode(childTagName); + now.add(temp); + now=temp; + return this; + } + + public TagBuilder addSibling(String siblingTagName) { + List children=prev.getChildren(); + now=new TagNode(siblingTagName); + children.add(now); + return this; + + } + + public TagBuilder setAttribute(String name, String value) { + now.setAttribute(name, value); + return this; + } + + public TagBuilder setText(String value) { + + return this; + } + + public String toXML() { + return root.toXML(); + } +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilderTest.java b/students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilderTest.java new file mode 100644 index 0000000000..147e159b23 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilderTest.java @@ -0,0 +1,45 @@ +package com.coderising.dp.builder; + +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class TagBuilderTest { + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testToXML() { + + TagBuilder builder = new TagBuilder("order"); + + String xml = builder.addChild("line-items") + .addChild("line-item").setAttribute("pid", "P3677").setAttribute("qty", "3") + .addSibling("line-item").setAttribute("pid", "P9877").setAttribute("qty", "10") + .toXML(); + + String expected = "" + + "" + + "" + + "" + + "" + + ""; + + System.out.println(xml); + assertEquals(expected, xml); + +// com.oracle.nio.BufferSecrets +// +// com.sun.corba.se.spi.extension.ServantCachingPolicy +// +// java.net.ProxySelector + } + +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/builder/TagNode.java b/students/1158154002/src/main/java/com/coderising/dp/builder/TagNode.java new file mode 100644 index 0000000000..33b421cf10 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/builder/TagNode.java @@ -0,0 +1,83 @@ +package com.coderising.dp.builder; + +import java.util.ArrayList; +import java.util.List; + +public class TagNode { + private String tagName; + private String tagValue; + private List children = new ArrayList<>(); + private List attributes = new ArrayList<>(); + + public TagNode(String name){ + this.tagName = name; + } + public void add(TagNode child){ + this.children.add(child); + } + public void setAttribute(String name, String value) { + Attribute attr = findAttribute(name); + if(attr != null){ + attr.value = value; + return; + } + + attributes.add(new Attribute(name,value)); + } + private Attribute findAttribute(String name){ + for(Attribute attr : attributes){ + if(attr.name.equals(name)){ + return attr; + } + } + return null; + } + public void setValue(String value) { + this.tagValue = value; + + } + public String getTagName() { + return tagName; + } + public List getChildren() { + return children; + } + + private static class Attribute{ + public Attribute(String name, String value) { + this.name = name; + this.value = value; + } + String name; + String value; + + } + public String toXML(){ + return toXML(this); + } + private String toXML(TagNode node){ + StringBuilder buffer = new StringBuilder(); + buffer.append("<").append(node.tagName); + if(node.attributes.size()> 0){ + for(int i=0;i"); + return buffer.toString(); + } + buffer.append(">"); + for(TagNode childNode : node.children){ + buffer.append(toXML(childNode)); + } + buffer.append(""); + + + return buffer.toString(); + } + private String toXML(Attribute attr){ + return attr.name+"=\""+attr.value + "\""; + } +} From be6e24a407227db90d15e8649fc9afb1e0d1e342 Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sun, 23 Jul 2017 15:35:17 +0800 Subject: [PATCH 30/81] =?UTF-8?q?2017=E5=B9=B47=E6=9C=8823=E6=97=A5=2015:3?= =?UTF-8?q?5:11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- students/740707954/pom.xml | 2 +- .../740707954/src/main/java/dp/Attribute.java | 25 ++++ .../src/main/java/dp/TagBuilder.java | 68 +++++++++ .../src/main/java/dp/TagBuilderTest.java | 41 ++++++ .../740707954/src/main/java/dp/TagNode.java | 130 ++++++++++++++++++ ...0\241\345\274\217\344\275\234\344\270\232" | 0 6 files changed, 265 insertions(+), 1 deletion(-) create mode 100644 students/740707954/src/main/java/dp/Attribute.java create mode 100644 students/740707954/src/main/java/dp/TagBuilder.java create mode 100644 students/740707954/src/main/java/dp/TagBuilderTest.java create mode 100644 students/740707954/src/main/java/dp/TagNode.java create mode 100644 "students/740707954/src/main/java/dp/\350\256\276\350\256\241\346\250\241\345\274\217\344\275\234\344\270\232" diff --git a/students/740707954/pom.xml b/students/740707954/pom.xml index 3c385fa294..d9ec615fe1 100644 --- a/students/740707954/pom.xml +++ b/students/740707954/pom.xml @@ -18,7 +18,7 @@ junit junit - 3.8.1 + 4.11 test diff --git a/students/740707954/src/main/java/dp/Attribute.java b/students/740707954/src/main/java/dp/Attribute.java new file mode 100644 index 0000000000..3ec9ee6dbf --- /dev/null +++ b/students/740707954/src/main/java/dp/Attribute.java @@ -0,0 +1,25 @@ +package dp; + +/** + * Created by lx on 2017/7/22. + */ +public class Attribute { + private String name; + private String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/students/740707954/src/main/java/dp/TagBuilder.java b/students/740707954/src/main/java/dp/TagBuilder.java new file mode 100644 index 0000000000..ea2c63df43 --- /dev/null +++ b/students/740707954/src/main/java/dp/TagBuilder.java @@ -0,0 +1,68 @@ +package dp; + +import java.util.List; + +/** + * 标签构造 + * Created by lx on 2017/7/22. + */ +public class TagBuilder { + private TagNode root;// 根节点 + private TagNode currentNode;// 当前节点 + private TagNode prevNode;// 上一节点 + + public TagBuilder(String order) { + root = new TagNode(order); + currentNode = root; + } + + /** + * 添加子标签 + * @param nodeName 节点名称 + * @return TagBuilder + */ + public TagBuilder addChild(String nodeName) { + TagNode node = new TagNode(nodeName); + List children = currentNode.getChildren(); + children.add(node); + prevNode = currentNode; + currentNode = node; + return this; + } + + /** + * 添加当前标签属性 + * @param key + * @param value + * @return TagBuilder + */ + public TagBuilder setAttribute(String key, String value) { + currentNode.setAttribute(key, value); + return this; + } + + /** + * 添加兄弟标签 + * @param nodeName 节点名称 + * @return TagBuilder + */ + public TagBuilder addSibling(String nodeName) { + TagNode node = new TagNode(nodeName); + prevNode.getChildren().add(node); + currentNode = node; + return this; + } + + /** + * 设置文本值 + * @param value + * @return 节点名称 + */ + public TagBuilder setText(String value) { + return null; + } + + public String toXML() { + return root.toXML(); + } +} diff --git a/students/740707954/src/main/java/dp/TagBuilderTest.java b/students/740707954/src/main/java/dp/TagBuilderTest.java new file mode 100644 index 0000000000..be4815e202 --- /dev/null +++ b/students/740707954/src/main/java/dp/TagBuilderTest.java @@ -0,0 +1,41 @@ +package dp; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; +/** + * Created by lx on 2017/7/23. + */ +public class TagBuilderTest { + + @Before + public void setUp() throws Exception{ + System.out.println("up"); + } + + @After + public void tearDown() { + System.out.println("down"); + } + + @Test + public void testToXML() { + TagBuilder builder = new TagBuilder("order"); + + String xml = builder.addChild("line-items") + .addChild("line-item").setAttribute("pid", "P3677").setAttribute("qty", "3") + .addSibling("line-item").setAttribute("pid", "P9877").setAttribute("qty", "10") + .toXML(); + + String expected = "" + + "" + + "" + + "" + + "" + + ""; + + System.out.println(xml); + assertEquals(expected, xml); + } +} diff --git a/students/740707954/src/main/java/dp/TagNode.java b/students/740707954/src/main/java/dp/TagNode.java new file mode 100644 index 0000000000..8bf58f772e --- /dev/null +++ b/students/740707954/src/main/java/dp/TagNode.java @@ -0,0 +1,130 @@ +package dp; + +import java.util.ArrayList; +import java.util.List; + +/** + * 标签 + * Created by lx on 2017/7/22. + */ +public class TagNode { + private String tagName; + private String tagValue; + private List children = new ArrayList<>(); + private List attributes = new ArrayList<>(); + + public TagNode(String tagName) { + this.tagName = tagName; + } + + /** + * 添加子标签 + * @param node + */ + public void add(TagNode node) { + children.add(node); + } + + /** + * 设置属性 + * @param key + * @param value + */ + public void setAttribute(String key, String value) { + Attribute attr = new Attribute(); + attr.setName(key); + attr.setValue(value); + attributes.add(attr); + } + + /** + * 查找当前标签属性 + * @param name + * @return + */ + private Attribute findAttribute(String name) { + for (Attribute attr : attributes) { + if (attr.getName().equals(name)) { + return attr; + } + } + return null; + } + + /** + * 转成xml字符串 + * @return + */ + public String toXML() { + return toXML(this); + } + + /** + * 将标签转成xml + * @param node + * @return + */ + private String toXML(TagNode node) { + StringBuilder buffer = new StringBuilder(); + buffer.append("<").append(node.tagName); + if (node.attributes.size() > 0) { + for (Attribute attr : node.attributes) { + buffer.append(" ").append(toXML(attr)); + } + } + + if (node.children.size() == 0) { + buffer.append("/>"); + return buffer.toString(); + } + + buffer.append(">"); + for (TagNode childrenNode : node.children) { + buffer.append(toXML(childrenNode)); + } + + buffer.append(""); + return buffer.toString(); + } + + /** + * 将属性转成xml + * @param attr + * @return + */ + private String toXML(Attribute attr) { + return attr.getName() + "=\"" + attr.getValue() + "\""; + } + + public String getTagName() { + return tagName; + } + + public void setTagName(String tagName) { + this.tagName = tagName; + } + + public String getTagValue() { + return tagValue; + } + + public void setTagValue(String tagValue) { + this.tagValue = tagValue; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public List getAttributes() { + return attributes; + } + + public void setAttributes(List attributes) { + this.attributes = attributes; + } +} diff --git "a/students/740707954/src/main/java/dp/\350\256\276\350\256\241\346\250\241\345\274\217\344\275\234\344\270\232" "b/students/740707954/src/main/java/dp/\350\256\276\350\256\241\346\250\241\345\274\217\344\275\234\344\270\232" new file mode 100644 index 0000000000..e69de29bb2 From 94a5da425ca19ca1da351047214aeb4d4eeab748 Mon Sep 17 00:00:00 2001 From: onlyliuxin <14703250@qq.com> Date: Sun, 23 Jul 2017 18:26:46 +0800 Subject: [PATCH 31/81] add implementation code --- .../com/coderising/dp/builder/TagBuilder.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/builder/TagBuilder.java b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/builder/TagBuilder.java index fe8673ec30..daa431f139 100644 --- a/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/builder/TagBuilder.java +++ b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/builder/TagBuilder.java @@ -1,30 +1,37 @@ package com.coderising.dp.builder; public class TagBuilder { - + private TagNode rootNode; + private TagNode currentNode; + private TagNode parentNode; public TagBuilder(String rootTagName){ - + rootNode = new TagNode(rootTagName); + currentNode = rootNode; + parentNode = null; } public TagBuilder addChild(String childTagName){ - - return null; + parentNode = this.currentNode; + this.currentNode = new TagNode(childTagName); + parentNode.add(currentNode); + return this; } public TagBuilder addSibling(String siblingTagName){ - - return null; + this.currentNode = new TagNode(siblingTagName); + parentNode.add(this.currentNode); + return this; } public TagBuilder setAttribute(String name, String value){ - - return null; + this.currentNode.setAttribute(name, value); + return this; } public TagBuilder setText(String value){ - - return null; + this.currentNode.setValue(value); + return this; } public String toXML(){ - return null; + return this.rootNode.toXML(); } } From bfd3d880c161963c5a076ed022f7b0b7d64ec89e Mon Sep 17 00:00:00 2001 From: onlyliuxin <14703250@qq.com> Date: Sun, 23 Jul 2017 18:30:16 +0800 Subject: [PATCH 32/81] add composite pattern --- .../main/java/com/coderising/dp/composite/Line.java | 11 +++++++++++ .../java/com/coderising/dp/composite/Rectangle.java | 11 +++++++++++ .../main/java/com/coderising/dp/composite/Shape.java | 5 +++++ .../main/java/com/coderising/dp/composite/Square.java | 11 +++++++++++ .../main/java/com/coderising/dp/composite/Text.java | 11 +++++++++++ 5 files changed, 49 insertions(+) create mode 100644 liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java diff --git a/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java new file mode 100644 index 0000000000..b3c769e63a --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java @@ -0,0 +1,11 @@ +package com.coderising.dp.composite; + +public class Line implements Shape { + + @Override + public void draw() { + + + } + +} diff --git a/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java new file mode 100644 index 0000000000..2960351a35 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java @@ -0,0 +1,11 @@ +package com.coderising.dp.composite; + +public class Rectangle implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + + } + +} diff --git a/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java new file mode 100644 index 0000000000..4562f10b12 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java @@ -0,0 +1,5 @@ +package com.coderising.dp.composite; + +public interface Shape { + public void draw(); +} diff --git a/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java new file mode 100644 index 0000000000..f106d65fd8 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java @@ -0,0 +1,11 @@ +package com.coderising.dp.composite; + +public class Square implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + + } + +} diff --git a/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java new file mode 100644 index 0000000000..3543a08be3 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java @@ -0,0 +1,11 @@ +package com.coderising.dp.composite; + +public class Text implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + + } + +} From f69d4e32798848fb74ead73b99228b1eb96e7ae1 Mon Sep 17 00:00:00 2001 From: onlyliuxin <14703250@qq.com> Date: Sun, 23 Jul 2017 18:35:03 +0800 Subject: [PATCH 33/81] add bridge pattern --- .../com/coderising/dp/bridge/GraphicLibrary1.java | 11 +++++++++++ .../com/coderising/dp/bridge/GraphicLibrary2.java | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java diff --git a/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java new file mode 100644 index 0000000000..798cfbc7f9 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java @@ -0,0 +1,11 @@ +package com.coderising.dp.bridge; + +public class GraphicLibrary1 { + public void draw_a_line(int x1,int y1,int x2,int y2){ + + } + public void draw_a_circle(int x,int y, int r){ + + } + +} diff --git a/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java new file mode 100644 index 0000000000..2e67a1220b --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java @@ -0,0 +1,11 @@ +package com.coderising.dp.bridge; + +public class GraphicLibrary2 { + public void drawLine(int x1,int x2,int y1,int y2){ + + } + public void drawCircle(int x,int y, int r){ + + } + +} From 8807be3223df8b35d7a62af925bd9ca386b9c8af Mon Sep 17 00:00:00 2001 From: sheng <1158154002@qq.com> Date: Sun, 23 Jul 2017 22:25:36 +0800 Subject: [PATCH 34/81] builder --- .../src/main/java/com/coderising/dp/builder/TagBuilder.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilder.java b/students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilder.java index c4efe3eaf3..baefede533 100644 --- a/students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilder.java +++ b/students/1158154002/src/main/java/com/coderising/dp/builder/TagBuilder.java @@ -13,9 +13,9 @@ public TagBuilder(String rootTagName) { public TagBuilder addChild(String childTagName) { prev=now; - TagNode temp=new TagNode(childTagName); - now.add(temp); - now=temp; + now=new TagNode(childTagName); + prev.add(now); + return this; } From c9169960b1cdf4481a8cc34db924297313349248 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Sun, 23 Jul 2017 23:54:28 +0800 Subject: [PATCH 35/81] =?UTF-8?q?[CI]=20=E6=8A=8A=E8=80=81=E5=B8=88?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E7=A7=BB=E5=8A=A8=E5=88=B0=E6=88=91?= =?UTF-8?q?=E7=9A=84=E7=9B=AE=E5=BD=95=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/coderising/mydp/bridge/GraphicLibrary1.java | 11 +++++++++++ .../com/coderising/mydp/bridge/GraphicLibrary2.java | 11 +++++++++++ .../{myood => mydp}/builder/TagBuilder.java | 2 +- .../{myood => mydp}/builder/TagBuilderTest.java | 2 +- .../coderising/{myood => mydp}/builder/TagNode.java | 2 +- .../{myood => mydp}/builder/tagExample.xml | 0 .../java/com/coderising/mydp/composite/Line.java | 11 +++++++++++ .../com/coderising/mydp/composite/Rectangle.java | 11 +++++++++++ .../java/com/coderising/mydp/composite/Shape.java | 5 +++++ .../java/com/coderising/mydp/composite/Square.java | 11 +++++++++++ .../java/com/coderising/mydp/composite/Text.java | 11 +++++++++++ .../java/com/coderising/mydp/decorator/Email.java | 6 ++++++ .../coderising/mydp/decorator/EmailDecorator.java | 5 +++++ .../com/coderising/mydp/decorator/EmailImpl.java | 12 ++++++++++++ 14 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary1.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary2.java rename students/812350401/src/main/java/com/coderising/{myood => mydp}/builder/TagBuilder.java (95%) rename students/812350401/src/main/java/com/coderising/{myood => mydp}/builder/TagBuilderTest.java (96%) rename students/812350401/src/main/java/com/coderising/{myood => mydp}/builder/TagNode.java (97%) rename students/812350401/src/main/java/com/coderising/{myood => mydp}/builder/tagExample.xml (100%) create mode 100644 students/812350401/src/main/java/com/coderising/mydp/composite/Line.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/composite/Rectangle.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/composite/Shape.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/composite/Square.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/composite/Text.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/decorator/Email.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/decorator/EmailDecorator.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/decorator/EmailImpl.java diff --git a/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary1.java b/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary1.java new file mode 100644 index 0000000000..74c8d723bf --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary1.java @@ -0,0 +1,11 @@ +package com.coderising.mydp.bridge; + +public class GraphicLibrary1 { + public void draw_a_line(int x1,int y1,int x2,int y2){ + + } + public void draw_a_circle(int x,int y, int r){ + + } + +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary2.java b/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary2.java new file mode 100644 index 0000000000..11cab3f2a0 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary2.java @@ -0,0 +1,11 @@ +package com.coderising.mydp.bridge; + +public class GraphicLibrary2 { + public void drawLine(int x1,int x2,int y1,int y2){ + + } + public void drawCircle(int x,int y, int r){ + + } + +} diff --git a/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilder.java b/students/812350401/src/main/java/com/coderising/mydp/builder/TagBuilder.java similarity index 95% rename from students/812350401/src/main/java/com/coderising/myood/builder/TagBuilder.java rename to students/812350401/src/main/java/com/coderising/mydp/builder/TagBuilder.java index ebfe9fe12b..4f6901c459 100644 --- a/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilder.java +++ b/students/812350401/src/main/java/com/coderising/mydp/builder/TagBuilder.java @@ -1,4 +1,4 @@ -package com.coderising.myood.builder; +package com.coderising.mydp.builder; public class TagBuilder { private TagNode rootNode; diff --git a/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilderTest.java b/students/812350401/src/main/java/com/coderising/mydp/builder/TagBuilderTest.java similarity index 96% rename from students/812350401/src/main/java/com/coderising/myood/builder/TagBuilderTest.java rename to students/812350401/src/main/java/com/coderising/mydp/builder/TagBuilderTest.java index cb80841992..d310d7eb1b 100644 --- a/students/812350401/src/main/java/com/coderising/myood/builder/TagBuilderTest.java +++ b/students/812350401/src/main/java/com/coderising/mydp/builder/TagBuilderTest.java @@ -1,4 +1,4 @@ -package com.coderising.myood.builder; +package com.coderising.mydp.builder; import static org.junit.Assert.*; diff --git a/students/812350401/src/main/java/com/coderising/myood/builder/TagNode.java b/students/812350401/src/main/java/com/coderising/mydp/builder/TagNode.java similarity index 97% rename from students/812350401/src/main/java/com/coderising/myood/builder/TagNode.java rename to students/812350401/src/main/java/com/coderising/mydp/builder/TagNode.java index a9bb180a30..06b0f1c9de 100644 --- a/students/812350401/src/main/java/com/coderising/myood/builder/TagNode.java +++ b/students/812350401/src/main/java/com/coderising/mydp/builder/TagNode.java @@ -1,4 +1,4 @@ -package com.coderising.myood.builder; +package com.coderising.mydp.builder; import java.util.ArrayList; import java.util.List; diff --git a/students/812350401/src/main/java/com/coderising/myood/builder/tagExample.xml b/students/812350401/src/main/java/com/coderising/mydp/builder/tagExample.xml similarity index 100% rename from students/812350401/src/main/java/com/coderising/myood/builder/tagExample.xml rename to students/812350401/src/main/java/com/coderising/mydp/builder/tagExample.xml diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/Line.java b/students/812350401/src/main/java/com/coderising/mydp/composite/Line.java new file mode 100644 index 0000000000..2be4e6406c --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/Line.java @@ -0,0 +1,11 @@ +package com.coderising.mydp.composite; + +public class Line implements Shape { + + @Override + public void draw() { + + + } + +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/Rectangle.java b/students/812350401/src/main/java/com/coderising/mydp/composite/Rectangle.java new file mode 100644 index 0000000000..ae90deb805 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/Rectangle.java @@ -0,0 +1,11 @@ +package com.coderising.mydp.composite; + +public class Rectangle implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + + } + +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/Shape.java b/students/812350401/src/main/java/com/coderising/mydp/composite/Shape.java new file mode 100644 index 0000000000..20e1e0b6d2 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/Shape.java @@ -0,0 +1,5 @@ +package com.coderising.mydp.composite; + +public interface Shape { + public void draw(); +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/Square.java b/students/812350401/src/main/java/com/coderising/mydp/composite/Square.java new file mode 100644 index 0000000000..68df86555f --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/Square.java @@ -0,0 +1,11 @@ +package com.coderising.mydp.composite; + +public class Square implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + + } + +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/Text.java b/students/812350401/src/main/java/com/coderising/mydp/composite/Text.java new file mode 100644 index 0000000000..22927e7789 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/Text.java @@ -0,0 +1,11 @@ +package com.coderising.mydp.composite; + +public class Text implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + + } + +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/decorator/Email.java b/students/812350401/src/main/java/com/coderising/mydp/decorator/Email.java new file mode 100644 index 0000000000..46775bf4bf --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/decorator/Email.java @@ -0,0 +1,6 @@ +package com.coderising.mydp.decorator; + +public interface Email { + public String getContent(); +} + diff --git a/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailDecorator.java b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailDecorator.java new file mode 100644 index 0000000000..3da5682260 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailDecorator.java @@ -0,0 +1,5 @@ +package com.coderising.mydp.decorator; + +public abstract class EmailDecorator implements Email{ + +} \ No newline at end of file diff --git a/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailImpl.java b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailImpl.java new file mode 100644 index 0000000000..0cedef84a2 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailImpl.java @@ -0,0 +1,12 @@ +package com.coderising.mydp.decorator; + +public class EmailImpl implements Email { + private String content; + + public EmailImpl(String content) { + this.content = content; + } + public String getContent() { + return content; + } +} From 8c2973b4fd548b8cbf6f3a5be492dad27379247b Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Mon, 24 Jul 2017 00:03:40 +0800 Subject: [PATCH 36/81] =?UTF-8?q?[feature]=20atm=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coderising/myood/atmSimulation/README.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md new file mode 100644 index 0000000000..8df2519517 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md @@ -0,0 +1,23 @@ +## 某位同学的atm实现 +https://github.com/onlyliuxin/coding2017/pull/512 + +## atm需求 +一个ATM是一台机器,包含读卡设备,显示屏,吐钞口,存钞口,键盘,打印机 + +当机器空闲时,会显示一个欢迎消息,此时键盘和存钞口都是不活动的,直到一张银行卡被插入,读卡器会尝试读取这张卡,如果不可读,会提示用户并且弹出卡片如果卡片可读,读卡设备会读取账号,然后要求用户输入密码, 用户的输入应该显示为星号,而不是真正输入的数字。 + +如果用户输入的密码正确,则显示主菜单; 如果不正确,再给用户两次输入机会,如果第三次依然失败,ATM就吞卡 +主菜单提示用户可以: +1. 存款 +如果选择了存款交易,ATM要求用户输入存款的金额,然后在存钞口放入钞票 +2. 取款 +如果选择了取款交易,ATM要求用户输入提取的金额,如果账户余额足够,并且ATM的现金足够,从吐钞口吐出相应的钞票。 +转账 +3. 如果选择了转账,ATM要求用户输入转入的账号,如果余额足够, 就会执行转账交易 +查看余额 +如果选择了查询余额,ATM则显示账号的的余额所有的交易都是ATM和银行服务器合作 +用户可以选定交易,提供相关信息,交易完成后,返回主菜单 + +所有的交易都是ATM和银行服务器合作完成的,银行保留了账户信息,必须在合适的时候向银行查询这些信息 + +这里其实是两个系统, 一个运行在ATM上,另外一个在银行端 From 86a02897da5ebd62090de6717d9d9399b91c9adb Mon Sep 17 00:00:00 2001 From: orajavac Date: Mon, 24 Jul 2017 15:44:29 +0800 Subject: [PATCH 37/81] 20170724_1544_homework --- .../coding2017/ood/dp/bridge/Bridage.java | 32 +++++++ .../ood/dp/bridge/GraphicLibrary1.java | 10 +++ .../ood/dp/bridge/GraphicLibrary2.java | 10 +++ .../ood/dp/bridge/GraphicLibraryInter1.java | 6 ++ .../ood/dp/bridge/GraphicLibraryInter2.java | 6 ++ .../coding2017/ood/dp/bridge/MyBridge.java | 14 ++++ .../coding2017/ood/dp/builder/TagBuilder.java | 38 +++++++++ .../ood/dp/builder/TagBuilderTest.java | 39 +++++++++ .../coding2017/ood/dp/builder/TagNode.java | 83 +++++++++++++++++++ .../coding2017/ood/dp/composite/Line.java | 9 ++ .../ood/dp/composite/Rectangle.java | 9 ++ .../coding2017/ood/dp/composite/Shape.java | 5 ++ .../coding2017/ood/dp/composite/Square.java | 9 ++ .../coding2017/ood/dp/composite/Text.java | 9 ++ .../coding2017/ood/dp/decorator/Email.java | 5 ++ .../ood/dp/decorator/EmailDecorator.java | 14 ++++ .../dp/decorator/EmailEncryptDecorator.java | 13 +++ .../ood/dp/decorator/EmailImpl.java | 12 +++ 18 files changed, 323 insertions(+) create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/Bridage.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibrary1.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibrary2.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibraryInter1.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibraryInter2.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/MyBridge.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagBuilder.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagBuilderTest.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagNode.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Line.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Rectangle.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Shape.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Square.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Text.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/Email.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/EmailDecorator.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/EmailEncryptDecorator.java create mode 100644 students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/EmailImpl.java diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/Bridage.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/Bridage.java new file mode 100644 index 0000000000..0b5f606a67 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/Bridage.java @@ -0,0 +1,32 @@ +package com.github.orajavac.coding2017.ood.dp.bridge; + +public abstract class Bridage { + + private GraphicLibraryInter1 g1; + + public GraphicLibraryInter1 getG1() { + return g1; + } + + public void setG1(GraphicLibraryInter1 g1) { + this.g1 = g1; + } + + public GraphicLibraryInter2 getG2() { + return g2; + } + + public void setG2(GraphicLibraryInter2 g2) { + this.g2 = g2; + } + + private GraphicLibraryInter2 g2; + + public void drawAGraph(){ + + } + + public void drawGraph(){ + + } +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibrary1.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibrary1.java new file mode 100644 index 0000000000..327caf7645 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibrary1.java @@ -0,0 +1,10 @@ +package com.github.orajavac.coding2017.ood.dp.bridge; + +public class GraphicLibrary1 implements GraphicLibraryInter1{ + public void draw_a_line(int x1,int y1,int x2,int y2){ + System.out.println("draw_a_line"); + } + public void draw_a_circle(int x,int y, int r){ + System.out.println("draw_a_circle"); + } +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibrary2.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibrary2.java new file mode 100644 index 0000000000..903f7e8869 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibrary2.java @@ -0,0 +1,10 @@ +package com.github.orajavac.coding2017.ood.dp.bridge; + +public class GraphicLibrary2 implements GraphicLibraryInter2{ + public void drawLine(int x1,int x2,int y1,int y2){ + System.out.println("drawLine"); + } + public void drawCircle(int x,int y, int r){ + System.out.println("drawCircle"); + } +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibraryInter1.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibraryInter1.java new file mode 100644 index 0000000000..514ea4362d --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibraryInter1.java @@ -0,0 +1,6 @@ +package com.github.orajavac.coding2017.ood.dp.bridge; + +public interface GraphicLibraryInter1 { + public void draw_a_line(int x1,int y1,int x2,int y2); + public void draw_a_circle(int x,int y, int r); +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibraryInter2.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibraryInter2.java new file mode 100644 index 0000000000..55946c6419 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/GraphicLibraryInter2.java @@ -0,0 +1,6 @@ +package com.github.orajavac.coding2017.ood.dp.bridge; + +public interface GraphicLibraryInter2 { + public void drawLine(int x1,int x2,int y1,int y2); + public void drawCircle(int x,int y, int r); +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/MyBridge.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/MyBridge.java new file mode 100644 index 0000000000..30762d49f9 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/bridge/MyBridge.java @@ -0,0 +1,14 @@ +package com.github.orajavac.coding2017.ood.dp.bridge; + +public class MyBridge extends Bridage{ + + public void drawAGraph(){ + getG1().draw_a_circle(1,2,3); + getG1().draw_a_line(1, 2,3,4); + } + + public void drawGraph(){ + getG2().drawLine(1,2,3,4); + getG2().drawCircle(1, 2,3); + } +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagBuilder.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagBuilder.java new file mode 100644 index 0000000000..9fa50d3529 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagBuilder.java @@ -0,0 +1,38 @@ +package com.github.orajavac.coding2017.ood.dp.builder; + +public class TagBuilder { + + private TagNode rootNode; + private TagNode currentNode; + private TagNode parentNode; + public TagBuilder(String rootTagName){ + rootNode = new TagNode(rootTagName); + currentNode = rootNode; + parentNode = null; + } + + public TagBuilder addChild(String childTagName){ + parentNode = this.currentNode; + this.currentNode = new TagNode(childTagName); + parentNode.add(currentNode); + return this; + } + public TagBuilder addSibling(String siblingTagName){ + + this.currentNode = new TagNode(siblingTagName); + parentNode.add(this.currentNode); + return this; + + } + public TagBuilder setAttribute(String name, String value){ + this.currentNode.setAttribute(name, value); + return this; + } + public TagBuilder setText(String value){ + this.currentNode.setValue(value); + return this; + } + public String toXML(){ + return this.rootNode.toXML(); + } +} \ No newline at end of file diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagBuilderTest.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagBuilderTest.java new file mode 100644 index 0000000000..4922057b53 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagBuilderTest.java @@ -0,0 +1,39 @@ +package com.github.orajavac.coding2017.ood.dp.builder; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class TagBuilderTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testToXML() { + +TagBuilder builder = new TagBuilder("order"); + + String xml = builder.addChild("line-items") + .addChild("line-item").setAttribute("pid", "P3677").setAttribute("qty", "3") + .addSibling("line-item").setAttribute("pid", "P9877").setAttribute("qty", "10") + .toXML(); + + String expected = "" + + "" + + "" + + "" + + "" + + ""; + + System.out.println(xml); + assertEquals(expected, xml); + } +} \ No newline at end of file diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagNode.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagNode.java new file mode 100644 index 0000000000..dd305c8c0f --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/builder/TagNode.java @@ -0,0 +1,83 @@ +package com.github.orajavac.coding2017.ood.dp.builder; + +import java.util.ArrayList; +import java.util.List; + +public class TagNode { + private String tagName; + private String tagValue; + private List children = new ArrayList<>(); + private List attributes = new ArrayList<>(); + + public TagNode(String name){ + this.tagName = name; + } + public void add(TagNode child){ + this.children.add(child); + } + public void setAttribute(String name, String value) { + Attribute attr = findAttribute(name); + if(attr != null){ + attr.value = value; + return; + } + + attributes.add(new Attribute(name,value)); + } + private Attribute findAttribute(String name){ + for(Attribute attr : attributes){ + if(attr.name.equals(name)){ + return attr; + } + } + return null; + } + public void setValue(String value) { + this.tagValue = value; + + } + public String getTagName() { + return tagName; + } + public List getChildren() { + return children; + } + + private static class Attribute{ + public Attribute(String name, String value) { + this.name = name; + this.value = value; + } + String name; + String value; + + } + public String toXML(){ + return toXML(this); + } + private String toXML(TagNode node){ + StringBuilder buffer = new StringBuilder(); + buffer.append("<").append(node.tagName); + if(node.attributes.size()> 0){ + for(int i=0;i"); + return buffer.toString(); + } + buffer.append(">"); + for(TagNode childNode : node.children){ + buffer.append(toXML(childNode)); + } + buffer.append(""); + + + return buffer.toString(); + } + private String toXML(Attribute attr){ + return attr.name+"=\""+attr.value + "\""; + } +} \ No newline at end of file diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Line.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Line.java new file mode 100644 index 0000000000..fd0187f8f7 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Line.java @@ -0,0 +1,9 @@ +package com.github.orajavac.coding2017.ood.dp.composite; + +public class Line implements Shape{ + @Override + public void draw() { + + + } +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Rectangle.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Rectangle.java new file mode 100644 index 0000000000..0c48433bd1 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Rectangle.java @@ -0,0 +1,9 @@ +package com.github.orajavac.coding2017.ood.dp.composite; + +public class Rectangle implements Shape{ + @Override + public void draw() { + // TODO Auto-generated method stub + + } +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Shape.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Shape.java new file mode 100644 index 0000000000..4760261807 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Shape.java @@ -0,0 +1,5 @@ +package com.github.orajavac.coding2017.ood.dp.composite; + +public interface Shape { + public void draw(); +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Square.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Square.java new file mode 100644 index 0000000000..4c722ef6b0 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Square.java @@ -0,0 +1,9 @@ +package com.github.orajavac.coding2017.ood.dp.composite; + +public class Square implements Shape{ + @Override + public void draw() { + // TODO Auto-generated method stub + + } +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Text.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Text.java new file mode 100644 index 0000000000..0f964c516e --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/composite/Text.java @@ -0,0 +1,9 @@ +package com.github.orajavac.coding2017.ood.dp.composite; + +public class Text implements Shape{ + @Override + public void draw() { + // TODO Auto-generated method stub + + } +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/Email.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/Email.java new file mode 100644 index 0000000000..b7ad769be7 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/Email.java @@ -0,0 +1,5 @@ +package com.github.orajavac.coding2017.ood.dp.decorator; + +public interface Email { + public String getContent(); +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/EmailDecorator.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/EmailDecorator.java new file mode 100644 index 0000000000..4a441ae7c4 --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/EmailDecorator.java @@ -0,0 +1,14 @@ +package com.github.orajavac.coding2017.ood.dp.decorator; + +public class EmailDecorator implements Email{ + + private Email email; + + public EmailDecorator(Email e){ + this.email = e; + } + + public String getContent(){ + return email.getContent()+",本邮件仅为个人观点,并不代表公司立场"; + } +} diff --git a/students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/EmailEncryptDecorator.java b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/EmailEncryptDecorator.java new file mode 100644 index 0000000000..56c653fcfe --- /dev/null +++ b/students/562768642/src/com/github/orajavac/coding2017/ood/dp/decorator/EmailEncryptDecorator.java @@ -0,0 +1,13 @@ +package com.github.orajavac.coding2017.ood.dp.decorator; + +public class EmailEncryptDecorator implements Email{ + private Email email; + + public EmailEncryptDecorator(Email e){ + this.email = e; + } + + public String getContent(){ + return "$a^@ Date: Tue, 25 Jul 2017 01:04:38 +0800 Subject: [PATCH 38/81] =?UTF-8?q?[feature]=20bridge=EF=BC=88=E6=A1=A5?= =?UTF-8?q?=E6=8E=A5=EF=BC=89=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 构造了画图接口Drawing及其实现类 2. 构造了图形接口Shape及其实现类 3. 将图形与画图桥接起来,完成用不同的画图库来绘制不同的图形 --- .../com/coderising/mydp/bridge/Circle.java | 34 +++++++++++++++++ .../coderising/mydp/bridge/DrawClient.java | 26 +++++++++++++ .../com/coderising/mydp/bridge/DrawGL1.java | 24 ++++++++++++ .../com/coderising/mydp/bridge/DrawGL2.java | 23 ++++++++++++ .../com/coderising/mydp/bridge/Drawing.java | 9 +++++ .../mydp/bridge/GraphicLibrary1.java | 17 +++++++-- .../mydp/bridge/GraphicLibrary2.java | 12 +++++- .../com/coderising/mydp/bridge/Rectangle.java | 37 +++++++++++++++++++ .../com/coderising/mydp/bridge/Shape.java | 11 ++++++ 9 files changed, 188 insertions(+), 5 deletions(-) create mode 100644 students/812350401/src/main/java/com/coderising/mydp/bridge/Circle.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/bridge/DrawClient.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/bridge/DrawGL1.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/bridge/DrawGL2.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/bridge/Drawing.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/bridge/Rectangle.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/bridge/Shape.java diff --git a/students/812350401/src/main/java/com/coderising/mydp/bridge/Circle.java b/students/812350401/src/main/java/com/coderising/mydp/bridge/Circle.java new file mode 100644 index 0000000000..267a5ec13e --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/bridge/Circle.java @@ -0,0 +1,34 @@ +package com.coderising.mydp.bridge; + +/** + * Created by thomas_young on 25/7/2017. + */ +public class Circle implements Shape { + private int x, y, r; + private Drawing drawing; + + @Override + public void draw() { + drawing.drawCircle(x, y, r); + } + + public Circle(int x, int y, int r) { + this.x = x; + this.y = y; + this.r = r; + this.drawing = drawing; + } + + @Override + public void setDrawing(Drawing drawing) { + this.drawing = drawing; + } + + public static void main(String[] args) { + Shape c = new Circle(3,4,0); + c.setDrawing(new DrawGL1()); + c.draw(); + c.setDrawing(new DrawGL2()); + c.draw(); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/bridge/DrawClient.java b/students/812350401/src/main/java/com/coderising/mydp/bridge/DrawClient.java new file mode 100644 index 0000000000..5c8c2cf2c8 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/bridge/DrawClient.java @@ -0,0 +1,26 @@ +package com.coderising.mydp.bridge; + +/** + * Created by thomas_young on 25/7/2017. + */ +public class DrawClient { + public static void main(String[] args) { + Shape r = new Rectangle(1,2,3,4); + Shape c = new Circle(2,3,4); + Drawing d1 = new DrawGL1(); + Drawing d2 = new DrawGL2(); + + r.setDrawing(d1); + r.draw(); + System.out.println(); + r.setDrawing(d2); + r.draw(); + System.out.println(); + + c.setDrawing(d1); + c.draw(); + System.out.println(); + c.setDrawing(d2); + c.draw(); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/bridge/DrawGL1.java b/students/812350401/src/main/java/com/coderising/mydp/bridge/DrawGL1.java new file mode 100644 index 0000000000..a1218aaae5 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/bridge/DrawGL1.java @@ -0,0 +1,24 @@ +package com.coderising.mydp.bridge; + +/** + * Created by thomas_young on 25/7/2017. + */ +public class DrawGL1 implements Drawing { + private GraphicLibrary1 gl1 = new GraphicLibrary1(); + + @Override + public void drawLine(int x1, int y1, int x2, int y2) { + gl1.draw_a_line(x1, y1, x2, y2); + } + + @Override + public void drawCircle(int x, int y, int r) { + gl1.draw_a_circle(x, y, r); + } + + public static void main(String[] args) { + DrawGL1 d1 = new DrawGL1(); + d1.drawCircle(4,5,1); + d1.drawLine(1,2,3,4); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/bridge/DrawGL2.java b/students/812350401/src/main/java/com/coderising/mydp/bridge/DrawGL2.java new file mode 100644 index 0000000000..03faf2a82a --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/bridge/DrawGL2.java @@ -0,0 +1,23 @@ +package com.coderising.mydp.bridge; + +/** + * Created by thomas_young on 25/7/2017. + */ +class DrawGL2 implements Drawing { + private GraphicLibrary2 gl2 = new GraphicLibrary2(); + @Override + public void drawLine(int x1, int y1, int x2, int y2) { + gl2.drawLine(x1, y1, x2, y2); + } + + @Override + public void drawCircle(int x, int y, int r) { + gl2.drawCircle(x, y, r); + } + + public static void main(String[] args) { + DrawGL2 d2 = new DrawGL2(); + d2.drawCircle(4,5,1); + d2.drawLine(1,2,3,4); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/bridge/Drawing.java b/students/812350401/src/main/java/com/coderising/mydp/bridge/Drawing.java new file mode 100644 index 0000000000..2c641784bc --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/bridge/Drawing.java @@ -0,0 +1,9 @@ +package com.coderising.mydp.bridge; + +/** + * Created by thomas_young on 25/7/2017. + */ +public interface Drawing { + void drawLine(int x1, int y1, int x2, int y2); + void drawCircle(int x, int y, int r); +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary1.java b/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary1.java index 74c8d723bf..7b5bafa6d3 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary1.java +++ b/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary1.java @@ -2,10 +2,21 @@ public class GraphicLibrary1 { public void draw_a_line(int x1,int y1,int x2,int y2){ - + System.out.println("Library1_line: " + get_a_line(x1, y1, x2, y2)); } - public void draw_a_circle(int x,int y, int r){ - + + private String get_a_line(int x1,int y1,int x2,int y2) { + return "(" + x1 + ", " + y1 + ")-----"+"(" + x2 + ", " + y2 + ")"; + } + + public void draw_a_circle(int x,int y, int r) { + System.out.println("Library1_circle: " + "(" + x + ", " + y +"), r=" + r); } + public static void main(String[] args) { + GraphicLibrary1 library1 = new GraphicLibrary1(); + library1.draw_a_line(1,3,4,5); + library1.draw_a_circle(0,2,4); + } + } diff --git a/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary2.java b/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary2.java index 11cab3f2a0..cac917ffc4 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary2.java +++ b/students/812350401/src/main/java/com/coderising/mydp/bridge/GraphicLibrary2.java @@ -2,10 +2,18 @@ public class GraphicLibrary2 { public void drawLine(int x1,int x2,int y1,int y2){ - + System.out.println("Library2_line: " + getLine(x1, y1, x2, y2)); } public void drawCircle(int x,int y, int r){ - + System.out.println("Library2_circle: " + "(" + x + ", " + y +"), r=" + r); + } + private String getLine(int x1,int y1,int x2,int y2) { + return "(" + x1 + ", " + y1 + ")-----"+"(" + x2 + ", " + y2 + ")"; } + public static void main(String[] args) { + GraphicLibrary2 library2 = new GraphicLibrary2(); + library2.drawLine(1,3,4,5); + library2.drawCircle(0,2,4); + } } diff --git a/students/812350401/src/main/java/com/coderising/mydp/bridge/Rectangle.java b/students/812350401/src/main/java/com/coderising/mydp/bridge/Rectangle.java new file mode 100644 index 0000000000..9ca3bb9591 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/bridge/Rectangle.java @@ -0,0 +1,37 @@ +package com.coderising.mydp.bridge; + +/** + * Created by thomas_young on 25/7/2017. + */ +public class Rectangle implements Shape { + private Drawing drawing; + private int x1, y1, x2, y2; + + @Override + public void setDrawing(Drawing drawing) { + this.drawing = drawing; + } + + @Override + public void draw() { + drawing.drawLine(x1, y1, x1, y2); + drawing.drawLine(x1, y1, x2, y1); + drawing.drawLine(x1, y2, x2, y2); + drawing.drawLine(x2, y1, x2, y2); + } + + public Rectangle(int x1, int y1, int x2, int y2) { + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = x2; + } + + public static void main(String[] args) { + Shape r = new Rectangle(1,2,3,4); + r.setDrawing(new DrawGL1()); + r.draw(); + r.setDrawing(new DrawGL2()); + r.draw(); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/bridge/Shape.java b/students/812350401/src/main/java/com/coderising/mydp/bridge/Shape.java new file mode 100644 index 0000000000..4a89d2cbe1 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/bridge/Shape.java @@ -0,0 +1,11 @@ +package com.coderising.mydp.bridge; + +/** + * Created by thomas_young on 25/7/2017. + */ +public interface Shape { + + void setDrawing(Drawing drawing); + + void draw(); +} From 5e10c457f848621a5b112e12a073658b2e634aec Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Tue, 25 Jul 2017 08:05:27 +0800 Subject: [PATCH 39/81] =?UTF-8?q?[feature]=20=E8=A3=85=E9=A5=B0=E8=80=85?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 实现了外发邮件装饰者 2. 实现了机密邮件装饰者 3. 编写了测试用例 --- students/812350401/pom.xml | 5 ++ .../com/coderising/mydp/decorator/Email.java | 2 +- .../mydp/decorator/EmailDecorator.java | 1 + .../mydp/decorator/EmailEncrypt.java | 24 ++++++++ .../mydp/decorator/EmailSendOut.java | 19 ++++++ .../coderising/mydp/decorator/EmailTest.java | 42 ++++++++++++++ .../com/coderising/mydp/utils/Encryptor.java | 58 +++++++++++++++++++ 7 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 students/812350401/src/main/java/com/coderising/mydp/decorator/EmailEncrypt.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/decorator/EmailSendOut.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/decorator/EmailTest.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/utils/Encryptor.java diff --git a/students/812350401/pom.xml b/students/812350401/pom.xml index 8f2f890209..13499886be 100644 --- a/students/812350401/pom.xml +++ b/students/812350401/pom.xml @@ -39,6 +39,11 @@ google-collections 1.0 + + commons-codec + commons-codec + 1.6 + diff --git a/students/812350401/src/main/java/com/coderising/mydp/decorator/Email.java b/students/812350401/src/main/java/com/coderising/mydp/decorator/Email.java index 46775bf4bf..d4b4bc12ab 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/decorator/Email.java +++ b/students/812350401/src/main/java/com/coderising/mydp/decorator/Email.java @@ -1,6 +1,6 @@ package com.coderising.mydp.decorator; public interface Email { - public String getContent(); + String getContent(); } diff --git a/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailDecorator.java b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailDecorator.java index 3da5682260..045b344b42 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailDecorator.java +++ b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailDecorator.java @@ -1,5 +1,6 @@ package com.coderising.mydp.decorator; public abstract class EmailDecorator implements Email{ + } \ No newline at end of file diff --git a/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailEncrypt.java b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailEncrypt.java new file mode 100644 index 0000000000..b31c09139d --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailEncrypt.java @@ -0,0 +1,24 @@ +package com.coderising.mydp.decorator; + +import com.coderising.mydp.utils.Encryptor; + +/** + * Created by thomas_young on 25/7/2017. + */ +public class EmailEncrypt extends EmailDecorator { + private Email email; + private String key; + private String initVector; + + public EmailEncrypt(String key, String initVector, Email email) { + this.key = key; + this.initVector = initVector; + this.email = email; + } + + @Override + public String getContent() { + String content = email.getContent(); + return Encryptor.encrypt(key, initVector, content); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailSendOut.java b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailSendOut.java new file mode 100644 index 0000000000..a553e7120a --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailSendOut.java @@ -0,0 +1,19 @@ +package com.coderising.mydp.decorator; + +/** + * Created by thomas_young on 25/7/2017. + */ +public class EmailSendOut extends EmailDecorator { + Email email; + + public EmailSendOut(Email email) { + this.email = email; + } + + @Override + public String getContent() { + String content = email.getContent(); + content += "\n" + "本邮件仅为个人观点,并不代表公司立场."; + return content; + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailTest.java b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailTest.java new file mode 100644 index 0000000000..48df0f5dd5 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/decorator/EmailTest.java @@ -0,0 +1,42 @@ +package com.coderising.mydp.decorator; + +import com.coderising.mydp.utils.Encryptor; +import org.junit.Test; + +/** + * Created by thomas_young on 25/7/2017. + */ +public class EmailTest { + private Email email = new EmailImpl("Hello World!"); + private String key = "Bar12345Bar12345"; // 128 bit key + private String initVector = "RandomInitVector"; // 16 bytes IV + + @Test + public void testSendToOut() { + Email emailSendOut = new EmailSendOut(email); + System.out.println(emailSendOut.getContent()); + } + + @Test + public void testEncrypt() { + Email emailEncrypt = new EmailEncrypt(key, initVector, email); + String encryptedContent = emailEncrypt.getContent(); + System.out.println("encrypted content: " + encryptedContent); + System.out.println(Encryptor.decrypt(key, initVector, encryptedContent)); + } + + @Test + public void testEncryptSendOut() { + Email emailsendOutEncrypt = new EmailSendOut(new EmailEncrypt(key, initVector, email)); + System.out.println(emailsendOutEncrypt.getContent()); + System.out.println(); + + Email emailEncryptSendOut = new EmailEncrypt(key, initVector, new EmailSendOut(email)); + String encryptedContent = emailEncryptSendOut.getContent(); + System.out.println("encrypted content: " + encryptedContent); + + System.out.println(); + System.out.println(Encryptor.decrypt(key, initVector, encryptedContent)); + + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/utils/Encryptor.java b/students/812350401/src/main/java/com/coderising/mydp/utils/Encryptor.java new file mode 100644 index 0000000000..af177ed678 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/utils/Encryptor.java @@ -0,0 +1,58 @@ +package com.coderising.mydp.utils; + +/** + * Created by thomas_young on 25/7/2017. + */ +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +import org.apache.commons.codec.binary.Base64; + +public class Encryptor { + public static String encrypt(String key, String initVector, String value) { + try { + IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8")); + SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); + + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); + cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv); + + byte[] encrypted = cipher.doFinal(value.getBytes()); + // System.out.println("encrypted string: " + // + Base64.encodeBase64String(encrypted)); + + return Base64.encodeBase64String(encrypted); + } catch (Exception ex) { + ex.printStackTrace(); + } + + return null; + } + + public static String decrypt(String key, String initVector, String encrypted) { + try { + IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8")); + SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); + + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); + cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); + + byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted)); + + return new String(original); + } catch (Exception ex) { + ex.printStackTrace(); + } + + return null; + } + + public static void main(String[] args) { + String key = "Bar12345Bar12345"; // 128 bit key + String initVector = "RandomInitVector"; // 16 bytes IV + + System.out.println(decrypt(key, initVector, + encrypt(key, initVector, "Hello World"))); + } +} From 77d3fdd9574adfe6119e24338937986b1f6d354c Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Wed, 26 Jul 2017 00:17:14 +0800 Subject: [PATCH 40/81] =?UTF-8?q?[feature]=20=E5=AE=9E=E7=8E=B0=E7=BB=84?= =?UTF-8?q?=E5=90=88(Composite)=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mydp/composite/CompositeTest.java | 26 +++++++++++++++++++ .../com/coderising/mydp/composite/Line.java | 3 +-- .../coderising/mydp/composite/Picture.java | 23 ++++++++++++++++ .../coderising/mydp/composite/Rectangle.java | 2 +- .../com/coderising/mydp/composite/Shape.java | 2 +- .../com/coderising/mydp/composite/Square.java | 2 +- .../com/coderising/mydp/composite/Text.java | 2 +- 7 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 students/812350401/src/main/java/com/coderising/mydp/composite/CompositeTest.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/composite/Picture.java diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/CompositeTest.java b/students/812350401/src/main/java/com/coderising/mydp/composite/CompositeTest.java new file mode 100644 index 0000000000..1a93f9e60b --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/CompositeTest.java @@ -0,0 +1,26 @@ +package com.coderising.mydp.composite; + +import org.junit.Test; + +/** + * Created by thomas_young on 25/7/2017. + */ +public class CompositeTest { + + @Test + public void testComposite() { + Picture aPicture = new Picture(); + aPicture.add(new Line()); + aPicture.add(new Rectangle()); + + Picture p = new Picture(); + p.add(new Text()); + p.add(new Line()); + p.add(new Square()); + + aPicture.add(p); + aPicture.add(new Picture()); + aPicture.add(new Line()); + aPicture.draw(); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/Line.java b/students/812350401/src/main/java/com/coderising/mydp/composite/Line.java index 2be4e6406c..2c469cadc4 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/composite/Line.java +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/Line.java @@ -4,8 +4,7 @@ public class Line implements Shape { @Override public void draw() { - - + System.out.println("Line"); } } diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/Picture.java b/students/812350401/src/main/java/com/coderising/mydp/composite/Picture.java new file mode 100644 index 0000000000..79a434679f --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/Picture.java @@ -0,0 +1,23 @@ +package com.coderising.mydp.composite; + +import java.util.LinkedList; +import java.util.List; + +/** + * Created by thomas_young on 26/7/2017. + */ +public class Picture implements Shape { + private List shapes = new LinkedList<>(); + + @Override + public void draw() { + System.out.println("Picture"); + for (Shape shape: shapes) { + shape.draw(); + } + } + public void add(Shape shape) { + shapes.add(shape); + } + +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/Rectangle.java b/students/812350401/src/main/java/com/coderising/mydp/composite/Rectangle.java index ae90deb805..3b068664e7 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/composite/Rectangle.java +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/Rectangle.java @@ -5,7 +5,7 @@ public class Rectangle implements Shape { @Override public void draw() { // TODO Auto-generated method stub - + System.out.println("Rectangle"); } } diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/Shape.java b/students/812350401/src/main/java/com/coderising/mydp/composite/Shape.java index 20e1e0b6d2..2ab46ef491 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/composite/Shape.java +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/Shape.java @@ -1,5 +1,5 @@ package com.coderising.mydp.composite; public interface Shape { - public void draw(); + void draw(); } diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/Square.java b/students/812350401/src/main/java/com/coderising/mydp/composite/Square.java index 68df86555f..2df037fb8f 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/composite/Square.java +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/Square.java @@ -5,7 +5,7 @@ public class Square implements Shape { @Override public void draw() { // TODO Auto-generated method stub - + System.out.println("Square"); } } diff --git a/students/812350401/src/main/java/com/coderising/mydp/composite/Text.java b/students/812350401/src/main/java/com/coderising/mydp/composite/Text.java index 22927e7789..1e6e9c7e9f 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/composite/Text.java +++ b/students/812350401/src/main/java/com/coderising/mydp/composite/Text.java @@ -5,7 +5,7 @@ public class Text implements Shape { @Override public void draw() { // TODO Auto-generated method stub - + System.out.println("Text"); } } From d1a785b12301feb09babca3e6e72b79513bd94c1 Mon Sep 17 00:00:00 2001 From: jy <977996067@qq.com> Date: Thu, 27 Jul 2017 23:27:49 +0800 Subject: [PATCH 41/81] Add Decorator&Composition&Bridge pattern homework --- .../coderising/dp/week2/bridge/Circle.java | 15 ++++++ .../dp/week2/bridge/DrawClient.java | 9 ++++ .../coderising/dp/week2/bridge/Drawing.java | 8 +++ .../dp/week2/bridge/DrawingGL1.java | 14 +++++ .../dp/week2/bridge/DrawingGL2.java | 14 +++++ .../coderising/dp/week2/bridge/Rectangle.java | 15 ++++++ .../com/coderising/dp/week2/bridge/Shape.java | 16 ++++++ .../coderising/dp/week2/composition/Line.java | 9 ++++ .../dp/week2/composition/Picture.java | 18 +++++++ .../dp/week2/composition/Rectangle.java | 9 ++++ .../dp/week2/composition/Shape.java | 6 +++ .../dp/week2/composition/ShapeClient.java | 17 +++++++ .../dp/week2/composition/Square.java | 9 ++++ .../coderising/dp/week2/composition/Text.java | 9 ++++ .../coderising/dp/week2/decorator/Email.java | 6 +++ .../dp/week2/decorator/EmailDecorator.java | 51 +++++++++++++++++++ .../dp/week2/decorator/EmailImpl.java | 15 ++++++ .../dp/week2/decorator/EmailType.java | 6 +++ 18 files changed, 246 insertions(+) create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/bridge/Circle.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawClient.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/bridge/Drawing.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawingGL1.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawingGL2.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/bridge/Rectangle.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/bridge/Shape.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/composition/Line.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/composition/Picture.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/composition/Rectangle.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/composition/Shape.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/composition/ShapeClient.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/composition/Square.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/composition/Text.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/decorator/Email.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailDecorator.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailImpl.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailType.java diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Circle.java b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Circle.java new file mode 100644 index 0000000000..c90c1b3889 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Circle.java @@ -0,0 +1,15 @@ +package com.coderising.dp.week2.bridge; + +public class Circle extends Shape { + + public Circle(Drawing drawing) { + super(drawing); + } + + @Override + public void draw() { + getDrawing().drawLine(); + getDrawing().drawCircle(); + System.out.println("I am drawing a circle ..."); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawClient.java b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawClient.java new file mode 100644 index 0000000000..c59cd73066 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawClient.java @@ -0,0 +1,9 @@ +package com.coderising.dp.week2.bridge; + +public class DrawClient { + + public static void main(String[] args) { + Drawing drawing = new DrawingGL1(); + new Rectangle(drawing).draw(); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Drawing.java b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Drawing.java new file mode 100644 index 0000000000..afa394c29f --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Drawing.java @@ -0,0 +1,8 @@ +package com.coderising.dp.week2.bridge; + +public interface Drawing { + + void drawLine(); + + void drawCircle(); +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawingGL1.java b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawingGL1.java new file mode 100644 index 0000000000..1b3f6c09c4 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawingGL1.java @@ -0,0 +1,14 @@ +package com.coderising.dp.week2.bridge; + +public class DrawingGL1 implements Drawing { + + @Override + public void drawLine() { + System.out.println("I am drawing line 1 ..."); + } + + @Override + public void drawCircle() { + System.out.println("I am drawing circle 1 ..."); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawingGL2.java b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawingGL2.java new file mode 100644 index 0000000000..23031c0122 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/DrawingGL2.java @@ -0,0 +1,14 @@ +package com.coderising.dp.week2.bridge; + +public class DrawingGL2 implements Drawing { + + @Override + public void drawLine() { + System.out.println("I am drawing line 2 ..."); + } + + @Override + public void drawCircle() { + System.out.println("I am drawing circle 2 ..."); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Rectangle.java b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Rectangle.java new file mode 100644 index 0000000000..9ebfaa12d5 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Rectangle.java @@ -0,0 +1,15 @@ +package com.coderising.dp.week2.bridge; + +public class Rectangle extends Shape { + + public Rectangle(Drawing drawing) { + super(drawing); + } + + @Override + public void draw() { + getDrawing().drawLine(); + getDrawing().drawCircle(); + System.out.println("I am drawing a rectangle ..."); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Shape.java b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Shape.java new file mode 100644 index 0000000000..28d2d90430 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/bridge/Shape.java @@ -0,0 +1,16 @@ +package com.coderising.dp.week2.bridge; + +public abstract class Shape { + + private Drawing drawing; + + public Shape(Drawing drawing) { + this.drawing = drawing; + } + + public Drawing getDrawing() { + return drawing; + } + + protected abstract void draw(); +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/composition/Line.java b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Line.java new file mode 100644 index 0000000000..d0d15396fa --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Line.java @@ -0,0 +1,9 @@ +package com.coderising.dp.week2.composition; + +public class Line implements Shape { + + @Override + public void draw() { + System.out.println("I am drawing a line ..."); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/composition/Picture.java b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Picture.java new file mode 100644 index 0000000000..8dd13fc673 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Picture.java @@ -0,0 +1,18 @@ +package com.coderising.dp.week2.composition; + +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +public class Picture implements Shape { + + private List shapes = new CopyOnWriteArrayList<>(); + + @Override + public void draw() { + shapes.forEach(Shape::draw); + } + + public void addShape(Shape shape) { + shapes.add(shape); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/composition/Rectangle.java b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Rectangle.java new file mode 100644 index 0000000000..00fb136dcb --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Rectangle.java @@ -0,0 +1,9 @@ +package com.coderising.dp.week2.composition; + +public class Rectangle implements Shape { + + @Override + public void draw() { + System.out.println("I am drawing a rectangle ..."); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/composition/Shape.java b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Shape.java new file mode 100644 index 0000000000..5ccbf9fa9c --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Shape.java @@ -0,0 +1,6 @@ +package com.coderising.dp.week2.composition; + +public interface Shape { + + void draw(); +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/composition/ShapeClient.java b/students/977996067/src/main/java/com/coderising/dp/week2/composition/ShapeClient.java new file mode 100644 index 0000000000..e8a0c2e7f3 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/composition/ShapeClient.java @@ -0,0 +1,17 @@ +package com.coderising.dp.week2.composition; + +public class ShapeClient { + + public static void main(String[] args) { + Picture subPicture = new Picture(); + Line line = new Line(); + subPicture.addShape(new Text()); + subPicture.addShape(line); + subPicture.addShape(new Square()); + Picture parentPicture = new Picture(); + parentPicture.addShape(subPicture); + parentPicture.addShape(line); + parentPicture.addShape(new Rectangle()); + parentPicture.draw(); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/composition/Square.java b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Square.java new file mode 100644 index 0000000000..7d21e6ead1 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Square.java @@ -0,0 +1,9 @@ +package com.coderising.dp.week2.composition; + +public class Square implements Shape { + + @Override + public void draw() { + System.out.println("I am drawing a square ..."); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/composition/Text.java b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Text.java new file mode 100644 index 0000000000..7c255262f6 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/composition/Text.java @@ -0,0 +1,9 @@ +package com.coderising.dp.week2.composition; + +public class Text implements Shape { + + @Override + public void draw() { + System.out.println("I am drawing a text..."); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/decorator/Email.java b/students/977996067/src/main/java/com/coderising/dp/week2/decorator/Email.java new file mode 100644 index 0000000000..f530f207ea --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/decorator/Email.java @@ -0,0 +1,6 @@ +package com.coderising.dp.week2.decorator; + +public interface Email { + + String getContent(); +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailDecorator.java b/students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailDecorator.java new file mode 100644 index 0000000000..8faae4222d --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailDecorator.java @@ -0,0 +1,51 @@ +package com.coderising.dp.week2.decorator; + +import java.nio.charset.Charset; +import java.util.Base64; + +public class EmailDecorator implements Email { + + private Email email; + + private String rawContent; + + private String handledContent; + + private EmailType emailType; + + public EmailDecorator(Email email) { + this(email, EmailType.PRIVATE); + } + + public EmailDecorator(Email email, EmailType emailType) { + this.email = email; + handle(email.getContent(), emailType); + } + + @Override + public String getContent() { + if (isModified()) { + handle(this.email.getContent(), this.emailType); + } + return this.handledContent; + } + + private void handle(String rawString, EmailType emailType) { + this.rawContent = rawString; + this.emailType = emailType; + String decodeString = decode(rawString); + this.handledContent = emailType == EmailType.PRIVATE ? decodeString : (decodeString + "本邮件仅为个人观点,并不代表公司立场"); + + } + + private String decode(String rawString) { + return new String(Base64.getEncoder().encode(rawString.getBytes()), Charset.defaultCharset()); + } + + private boolean isModified() { + if (this.rawContent == null) { + throw new RuntimeException(); + } + return email != null && rawContent.equals(email.getContent()); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailImpl.java b/students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailImpl.java new file mode 100644 index 0000000000..fd1a0eb48b --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailImpl.java @@ -0,0 +1,15 @@ +package com.coderising.dp.week2.decorator; + +public class EmailImpl implements Email { + + private String content; + + public EmailImpl(String content) { + this.content = content; + } + + @Override + public String getContent() { + return this.content; + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailType.java b/students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailType.java new file mode 100644 index 0000000000..97ed1febea --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week2/decorator/EmailType.java @@ -0,0 +1,6 @@ +package com.coderising.dp.week2.decorator; + +public enum EmailType { + PRIVATE, + PUBLIC +} From ef5a65856f94d9adba5ae5bc189fe7b9dcb6c5ea Mon Sep 17 00:00:00 2001 From: Liu Zengzeng Date: Fri, 28 Jul 2017 10:12:43 +0800 Subject: [PATCH 42/81] dp homework compoiste bridge and decorator --- .../java/com/coderings/dp/bridge/Circle.java | 35 ++++++++++++++++ .../com/coderings/dp/bridge/ClientMain.java | 19 +++++++++ .../coderings/dp/bridge/GraphicLibrary.java | 11 +++++ .../coderings/dp/bridge/GraphicLibrary1.java | 24 +++++++++++ .../coderings/dp/bridge/GraphicLibrary2.java | 23 +++++++++++ .../java/com/coderings/dp/bridge/Line.java | 40 +++++++++++++++++++ .../java/com/coderings/dp/bridge/Shape.java | 5 +++ .../coderings/dp/composite/ClientMain.java | 16 ++++++++ .../coderings/dp/composite/ComponetShape.java | 9 +++++ .../dp/composite/CompositeShape.java | 26 ++++++++++++ .../java/com/coderings/dp/composite/Line.java | 10 +++++ .../com/coderings/dp/composite/Rectangle.java | 11 +++++ .../com/coderings/dp/composite/Shape.java | 5 +++ .../com/coderings/dp/composite/Square.java | 11 +++++ .../java/com/coderings/dp/composite/Text.java | 11 +++++ .../com/coderings/dp/decorator/Email.java | 6 +++ .../dp/decorator/EmailDecorator.java | 13 ++++++ .../com/coderings/dp/decorator/EmailImpl.java | 12 ++++++ .../com/coderings/dp/decorator/EmailMain.java | 15 +++++++ .../dp/decorator/EncryptEmailImpl.java | 20 ++++++++++ .../dp/decorator/StatementEmailImpl.java | 17 ++++++++ 21 files changed, 339 insertions(+) create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Circle.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/ClientMain.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary1.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary2.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Line.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Shape.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/ClientMain.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/ComponetShape.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/CompositeShape.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Line.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Rectangle.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Shape.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Square.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Text.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/Email.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailDecorator.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailImpl.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailMain.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EncryptEmailImpl.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/StatementEmailImpl.java diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Circle.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Circle.java new file mode 100644 index 0000000000..f0395794a4 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Circle.java @@ -0,0 +1,35 @@ +package com.coderings.dp.bridge; + +public class Circle implements Shape { + + int x; + int y; + int r; + + private GraphicLibrary graphicLibrary; + + public Circle(int x, int y, int r, GraphicLibrary graphicLibrary) { + this.x = x; + this.y = y; + this.r = r; + this.graphicLibrary = graphicLibrary; + } + + public int getX() { + return x; + } + + public int getY() { + return y; + } + + public int getR() { + return r; + } + + @Override + public void draw() { + graphicLibrary.drawCircle(this); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/ClientMain.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/ClientMain.java new file mode 100644 index 0000000000..0414dd6df9 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/ClientMain.java @@ -0,0 +1,19 @@ +package com.coderings.dp.bridge; + +/** + * @author nvarchar + * date 2017/7/28 + */ +public class ClientMain { + public static void main(String[] args) { + Shape line = new Line(1,2,1,2,new GraphicLibrary1()); + Shape line2 = new Line(1,2,1,2,new GraphicLibrary2()); + Shape circle = new Circle(1,2,2,new GraphicLibrary1()); + Shape circle2 = new Circle(1,2,1,new GraphicLibrary2()); + + line.draw(); + line2.draw(); + circle.draw(); + circle2.draw(); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary.java new file mode 100644 index 0000000000..d9fcb6ae5a --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary.java @@ -0,0 +1,11 @@ +package com.coderings.dp.bridge; + +/** + * @author nvarchar + * date 2017/7/28 + */ +public interface GraphicLibrary { + void drawLine(Shape shape); + + void drawCircle(Shape shape); +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary1.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary1.java new file mode 100644 index 0000000000..31776b21d8 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary1.java @@ -0,0 +1,24 @@ +package com.coderings.dp.bridge; + +public class GraphicLibrary1 implements GraphicLibrary{ + + @Override + public void drawLine(Shape shape) { + Line line = (Line)shape; + draw_a_line(line.getX1(), line.getY1(), line.getX2(), line.getY2()); + } + + @Override + public void drawCircle(Shape shape) { + Circle circle = (Circle)shape; + draw_a_circle(circle.getX(), circle.getY(), circle.getY()); + } + + public void draw_a_line(int x1, int y1, int x2, int y2){ + System.out.println("graphic1 draw a line..."); + } + public void draw_a_circle(int x,int y, int r){ + System.out.println("graphic1 draw a circle..."); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary2.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary2.java new file mode 100644 index 0000000000..ee9d7e8685 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/GraphicLibrary2.java @@ -0,0 +1,23 @@ +package com.coderings.dp.bridge; + +public class GraphicLibrary2 implements GraphicLibrary{ + @Override + public void drawLine(Shape shape) { + Line line = (Line)shape; + drawLine(line.getX1(), line.getX2(), line.getY1(), line.getY2()); + } + + @Override + public void drawCircle(Shape shape) { + Circle circle = (Circle)shape; + drawCircle(circle.getX(), circle.getY(), circle.getY()); + } + + public void drawLine(int x1, int x2, int y1, int y2){ + System.out.println("graphic2 draw a line..."); + } + public void drawCircle(int x,int y, int r){ + System.out.println("graphic2 draw a circle..."); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Line.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Line.java new file mode 100644 index 0000000000..3d0b7a9077 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Line.java @@ -0,0 +1,40 @@ +package com.coderings.dp.bridge; + +public class Line implements Shape { + private int x1; + private int y1; + private int x2; + private int y2; + + private GraphicLibrary graphicLibrary; + + public Line(int x1, int y1, int x2, int y2, GraphicLibrary graphicLibrary) { + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = y2; + this.graphicLibrary = graphicLibrary; + } + + public int getX1() { + return x1; + } + + public int getY1() { + return y1; + } + + public int getX2() { + return x2; + } + + public int getY2() { + return y2; + } + + @Override + public void draw() { + graphicLibrary.drawLine(this); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Shape.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Shape.java new file mode 100644 index 0000000000..658219a872 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/bridge/Shape.java @@ -0,0 +1,5 @@ +package com.coderings.dp.bridge; + +public interface Shape { + public void draw(); +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/ClientMain.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/ClientMain.java new file mode 100644 index 0000000000..62b6c44a11 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/ClientMain.java @@ -0,0 +1,16 @@ +package com.coderings.dp.composite; + +/** + * @author nvarchar + * date 2017/7/28 + */ +public class ClientMain { + public static void main(String[] args) { + CompositeShape compositeShape = new CompositeShape(); + compositeShape.add(new Line()); + compositeShape.add(new Square()); + compositeShape.add(new Rectangle()); + compositeShape.add(new Text()); + compositeShape.draw(); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/ComponetShape.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/ComponetShape.java new file mode 100644 index 0000000000..9992c45c2d --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/ComponetShape.java @@ -0,0 +1,9 @@ +package com.coderings.dp.composite; + +/** + * @author nvarchar + * date 2017/7/28 + */ +public abstract class ComponetShape implements Shape { + public abstract void add(Shape shape); +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/CompositeShape.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/CompositeShape.java new file mode 100644 index 0000000000..2fe2e164e0 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/CompositeShape.java @@ -0,0 +1,26 @@ +package com.coderings.dp.composite; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author nvarchar + * date 2017/7/28 + */ +public class CompositeShape extends ComponetShape{ + + private List shapes = new ArrayList<>(); + + @Override + public void draw() { + for(Shape shape : shapes){ + shape.draw(); + } + } + + @Override + public void add(Shape shape) { + shapes.add(shape); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Line.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Line.java new file mode 100644 index 0000000000..cc1f6c858a --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Line.java @@ -0,0 +1,10 @@ +package com.coderings.dp.composite; + +public class Line implements Shape { + + @Override + public void draw() { + System.out.println("draw line"); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Rectangle.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Rectangle.java new file mode 100644 index 0000000000..95a91e522a --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Rectangle.java @@ -0,0 +1,11 @@ +package com.coderings.dp.composite; + +public class Rectangle implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + System.out.println("draw rectangle"); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Shape.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Shape.java new file mode 100644 index 0000000000..ea353dad66 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Shape.java @@ -0,0 +1,5 @@ +package com.coderings.dp.composite; + +public interface Shape { + public void draw(); +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Square.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Square.java new file mode 100644 index 0000000000..2f6b44bdad --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Square.java @@ -0,0 +1,11 @@ +package com.coderings.dp.composite; + +public class Square implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + System.out.println("draw square"); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Text.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Text.java new file mode 100644 index 0000000000..e44cb39591 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/composite/Text.java @@ -0,0 +1,11 @@ +package com.coderings.dp.composite; + +public class Text implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + System.out.println("draw text"); + } + +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/Email.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/Email.java new file mode 100644 index 0000000000..f06ce0174f --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/Email.java @@ -0,0 +1,6 @@ +package com.coderings.dp.decorator; + +public interface Email { + public String getContent(); +} + diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailDecorator.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailDecorator.java new file mode 100644 index 0000000000..acb9cb5ec5 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailDecorator.java @@ -0,0 +1,13 @@ +package com.coderings.dp.decorator; + +public abstract class EmailDecorator implements Email{ + protected Email email; + + public EmailDecorator(Email email) { + this.email = email; + } + + public String getContent() { + return email.getContent(); + } +} \ No newline at end of file diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailImpl.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailImpl.java new file mode 100644 index 0000000000..2d0abae365 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailImpl.java @@ -0,0 +1,12 @@ +package com.coderings.dp.decorator; + +public class EmailImpl implements Email { + private String content; + + public EmailImpl(String content) { + this.content = content; + } + public String getContent() { + return content; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailMain.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailMain.java new file mode 100644 index 0000000000..e2822ab9de --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EmailMain.java @@ -0,0 +1,15 @@ +package com.coderings.dp.decorator; + +/** + * @author nvarchar + * date 2017/7/28 + */ +public class EmailMain { + public static void main(String[] args) { + Email stateEmail = new StatementEmailImpl(new EmailImpl("发邮件")); + Email encryptEmail = new EncryptEmailImpl(new EmailImpl("发邮件")); + + System.out.println(stateEmail.getContent()); + System.out.println(encryptEmail.getContent()); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EncryptEmailImpl.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EncryptEmailImpl.java new file mode 100644 index 0000000000..5a63aa84cf --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/EncryptEmailImpl.java @@ -0,0 +1,20 @@ +package com.coderings.dp.decorator; + +/** + * @author nvarchar + * date 2017/7/26 + */ +public class EncryptEmailImpl extends EmailDecorator { + + public EncryptEmailImpl(Email email) { + super(email); + } + + private String encrypt(String content) { + return "****" + content + "****"; + } + + public String getContent() { + return encrypt(email.getContent()); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/StatementEmailImpl.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/StatementEmailImpl.java new file mode 100644 index 0000000000..a71b0dd7ac --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/decorator/StatementEmailImpl.java @@ -0,0 +1,17 @@ +package com.coderings.dp.decorator; + +/** + * @author nvarchar + * date 2017/7/26 + */ +public class StatementEmailImpl extends EmailDecorator { + + public StatementEmailImpl(Email email) { + super(email); + } + + public String getContent(){ + String state = "本邮件仅代表个人立场,不代表公司立场;"; + return email.getContent() + state; + } +} From f6062be9d17b45778a298f5efe4f53dda9bf8697 Mon Sep 17 00:00:00 2001 From: yangzhm Date: Fri, 28 Jul 2017 10:14:23 +0800 Subject: [PATCH 43/81] add homework of bridgepattern,compositepattern and decoratorpattern --- .../OOD/bridgepattern/DrawCircle.java | 15 +++++++++++++ .../495232796/OOD/bridgepattern/DrawLine.java | 16 ++++++++++++++ .../495232796/OOD/bridgepattern/Drawing.java | 6 +++++ .../OOD/bridgepattern/GraphicLibrary1.java | 10 +++++++++ .../bridgepattern/GraphicLibrary1Adapter.java | 15 +++++++++++++ .../OOD/bridgepattern/GraphicLibrary2.java | 10 +++++++++ .../495232796/OOD/bridgepattern/Shape.java | 10 +++++++++ .../495232796/OOD/compositepattern/Line.java | 10 +++++++++ .../OOD/compositepattern/Picture.java | 19 ++++++++++++++++ .../OOD/compositepattern/Rectangle.java | 10 +++++++++ .../495232796/OOD/compositepattern/Shape.java | 5 +++++ .../OOD/compositepattern/Square.java | 10 +++++++++ .../495232796/OOD/compositepattern/Text.java | 10 +++++++++ .../495232796/OOD/decoratorpattern/Email.java | 6 +++++ .../OOD/decoratorpattern/EmailDecorator.java | 13 +++++++++++ .../EmailEncryptionDecorator.java | 20 +++++++++++++++++ .../OOD/decoratorpattern/EmailImpl.java | 12 ++++++++++ .../EmailStatementDecorator.java | 22 +++++++++++++++++++ 18 files changed, 219 insertions(+) create mode 100644 students/495232796/OOD/bridgepattern/DrawCircle.java create mode 100644 students/495232796/OOD/bridgepattern/DrawLine.java create mode 100644 students/495232796/OOD/bridgepattern/Drawing.java create mode 100644 students/495232796/OOD/bridgepattern/GraphicLibrary1.java create mode 100644 students/495232796/OOD/bridgepattern/GraphicLibrary1Adapter.java create mode 100644 students/495232796/OOD/bridgepattern/GraphicLibrary2.java create mode 100644 students/495232796/OOD/bridgepattern/Shape.java create mode 100644 students/495232796/OOD/compositepattern/Line.java create mode 100644 students/495232796/OOD/compositepattern/Picture.java create mode 100644 students/495232796/OOD/compositepattern/Rectangle.java create mode 100644 students/495232796/OOD/compositepattern/Shape.java create mode 100644 students/495232796/OOD/compositepattern/Square.java create mode 100644 students/495232796/OOD/compositepattern/Text.java create mode 100644 students/495232796/OOD/decoratorpattern/Email.java create mode 100644 students/495232796/OOD/decoratorpattern/EmailDecorator.java create mode 100644 students/495232796/OOD/decoratorpattern/EmailEncryptionDecorator.java create mode 100644 students/495232796/OOD/decoratorpattern/EmailImpl.java create mode 100644 students/495232796/OOD/decoratorpattern/EmailStatementDecorator.java diff --git a/students/495232796/OOD/bridgepattern/DrawCircle.java b/students/495232796/OOD/bridgepattern/DrawCircle.java new file mode 100644 index 0000000000..a9d515fbb4 --- /dev/null +++ b/students/495232796/OOD/bridgepattern/DrawCircle.java @@ -0,0 +1,15 @@ +package com.coderising.dp.bridge; + +public class DrawCircle extends Shape{ + public int x, y, r; + + public DrawCircle(Drawing drawing, int x, int y, int r) { + super(drawing); + this.x =x; + this.y = y; + this.r = r; + } + public void draw() { + this.drawing.drawCircle(x, y, r); + } +} diff --git a/students/495232796/OOD/bridgepattern/DrawLine.java b/students/495232796/OOD/bridgepattern/DrawLine.java new file mode 100644 index 0000000000..df0271d16b --- /dev/null +++ b/students/495232796/OOD/bridgepattern/DrawLine.java @@ -0,0 +1,16 @@ +package com.coderising.dp.bridge; + +public class DrawLine extends Shape{ + int x1, y1, x2, y2; + + public DrawLine(Drawing drawing, int x1, int y1, int x2, int y2) { + super(drawing); + this.x1 = x1; + this.x2 = x2; + this.y1 = y1; + this.y2 = y2; + } + public void draw() { + this.drawing.drawLine(x1, y1, x2, y2); + } +} diff --git a/students/495232796/OOD/bridgepattern/Drawing.java b/students/495232796/OOD/bridgepattern/Drawing.java new file mode 100644 index 0000000000..3149c68822 --- /dev/null +++ b/students/495232796/OOD/bridgepattern/Drawing.java @@ -0,0 +1,6 @@ +package com.coderising.dp.bridge; + +public interface Drawing { + public void drawLine(int x1,int y1,int x2,int y2); + public void drawCircle(int x,int y, int r); +} diff --git a/students/495232796/OOD/bridgepattern/GraphicLibrary1.java b/students/495232796/OOD/bridgepattern/GraphicLibrary1.java new file mode 100644 index 0000000000..1ecf2f0548 --- /dev/null +++ b/students/495232796/OOD/bridgepattern/GraphicLibrary1.java @@ -0,0 +1,10 @@ +package com.coderising.dp.bridge; + +public class GraphicLibrary1{ + public void draw_a_line(int x1,int y1,int x2,int y2){ + System.out.println("Draw a line with using library1."); + } + public void draw_a_circle(int x,int y, int r){ + System.out.println("Draw a circle with using library1"); + } +} diff --git a/students/495232796/OOD/bridgepattern/GraphicLibrary1Adapter.java b/students/495232796/OOD/bridgepattern/GraphicLibrary1Adapter.java new file mode 100644 index 0000000000..8e33fd2482 --- /dev/null +++ b/students/495232796/OOD/bridgepattern/GraphicLibrary1Adapter.java @@ -0,0 +1,15 @@ +package com.coderising.dp.bridge; + +public class GraphicLibrary1Adapter implements Drawing{ + GraphicLibrary1 glib = new GraphicLibrary1(); + @Override + public void drawLine(int x1, int y1, int x2, int y2) { + this.glib.draw_a_line(x1, y1, x2, y2); + } + + @Override + public void drawCircle(int x, int y, int r) { + this.glib.draw_a_circle(x, y, r); + } + +} diff --git a/students/495232796/OOD/bridgepattern/GraphicLibrary2.java b/students/495232796/OOD/bridgepattern/GraphicLibrary2.java new file mode 100644 index 0000000000..f008fa54db --- /dev/null +++ b/students/495232796/OOD/bridgepattern/GraphicLibrary2.java @@ -0,0 +1,10 @@ +package com.coderising.dp.bridge; + +public class GraphicLibrary2 implements Drawing{ + public void drawLine(int x1,int x2,int y1,int y2){ + System.out.println("Draw a line with using library2."); + } + public void drawCircle(int x,int y, int r){ + System.out.println("Draw a circle with using library2."); + } +} diff --git a/students/495232796/OOD/bridgepattern/Shape.java b/students/495232796/OOD/bridgepattern/Shape.java new file mode 100644 index 0000000000..34861f43f9 --- /dev/null +++ b/students/495232796/OOD/bridgepattern/Shape.java @@ -0,0 +1,10 @@ +package com.coderising.dp.bridge; + +public abstract class Shape { + public Drawing drawing; + public Shape(Drawing drawing) { + this.drawing = drawing; + } + public void draw() { + } +} diff --git a/students/495232796/OOD/compositepattern/Line.java b/students/495232796/OOD/compositepattern/Line.java new file mode 100644 index 0000000000..884e8d9220 --- /dev/null +++ b/students/495232796/OOD/compositepattern/Line.java @@ -0,0 +1,10 @@ +package com.coderising.dp.composite; + +public class Line implements Shape { + + @Override + public void draw() { + System.out.println("This is a line."); + } + +} diff --git a/students/495232796/OOD/compositepattern/Picture.java b/students/495232796/OOD/compositepattern/Picture.java new file mode 100644 index 0000000000..8029dc4aac --- /dev/null +++ b/students/495232796/OOD/compositepattern/Picture.java @@ -0,0 +1,19 @@ +package com.coderising.dp.composite; + +import java.util.ArrayList; +import java.util.List; + +public class Picture implements Shape{ + List shapes = new ArrayList<>(); + + @Override + public void draw() { + for(Shape shape : shapes) { + shape.draw(); + } + } + + public void addShape(Shape shape) { + shapes.add(shape); + } +} diff --git a/students/495232796/OOD/compositepattern/Rectangle.java b/students/495232796/OOD/compositepattern/Rectangle.java new file mode 100644 index 0000000000..d0734b4d63 --- /dev/null +++ b/students/495232796/OOD/compositepattern/Rectangle.java @@ -0,0 +1,10 @@ +package com.coderising.dp.composite; + +public class Rectangle implements Shape { + + @Override + public void draw() { + System.out.println("This is a rectangle."); + } + +} diff --git a/students/495232796/OOD/compositepattern/Shape.java b/students/495232796/OOD/compositepattern/Shape.java new file mode 100644 index 0000000000..4562f10b12 --- /dev/null +++ b/students/495232796/OOD/compositepattern/Shape.java @@ -0,0 +1,5 @@ +package com.coderising.dp.composite; + +public interface Shape { + public void draw(); +} diff --git a/students/495232796/OOD/compositepattern/Square.java b/students/495232796/OOD/compositepattern/Square.java new file mode 100644 index 0000000000..30ab0e7b85 --- /dev/null +++ b/students/495232796/OOD/compositepattern/Square.java @@ -0,0 +1,10 @@ +package com.coderising.dp.composite; + +public class Square implements Shape { + + @Override + public void draw() { + System.out.println("This is a sqare."); + } + +} diff --git a/students/495232796/OOD/compositepattern/Text.java b/students/495232796/OOD/compositepattern/Text.java new file mode 100644 index 0000000000..0f831f62fe --- /dev/null +++ b/students/495232796/OOD/compositepattern/Text.java @@ -0,0 +1,10 @@ +package com.coderising.dp.composite; + +public class Text implements Shape { + + @Override + public void draw() { + System.out.println("This is a text."); + } + +} diff --git a/students/495232796/OOD/decoratorpattern/Email.java b/students/495232796/OOD/decoratorpattern/Email.java new file mode 100644 index 0000000000..064de1e837 --- /dev/null +++ b/students/495232796/OOD/decoratorpattern/Email.java @@ -0,0 +1,6 @@ +package com.coderising.dp.decorator; + +public interface Email { + public String getContent(); +} + diff --git a/students/495232796/OOD/decoratorpattern/EmailDecorator.java b/students/495232796/OOD/decoratorpattern/EmailDecorator.java new file mode 100644 index 0000000000..61ea7c2d2a --- /dev/null +++ b/students/495232796/OOD/decoratorpattern/EmailDecorator.java @@ -0,0 +1,13 @@ +package com.coderising.dp.decorator; + +public abstract class EmailDecorator implements Email{ + protected Email email; + + public EmailDecorator(Email e) { + this.email = e; + } + + public String getContent(){ + return this.email.getContent(); + } +} \ No newline at end of file diff --git a/students/495232796/OOD/decoratorpattern/EmailEncryptionDecorator.java b/students/495232796/OOD/decoratorpattern/EmailEncryptionDecorator.java new file mode 100644 index 0000000000..65a6e56a26 --- /dev/null +++ b/students/495232796/OOD/decoratorpattern/EmailEncryptionDecorator.java @@ -0,0 +1,20 @@ +package com.coderising.dp.decorator; + +public class EmailEncryptionDecorator extends EmailDecorator{ + + public EmailEncryptionDecorator(Email e) { + super(e); + } + + public String encryptContext() { + return this.email.getContent(); + } + + public String decryptContext() { + return this.email.getContent(); + } + + public String getContent() { + return this.encryptContext(); + } +} diff --git a/students/495232796/OOD/decoratorpattern/EmailImpl.java b/students/495232796/OOD/decoratorpattern/EmailImpl.java new file mode 100644 index 0000000000..640aef6da3 --- /dev/null +++ b/students/495232796/OOD/decoratorpattern/EmailImpl.java @@ -0,0 +1,12 @@ +package com.coderising.dp.decorator; + +public class EmailImpl implements Email { + private String content; + + public EmailImpl(String content) { + this.content = content; + } + public String getContent() { + return content; + } +} diff --git a/students/495232796/OOD/decoratorpattern/EmailStatementDecorator.java b/students/495232796/OOD/decoratorpattern/EmailStatementDecorator.java new file mode 100644 index 0000000000..15e14ecabd --- /dev/null +++ b/students/495232796/OOD/decoratorpattern/EmailStatementDecorator.java @@ -0,0 +1,22 @@ +package com.coderising.dp.decorator; + +public class EmailStatementDecorator extends EmailDecorator{ + private String statement; + + public EmailStatementDecorator(Email e) { + super(e); + } + + public String getStatement() { + return statement; + } + + public void setStatement(String statement) { + this.statement = statement; + } + + public String getContent() { + return this.email.getContent() + this.statement; + } + +} From 08e5727dd19bd1141e7b1a190f7ead50ff15bb10 Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 29 Jul 2017 18:57:22 +0800 Subject: [PATCH 44/81] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/dp/bridge/BridgeTest.java | 21 ++++++++++ .../src/main/java/dp/bridge/Circle.java | 17 ++++++++ .../src/main/java/dp/bridge/Drawing.java | 10 +++++ .../src/main/java/dp/bridge/DrawingGL1.java | 17 ++++++++ .../src/main/java/dp/bridge/DrawingGL2.java | 17 ++++++++ .../src/main/java/dp/bridge/Retangle.java | 16 +++++++ .../src/main/java/dp/bridge/Shape.java | 18 ++++++++ .../main/java/dp/{ => builder}/Attribute.java | 2 +- .../java/dp/{ => builder}/TagBuilder.java | 2 +- .../java/dp/{ => builder}/TagBuilderTest.java | 2 +- .../main/java/dp/{ => builder}/TagNode.java | 2 +- .../main/java/dp/composite/CompositeTest.java | 24 +++++++++++ .../src/main/java/dp/composite/Line.java | 12 ++++++ .../src/main/java/dp/composite/Picture.java | 42 +++++++++++++++++++ .../src/main/java/dp/composite/Rectangle.java | 12 ++++++ .../src/main/java/dp/composite/Shape.java | 8 ++++ .../src/main/java/dp/composite/Square.java | 12 ++++++ .../src/main/java/dp/composite/Text.java | 12 ++++++ .../src/main/java/dp/decorator/Email.java | 8 ++++ .../src/main/java/dp/decorator/EmailImpl.java | 17 ++++++++ .../src/main/java/dp/decorator/EmailTest.java | 15 +++++++ .../dp/decorator/EncryptionEmailImpl.java | 22 ++++++++++ .../main/java/dp/decorator/FilterEmail.java | 18 ++++++++ .../java/dp/decorator/OutsideEmailImpl.java | 22 ++++++++++ 24 files changed, 344 insertions(+), 4 deletions(-) create mode 100644 students/740707954/src/main/java/dp/bridge/BridgeTest.java create mode 100644 students/740707954/src/main/java/dp/bridge/Circle.java create mode 100644 students/740707954/src/main/java/dp/bridge/Drawing.java create mode 100644 students/740707954/src/main/java/dp/bridge/DrawingGL1.java create mode 100644 students/740707954/src/main/java/dp/bridge/DrawingGL2.java create mode 100644 students/740707954/src/main/java/dp/bridge/Retangle.java create mode 100644 students/740707954/src/main/java/dp/bridge/Shape.java rename students/740707954/src/main/java/dp/{ => builder}/Attribute.java (95%) rename students/740707954/src/main/java/dp/{ => builder}/TagBuilder.java (98%) rename students/740707954/src/main/java/dp/{ => builder}/TagBuilderTest.java (98%) rename students/740707954/src/main/java/dp/{ => builder}/TagNode.java (99%) create mode 100644 students/740707954/src/main/java/dp/composite/CompositeTest.java create mode 100644 students/740707954/src/main/java/dp/composite/Line.java create mode 100644 students/740707954/src/main/java/dp/composite/Picture.java create mode 100644 students/740707954/src/main/java/dp/composite/Rectangle.java create mode 100644 students/740707954/src/main/java/dp/composite/Shape.java create mode 100644 students/740707954/src/main/java/dp/composite/Square.java create mode 100644 students/740707954/src/main/java/dp/composite/Text.java create mode 100644 students/740707954/src/main/java/dp/decorator/Email.java create mode 100644 students/740707954/src/main/java/dp/decorator/EmailImpl.java create mode 100644 students/740707954/src/main/java/dp/decorator/EmailTest.java create mode 100644 students/740707954/src/main/java/dp/decorator/EncryptionEmailImpl.java create mode 100644 students/740707954/src/main/java/dp/decorator/FilterEmail.java create mode 100644 students/740707954/src/main/java/dp/decorator/OutsideEmailImpl.java diff --git a/students/740707954/src/main/java/dp/bridge/BridgeTest.java b/students/740707954/src/main/java/dp/bridge/BridgeTest.java new file mode 100644 index 0000000000..838014f92a --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/BridgeTest.java @@ -0,0 +1,21 @@ +package dp.bridge; + +import org.junit.Test; + +/** + * Created by lx on 2017/7/29. + */ +public class BridgeTest { + + @Test + public void testBridge() { + Shape shape1 = new Circle(new DrawingGL1()); + Shape shape2 = new Retangle(new DrawingGL1()); + Shape shape3 = new Circle(new DrawingGL2()); + Shape shape4 = new Retangle(new DrawingGL2()); + shape1.shape(); + shape2.shape(); + shape3.shape(); + shape4.shape(); + } +} diff --git a/students/740707954/src/main/java/dp/bridge/Circle.java b/students/740707954/src/main/java/dp/bridge/Circle.java new file mode 100644 index 0000000000..4224535816 --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/Circle.java @@ -0,0 +1,17 @@ +package dp.bridge; + +/** + * Created by lx on 2017/7/29. + */ +public class Circle extends Shape { + public Circle(Drawing drawing) { + setDrawing(drawing); + } + + @Override + public void shape() { + getDrawing().drawCircle(); + } + + +} diff --git a/students/740707954/src/main/java/dp/bridge/Drawing.java b/students/740707954/src/main/java/dp/bridge/Drawing.java new file mode 100644 index 0000000000..1faae5781f --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/Drawing.java @@ -0,0 +1,10 @@ +package dp.bridge; + +/** + * Created by lx on 2017/7/29. + */ +public interface Drawing { + void drawLine(); + + void drawCircle(); +} diff --git a/students/740707954/src/main/java/dp/bridge/DrawingGL1.java b/students/740707954/src/main/java/dp/bridge/DrawingGL1.java new file mode 100644 index 0000000000..8a27855227 --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/DrawingGL1.java @@ -0,0 +1,17 @@ +package dp.bridge; + +/** + * 图形库1 + * Created by lx on 2017/7/29. + */ +public class DrawingGL1 implements Drawing{ + @Override + public void drawLine() { + System.out.println("图形库1画线"); + } + + @Override + public void drawCircle() { + System.out.println("图形库1画圆"); + } +} diff --git a/students/740707954/src/main/java/dp/bridge/DrawingGL2.java b/students/740707954/src/main/java/dp/bridge/DrawingGL2.java new file mode 100644 index 0000000000..419a6853bc --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/DrawingGL2.java @@ -0,0 +1,17 @@ +package dp.bridge; + +/** + * 图形库2 + * Created by lx on 2017/7/29. + */ +public class DrawingGL2 implements Drawing { + @Override + public void drawLine() { + System.out.println("图形库2画线"); + } + + @Override + public void drawCircle() { + System.out.println("图形库2画圆"); + } +} diff --git a/students/740707954/src/main/java/dp/bridge/Retangle.java b/students/740707954/src/main/java/dp/bridge/Retangle.java new file mode 100644 index 0000000000..ea869f1b46 --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/Retangle.java @@ -0,0 +1,16 @@ +package dp.bridge; + +/** + * Created by lx on 2017/7/29. + */ +public class Retangle extends Shape { + public Retangle(Drawing drawing) { + setDrawing(drawing); + } + + @Override + public void shape() { + getDrawing().drawLine(); + } + +} diff --git a/students/740707954/src/main/java/dp/bridge/Shape.java b/students/740707954/src/main/java/dp/bridge/Shape.java new file mode 100644 index 0000000000..1ec254c30b --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/Shape.java @@ -0,0 +1,18 @@ +package dp.bridge; + +/** + * Created by lx on 2017/7/29. + */ +public abstract class Shape { + private Drawing drawing; + + abstract void shape(); + + public void setDrawing(Drawing drawing) { + this.drawing = drawing; + } + + public Drawing getDrawing() { + return drawing; + } +} diff --git a/students/740707954/src/main/java/dp/Attribute.java b/students/740707954/src/main/java/dp/builder/Attribute.java similarity index 95% rename from students/740707954/src/main/java/dp/Attribute.java rename to students/740707954/src/main/java/dp/builder/Attribute.java index 3ec9ee6dbf..a44481c71a 100644 --- a/students/740707954/src/main/java/dp/Attribute.java +++ b/students/740707954/src/main/java/dp/builder/Attribute.java @@ -1,4 +1,4 @@ -package dp; +package dp.builder; /** * Created by lx on 2017/7/22. diff --git a/students/740707954/src/main/java/dp/TagBuilder.java b/students/740707954/src/main/java/dp/builder/TagBuilder.java similarity index 98% rename from students/740707954/src/main/java/dp/TagBuilder.java rename to students/740707954/src/main/java/dp/builder/TagBuilder.java index ea2c63df43..74615b5797 100644 --- a/students/740707954/src/main/java/dp/TagBuilder.java +++ b/students/740707954/src/main/java/dp/builder/TagBuilder.java @@ -1,4 +1,4 @@ -package dp; +package dp.builder; import java.util.List; diff --git a/students/740707954/src/main/java/dp/TagBuilderTest.java b/students/740707954/src/main/java/dp/builder/TagBuilderTest.java similarity index 98% rename from students/740707954/src/main/java/dp/TagBuilderTest.java rename to students/740707954/src/main/java/dp/builder/TagBuilderTest.java index be4815e202..450b7fc043 100644 --- a/students/740707954/src/main/java/dp/TagBuilderTest.java +++ b/students/740707954/src/main/java/dp/builder/TagBuilderTest.java @@ -1,4 +1,4 @@ -package dp; +package dp.builder; import org.junit.After; import org.junit.Before; diff --git a/students/740707954/src/main/java/dp/TagNode.java b/students/740707954/src/main/java/dp/builder/TagNode.java similarity index 99% rename from students/740707954/src/main/java/dp/TagNode.java rename to students/740707954/src/main/java/dp/builder/TagNode.java index 8bf58f772e..bf8caeed0f 100644 --- a/students/740707954/src/main/java/dp/TagNode.java +++ b/students/740707954/src/main/java/dp/builder/TagNode.java @@ -1,4 +1,4 @@ -package dp; +package dp.builder; import java.util.ArrayList; import java.util.List; diff --git a/students/740707954/src/main/java/dp/composite/CompositeTest.java b/students/740707954/src/main/java/dp/composite/CompositeTest.java new file mode 100644 index 0000000000..0b0ea0c60e --- /dev/null +++ b/students/740707954/src/main/java/dp/composite/CompositeTest.java @@ -0,0 +1,24 @@ +package dp.composite; + +import org.junit.Test; + +/** + * Created by lx on 2017/7/29. + */ +public class CompositeTest { + + @Test + public void testComp() { + Picture picture1 = new Picture(); + Picture picture = new Picture(); + picture1.addShape(new Text()); + picture1.addShape(new Line()); + picture1.addShape(new Square()); + picture.addShape(picture1); + picture.addShape(new Line()); + picture.addShape(new Rectangle()); + + picture.draw(); + + } +} diff --git a/students/740707954/src/main/java/dp/composite/Line.java b/students/740707954/src/main/java/dp/composite/Line.java new file mode 100644 index 0000000000..bc3e9a6c0c --- /dev/null +++ b/students/740707954/src/main/java/dp/composite/Line.java @@ -0,0 +1,12 @@ +package dp.composite; + +/** + * 线 + * Created by lx on 2017/7/29. + */ +public class Line implements Shape { + @Override + public void draw() { + System.out.println("画线"); + } +} diff --git a/students/740707954/src/main/java/dp/composite/Picture.java b/students/740707954/src/main/java/dp/composite/Picture.java new file mode 100644 index 0000000000..4809e7bf6b --- /dev/null +++ b/students/740707954/src/main/java/dp/composite/Picture.java @@ -0,0 +1,42 @@ +package dp.composite; + +import java.util.ArrayList; +import java.util.List; + +/** + * 图片 + * Created by lx on 2017/7/29. + */ +public class Picture implements Shape{ + + private List shapes = new ArrayList<>(); + + @Override + public void draw() { + shapes.forEach((shape) -> shape.draw()); + } + + /** + * 添加图形 + * @param shape + */ + public void addShape(Shape shape) { + shapes.add(shape); + } + + /** + * 获取图形 + * @param i + */ + public void getShape(int i) { + shapes.get(i); + } + + /** + * 删除图形 + * @param i + */ + public void deleteShape(int i) { + shapes.remove(i); + } +} diff --git a/students/740707954/src/main/java/dp/composite/Rectangle.java b/students/740707954/src/main/java/dp/composite/Rectangle.java new file mode 100644 index 0000000000..a2b83477c4 --- /dev/null +++ b/students/740707954/src/main/java/dp/composite/Rectangle.java @@ -0,0 +1,12 @@ +package dp.composite; + +/** + * 矩形 + * Created by lx on 2017/7/29. + */ +public class Rectangle implements Shape{ + @Override + public void draw() { + System.out.println("画矩形"); + } +} diff --git a/students/740707954/src/main/java/dp/composite/Shape.java b/students/740707954/src/main/java/dp/composite/Shape.java new file mode 100644 index 0000000000..c7821b1a95 --- /dev/null +++ b/students/740707954/src/main/java/dp/composite/Shape.java @@ -0,0 +1,8 @@ +package dp.composite; + +/** + * Created by lx on 2017/7/29. + */ +public interface Shape { + void draw(); +} diff --git a/students/740707954/src/main/java/dp/composite/Square.java b/students/740707954/src/main/java/dp/composite/Square.java new file mode 100644 index 0000000000..3fd2236441 --- /dev/null +++ b/students/740707954/src/main/java/dp/composite/Square.java @@ -0,0 +1,12 @@ +package dp.composite; + +/** + * 正方形 + * Created by lx on 2017/7/29. + */ +public class Square implements Shape{ + @Override + public void draw() { + System.out.println("画正方形"); + } +} diff --git a/students/740707954/src/main/java/dp/composite/Text.java b/students/740707954/src/main/java/dp/composite/Text.java new file mode 100644 index 0000000000..2a07f699fd --- /dev/null +++ b/students/740707954/src/main/java/dp/composite/Text.java @@ -0,0 +1,12 @@ +package dp.composite; + +/** + * 文本 + * Created by lx on 2017/7/29. + */ +public class Text implements Shape{ + @Override + public void draw() { + System.out.println("画文本"); + } +} diff --git a/students/740707954/src/main/java/dp/decorator/Email.java b/students/740707954/src/main/java/dp/decorator/Email.java new file mode 100644 index 0000000000..520475c0a3 --- /dev/null +++ b/students/740707954/src/main/java/dp/decorator/Email.java @@ -0,0 +1,8 @@ +package dp.decorator; + +/** + * Created by lx on 2017/7/29. + */ +public interface Email { + String getContent(); +} diff --git a/students/740707954/src/main/java/dp/decorator/EmailImpl.java b/students/740707954/src/main/java/dp/decorator/EmailImpl.java new file mode 100644 index 0000000000..58ef0b4d82 --- /dev/null +++ b/students/740707954/src/main/java/dp/decorator/EmailImpl.java @@ -0,0 +1,17 @@ +package dp.decorator; + +/** + * Created by lx on 2017/7/29. + */ +public class EmailImpl implements Email { + private String content; + + public EmailImpl(String content) { + this.content = content; + } + + @Override + public String getContent() { + return content; + } +} diff --git a/students/740707954/src/main/java/dp/decorator/EmailTest.java b/students/740707954/src/main/java/dp/decorator/EmailTest.java new file mode 100644 index 0000000000..81ba464e17 --- /dev/null +++ b/students/740707954/src/main/java/dp/decorator/EmailTest.java @@ -0,0 +1,15 @@ +package dp.decorator; + +import org.junit.Test; + +/** + * Created by lx on 2017/7/29. + */ +public class EmailTest { + @Test + public void testEmail() { + Email e = new OutsideEmailImpl(new EncryptionEmailImpl(new EmailImpl("内容\n"))); + System.out.println(e.getContent()); + } + +} diff --git a/students/740707954/src/main/java/dp/decorator/EncryptionEmailImpl.java b/students/740707954/src/main/java/dp/decorator/EncryptionEmailImpl.java new file mode 100644 index 0000000000..f3adfce50a --- /dev/null +++ b/students/740707954/src/main/java/dp/decorator/EncryptionEmailImpl.java @@ -0,0 +1,22 @@ +package dp.decorator; + +/** + * 加密邮件 + * Created by lx on 2017/7/29. + */ +public class EncryptionEmailImpl extends FilterEmail{ + + public EncryptionEmailImpl(Email email) { + super(email); + } + + @Override + public String getContent() { + return encryptionEmail(super.getContent()); + } + + public String encryptionEmail(String content) { + System.out.println("加密邮件。。"); + return "加密:" + content; + } +} diff --git a/students/740707954/src/main/java/dp/decorator/FilterEmail.java b/students/740707954/src/main/java/dp/decorator/FilterEmail.java new file mode 100644 index 0000000000..c063b0c3da --- /dev/null +++ b/students/740707954/src/main/java/dp/decorator/FilterEmail.java @@ -0,0 +1,18 @@ +package dp.decorator; + +/** + * Created by lx on 2017/7/29. + */ +public class FilterEmail implements Email { + + private Email email; + + public FilterEmail(Email email) { + this.email = email; + } + + @Override + public String getContent() { + return email.getContent(); + } +} diff --git a/students/740707954/src/main/java/dp/decorator/OutsideEmailImpl.java b/students/740707954/src/main/java/dp/decorator/OutsideEmailImpl.java new file mode 100644 index 0000000000..07f53202af --- /dev/null +++ b/students/740707954/src/main/java/dp/decorator/OutsideEmailImpl.java @@ -0,0 +1,22 @@ +package dp.decorator; + +/** + * 外部邮件 + * Created by lx on 2017/7/29. + */ +public class OutsideEmailImpl extends FilterEmail { + + public OutsideEmailImpl(Email email) { + super(email); + } + + @Override + public String getContent() { + return super.getContent() + addSuffix(); + } + + public String addSuffix() { + return "本邮件仅为个人观点,并不代表公司立场"; + } + +} From eb15c6a24a2665f118551ae680579db538594a77 Mon Sep 17 00:00:00 2001 From: akinaru-lu Date: Sun, 30 Jul 2017 10:28:08 +0900 Subject: [PATCH 45/81] =?UTF-8?q?7-23=E6=97=A5=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/coderising/dp/bridge/Circle.java | 20 ++++++++++++++ .../coderising/dp/bridge/GraphicLibrary.java | 9 +++++++ .../coderising/dp/bridge/GraphicLibrary1.java | 26 +++++++++++++++++++ .../coderising/dp/bridge/GraphicLibrary2.java | 21 +++++++++++++++ .../com/coderising/dp/bridge/Rectangle.java | 21 +++++++++++++++ .../java/com/coderising/dp/bridge/Shape.java | 7 +++++ .../com/coderising/dp/composite/Line.java | 9 +++++++ .../com/coderising/dp/composite/Picture.java | 17 ++++++++++++ .../coderising/dp/composite/Rectangle.java | 11 ++++++++ .../com/coderising/dp/composite/Shape.java | 5 ++++ .../com/coderising/dp/composite/Square.java | 10 +++++++ .../com/coderising/dp/composite/Text.java | 10 +++++++ .../com/coderising/dp/decorator/Email.java | 8 ++++++ .../dp/decorator/EmailDecorator.java | 4 +++ .../coderising/dp/decorator/EmailImpl.java | 14 ++++++++++ .../dp/decorator/ExternalEmail.java | 14 ++++++++++ .../dp/decorator/InternalEmail.java | 11 ++++++++ 17 files changed, 217 insertions(+) create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Circle.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Rectangle.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Shape.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Picture.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/Email.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailDecorator.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailImpl.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/ExternalEmail.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/InternalEmail.java diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Circle.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Circle.java new file mode 100644 index 0000000000..af7b07c91b --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Circle.java @@ -0,0 +1,20 @@ +package bridge; + +public class Circle implements Shape { + + private int x; + private int y; + private int r; + + public Circle(int x, int y, int r) { + this.x = x; + this.y = y; + this.r = r; + } + + @Override + public void draw(GraphicLibrary gl) { + gl.drawCircle(x, y, r); + } + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary.java new file mode 100644 index 0000000000..73088a9324 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary.java @@ -0,0 +1,9 @@ +package bridge; + +public interface GraphicLibrary { + + void drawRectangle(int x1, int y1, int x2, int y2); + + void drawCircle(int x, int y, int r); + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java new file mode 100644 index 0000000000..a53f877500 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java @@ -0,0 +1,26 @@ +package bridge; + +public class GraphicLibrary1 implements GraphicLibrary { + + @Override + public void drawRectangle(int x1, int y1, int x2, int y2) { + draw_a_line(x1, y1, x1, y2); + draw_a_line(x1, y2, x2, y2); + draw_a_line(x2, y2, x2, y1); + draw_a_line(x2, y1, x1, y1); + } + + @Override + public void drawCircle(int x, int y, int r) { + draw_a_circle(x, y, r); + } + + private void draw_a_line(int x1, int y1, int x2, int y2) { + + } + + private void draw_a_circle(int x, int y, int r) { + + } + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java new file mode 100644 index 0000000000..6ad1bdc5dd --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java @@ -0,0 +1,21 @@ +package bridge; + +public class GraphicLibrary2 implements GraphicLibrary { + + @Override + public void drawRectangle(int x1, int y1, int x2, int y2) { + drawLine(x1, x2, y1, y2); + drawLine(x1, x2, y2, y2); + drawLine(x2, x2, y2, y1); + drawLine(x2, x1, y1, y1); + } + + @Override + public void drawCircle(int x,int y, int r) { + + } + + private void drawLine(int x1, int x2, int y1, int y2) { + } + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Rectangle.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Rectangle.java new file mode 100644 index 0000000000..471c2b94ec --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Rectangle.java @@ -0,0 +1,21 @@ +package bridge; + +public class Rectangle implements Shape { + + private int x1; + private int y1; + private int x2; + private int y2; + + public Rectangle(int x1, int y1, int x2, int y2) { + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = y2; + } + + @Override + public void draw(GraphicLibrary gl) { + gl.drawRectangle(x1, y1, x2, y2); + } +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Shape.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Shape.java new file mode 100644 index 0000000000..1b6e584cd4 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Shape.java @@ -0,0 +1,7 @@ +package bridge; + +public interface Shape { + + void draw(GraphicLibrary gl); + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java new file mode 100644 index 0000000000..d15975aaad --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java @@ -0,0 +1,9 @@ +package composite; + +public class Line implements Shape { + + @Override + public void draw() { + } + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Picture.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Picture.java new file mode 100644 index 0000000000..80bfa14450 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Picture.java @@ -0,0 +1,17 @@ +package composite; + +import java.util.ArrayList; +import java.util.List; + +public class Picture implements Shape { + private final List shapes = new ArrayList<>(); + + @Override + public void draw() { + shapes.forEach(shape -> draw()); + } + + public void add(Shape shape) { + shapes.add(shape); + } +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java new file mode 100644 index 0000000000..4902fbcd99 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java @@ -0,0 +1,11 @@ +package composite; + +public class Rectangle implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + + } + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java new file mode 100644 index 0000000000..8864087e5f --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java @@ -0,0 +1,5 @@ +package composite; + +public interface Shape { + public void draw(); +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java new file mode 100644 index 0000000000..9aff729f35 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java @@ -0,0 +1,10 @@ +package composite; + +public class Square implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + } + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java new file mode 100644 index 0000000000..15305bb9e6 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java @@ -0,0 +1,10 @@ +package composite; + +public class Text implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + } + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/Email.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/Email.java new file mode 100644 index 0000000000..c36050aa31 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/Email.java @@ -0,0 +1,8 @@ +package decorator; + +public interface Email { + + String getContent(); + +} + diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailDecorator.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailDecorator.java new file mode 100644 index 0000000000..0cadd60575 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailDecorator.java @@ -0,0 +1,4 @@ +package decorator; + +public abstract class EmailDecorator implements Email { +} \ No newline at end of file diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailImpl.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailImpl.java new file mode 100644 index 0000000000..7044dc9c47 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailImpl.java @@ -0,0 +1,14 @@ +package decorator; + +public class EmailImpl implements Email { + + private String content; + + public EmailImpl(String content) { + this.content = content; + } + + public String getContent() { + return content; + } +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/ExternalEmail.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/ExternalEmail.java new file mode 100644 index 0000000000..1dc01a34bf --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/ExternalEmail.java @@ -0,0 +1,14 @@ +package decorator; + +public class ExternalEmail extends EmailDecorator { + + private Email email; + + public ExternalEmail(Email email) { + this.email = email; + } + + public String getContent() { + return email.getContent() + "\n\n本邮件仅为个人观点,并不代表公司立场"; + } +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/InternalEmail.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/InternalEmail.java new file mode 100644 index 0000000000..885a7573db --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/InternalEmail.java @@ -0,0 +1,11 @@ +package decorator; + +public class InternalEmail extends EmailDecorator { + + private Email email; + + public String getContent() { + return email.getContent(); + } + +} From 155bd791bf3ddfe6a7bb00c22182b4a0e2e75f12 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Sun, 30 Jul 2017 21:17:25 +0800 Subject: [PATCH 46/81] =?UTF-8?q?[Feature]=20ATM=E5=88=9D=E6=AD=A5?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- students/812350401/pom.xml | 9 +- .../coderising/myood/atmSimulation/README.md | 4 +- .../myood/atmSimulation/impl/ATM.java | 137 ++++++++++++++++++ .../atmSimulation/impl/BankProxyImpl.java | 23 +++ .../atmSimulation/impl/CardReaderImpl.java | 33 +++++ .../atmSimulation/impl/CashDispenserImpl.java | 24 +++ .../atmSimulation/impl/DepositSlotImpl.java | 16 ++ .../impl/DepositTransaction.java | 56 +++++++ .../myood/atmSimulation/impl/DisplayImpl.java | 23 +++ .../atmSimulation/impl/KeyBoardImpl.java | 27 ++++ .../atmSimulation/impl/NetworkClient.java | 16 ++ .../myood/atmSimulation/impl/SuperKeyPad.java | 98 +++++++++++++ .../impl/WithdrawTransaction.java | 49 +++++++ .../myood/atmSimulation/model/BankProxy.java | 22 +++ .../myood/atmSimulation/model/CardReader.java | 10 ++ .../atmSimulation/model/CashDispenser.java | 22 +++ .../atmSimulation/model/DepositSlot.java | 14 ++ .../myood/atmSimulation/model/Display.java | 9 ++ .../myood/atmSimulation/model/KeyBoard.java | 8 + .../myood/atmSimulation/model/Printer.java | 8 + .../atmSimulation/model/Transaction.java | 45 ++++++ .../atmSimulation/utils/SingletonScanner.java | 18 +++ .../myood/atmSimulation/impl/ATMTest.java | 34 +++++ .../atmSimulation/impl/BankProxyImplTest.java | 31 ++++ .../atmSimulation/impl/SuperKeyPadTest.java | 72 +++++++++ .../atmSimulation/model/CardReaderTest.java | 33 +++++ .../atmSimulation/model/DisplayTest.java | 23 +++ .../atmSimulation/model/KeyBoardTest.java | 29 ++++ .../atmSimulation/model/TransactionTest.java | 54 +++++++ 29 files changed, 944 insertions(+), 3 deletions(-) create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/BankProxyImpl.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CardReaderImpl.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CashDispenserImpl.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositSlotImpl.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositTransaction.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DisplayImpl.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/KeyBoardImpl.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/NetworkClient.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/WithdrawTransaction.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/BankProxy.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/CardReader.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/CashDispenser.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/DepositSlot.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Display.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/KeyBoard.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Printer.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Transaction.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/utils/SingletonScanner.java create mode 100644 students/812350401/tests/com/coderising/myood/atmSimulation/impl/ATMTest.java create mode 100644 students/812350401/tests/com/coderising/myood/atmSimulation/impl/BankProxyImplTest.java create mode 100644 students/812350401/tests/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java create mode 100644 students/812350401/tests/com/coderising/myood/atmSimulation/model/CardReaderTest.java create mode 100644 students/812350401/tests/com/coderising/myood/atmSimulation/model/DisplayTest.java create mode 100644 students/812350401/tests/com/coderising/myood/atmSimulation/model/KeyBoardTest.java create mode 100644 students/812350401/tests/com/coderising/myood/atmSimulation/model/TransactionTest.java diff --git a/students/812350401/pom.xml b/students/812350401/pom.xml index 13499886be..e33e2dad03 100644 --- a/students/812350401/pom.xml +++ b/students/812350401/pom.xml @@ -28,8 +28,13 @@ - - + + + org.apache.commons + commons-lang3 + 3.6 + + junit junit 4.12 diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md index 8df2519517..0353e9cc41 100644 --- a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md @@ -4,7 +4,9 @@ https://github.com/onlyliuxin/coding2017/pull/512 ## atm需求 一个ATM是一台机器,包含读卡设备,显示屏,吐钞口,存钞口,键盘,打印机 -当机器空闲时,会显示一个欢迎消息,此时键盘和存钞口都是不活动的,直到一张银行卡被插入,读卡器会尝试读取这张卡,如果不可读,会提示用户并且弹出卡片如果卡片可读,读卡设备会读取账号,然后要求用户输入密码, 用户的输入应该显示为星号,而不是真正输入的数字。 +当机器空闲时,会显示一个欢迎消息,此时键盘和存钞口都是不活动的,直到一张银行卡被插入,读卡器会尝试读取这张卡,如果不可读, +会提示用户并且弹出卡片 +如果卡片可读,读卡设备会读取账号,然后要求用户输入密码, 用户的输入应该显示为星号,而不是真正输入的数字。 如果用户输入的密码正确,则显示主菜单; 如果不正确,再给用户两次输入机会,如果第三次依然失败,ATM就吞卡 主菜单提示用户可以: diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java new file mode 100644 index 0000000000..dd51fcae73 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java @@ -0,0 +1,137 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.*; + +/** + * Created by thomas_young on 30/7/2017. + * ATM对象 + */ +public class ATM { + private CardReader cardReader; + private SuperKeyPad superKeyPad; + private CashDispenser cashDispenser; + private DepositSlot depositSlot; + private Printer printer; + private BankProxy bankProxy; + /** + * 判断取款金额 + * @param amount + * @return + */ + public boolean hasEnoughMoney(Double amount) { + return cashDispenser.hasEnoughMoney(amount); + } + + /** + * 取款 + * @param amount + */ + public void dispenseMoney(Double amount) { + cashDispenser.dispenseMoney(amount); + } + + /** + * 存款 + * @return + */ + public Double retrieveMoney(Double amount) { + return depositSlot.saveMoney(amount); + } + + /** + * 主流程 + */ + public void start() { + // step1. 读卡 + String account; + while(true) { + account = cardReader.getAccount(); + if(account != null) { + System.out.println("读卡成功,卡号是"+account); + break; + } + try { + Thread.sleep(100); + } catch (InterruptedException e) { + } + } + + // step2. 读取密码,并做校验 + int failedCount = 0; + boolean verfied = false; + String password = null; + while (failedCount < 3) { + password = superKeyPad.getPassword(); + verfied = bankProxy.verify(account, password); + if (verfied) { + break; + } + } + if (!verfied) { + System.out.println("输错密码超过3次"); + cardReader.eatCard(); + return; + } + + // step3. 输入交易类型,进行交易 + Transaction transaction = superKeyPad.getTransaction(account, password); + boolean valid = transaction.preProcess(this); + if (!valid) { + return; + } + boolean success = bankProxy.process(transaction); + if (!success) { + System.out.printf("银行处理出错"); + } else { + System.out.println("银行已经处理完成"); + transaction.postProcess(this); + } + + // last step. 最后记得把卡吐出 + cardReader.ejectCard(); + } + + public CardReader getCardReader() { + return cardReader; + } + + public void setCardReader(CardReader cardReader) { + this.cardReader = cardReader; + } + + public SuperKeyPad getSuperKeyPad() { + return superKeyPad; + } + + public void setSuperKeyPad(SuperKeyPad superKeyPad) { + this.superKeyPad = superKeyPad; + } + + public CashDispenser getCashDispenser() { + return cashDispenser; + } + + public void setCashDispenser(CashDispenser cashDispenser) { + this.cashDispenser = cashDispenser; + } + + public DepositSlot getDepositSlot() { + return depositSlot; + } + + public void setDepositSlot(DepositSlot depositSlot) { + this.depositSlot = depositSlot; + } + + public Printer getPrinter() { + return printer; + } + + public void setPrinter(Printer printer) { + this.printer = printer; + } + + public void setBankProxy(BankProxy bankProxy) { + this.bankProxy = bankProxy; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/BankProxyImpl.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/BankProxyImpl.java new file mode 100644 index 0000000000..59de304cae --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/BankProxyImpl.java @@ -0,0 +1,23 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.BankProxy; +import com.coderising.myood.atmSimulation.model.Transaction; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class BankProxyImpl extends BankProxy { + + @Override + public boolean verify(String account, String password) { + return networkClient.verify(account, password); + } + + @Override + public boolean process(Transaction transaction) { + System.out.println("开始把transaction发给银行做处理"); + System.out.println(transaction.getClass()); + System.out.println(transaction); + return true; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CardReaderImpl.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CardReaderImpl.java new file mode 100644 index 0000000000..bdc62a8ffc --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CardReaderImpl.java @@ -0,0 +1,33 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.CardReader; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class CardReaderImpl implements CardReader { + private Integer retryTimes = 0; + + @Override + public String getAccount() { + // 模拟读三次才把卡读出 + if (retryTimes <= 2) { + System.out.println("没有卡哟"); + retryTimes++; + return null; + } + return "123456"; + } + + @Override + public void ejectCard() { + System.out.printf("吐出卡片, 请收好"); + retryTimes = 0; + } + + @Override + public void eatCard() { + System.out.printf("吞卡!"); + retryTimes = 0; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CashDispenserImpl.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CashDispenserImpl.java new file mode 100644 index 0000000000..22483bb6a6 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CashDispenserImpl.java @@ -0,0 +1,24 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.CashDispenser; + +/** + * Created by thomas_young on 30/7/2017. + * 吐钞口/取款口 + */ +public class CashDispenserImpl implements CashDispenser { + // 方便起见,假设atm机子里有这么多前,而且不会变 todo magic number! + private static Double totalAmount = 10000d; + @Override + public boolean hasEnoughMoney(Double amount) { + if (amount <= totalAmount) + return true; + System.out.println("atm没钱啦"); + return false; + } + + @Override + public void dispenseMoney(Double amount) { + System.out.println("取款:吐出"+amount+"元"); + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositSlotImpl.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositSlotImpl.java new file mode 100644 index 0000000000..b04b9016db --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositSlotImpl.java @@ -0,0 +1,16 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.DepositSlot; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class DepositSlotImpl implements DepositSlot { + @Override + public Double saveMoney(Double amount) { + System.out.println("存款: 请放入钞票"+amount+"元"); + // TODO: 30/7/2017 magic number! + Double actualAmount = amount - 5d; // 5元手续费 + return actualAmount < 0d ? 0d:actualAmount; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositTransaction.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositTransaction.java new file mode 100644 index 0000000000..ad2679a8c5 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositTransaction.java @@ -0,0 +1,56 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.Transaction; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class DepositTransaction extends Transaction { + // 该取款交易的存款金额 + private Double amount; + private Double actualAmount; + + public DepositTransaction(String account, String password, Double amount) { + super(account, password); + this.amount = amount; + } + + @Override + public boolean preProcess(ATM atm) { + actualAmount = atm.retrieveMoney(amount); + System.out.println("实际存款"+actualAmount+"元"); + return true; + } + + /** + * 什么都不做 + * @param atm + * @return + */ + @Override + public boolean postProcess(ATM atm) { + // TODO: 30/7/2017 只是为了调试,建议删除 + System.out.printf("存款postProcess: 什么都不做"); + return true; + } + + @Override + public String toNetworkPackage() { + return null; + } + + @Override + public String toString() { + return super.toString() + " DepositTransaction{" + + "amount=" + amount + + '}'; + } + + public Double getAmount() { + return amount; + } + + public Double getActualAmount() { + return actualAmount; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DisplayImpl.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DisplayImpl.java new file mode 100644 index 0000000000..7a4e638143 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DisplayImpl.java @@ -0,0 +1,23 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.Display; +import org.apache.commons.lang3.StringUtils; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class DisplayImpl implements Display { + @Override + public void outputPlainText(String message) { + System.out.printf(message); + } + + @Override + public void outputEncryptedText(String message) { + System.out.println(StringUtils.repeat("*", message.length())); + } + + public static void main(String[] args) { + System.out.printf(StringUtils.repeat("*", "abc".length())); + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/KeyBoardImpl.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/KeyBoardImpl.java new file mode 100644 index 0000000000..15ad2aaf31 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/KeyBoardImpl.java @@ -0,0 +1,27 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.KeyBoard; +import com.coderising.myood.atmSimulation.utils.SingletonScanner; + +import java.util.Scanner; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class KeyBoardImpl implements KeyBoard { + @Override + public String input() { + Scanner sc = SingletonScanner.getInstance(); + String input = sc.nextLine(); + return input; + } + + public static void main(String[] args) { + KeyBoard keyBoard = new KeyBoardImpl(); + String input = keyBoard.input(); + System.out.printf(input); + input = keyBoard.input(); + System.out.printf(input); + + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/NetworkClient.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/NetworkClient.java new file mode 100644 index 0000000000..8339ac8768 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/NetworkClient.java @@ -0,0 +1,16 @@ +package com.coderising.myood.atmSimulation.impl; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class NetworkClient { + private static final String actualPwd = "123456"; + + public boolean verify(String account, String password) { + // TODO: 30/7/2017 暂时写死,以后可以考虑加入银行那边类的交互 + if (account!=null && actualPwd.equals(password)) { + return true; + } + return false; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java new file mode 100644 index 0000000000..befc2fb46b --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java @@ -0,0 +1,98 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.Display; +import com.coderising.myood.atmSimulation.model.KeyBoard; +import com.coderising.myood.atmSimulation.model.Transaction; + +/** + * Created by thomas_young on 30/7/2017. + * 超级键盘协调用户输入和显示星号的关系 + */ +public class SuperKeyPad { + private Display display; + private KeyBoard keyBoard; + + /** + * 提示用户输入密码,待用户输入完成后,显示星号 + * 并把明文密码返回(为了简单起见) + * @return + */ + public String getPassword() { + System.out.println("请输入密码:"); + String input = keyBoard.input(); + display.outputEncryptedText(input); + return input; + } + + public void displayMessage(String message) { + display.outputPlainText(message); + } + + public Transaction getTransaction(String account, String password) { + display.outputPlainText("请输入交易类型:"); + display.outputPlainText("W: 取款"); + display.outputPlainText("D: 存款"); + display.outputPlainText("T: 转账"); + display.outputPlainText("B: 查询余额"); + while(true) { + String input = keyBoard.input(); + switch (input) { + case "W": + return getWithdrawTrx(account, password); + case "D": + return getDepositTrx(account, password); + case "T": + return null; + case "B": + return null; + default: + System.out.printf("输入有误,请重新输入"); + } + } + } + + private Transaction getWithdrawTrx(String account, String password) { + while(true) { + display.outputPlainText("请输入取现金额:"); + String input = keyBoard.input(); + try { + Double amount = Double.valueOf(input); + return new WithdrawTransaction(account, password, amount); + } catch (NumberFormatException e) { + System.out.printf("格式有误,请重新输入"); + } + } + } + + private Transaction getDepositTrx(String account, String password) { + while(true) { + display.outputPlainText("请输入存款金额:"); + String input = keyBoard.input(); + try { + Double amount = Double.valueOf(input); + return new DepositTransaction(account, password, amount); + } catch (NumberFormatException e) { + System.out.printf("格式有误,请重新输入"); + } + } + } + + public void setDisplay(Display display) { + this.display = display; + } + + public void setKeyBoard(KeyBoard keyBoard) { + this.keyBoard = keyBoard; + } + + public static void main(String[] args) { + SuperKeyPad superKeyPad = new SuperKeyPad(); + Display display = new DisplayImpl(); + KeyBoard keyBoard = new KeyBoardImpl(); + superKeyPad.setKeyBoard(keyBoard); + superKeyPad.setDisplay(display); + Transaction transaction = superKeyPad.getTransaction("yangkai", "123456"); + System.out.println(transaction); + + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/WithdrawTransaction.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/WithdrawTransaction.java new file mode 100644 index 0000000000..74b9f32113 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/WithdrawTransaction.java @@ -0,0 +1,49 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.Transaction; + +/** + * Created by thomas_young on 30/7/2017. + * 取款交易 + */ +public class WithdrawTransaction extends Transaction { + // 该取款交易的取款金额 + private Double amount; + + public WithdrawTransaction(String account, String password, Double amount) { + super(account, password); + this.amount = amount; + } + + /** + * 判断atm里的钱是否足够 + * @param atm + * @return + */ + @Override + public boolean preProcess(ATM atm) { + return atm.hasEnoughMoney(amount); + } + + @Override + public boolean postProcess(ATM atm) { + atm.dispenseMoney(amount); + return true; + } + + @Override + public String toNetworkPackage() { + return null; + } + + public Double getAmount() { + return amount; + } + + @Override + public String toString() { + return super.toString() + " WithdrawTransaction{" + + "amount=" + amount + + '}'; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/BankProxy.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/BankProxy.java new file mode 100644 index 0000000000..bd1ae67ee5 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/BankProxy.java @@ -0,0 +1,22 @@ +package com.coderising.myood.atmSimulation.model; + +import com.coderising.myood.atmSimulation.impl.NetworkClient; + +/** + * Created by thomas_young on 30/7/2017. + */ +public abstract class BankProxy { + protected NetworkClient networkClient; + + public abstract boolean verify(String account, String password); + + /** + * 交易发送到银行做处理 + * @param transaction + */ + public abstract boolean process(Transaction transaction); + + public void setNetworkClient(NetworkClient networkClient) { + this.networkClient = networkClient; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/CardReader.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/CardReader.java new file mode 100644 index 0000000000..4488591a45 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/CardReader.java @@ -0,0 +1,10 @@ +package com.coderising.myood.atmSimulation.model; + +/** + * Created by thomas_young on 30/7/2017. + */ +public interface CardReader { + String getAccount(); + void ejectCard(); + void eatCard(); +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/CashDispenser.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/CashDispenser.java new file mode 100644 index 0000000000..81d167eeb7 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/CashDispenser.java @@ -0,0 +1,22 @@ +package com.coderising.myood.atmSimulation.model; + + +/** + * Created by thomas_young on 30/7/2017. + * 吐钞口/取款口 + * 判断金额是否足够(我们用它来负责管理atm的金额,不再专门搞一个储钱箱了) + */ +public interface CashDispenser { + /** + * 取款amount,判断余额是否足够 + * @param amount + * @return + */ + boolean hasEnoughMoney(Double amount); + + /** + * 吐出amount的钞票 + * @param amount + */ + void dispenseMoney(Double amount); +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/DepositSlot.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/DepositSlot.java new file mode 100644 index 0000000000..797efc3ba1 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/DepositSlot.java @@ -0,0 +1,14 @@ +package com.coderising.myood.atmSimulation.model; + +/** + * Created by thomas_young on 30/7/2017. + * 入钞口/存款口 + */ +public interface DepositSlot { + /** + * 存款,可能会口手续费,返回实际存款金额 + * @param amount + * @return + */ + Double saveMoney(Double amount); +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Display.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Display.java new file mode 100644 index 0000000000..fb9be85412 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Display.java @@ -0,0 +1,9 @@ +package com.coderising.myood.atmSimulation.model; + +/** + * Created by thomas_young on 30/7/2017. + */ +public interface Display { + void outputPlainText(String message); + void outputEncryptedText(String message); +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/KeyBoard.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/KeyBoard.java new file mode 100644 index 0000000000..4bafd55dc0 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/KeyBoard.java @@ -0,0 +1,8 @@ +package com.coderising.myood.atmSimulation.model; + +/** + * Created by thomas_young on 30/7/2017. + */ +public interface KeyBoard { + String input(); +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Printer.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Printer.java new file mode 100644 index 0000000000..0399b65110 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Printer.java @@ -0,0 +1,8 @@ +package com.coderising.myood.atmSimulation.model; + +/** + * Created by thomas_young on 30/7/2017. + */ +public interface Printer { + void print(Transaction t); +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Transaction.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Transaction.java new file mode 100644 index 0000000000..5880b4248b --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/model/Transaction.java @@ -0,0 +1,45 @@ +package com.coderising.myood.atmSimulation.model; + +import com.coderising.myood.atmSimulation.impl.ATM; + +/** + * Created by thomas_young on 30/7/2017. + * 该对象并不持有ATM的实例,它只是依赖ATM罢了 + */ +public abstract class Transaction { + private String account; + private String password; + + public Transaction(String account, String password) { + this.account = account; + this.password = password; + } + + public abstract boolean preProcess(ATM atm); + public abstract boolean postProcess(ATM atm); + public abstract String toNetworkPackage(); + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public String toString() { + return "Transaction{" + + "account='" + account + '\'' + + ", password='" + password + '\'' + + '}'; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/utils/SingletonScanner.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/utils/SingletonScanner.java new file mode 100644 index 0000000000..249e9cb895 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/utils/SingletonScanner.java @@ -0,0 +1,18 @@ +package com.coderising.myood.atmSimulation.utils; + +import java.util.Scanner; + +/** + * Created by thomas_young on 30/7/2017. + * todo 不得已这么做,因为没法测试连续的控制台输入 + */ +public class SingletonScanner { + private static Scanner ourInstance = new Scanner(System.in); + + public static Scanner getInstance() { + return ourInstance; + } + + private SingletonScanner() { + } +} diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/impl/ATMTest.java b/students/812350401/tests/com/coderising/myood/atmSimulation/impl/ATMTest.java new file mode 100644 index 0000000000..8dae11554b --- /dev/null +++ b/students/812350401/tests/com/coderising/myood/atmSimulation/impl/ATMTest.java @@ -0,0 +1,34 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.*; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class ATMTest { + private static ATM atm; + + static { + atm = new ATM(); + CardReader cardReader = new CardReaderImpl(); + SuperKeyPad superKeyPad = new SuperKeyPad(); + CashDispenser cashDispenser = new CashDispenserImpl(); + DepositSlot depositSlot = new DepositSlotImpl(); + Printer printer; + BankProxy bankProxy = new BankProxyImpl(); + atm.setBankProxy(bankProxy); + atm.setCardReader(cardReader); + atm.setCashDispenser(cashDispenser); + atm.setDepositSlot(depositSlot); + atm.setSuperKeyPad(superKeyPad); + } + + @Test + public void start() throws Exception { + atm.start(); + } + +} \ No newline at end of file diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/impl/BankProxyImplTest.java b/students/812350401/tests/com/coderising/myood/atmSimulation/impl/BankProxyImplTest.java new file mode 100644 index 0000000000..6fdfc3e91e --- /dev/null +++ b/students/812350401/tests/com/coderising/myood/atmSimulation/impl/BankProxyImplTest.java @@ -0,0 +1,31 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.BankProxy; +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class BankProxyImplTest { + private static BankProxy bankProxy; + { + bankProxy = new BankProxyImpl(); + NetworkClient networkClient = new NetworkClient(); + bankProxy.setNetworkClient(networkClient); + } + @Test + public void verify() throws Exception { + Assert.assertFalse(bankProxy.verify("yangkai", "12345")); + Assert.assertFalse(bankProxy.verify(null, "12345")); + Assert.assertTrue(bankProxy.verify("yangkai", "123456")); + } + + @Test + public void process() throws Exception { + + } + +} \ No newline at end of file diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java b/students/812350401/tests/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java new file mode 100644 index 0000000000..94a9125dc6 --- /dev/null +++ b/students/812350401/tests/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java @@ -0,0 +1,72 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.Display; +import com.coderising.myood.atmSimulation.model.KeyBoard; +import com.coderising.myood.atmSimulation.model.Transaction; +import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import static org.junit.Assert.*; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class SuperKeyPadTest { + private SuperKeyPad superKeyPad; + { + superKeyPad = new SuperKeyPad(); + Display display = new DisplayImpl(); + KeyBoard keyBoard = new KeyBoardImpl(); + superKeyPad.setDisplay(display); + superKeyPad.setKeyBoard(keyBoard); + } + + @Test + public void testGetPassword() throws Exception { + String password = "123456"; + String output; + InputStream stdin = System.in; + try { + System.setIn(new ByteArrayInputStream(password.getBytes())); + output = superKeyPad.getPassword(); + } finally { + System.setIn(stdin); + } + Assert.assertEquals(password, output); + } + + @Test + public void testDisplayMessage() throws Exception { + superKeyPad.displayMessage("欢迎"); + } + + @Ignore + @Test + public void testGetTransaction() throws Exception { + + String lineSeparator = System.getProperty("line.separator"); + String trxInput = "X" + lineSeparator + "D" + lineSeparator + "xx" + lineSeparator + "190"; + + InputStream stdin = System.in; + Transaction transaction; + try { + System.setIn(new ByteArrayInputStream(trxInput.getBytes())); + transaction = superKeyPad.getTransaction("yangkai", "123456"); + } finally { + System.setIn(stdin); + } + System.out.println(transaction); + + // TODO: 30/7/2017 finally语句并不能使keyborad恢复到从console输入接收字符串,以后再说。因为源代码中流是不会变的 + //测试输入流有没有问题 +// KeyBoard keyBoard = new KeyBoardImpl(); +// String input = keyBoard.input(); +// System.out.println(input); + } + +} \ No newline at end of file diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/model/CardReaderTest.java b/students/812350401/tests/com/coderising/myood/atmSimulation/model/CardReaderTest.java new file mode 100644 index 0000000000..9c88dfa4d7 --- /dev/null +++ b/students/812350401/tests/com/coderising/myood/atmSimulation/model/CardReaderTest.java @@ -0,0 +1,33 @@ +package com.coderising.myood.atmSimulation.model; + +import com.coderising.myood.atmSimulation.impl.CardReaderImpl; +import com.coderising.myood.atmSimulation.model.CardReader; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class CardReaderTest { + CardReader cardReader = new CardReaderImpl(); + @Test + public void getAccount() throws Exception { + String account; + while(true) { + account = cardReader.getAccount(); + if(account != null) { + System.out.println("读卡成功,卡号是"+account); + break; + } + System.out.println("读卡失败"); + } + cardReader.ejectCard(); + } + + @Test + public void ejectCard() throws Exception { + cardReader.ejectCard(); + } + +} \ No newline at end of file diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/model/DisplayTest.java b/students/812350401/tests/com/coderising/myood/atmSimulation/model/DisplayTest.java new file mode 100644 index 0000000000..5bc7779d86 --- /dev/null +++ b/students/812350401/tests/com/coderising/myood/atmSimulation/model/DisplayTest.java @@ -0,0 +1,23 @@ +package com.coderising.myood.atmSimulation.model; + +import com.coderising.myood.atmSimulation.impl.DisplayImpl; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class DisplayTest { + private static Display display = new DisplayImpl(); + @Test + public void outputPlainText() throws Exception { + display.outputPlainText("欢迎你!"); + } + + @Test + public void outputEncryptedText() throws Exception { + display.outputEncryptedText("345677"); + } + +} \ No newline at end of file diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/model/KeyBoardTest.java b/students/812350401/tests/com/coderising/myood/atmSimulation/model/KeyBoardTest.java new file mode 100644 index 0000000000..151ff5178d --- /dev/null +++ b/students/812350401/tests/com/coderising/myood/atmSimulation/model/KeyBoardTest.java @@ -0,0 +1,29 @@ +package com.coderising.myood.atmSimulation.model; + +import com.coderising.myood.atmSimulation.impl.KeyBoardImpl; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class KeyBoardTest { + KeyBoard keyBoard = new KeyBoardImpl(); + + @Test + public void testInput() throws Exception { + String data = "Hello, World!\r\n"; + String input; + InputStream stdin = System.in; + try { + System.setIn(new ByteArrayInputStream(data.getBytes())); + input = keyBoard.input(); + } finally { + System.setIn(stdin); + } + System.out.println("input is----" + input); + } + +} \ No newline at end of file diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/model/TransactionTest.java b/students/812350401/tests/com/coderising/myood/atmSimulation/model/TransactionTest.java new file mode 100644 index 0000000000..c8efb805f7 --- /dev/null +++ b/students/812350401/tests/com/coderising/myood/atmSimulation/model/TransactionTest.java @@ -0,0 +1,54 @@ +package com.coderising.myood.atmSimulation.model; + +import com.coderising.myood.atmSimulation.impl.*; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class TransactionTest { + private static Transaction withdrawTrx; + private static Transaction noMoneyWithdrawTrx; + private static Transaction depositTrx; + private static ATM atm; + + static { + atm = new ATM(); + withdrawTrx = new WithdrawTransaction("withdraw", "1023", 100d); + noMoneyWithdrawTrx = new WithdrawTransaction("withdraw", "1023", 10001d); + depositTrx = new DepositTransaction("deposit", "456", 200d); + CardReader cardReader = new CardReaderImpl(); + SuperKeyPad superKeyPad = new SuperKeyPad(); + CashDispenser cashDispenser = new CashDispenserImpl(); + DepositSlot depositSlot = new DepositSlotImpl(); + Printer printer; + BankProxy bankProxy = new BankProxyImpl(); + atm.setBankProxy(bankProxy); + atm.setCardReader(cardReader); + atm.setCashDispenser(cashDispenser); + atm.setDepositSlot(depositSlot); + atm.setSuperKeyPad(superKeyPad); + } + + @Test + public void preProcess() throws Exception { + assertTrue(withdrawTrx.preProcess(atm)); + assertFalse(noMoneyWithdrawTrx.preProcess(atm)); + depositTrx.preProcess(atm); + assertEquals((Double)(((DepositTransaction)depositTrx).getAmount()-5d), ((DepositTransaction)depositTrx).getActualAmount()); + } + + @Test + public void postProcess() throws Exception { + assertTrue(withdrawTrx.postProcess(atm)); + depositTrx.postProcess(atm); + } + + @Test + public void toNetworkPackage() throws Exception { + + } + +} \ No newline at end of file From fe51642fc54c3a772d57f39cfb8f51da3d8c9f8e Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Sun, 30 Jul 2017 21:48:54 +0800 Subject: [PATCH 47/81] =?UTF-8?q?[Feature]=20ATM=E5=8F=96=E6=AC=BE?= =?UTF-8?q?=E6=9C=BA=EF=BC=8C=E5=AE=8C=E6=88=90=E5=8F=96=E6=AC=BE=E5=92=8C?= =?UTF-8?q?=E5=AD=98=E6=AC=BE2=E4=B8=AA=E4=BA=A4=E6=98=93=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/coderising/myood/atmSimulation/impl/ATM.java | 9 +++++---- .../myood/atmSimulation/impl/CardReaderImpl.java | 2 +- .../myood/atmSimulation/impl/DepositTransaction.java | 4 ++-- .../myood/atmSimulation/impl/SuperKeyPad.java | 10 +++++++--- .../coderising/myood/atmSimulation/impl/ATMTest.java | 10 +++++++--- .../myood/atmSimulation/impl/BankProxyImplTest.java | 0 .../myood/atmSimulation/impl/SuperKeyPadTest.java | 0 .../myood/atmSimulation/model/CardReaderTest.java | 0 .../myood/atmSimulation/model/DisplayTest.java | 0 .../myood/atmSimulation/model/KeyBoardTest.java | 1 - .../myood/atmSimulation/model/TransactionTest.java | 0 11 files changed, 22 insertions(+), 14 deletions(-) rename students/812350401/{tests => src/test}/com/coderising/myood/atmSimulation/impl/ATMTest.java (71%) rename students/812350401/{tests => src/test}/com/coderising/myood/atmSimulation/impl/BankProxyImplTest.java (100%) rename students/812350401/{tests => src/test}/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java (100%) rename students/812350401/{tests => src/test}/com/coderising/myood/atmSimulation/model/CardReaderTest.java (100%) rename students/812350401/{tests => src/test}/com/coderising/myood/atmSimulation/model/DisplayTest.java (100%) rename students/812350401/{tests => src/test}/com/coderising/myood/atmSimulation/model/KeyBoardTest.java (99%) rename students/812350401/{tests => src/test}/com/coderising/myood/atmSimulation/model/TransactionTest.java (100%) diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java index dd51fcae73..7294083441 100644 --- a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java @@ -58,16 +58,17 @@ public void start() { // step2. 读取密码,并做校验 int failedCount = 0; - boolean verfied = false; + boolean verified = false; String password = null; while (failedCount < 3) { password = superKeyPad.getPassword(); - verfied = bankProxy.verify(account, password); - if (verfied) { + verified = bankProxy.verify(account, password); + if (verified) { break; } + failedCount++; } - if (!verfied) { + if (!verified) { System.out.println("输错密码超过3次"); cardReader.eatCard(); return; diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CardReaderImpl.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CardReaderImpl.java index bdc62a8ffc..5cd59b67d4 100644 --- a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CardReaderImpl.java +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/CardReaderImpl.java @@ -16,7 +16,7 @@ public String getAccount() { retryTimes++; return null; } - return "123456"; + return "yangkaiAccount"; } @Override diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositTransaction.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositTransaction.java index ad2679a8c5..705a01fba5 100644 --- a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositTransaction.java +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/DepositTransaction.java @@ -30,7 +30,7 @@ public boolean preProcess(ATM atm) { @Override public boolean postProcess(ATM atm) { // TODO: 30/7/2017 只是为了调试,建议删除 - System.out.printf("存款postProcess: 什么都不做"); + System.out.println("存款postProcess: 什么都不做"); return true; } @@ -42,7 +42,7 @@ public String toNetworkPackage() { @Override public String toString() { return super.toString() + " DepositTransaction{" + - "amount=" + amount + + "amount=" + amount + ", actualAmount=" + actualAmount + '}'; } diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java index befc2fb46b..fb5da93cd8 100644 --- a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java @@ -30,9 +30,9 @@ public void displayMessage(String message) { public Transaction getTransaction(String account, String password) { display.outputPlainText("请输入交易类型:"); - display.outputPlainText("W: 取款"); - display.outputPlainText("D: 存款"); - display.outputPlainText("T: 转账"); + display.outputPlainText("W: 取款, "); + display.outputPlainText("D: 存款, "); + display.outputPlainText("T: 转账, "); display.outputPlainText("B: 查询余额"); while(true) { String input = keyBoard.input(); @@ -77,6 +77,8 @@ private Transaction getDepositTrx(String account, String password) { } } + public Transaction + public void setDisplay(Display display) { this.display = display; } @@ -94,5 +96,7 @@ public static void main(String[] args) { Transaction transaction = superKeyPad.getTransaction("yangkai", "123456"); System.out.println(transaction); + String password = superKeyPad.getPassword(); + System.out.println(password); } } diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/impl/ATMTest.java b/students/812350401/src/test/com/coderising/myood/atmSimulation/impl/ATMTest.java similarity index 71% rename from students/812350401/tests/com/coderising/myood/atmSimulation/impl/ATMTest.java rename to students/812350401/src/test/com/coderising/myood/atmSimulation/impl/ATMTest.java index 8dae11554b..408d70d68c 100644 --- a/students/812350401/tests/com/coderising/myood/atmSimulation/impl/ATMTest.java +++ b/students/812350401/src/test/com/coderising/myood/atmSimulation/impl/ATMTest.java @@ -15,10 +15,16 @@ public class ATMTest { atm = new ATM(); CardReader cardReader = new CardReaderImpl(); SuperKeyPad superKeyPad = new SuperKeyPad(); + KeyBoard keyBoard = new KeyBoardImpl(); + Display display = new DisplayImpl(); + superKeyPad.setDisplay(display); + superKeyPad.setKeyBoard(keyBoard); CashDispenser cashDispenser = new CashDispenserImpl(); DepositSlot depositSlot = new DepositSlotImpl(); Printer printer; BankProxy bankProxy = new BankProxyImpl(); + NetworkClient networkClient = new NetworkClient(); + bankProxy.setNetworkClient(networkClient); atm.setBankProxy(bankProxy); atm.setCardReader(cardReader); atm.setCashDispenser(cashDispenser); @@ -26,9 +32,7 @@ public class ATMTest { atm.setSuperKeyPad(superKeyPad); } - @Test - public void start() throws Exception { + public static void main(String[] args) { atm.start(); } - } \ No newline at end of file diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/impl/BankProxyImplTest.java b/students/812350401/src/test/com/coderising/myood/atmSimulation/impl/BankProxyImplTest.java similarity index 100% rename from students/812350401/tests/com/coderising/myood/atmSimulation/impl/BankProxyImplTest.java rename to students/812350401/src/test/com/coderising/myood/atmSimulation/impl/BankProxyImplTest.java diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java b/students/812350401/src/test/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java similarity index 100% rename from students/812350401/tests/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java rename to students/812350401/src/test/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/model/CardReaderTest.java b/students/812350401/src/test/com/coderising/myood/atmSimulation/model/CardReaderTest.java similarity index 100% rename from students/812350401/tests/com/coderising/myood/atmSimulation/model/CardReaderTest.java rename to students/812350401/src/test/com/coderising/myood/atmSimulation/model/CardReaderTest.java diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/model/DisplayTest.java b/students/812350401/src/test/com/coderising/myood/atmSimulation/model/DisplayTest.java similarity index 100% rename from students/812350401/tests/com/coderising/myood/atmSimulation/model/DisplayTest.java rename to students/812350401/src/test/com/coderising/myood/atmSimulation/model/DisplayTest.java diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/model/KeyBoardTest.java b/students/812350401/src/test/com/coderising/myood/atmSimulation/model/KeyBoardTest.java similarity index 99% rename from students/812350401/tests/com/coderising/myood/atmSimulation/model/KeyBoardTest.java rename to students/812350401/src/test/com/coderising/myood/atmSimulation/model/KeyBoardTest.java index 151ff5178d..652aabcf3a 100644 --- a/students/812350401/tests/com/coderising/myood/atmSimulation/model/KeyBoardTest.java +++ b/students/812350401/src/test/com/coderising/myood/atmSimulation/model/KeyBoardTest.java @@ -25,5 +25,4 @@ public void testInput() throws Exception { } System.out.println("input is----" + input); } - } \ No newline at end of file diff --git a/students/812350401/tests/com/coderising/myood/atmSimulation/model/TransactionTest.java b/students/812350401/src/test/com/coderising/myood/atmSimulation/model/TransactionTest.java similarity index 100% rename from students/812350401/tests/com/coderising/myood/atmSimulation/model/TransactionTest.java rename to students/812350401/src/test/com/coderising/myood/atmSimulation/model/TransactionTest.java From b97e05e397d2ce4c4fae390e71689b52b8122fef Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Sun, 30 Jul 2017 22:48:00 +0800 Subject: [PATCH 48/81] =?UTF-8?q?[Feature]=20ATM=E5=AE=9E=E7=8E=B02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 完成测试用例和README的修改 2. 完成查询和转账 注: 缺乏和银行的逻辑,比如查询银行应该返回一个查询金额。 而我目前所有的交易都只是返回成功或失败,应该有一个类包装返回值 --- .../coderising/myood/atmSimulation/README.md | 12 +++++ .../myood/atmSimulation/impl/ATM.java | 1 + .../atmSimulation/impl/QueryTransaction.java | 29 ++++++++++++ .../myood/atmSimulation/impl/SuperKeyPad.java | 31 ++++++++++--- .../impl/TransferTransaction.java | 44 +++++++++++++++++++ 5 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/QueryTransaction.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/TransferTransaction.java diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md index 0353e9cc41..50f8c65813 100644 --- a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/README.md @@ -23,3 +23,15 @@ https://github.com/onlyliuxin/coding2017/pull/512 所有的交易都是ATM和银行服务器合作完成的,银行保留了账户信息,必须在合适的时候向银行查询这些信息 这里其实是两个系统, 一个运行在ATM上,另外一个在银行端 + +### 请在com.coderising.myood.atmSimulation.impl.ATMTest的main函数处进行测试 +需要测试的场景: +输入密码错误:不是123456 +输入密码正确:是123456 +取款,取款金额>10000元 +存款,存款金额<5元 +存款,取款金额<10000元,正常存款 +取款,存款金额>5元,正常取现 +查询 +转账 + diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java index 7294083441..9d55be57ef 100644 --- a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/ATM.java @@ -78,6 +78,7 @@ public void start() { Transaction transaction = superKeyPad.getTransaction(account, password); boolean valid = transaction.preProcess(this); if (!valid) { + cardReader.ejectCard(); return; } boolean success = bankProxy.process(transaction); diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/QueryTransaction.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/QueryTransaction.java new file mode 100644 index 0000000000..e7f7d39430 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/QueryTransaction.java @@ -0,0 +1,29 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.Transaction; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class QueryTransaction extends Transaction { + public QueryTransaction(String account, String password) { + super(account, password); + } + + @Override + public boolean preProcess(ATM atm) { + System.out.println("查询:不做前处理"); + return true; + } + + @Override + public boolean postProcess(ATM atm) { + System.out.println("查询:不做后处理"); + return true; + } + + @Override + public String toNetworkPackage() { + return null; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java index fb5da93cd8..b0d57463eb 100644 --- a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/SuperKeyPad.java @@ -33,7 +33,7 @@ public Transaction getTransaction(String account, String password) { display.outputPlainText("W: 取款, "); display.outputPlainText("D: 存款, "); display.outputPlainText("T: 转账, "); - display.outputPlainText("B: 查询余额"); + display.outputPlainText("Q: 查询余额"); while(true) { String input = keyBoard.input(); switch (input) { @@ -42,9 +42,9 @@ public Transaction getTransaction(String account, String password) { case "D": return getDepositTrx(account, password); case "T": - return null; - case "B": - return null; + return getTransferTrx(account, password); + case "Q": + return getQueryTrx(account, password); default: System.out.printf("输入有误,请重新输入"); } @@ -77,7 +77,28 @@ private Transaction getDepositTrx(String account, String password) { } } - public Transaction + private Transaction getTransferTrx(String account, String password) { + while(true) { + display.outputPlainText("请输入对方账户:"); + String counterAccount = keyBoard.input(); + if ("".equals(counterAccount)) { + System.out.printf("输入账户有误,请重新输入"); + continue; + } + display.outputPlainText("请输入转账金额:"); + String input = keyBoard.input(); + try { + Double amount = Double.valueOf(input); + return new TransferTransaction(account, password, amount, counterAccount); + } catch (NumberFormatException e) { + System.out.printf("格式有误,请重新输入"); + } + } + } + + private Transaction getQueryTrx(String account, String password) { + return new QueryTransaction(account, password); + } public void setDisplay(Display display) { this.display = display; diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/TransferTransaction.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/TransferTransaction.java new file mode 100644 index 0000000000..d34e00b664 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/TransferTransaction.java @@ -0,0 +1,44 @@ +package com.coderising.myood.atmSimulation.impl; + +import com.coderising.myood.atmSimulation.model.Transaction; + +/** + * Created by thomas_young on 30/7/2017. + */ +public class TransferTransaction extends Transaction { + // 转账金额 + private Double amount; + // 对方账户 + private String counterAccount; + + public TransferTransaction(String account, String password, Double amount, String counterAccount) { + super(account, password); + this.amount = amount; + this.counterAccount = counterAccount; + } + + @Override + public boolean preProcess(ATM atm) { + System.out.println("转账: 不做前处理"); + return true; + } + + @Override + public boolean postProcess(ATM atm) { + System.out.println("转账: 不做后处理"); + return true; + } + + @Override + public String toNetworkPackage() { + return null; + } + + @Override + public String toString() { + return super.toString() + " TransferTransaction{" + + "amount=" + amount + + ", counterAccount='" + counterAccount + '\'' + + '}'; + } +} From e4590f3e4661c33f9d2a1cb30844b9acc9f62187 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Sun, 30 Jul 2017 23:02:00 +0800 Subject: [PATCH 49/81] =?UTF-8?q?[Fix]:=20=E4=BF=AE=E6=94=B9=E8=8B=A5?= =?UTF-8?q?=E5=B9=B2=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 废止用Scanner的单例模式 --- .../coderising/myood/atmSimulation/impl/KeyBoardImpl.java | 4 +++- .../myood/atmSimulation/utils/SingletonScanner.java | 2 +- .../myood/atmSimulation/impl/SuperKeyPadTest.java | 6 ------ .../coderising/myood/atmSimulation/model/KeyBoardTest.java | 5 +++++ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/KeyBoardImpl.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/KeyBoardImpl.java index 15ad2aaf31..df98335a78 100644 --- a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/KeyBoardImpl.java +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/impl/KeyBoardImpl.java @@ -11,7 +11,9 @@ public class KeyBoardImpl implements KeyBoard { @Override public String input() { - Scanner sc = SingletonScanner.getInstance(); + // TODO: 30/7/2017 强烈建议改成正常的方式,否则后患无穷,现在已经有测试用例跑不过了 +// Scanner sc = SingletonScanner.getInstance(); + Scanner sc = new Scanner(System.in); String input = sc.nextLine(); return input; } diff --git a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/utils/SingletonScanner.java b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/utils/SingletonScanner.java index 249e9cb895..3fc5002dca 100644 --- a/students/812350401/src/main/java/com/coderising/myood/atmSimulation/utils/SingletonScanner.java +++ b/students/812350401/src/main/java/com/coderising/myood/atmSimulation/utils/SingletonScanner.java @@ -4,7 +4,7 @@ /** * Created by thomas_young on 30/7/2017. - * todo 不得已这么做,因为没法测试连续的控制台输入 + * todo 不得已这么做,因为没法测试连续的控制台输入,强烈建议删除 */ public class SingletonScanner { private static Scanner ourInstance = new Scanner(System.in); diff --git a/students/812350401/src/test/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java b/students/812350401/src/test/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java index 94a9125dc6..455c721402 100644 --- a/students/812350401/src/test/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java +++ b/students/812350401/src/test/com/coderising/myood/atmSimulation/impl/SuperKeyPadTest.java @@ -61,12 +61,6 @@ public void testGetTransaction() throws Exception { System.setIn(stdin); } System.out.println(transaction); - - // TODO: 30/7/2017 finally语句并不能使keyborad恢复到从console输入接收字符串,以后再说。因为源代码中流是不会变的 - //测试输入流有没有问题 -// KeyBoard keyBoard = new KeyBoardImpl(); -// String input = keyBoard.input(); -// System.out.println(input); } } \ No newline at end of file diff --git a/students/812350401/src/test/com/coderising/myood/atmSimulation/model/KeyBoardTest.java b/students/812350401/src/test/com/coderising/myood/atmSimulation/model/KeyBoardTest.java index 652aabcf3a..7c732d0786 100644 --- a/students/812350401/src/test/com/coderising/myood/atmSimulation/model/KeyBoardTest.java +++ b/students/812350401/src/test/com/coderising/myood/atmSimulation/model/KeyBoardTest.java @@ -1,6 +1,7 @@ package com.coderising.myood.atmSimulation.model; import com.coderising.myood.atmSimulation.impl.KeyBoardImpl; +import org.junit.Ignore; import org.junit.Test; import java.io.ByteArrayInputStream; @@ -24,5 +25,9 @@ public void testInput() throws Exception { System.setIn(stdin); } System.out.println("input is----" + input); + + System.setIn(new ByteArrayInputStream("haha\n".getBytes())); + input = keyBoard.input(); + System.out.println(input); } } \ No newline at end of file From 30d4ab385bd80a442465a6551ffca71ffea0fc72 Mon Sep 17 00:00:00 2001 From: sheng <1158154002@qq.com> Date: Wed, 2 Aug 2017 08:02:02 +0800 Subject: [PATCH 50/81] dp --- .../java/com/coderising/dp/bridge/Circle.java | 12 +++ .../com/coderising/dp/bridge/Drawing.java | 6 ++ .../com/coderising/dp/bridge/DrawingGL1.java | 15 ++++ .../com/coderising/dp/bridge/DrawingGL2.java | 15 ++++ .../com/coderising/dp/bridge/Rectangle.java | 11 +++ .../java/com/coderising/dp/bridge/Shape.java | 12 +++ .../java/com/coderising/dp/bridge/Test.java | 16 ++++ .../com/coderising/dp/composite/Line.java | 11 +++ .../com/coderising/dp/composite/Picture.java | 33 ++++++++ .../coderising/dp/composite/Rectangle.java | 10 +++ .../com/coderising/dp/composite/Shape.java | 5 ++ .../com/coderising/dp/composite/Square.java | 10 +++ .../com/coderising/dp/composite/Text.java | 10 +++ .../com/coderising/dp/decorator/Email.java | 5 ++ .../coderising/dp/decorator/EmailImpl.java | 14 ++++ .../coderising/dp/decorator/EmailProxy.java | 29 +++++++ .../com/coderising/dp/decorator/Encrypt.java | 76 +++++++++++++++++++ 17 files changed, 290 insertions(+) create mode 100644 students/1158154002/src/main/java/com/coderising/dp/bridge/Circle.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/bridge/Drawing.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/bridge/DrawingGL1.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/bridge/DrawingGL2.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/bridge/Rectangle.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/bridge/Shape.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/bridge/Test.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/composite/Line.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/composite/Picture.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/composite/Rectangle.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/composite/Shape.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/composite/Square.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/composite/Text.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/decorator/Email.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/decorator/EmailImpl.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/decorator/EmailProxy.java create mode 100644 students/1158154002/src/main/java/com/coderising/dp/decorator/Encrypt.java diff --git a/students/1158154002/src/main/java/com/coderising/dp/bridge/Circle.java b/students/1158154002/src/main/java/com/coderising/dp/bridge/Circle.java new file mode 100644 index 0000000000..39483dabb9 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/bridge/Circle.java @@ -0,0 +1,12 @@ +package com.coderising.dp.bridge; + +public class Circle extends Shape { + + @Override + public void draw() { + super.getDrawing().drawCircle(); + System.out.println("I'm a Line"); + + } + +} \ No newline at end of file diff --git a/students/1158154002/src/main/java/com/coderising/dp/bridge/Drawing.java b/students/1158154002/src/main/java/com/coderising/dp/bridge/Drawing.java new file mode 100644 index 0000000000..97ad4b2378 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/bridge/Drawing.java @@ -0,0 +1,6 @@ +package com.coderising.dp.bridge; + +public interface Drawing { +void drawLine(); +void drawCircle(); +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/bridge/DrawingGL1.java b/students/1158154002/src/main/java/com/coderising/dp/bridge/DrawingGL1.java new file mode 100644 index 0000000000..c1addd2658 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/bridge/DrawingGL1.java @@ -0,0 +1,15 @@ +package com.coderising.dp.bridge; + +public class DrawingGL1 implements Drawing{ + + @Override + public void drawLine() { + System.out.println("DrawingGL1.drawLine"); + } + + @Override + public void drawCircle() { + System.out.println("DrawingGL1.drawCircle"); + } + +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/bridge/DrawingGL2.java b/students/1158154002/src/main/java/com/coderising/dp/bridge/DrawingGL2.java new file mode 100644 index 0000000000..b30a86d053 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/bridge/DrawingGL2.java @@ -0,0 +1,15 @@ +package com.coderising.dp.bridge; + +public class DrawingGL2 implements Drawing{ + + @Override + public void drawLine() { + System.out.println("DrawingGL2.drawLine"); + } + + @Override + public void drawCircle() { + System.out.println("DrawingGL2.drawCircle"); + } + +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/bridge/Rectangle.java b/students/1158154002/src/main/java/com/coderising/dp/bridge/Rectangle.java new file mode 100644 index 0000000000..ab4f171f96 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/bridge/Rectangle.java @@ -0,0 +1,11 @@ +package com.coderising.dp.bridge; + +public class Rectangle extends Shape { + + @Override + public void draw() { + super.getDrawing().drawLine(); + System.out.println("I'm a Rectangle"); + } + +} \ No newline at end of file diff --git a/students/1158154002/src/main/java/com/coderising/dp/bridge/Shape.java b/students/1158154002/src/main/java/com/coderising/dp/bridge/Shape.java new file mode 100644 index 0000000000..f317e344d4 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/bridge/Shape.java @@ -0,0 +1,12 @@ +package com.coderising.dp.bridge; + +public abstract class Shape { + public Drawing drawing; + public Drawing getDrawing() { + return drawing; + } + public void setDrawing(Drawing drawing) { + this.drawing = drawing; + } + public abstract void draw(); +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/bridge/Test.java b/students/1158154002/src/main/java/com/coderising/dp/bridge/Test.java new file mode 100644 index 0000000000..3aceb7fe89 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/bridge/Test.java @@ -0,0 +1,16 @@ +package com.coderising.dp.bridge; + +public class Test { + + public static void main(String[] args) { + Shape rectangel=new Rectangle(); + rectangel.setDrawing(new DrawingGL1()); + rectangel.draw(); + + + Shape circle=new Circle(); + circle.setDrawing(new DrawingGL2()); + circle.draw(); + } + +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/composite/Line.java b/students/1158154002/src/main/java/com/coderising/dp/composite/Line.java new file mode 100644 index 0000000000..411eb80876 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/composite/Line.java @@ -0,0 +1,11 @@ +package com.coderising.dp.composite; + +public class Line implements Shape { + + @Override + public void draw() { + System.out.println("I'm a Line"); + + } + +} \ No newline at end of file diff --git a/students/1158154002/src/main/java/com/coderising/dp/composite/Picture.java b/students/1158154002/src/main/java/com/coderising/dp/composite/Picture.java new file mode 100644 index 0000000000..b52ac69ae2 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/composite/Picture.java @@ -0,0 +1,33 @@ +package com.coderising.dp.composite; + +import java.util.ArrayList; +import java.util.List; + +public class Picture implements Shape{ + private List shapes=new ArrayList<>(); + @Override + public void draw() { + for (Shape shape : shapes) { + shape.draw(); + } + } + + public void add(Shape shape){ + shapes.add(shape); + } + + public static void main(String[] args) { + Picture aPicture=new Picture(); + aPicture.add(new Line()); + aPicture.add(new Rectangle()); + + Picture a=new Picture(); + a.add(new Text()); + a.add(new Line()); + a.add(new Square()); + aPicture.add(a); + + aPicture.draw(); + } + +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/composite/Rectangle.java b/students/1158154002/src/main/java/com/coderising/dp/composite/Rectangle.java new file mode 100644 index 0000000000..9547cd7aa9 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/composite/Rectangle.java @@ -0,0 +1,10 @@ +package com.coderising.dp.composite; + +public class Rectangle implements Shape { + + @Override + public void draw() { + System.out.println("I'm a Rectangle"); + } + +} \ No newline at end of file diff --git a/students/1158154002/src/main/java/com/coderising/dp/composite/Shape.java b/students/1158154002/src/main/java/com/coderising/dp/composite/Shape.java new file mode 100644 index 0000000000..45c428c6b9 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/composite/Shape.java @@ -0,0 +1,5 @@ +package com.coderising.dp.composite; + +public interface Shape { + public void draw(); +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/composite/Square.java b/students/1158154002/src/main/java/com/coderising/dp/composite/Square.java new file mode 100644 index 0000000000..50b94ca09d --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/composite/Square.java @@ -0,0 +1,10 @@ +package com.coderising.dp.composite; + +public class Square implements Shape { + + @Override + public void draw() { + System.out.println("I'm a Square"); + } + +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/composite/Text.java b/students/1158154002/src/main/java/com/coderising/dp/composite/Text.java new file mode 100644 index 0000000000..db0268f18a --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/composite/Text.java @@ -0,0 +1,10 @@ +package com.coderising.dp.composite; + +public class Text implements Shape { + + @Override + public void draw() { + System.out.println("I'm a Text"); + } + +} \ No newline at end of file diff --git a/students/1158154002/src/main/java/com/coderising/dp/decorator/Email.java b/students/1158154002/src/main/java/com/coderising/dp/decorator/Email.java new file mode 100644 index 0000000000..50ce116777 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/decorator/Email.java @@ -0,0 +1,5 @@ +package com.coderising.dp.decorator; + +public interface Email { + public String getContent(); +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/decorator/EmailImpl.java b/students/1158154002/src/main/java/com/coderising/dp/decorator/EmailImpl.java new file mode 100644 index 0000000000..7ce815ca35 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/decorator/EmailImpl.java @@ -0,0 +1,14 @@ +package com.coderising.dp.decorator; + +public class EmailImpl implements Email{ + private String content; + + public EmailImpl(String content) { + this.content = content; + } + + @Override + public String getContent() { + return content; + } +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/decorator/EmailProxy.java b/students/1158154002/src/main/java/com/coderising/dp/decorator/EmailProxy.java new file mode 100644 index 0000000000..344459a35f --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/decorator/EmailProxy.java @@ -0,0 +1,29 @@ +package com.coderising.dp.decorator; + +public class EmailProxy implements Email{ + Email email; + + @Override + public String getContent() { + String content=email.getContent()+"\n本邮件仅为个人观点,并不代表公司立场"; + System.out.println(content); + content=Encrypt.SHA256(content); + System.out.println(content); + return content; + } + + public void setEmail(Email email) { + this.email = email; + } + + public static void main(String[] args) { + EmailImpl email=new EmailImpl("hello world!"); + EmailProxy proxy=new EmailProxy(); + EmailProxy proxy1=new EmailProxy(); + proxy.setEmail(email); + // proxy.getContent(); + proxy1.setEmail(proxy); + proxy1.getContent(); + } + +} diff --git a/students/1158154002/src/main/java/com/coderising/dp/decorator/Encrypt.java b/students/1158154002/src/main/java/com/coderising/dp/decorator/Encrypt.java new file mode 100644 index 0000000000..79f2a4a4d6 --- /dev/null +++ b/students/1158154002/src/main/java/com/coderising/dp/decorator/Encrypt.java @@ -0,0 +1,76 @@ +package com.coderising.dp.decorator; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class Encrypt { + /** + * 传入文本内容,返回 SHA-256 串 + * + * @param strText + * @return + */ + public static String SHA256(final String strText) + { + return SHA(strText, "SHA-256"); + } + + /** + * 传入文本内容,返回 SHA-512 串 + * + * @param strText + * @return + */ + public static String SHA512(final String strText) + { + return SHA(strText, "SHA-512"); + } + + /** + * 字符串 SHA 加密 + * + * @param strSourceText + * @return + */ + private static String SHA(final String strText, final String strType) + { + // 返回值 + String strResult = null; + + // 是否是有效字符串 + if (strText != null && strText.length() > 0) + { + try + { + // SHA 加密开始 + // 创建加密对象 并傳入加密類型 + MessageDigest messageDigest = MessageDigest.getInstance(strType); + // 传入要加密的字符串 + messageDigest.update(strText.getBytes()); + // 得到 byte 類型结果 + byte byteBuffer[] = messageDigest.digest(); + + // 將 byte 轉換爲 string + StringBuffer strHexString = new StringBuffer(); + // 遍歷 byte buffer + for (int i = 0; i < byteBuffer.length; i++) + { + String hex = Integer.toHexString(0xff & byteBuffer[i]); + if (hex.length() == 1) + { + strHexString.append('0'); + } + strHexString.append(hex); + } + // 得到返回結果 + strResult = strHexString.toString(); + } + catch (NoSuchAlgorithmException e) + { + e.printStackTrace(); + } + } + + return strResult; + } +} From 2bc90bae989a979f278865ef53c1ff09517cc2f8 Mon Sep 17 00:00:00 2001 From: bendell02 <1203029076@qq.com> Date: Thu, 3 Aug 2017 01:31:23 +0800 Subject: [PATCH 51/81] =?UTF-8?q?=E4=BD=9C=E4=B8=9A3=EF=BC=9A=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E8=A3=85=E9=A5=B0=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/coderising/dp/decorator/Email.java | 6 ++++++ .../dp/decorator/EmailDecorator.java | 15 +++++++++++++++ .../coderising/dp/decorator/EmailImpl.java | 12 ++++++++++++ .../coderising/dp/decorator/EncryptEmail.java | 19 +++++++++++++++++++ .../coderising/dp/decorator/SendOutEmail.java | 14 ++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/Email.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailDecorator.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailImpl.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EncryptEmail.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/SendOutEmail.java diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/Email.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/Email.java new file mode 100644 index 0000000000..064de1e837 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/Email.java @@ -0,0 +1,6 @@ +package com.coderising.dp.decorator; + +public interface Email { + public String getContent(); +} + diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailDecorator.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailDecorator.java new file mode 100644 index 0000000000..093d9d92c1 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailDecorator.java @@ -0,0 +1,15 @@ +package com.coderising.dp.decorator; + +public abstract class EmailDecorator implements Email{ + protected Email email; + + public EmailDecorator(Email email) { + // TODO Auto-generated constructor stub + this.email = email; + } + + public String getContent() { + // TODO Auto-generated method stub + return email.getContent(); + } +} \ No newline at end of file diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailImpl.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailImpl.java new file mode 100644 index 0000000000..640aef6da3 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EmailImpl.java @@ -0,0 +1,12 @@ +package com.coderising.dp.decorator; + +public class EmailImpl implements Email { + private String content; + + public EmailImpl(String content) { + this.content = content; + } + public String getContent() { + return content; + } +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EncryptEmail.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EncryptEmail.java new file mode 100644 index 0000000000..5715936bd2 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/EncryptEmail.java @@ -0,0 +1,19 @@ +package com.coderising.dp.decorator; + +public class EncryptEmail extends EmailDecorator { + public EncryptEmail(Email email) { + // TODO Auto-generated constructor stub + super(email); + } + + @Override + public String getContent() { + // TODO Auto-generated method stub + return encrypt(super.getContent()); + } + + private String encrypt(String content) { + // concrete encrypt algorithm + return content+"encrypt"; + } +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/SendOutEmail.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/SendOutEmail.java new file mode 100644 index 0000000000..cd756c3cab --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/decorator/SendOutEmail.java @@ -0,0 +1,14 @@ +package com.coderising.dp.decorator; + +public class SendOutEmail extends EmailDecorator{ + public SendOutEmail(Email email) { + // TODO Auto-generated constructor stub + super(email); + } + + @Override + public String getContent() { + // TODO Auto-generated method stub + return super.getContent()+"\nʼΪ˹۵㣬˾"; + } +} From 2d33ec72ed7eb047da9186c5d1f1da7d07ca40f0 Mon Sep 17 00:00:00 2001 From: bendell02 <1203029076@qq.com> Date: Thu, 3 Aug 2017 01:32:20 +0800 Subject: [PATCH 52/81] =?UTF-8?q?=E4=BD=9C=E4=B8=9A4=EF=BC=9A=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0Composite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/coderising/dp/composite/Line.java | 10 ++++++ .../com/coderising/dp/composite/Picture.java | 35 +++++++++++++++++++ .../coderising/dp/composite/Rectangle.java | 11 ++++++ .../com/coderising/dp/composite/Shape.java | 5 +++ .../com/coderising/dp/composite/Square.java | 11 ++++++ .../com/coderising/dp/composite/Text.java | 11 ++++++ 6 files changed, 83 insertions(+) create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Picture.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java new file mode 100644 index 0000000000..e6ab14c61b --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Line.java @@ -0,0 +1,10 @@ +package com.coderising.dp.composite; + +public class Line implements Shape { + + @Override + public void draw() { + System.out.println("I'm a line"); + } + +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Picture.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Picture.java new file mode 100644 index 0000000000..6775f730ac --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Picture.java @@ -0,0 +1,35 @@ +package com.coderising.dp.composite; + +import java.util.ArrayList; + +public class Picture implements Shape { + ArrayList shapes = new ArrayList<>(); + + @Override + public void draw() { + // TODO Auto-generated method stub + for(Shape shape:shapes) { + shape.draw(); + } + } + + public void add(Shape shape) { + shapes.add(shape); + } + + public static void main(String[] args) { + Picture aPicture = new Picture(); + + Picture p = new Picture(); + p.add(new Text()); + p.add(new Line()); + p.add(new Rectangle()); + + aPicture.add(p); + + aPicture.add(new Line()); + aPicture.add(new Rectangle()); + + aPicture.draw(); + } +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java new file mode 100644 index 0000000000..7db5bb1c22 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Rectangle.java @@ -0,0 +1,11 @@ +package com.coderising.dp.composite; + +public class Rectangle implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + System.out.println("I'm a rectangle"); + } + +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java new file mode 100644 index 0000000000..4562f10b12 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Shape.java @@ -0,0 +1,5 @@ +package com.coderising.dp.composite; + +public interface Shape { + public void draw(); +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java new file mode 100644 index 0000000000..fd17ae3059 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Square.java @@ -0,0 +1,11 @@ +package com.coderising.dp.composite; + +public class Square implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + System.out.println("I'm a Square"); + } + +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java new file mode 100644 index 0000000000..c3c9ebf609 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/composite/Text.java @@ -0,0 +1,11 @@ +package com.coderising.dp.composite; + +public class Text implements Shape { + + @Override + public void draw() { + // TODO Auto-generated method stub + System.out.println("I'm a Text"); + } + +} From dce082aa15af182f40b276535db89918120e5ffc Mon Sep 17 00:00:00 2001 From: bendell02 <1203029076@qq.com> Date: Thu, 3 Aug 2017 01:33:32 +0800 Subject: [PATCH 53/81] =?UTF-8?q?=E4=BD=9C=E4=B8=9A5=EF=BC=9A=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0Bridge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/coderising/dp/bridge/Circle.java | 19 +++++++++++++++ .../com/coderising/dp/bridge/Drawing.java | 6 +++++ .../com/coderising/dp/bridge/DrawingGL1.java | 18 ++++++++++++++ .../com/coderising/dp/bridge/DrawingGL2.java | 18 ++++++++++++++ .../coderising/dp/bridge/GraphicLibrary1.java | 11 +++++++++ .../coderising/dp/bridge/GraphicLibrary2.java | 11 +++++++++ .../com/coderising/dp/bridge/Rectangle.java | 24 +++++++++++++++++++ .../java/com/coderising/dp/bridge/Shape.java | 11 +++++++++ 8 files changed, 118 insertions(+) create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Circle.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Drawing.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/DrawingGL1.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/DrawingGL2.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Rectangle.java create mode 100644 students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Shape.java diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Circle.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Circle.java new file mode 100644 index 0000000000..9762bd591d --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Circle.java @@ -0,0 +1,19 @@ +package com.coderising.dp.bridge; + +public class Circle extends Shape { + private int x, y, r; + + public Circle(Drawing drawing, int x, int y, int r) { + super(drawing); + this.x = x; + this.y = y; + this.r = r; + } + + @Override + public void draw() { + // TODO Auto-generated method stub + drawing.drawCircle(x, y, r); + } + +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Drawing.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Drawing.java new file mode 100644 index 0000000000..d81f4709b9 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Drawing.java @@ -0,0 +1,6 @@ +package com.coderising.dp.bridge; + +public interface Drawing { + public void drawLine(int x1, int y1, int x2, int y2); + public void drawCircle(int x, int y, int r); +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/DrawingGL1.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/DrawingGL1.java new file mode 100644 index 0000000000..94410c0655 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/DrawingGL1.java @@ -0,0 +1,18 @@ +package com.coderising.dp.bridge; + +public class DrawingGL1 implements Drawing { + private GraphicLibrary1 graphicLibray1; + + @Override + public void drawLine(int x1, int y1, int x2, int y2) { + // TODO Auto-generated method stub + graphicLibray1.draw_a_line(x1, y1, x2, y2); + } + + @Override + public void drawCircle(int x, int y, int r) { + // TODO Auto-generated method stub + graphicLibray1.draw_a_circle(x, y, r); + } + +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/DrawingGL2.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/DrawingGL2.java new file mode 100644 index 0000000000..757cc2c4b2 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/DrawingGL2.java @@ -0,0 +1,18 @@ +package com.coderising.dp.bridge; + +public class DrawingGL2 implements Drawing { + private GraphicLibrary2 graphicLibrary2; + + @Override + public void drawLine(int x1, int y1, int x2, int y2) { + // TODO Auto-generated method stub + graphicLibrary2.drawLine(x1, x2, y1, y2); + } + + @Override + public void drawCircle(int x, int y, int r) { + // TODO Auto-generated method stub + graphicLibrary2.drawCircle(x, y, r); + } + +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java new file mode 100644 index 0000000000..798cfbc7f9 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary1.java @@ -0,0 +1,11 @@ +package com.coderising.dp.bridge; + +public class GraphicLibrary1 { + public void draw_a_line(int x1,int y1,int x2,int y2){ + + } + public void draw_a_circle(int x,int y, int r){ + + } + +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java new file mode 100644 index 0000000000..2e67a1220b --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/GraphicLibrary2.java @@ -0,0 +1,11 @@ +package com.coderising.dp.bridge; + +public class GraphicLibrary2 { + public void drawLine(int x1,int x2,int y1,int y2){ + + } + public void drawCircle(int x,int y, int r){ + + } + +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Rectangle.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Rectangle.java new file mode 100644 index 0000000000..b297769c9a --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Rectangle.java @@ -0,0 +1,24 @@ +package com.coderising.dp.bridge; + +public class Rectangle extends Shape { + private int x1, y1, x2, y2; + + public Rectangle(Drawing drawing, int x1, int y1, int x2, int y2) { + // TODO Auto-generated constructor stub + super(drawing); + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = y2; + } + + @Override + public void draw() { + // TODO Auto-generated method stub + drawing.drawLine(x1, y1, x1, y2); + drawing.drawLine(x1, y2, x2, y2); + drawing.drawLine(x2, y2, x2, y1); + drawing.drawLine(x2, y1, x1, y1); + } + +} diff --git a/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Shape.java b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Shape.java new file mode 100644 index 0000000000..d909382018 --- /dev/null +++ b/students/1203029076/ood/ood-assignment/src/main/java/com/coderising/dp/bridge/Shape.java @@ -0,0 +1,11 @@ +package com.coderising.dp.bridge; + +public abstract class Shape { + protected Drawing drawing; + public Shape(Drawing drawing) { + // TODO Auto-generated constructor stub + this.drawing = drawing; + } + + public abstract void draw(); +} From 21714123c4bf094835b147e7b03fc6ad8b03280a Mon Sep 17 00:00:00 2001 From: doublesouth <1241588932@qq.com> Date: Sun, 6 Aug 2017 12:32:45 +0800 Subject: [PATCH 54/81] =?UTF-8?q?1241588932:=E8=AE=BE=E8=AE=A1=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=AC=AC=E4=B8=80=E6=AC=A1=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1241588932/design-patterns-enan/pom.xml | 54 ++++++++++++ .../src/main/java/first/TagBuilder.java | 39 +++++++++ .../src/main/java/first/TagBuilderTest.java | 41 +++++++++ .../src/main/java/first/TagNode.java | 83 +++++++++++++++++++ .../{ => ood-assignment-enan}/pom.xml | 0 .../ood/srp/config/Configuration.java | 0 .../ood/srp/config/ConfigurationKeys.java | 0 .../com/coderising/ood/srp/dao/UserDao.java | 0 .../coderising/ood/srp/entity/Product.java | 0 .../com/coderising/ood/srp/entity/User.java | 0 .../java/com/coderising/ood/srp/main.java | 0 .../ood/srp/service/IPromotionMail.java | 0 .../ood/srp/service/IReadProductConfig.java | 0 .../ood/srp/service/IUserService.java | 0 .../srp/service/impl/PromotionMailImpl.java | 0 .../service/impl/ReadProductConfigImpl.java | 0 .../ood/srp/service/impl/UserServiceImpl.java | 0 .../com/coderising/ood/srp/util/DBUtil.java | 0 .../com/coderising/ood/srp/util/MailUtil.java | 0 .../main/resources/email_config.properties | 0 .../src/main/resources/product_promotion.txt | 0 21 files changed, 217 insertions(+) create mode 100644 students/1241588932/design-patterns-enan/pom.xml create mode 100644 students/1241588932/design-patterns-enan/src/main/java/first/TagBuilder.java create mode 100644 students/1241588932/design-patterns-enan/src/main/java/first/TagBuilderTest.java create mode 100644 students/1241588932/design-patterns-enan/src/main/java/first/TagNode.java rename students/1241588932/{ => ood-assignment-enan}/pom.xml (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/config/Configuration.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/config/ConfigurationKeys.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/dao/UserDao.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/entity/Product.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/entity/User.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/main.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/service/IPromotionMail.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/service/IReadProductConfig.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/service/IUserService.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/service/impl/PromotionMailImpl.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/service/impl/ReadProductConfigImpl.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/service/impl/UserServiceImpl.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/util/DBUtil.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/java/com/coderising/ood/srp/util/MailUtil.java (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/resources/email_config.properties (100%) rename students/1241588932/{ => ood-assignment-enan}/src/main/resources/product_promotion.txt (100%) diff --git a/students/1241588932/design-patterns-enan/pom.xml b/students/1241588932/design-patterns-enan/pom.xml new file mode 100644 index 0000000000..fd2c597497 --- /dev/null +++ b/students/1241588932/design-patterns-enan/pom.xml @@ -0,0 +1,54 @@ + + 4.0.0 + + com.coderising + design-patterns-enan + 0.0.1-SNAPSHOT + jar + + design-patterns-enan + http://maven.apache.org + + + UTF-8 + + + + + + junit + junit + 4.12 + + + + org.projectlombok + lombok + 1.16.16 + true + + + + + + aliyunmaven + http://maven.aliyun.com/nexus/content/groups/public/ + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + ${project.build.sourceEncoding} + + + + + diff --git a/students/1241588932/design-patterns-enan/src/main/java/first/TagBuilder.java b/students/1241588932/design-patterns-enan/src/main/java/first/TagBuilder.java new file mode 100644 index 0000000000..586cbf37ef --- /dev/null +++ b/students/1241588932/design-patterns-enan/src/main/java/first/TagBuilder.java @@ -0,0 +1,39 @@ +package first; + +public class TagBuilder { + + private TagNode tagNode; + private TagNode currentTagNode; + private TagNode superTagNode; + + public TagBuilder(String tagName) { + this.tagNode = new TagNode(tagName); + this.currentTagNode = this.tagNode; + this.superTagNode = null; + } + + public TagBuilder addChild(String childTagName) { + this.superTagNode = this.currentTagNode; + TagNode tagNode = new TagNode(childTagName); + this.currentTagNode.add(tagNode); + this.currentTagNode = tagNode; + return this; + } + + public TagBuilder setAttribute(String key, String value) { + this.currentTagNode.setAttribute(key, value); + return this; + } + + public TagBuilder addSibling(String siblingTagName) { + TagNode tagNode = new TagNode(siblingTagName); + this.superTagNode.add(tagNode); + this.currentTagNode = tagNode; + return this; + } + + public TagNode build() { + return tagNode; + } + +} diff --git a/students/1241588932/design-patterns-enan/src/main/java/first/TagBuilderTest.java b/students/1241588932/design-patterns-enan/src/main/java/first/TagBuilderTest.java new file mode 100644 index 0000000000..d17f0592f2 --- /dev/null +++ b/students/1241588932/design-patterns-enan/src/main/java/first/TagBuilderTest.java @@ -0,0 +1,41 @@ +package first; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class TagBuilderTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testToXML() { + + TagBuilder builder = new TagBuilder("order"); + + String xml = builder.addChild("line-items") + .addChild("line-item").setAttribute("pid", "P3677").setAttribute("qty", "3") + .addSibling("line-item").setAttribute("pid", "P9877").setAttribute("qty", "10") + .build() + .toXML(); + + String expected = "" + + "" + + "" + + "" + + "" + + ""; + + System.out.println(xml); + assertEquals(expected, xml); + } + +} diff --git a/students/1241588932/design-patterns-enan/src/main/java/first/TagNode.java b/students/1241588932/design-patterns-enan/src/main/java/first/TagNode.java new file mode 100644 index 0000000000..f27f48db82 --- /dev/null +++ b/students/1241588932/design-patterns-enan/src/main/java/first/TagNode.java @@ -0,0 +1,83 @@ +package first; + +import java.util.ArrayList; +import java.util.List; + +public class TagNode { + private String tagName; + private String tagValue; + private List children = new ArrayList<>(); + private List attributes = new ArrayList<>(); + + public TagNode(String name){ + this.tagName = name; + } + public void add(TagNode child){ + this.children.add(child); + } + public void setAttribute(String name, String value) { + Attribute attr = findAttribute(name); + if(attr != null){ + attr.value = value; + return; + } + + attributes.add(new Attribute(name,value)); + } + private Attribute findAttribute(String name){ + for(Attribute attr : attributes){ + if(attr.name.equals(name)){ + return attr; + } + } + return null; + } + public void setValue(String value) { + this.tagValue = value; + + } + public String getTagName() { + return tagName; + } + public List getChildren() { + return children; + } + + private static class Attribute{ + public Attribute(String name, String value) { + this.name = name; + this.value = value; + } + String name; + String value; + + } + public String toXML(){ + return toXML(this); + } + private String toXML(TagNode node){ + StringBuilder buffer = new StringBuilder(); + buffer.append("<").append(node.tagName); + if(node.attributes.size()> 0){ + for(int i=0;i"); + return buffer.toString(); + } + buffer.append(">"); + for(TagNode childNode : node.children){ + buffer.append(toXML(childNode)); + } + buffer.append(""); + + + return buffer.toString(); + } + private String toXML(Attribute attr){ + return attr.name+"=\""+attr.value + "\""; + } +} diff --git a/students/1241588932/pom.xml b/students/1241588932/ood-assignment-enan/pom.xml similarity index 100% rename from students/1241588932/pom.xml rename to students/1241588932/ood-assignment-enan/pom.xml diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/config/Configuration.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/config/Configuration.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/config/Configuration.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/config/Configuration.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/config/ConfigurationKeys.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/config/ConfigurationKeys.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/config/ConfigurationKeys.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/config/ConfigurationKeys.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/dao/UserDao.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/dao/UserDao.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/dao/UserDao.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/dao/UserDao.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/entity/Product.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/entity/Product.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/entity/Product.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/entity/Product.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/entity/User.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/entity/User.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/entity/User.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/entity/User.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/main.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/main.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/main.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/main.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/service/IPromotionMail.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/IPromotionMail.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/service/IPromotionMail.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/IPromotionMail.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/service/IReadProductConfig.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/IReadProductConfig.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/service/IReadProductConfig.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/IReadProductConfig.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/service/IUserService.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/IUserService.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/service/IUserService.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/IUserService.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/service/impl/PromotionMailImpl.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/impl/PromotionMailImpl.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/service/impl/PromotionMailImpl.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/impl/PromotionMailImpl.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/service/impl/ReadProductConfigImpl.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/impl/ReadProductConfigImpl.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/service/impl/ReadProductConfigImpl.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/impl/ReadProductConfigImpl.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/service/impl/UserServiceImpl.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/impl/UserServiceImpl.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/service/impl/UserServiceImpl.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/service/impl/UserServiceImpl.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/util/DBUtil.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/util/DBUtil.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/util/DBUtil.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/util/DBUtil.java diff --git a/students/1241588932/src/main/java/com/coderising/ood/srp/util/MailUtil.java b/students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/util/MailUtil.java similarity index 100% rename from students/1241588932/src/main/java/com/coderising/ood/srp/util/MailUtil.java rename to students/1241588932/ood-assignment-enan/src/main/java/com/coderising/ood/srp/util/MailUtil.java diff --git a/students/1241588932/src/main/resources/email_config.properties b/students/1241588932/ood-assignment-enan/src/main/resources/email_config.properties similarity index 100% rename from students/1241588932/src/main/resources/email_config.properties rename to students/1241588932/ood-assignment-enan/src/main/resources/email_config.properties diff --git a/students/1241588932/src/main/resources/product_promotion.txt b/students/1241588932/ood-assignment-enan/src/main/resources/product_promotion.txt similarity index 100% rename from students/1241588932/src/main/resources/product_promotion.txt rename to students/1241588932/ood-assignment-enan/src/main/resources/product_promotion.txt From 4f2e0cc2cb430f09a189e561f7480110f6cf4822 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Thu, 10 Aug 2017 00:03:30 +0800 Subject: [PATCH 55/81] =?UTF-8?q?[Fix]=20=E5=A2=9E=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=B8=AAjunit3=E9=A3=8E=E6=A0=BC=E7=9A=84=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- students/812350401/pom.xml | 2 +- .../coderising/mydp/bridge/CircleTest.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 students/812350401/src/test/com/coderising/mydp/bridge/CircleTest.java diff --git a/students/812350401/pom.xml b/students/812350401/pom.xml index e33e2dad03..80ef597876 100644 --- a/students/812350401/pom.xml +++ b/students/812350401/pom.xml @@ -38,6 +38,7 @@ junit junit 4.12 + com.google.collections @@ -49,7 +50,6 @@ commons-codec 1.6 - diff --git a/students/812350401/src/test/com/coderising/mydp/bridge/CircleTest.java b/students/812350401/src/test/com/coderising/mydp/bridge/CircleTest.java new file mode 100644 index 0000000000..f7dc934648 --- /dev/null +++ b/students/812350401/src/test/com/coderising/mydp/bridge/CircleTest.java @@ -0,0 +1,21 @@ +package com.coderising.mydp.bridge; + +import junit.framework.TestCase; + +/** + * Created by thomas_young on 6/8/2017. + */ +public class CircleTest extends TestCase { + public void testDraw() throws Exception { + + } + + public void testSetDrawing() throws Exception { + + } + + public void testMain() throws Exception { + + } + +} \ No newline at end of file From 6d95c2357329d38b4494bebfd20c56b5398f36a7 Mon Sep 17 00:00:00 2001 From: yangzhm Date: Thu, 10 Aug 2017 09:52:04 +0800 Subject: [PATCH 56/81] add project of responsibility chain pattern and command pattern --- students/495232796/OOD/commandpattern/pom.xml | 42 +++++++++++++++++++ .../java/com/coderising/dp/command/Cook.java | 11 +++++ .../coderising/dp/command/OrderCommand.java | 5 +++ .../dp/command/OrderPorkCommand.java | 14 +++++++ .../dp/command/OrderSteakCommand.java | 15 +++++++ .../com/coderising/dp/command/Waiter.java | 18 ++++++++ .../OOD/responsibilitychainpattern/pom.xml | 42 +++++++++++++++++++ .../dp/ResponsibilityChain/EmailLogger.java | 25 +++++++++++ .../dp/ResponsibilityChain/FileLogger.java | 24 +++++++++++ .../dp/ResponsibilityChain/Logger.java | 10 +++++ .../dp/ResponsibilityChain/StdoutLogger.java | 26 ++++++++++++ 11 files changed, 232 insertions(+) create mode 100644 students/495232796/OOD/commandpattern/pom.xml create mode 100644 students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/Cook.java create mode 100644 students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderCommand.java create mode 100644 students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderPorkCommand.java create mode 100644 students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderSteakCommand.java create mode 100644 students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/Waiter.java create mode 100644 students/495232796/OOD/responsibilitychainpattern/pom.xml create mode 100644 students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/EmailLogger.java create mode 100644 students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/FileLogger.java create mode 100644 students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/Logger.java create mode 100644 students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/StdoutLogger.java diff --git a/students/495232796/OOD/commandpattern/pom.xml b/students/495232796/OOD/commandpattern/pom.xml new file mode 100644 index 0000000000..84bf4627e3 --- /dev/null +++ b/students/495232796/OOD/commandpattern/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + com.coderising + ood-assignment + 0.0.1-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + + + + jar + + ood-assignment + http://maven.apache.org + + + UTF-8 + + + + + + junit + junit + 4.12 + + + + + + aliyunmaven + http://maven.aliyun.com/nexus/content/groups/public/ + + + \ No newline at end of file diff --git a/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/Cook.java b/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/Cook.java new file mode 100644 index 0000000000..d832433731 --- /dev/null +++ b/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/Cook.java @@ -0,0 +1,11 @@ +package com.coderising.dp.command; + +public class Cook { + public void cookSteak() { + System.out.println("Steak is OK."); + } + + public void cookPork() { + System.out.println("Pork is OK."); + } +} diff --git a/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderCommand.java b/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderCommand.java new file mode 100644 index 0000000000..361a489e6e --- /dev/null +++ b/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderCommand.java @@ -0,0 +1,5 @@ +package com.coderising.dp.command; + +public interface OrderCommand { + public void doOrder(); +} diff --git a/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderPorkCommand.java b/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderPorkCommand.java new file mode 100644 index 0000000000..cbe37e372a --- /dev/null +++ b/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderPorkCommand.java @@ -0,0 +1,14 @@ +package com.coderising.dp.command; + +public class OrderPorkCommand implements OrderCommand{ + private Cook cook; + + public OrderPorkCommand(Cook cook) { + this.cook = cook; + } + + @Override + public void doOrder() { + this.cook.cookPork();; + } +} diff --git a/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderSteakCommand.java b/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderSteakCommand.java new file mode 100644 index 0000000000..9884e14bb2 --- /dev/null +++ b/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/OrderSteakCommand.java @@ -0,0 +1,15 @@ +package com.coderising.dp.command; + +public class OrderSteakCommand implements OrderCommand{ + private Cook cook; + + public OrderSteakCommand(Cook cook) { + this.cook = cook; + } + + @Override + public void doOrder() { + this.cook.cookSteak(); + } + +} diff --git a/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/Waiter.java b/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/Waiter.java new file mode 100644 index 0000000000..acc9f1418e --- /dev/null +++ b/students/495232796/OOD/commandpattern/src/main/java/com/coderising/dp/command/Waiter.java @@ -0,0 +1,18 @@ +package com.coderising.dp.command; + +import java.util.LinkedList; +import java.util.List; + +public class Waiter { + private List orderList = new LinkedList<>(); + + public void addOrder(OrderCommand order) { + this.orderList.add(order); + } + + public void sendOrders() { + for (int i = 0; i < orderList.size(); i++) { + orderList.get(i).doOrder(); + } + } +} diff --git a/students/495232796/OOD/responsibilitychainpattern/pom.xml b/students/495232796/OOD/responsibilitychainpattern/pom.xml new file mode 100644 index 0000000000..84bf4627e3 --- /dev/null +++ b/students/495232796/OOD/responsibilitychainpattern/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + com.coderising + ood-assignment + 0.0.1-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + + + + jar + + ood-assignment + http://maven.apache.org + + + UTF-8 + + + + + + junit + junit + 4.12 + + + + + + aliyunmaven + http://maven.aliyun.com/nexus/content/groups/public/ + + + \ No newline at end of file diff --git a/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/EmailLogger.java b/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/EmailLogger.java new file mode 100644 index 0000000000..bc3d446019 --- /dev/null +++ b/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/EmailLogger.java @@ -0,0 +1,25 @@ +package com.coderising.dp.ResponsibilityChain; + +public class EmailLogger implements Logger{ + private int level = Logger.DEBUG; + private Logger next; + + public EmailLogger(int level) { + this.level = level; + } + @Override + public void message(String context, int level) { + if (level >= this.level) { + System.out.println(this.getClass().getName()+ " " + context); + } + if (this.next != null) { + this.next.message(context, level); + } + } + + @Override + public void setNext(Logger next) { + this.next = next; + } + +} diff --git a/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/FileLogger.java b/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/FileLogger.java new file mode 100644 index 0000000000..e549d9b626 --- /dev/null +++ b/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/FileLogger.java @@ -0,0 +1,24 @@ +package com.coderising.dp.ResponsibilityChain; + +public class FileLogger implements Logger{ + private int level = Logger.DEBUG; + private Logger next; + + public FileLogger(int level) { + this.level = level; + } + @Override + public void message(String context, int level) { + if (level >= this.level) { + System.out.println(this.getClass().getName()+ " " + context); + } + if (this.next != null) { + this.next.message(context, level); + } + } + + @Override + public void setNext(Logger next) { + this.next = next; + } +} diff --git a/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/Logger.java b/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/Logger.java new file mode 100644 index 0000000000..3edbc68e0f --- /dev/null +++ b/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/Logger.java @@ -0,0 +1,10 @@ +package com.coderising.dp.ResponsibilityChain; + +public interface Logger { + public static final int DEBUG = 0; + public static final int NOTICE = 1; + public static final int ERR = 2; + + public void message(String context, int level); + public void setNext(Logger next); +} diff --git a/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/StdoutLogger.java b/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/StdoutLogger.java new file mode 100644 index 0000000000..fcc49437f6 --- /dev/null +++ b/students/495232796/OOD/responsibilitychainpattern/src/main/java/com/coderising/dp/ResponsibilityChain/StdoutLogger.java @@ -0,0 +1,26 @@ +package com.coderising.dp.ResponsibilityChain; + +public class StdoutLogger implements Logger { + private int level = Logger.DEBUG; + private Logger next; + + public StdoutLogger(int level) { + this.level = level; + } + + @Override + public void message(String context, int level) { + if (level >= this.level) { + System.out.println(this.getClass().getName()+ " " + context); + } + if (this.next != null) { + this.next.message(context, level); + } + } + + @Override + public void setNext(Logger next) { + this.next = next; + } + +} From 3e87b07a586d5564d454cac0da3835791b83ad1d Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Thu, 10 Aug 2017 20:30:51 +0800 Subject: [PATCH 57/81] =?UTF-8?q?[Train]=20=E8=B4=A3=E4=BB=BB=E9=93=BE?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E5=B0=9D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mydp/myResponseChain/Client.java | 36 +++++++++++++++++++ .../mydp/myResponseChain/DeptManager.java | 35 ++++++++++++++++++ .../mydp/myResponseChain/GeneralManager.java | 34 ++++++++++++++++++ .../mydp/myResponseChain/Handler.java | 30 ++++++++++++++++ .../mydp/myResponseChain/ProjectManager.java | 35 ++++++++++++++++++ 5 files changed, 170 insertions(+) create mode 100644 students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Client.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/myResponseChain/DeptManager.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/myResponseChain/GeneralManager.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Handler.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/myResponseChain/ProjectManager.java diff --git a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Client.java b/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Client.java new file mode 100644 index 0000000000..1c0280e00a --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Client.java @@ -0,0 +1,36 @@ +package com.coderising.mydp.myResponseChain; + +/** + * Created by thomas_young on 10/8/2017. + */ + +public class Client { + + public static void main(String[] args) { + //先要组装责任链 + Handler h1 = new GeneralManager(); + Handler h2 = new DeptManager(); + Handler h3 = new ProjectManager(); + h3.setSuccessor(h2); + h2.setSuccessor(h1); + + //开始测试 + String test1 = h3.handleFeeRequest("张三", 300); + System.out.println("test1 = " + test1); + String test2 = h3.handleFeeRequest("李四", 300); + System.out.println("test2 = " + test2); + System.out.println("---------------------------------------"); + + String test3 = h3.handleFeeRequest("张三", 700); + System.out.println("test3 = " + test3); + String test4 = h3.handleFeeRequest("李四", 700); + System.out.println("test4 = " + test4); + System.out.println("---------------------------------------"); + + String test5 = h3.handleFeeRequest("张三", 1500); + System.out.println("test5 = " + test5); + String test6 = h3.handleFeeRequest("李四", 1500); + System.out.println("test6 = " + test6); + } + +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/DeptManager.java b/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/DeptManager.java new file mode 100644 index 0000000000..e64b5c484e --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/DeptManager.java @@ -0,0 +1,35 @@ +package com.coderising.mydp.myResponseChain; + +/** + * Created by thomas_young on 10/8/2017. + */ +public class DeptManager extends Handler { + + @Override + public String handleFeeRequest(String user, double fee) { + + String str = ""; + //部门经理的权限只能在1000以内 + if(fee < 1000) + { + //为了测试,简单点,只同意张三的请求 + if("张三".equals(user)) + { + str = "成功:部门经理同意【" + user + "】的聚餐费用,金额为" + fee + "元"; + }else + { + //其他人一律不同意 + str = "失败:部门经理不同意【" + user + "】的聚餐费用,金额为" + fee + "元"; + } + }else + { + //超过1000,继续传递给级别更高的人处理 + if(getSuccessor() != null) + { + return getSuccessor().handleFeeRequest(user, fee); + } + } + return str; + } + +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/GeneralManager.java b/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/GeneralManager.java new file mode 100644 index 0000000000..1094d6eeaf --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/GeneralManager.java @@ -0,0 +1,34 @@ +package com.coderising.mydp.myResponseChain; + +/** + * Created by thomas_young on 10/8/2017. + */ +public class GeneralManager extends Handler { + + @Override + public String handleFeeRequest(String user, double fee) { + + String str = ""; + //总经理的权限很大,只要请求到了这里,他都可以处理 + if(fee >= 1000) + { + //为了测试,简单点,只同意张三的请求 + if("张三".equals(user)) + { + str = "成功:总经理同意【" + user + "】的聚餐费用,金额为" + fee + "元"; + }else + { + //其他人一律不同意 + str = "失败:总经理不同意【" + user + "】的聚餐费用,金额为" + fee + "元"; + } + }else { + //如果还有后继的处理对象,继续传递 + if(getSuccessor() != null) + { + return getSuccessor().handleFeeRequest(user, fee); + } + } + return str; + } + +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Handler.java b/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Handler.java new file mode 100644 index 0000000000..0b16a52eee --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Handler.java @@ -0,0 +1,30 @@ +package com.coderising.mydp.myResponseChain; + +/** + * Created by thomas_young on 10/8/2017. + */ +public abstract class Handler { + /** + * 持有下一个处理请求的对象 + */ + protected Handler successor = null; + /** + * 取值方法 + */ + public Handler getSuccessor() { + return successor; + } + /** + * 设置下一个处理请求的对象 + */ + public void setSuccessor(Handler successor) { + this.successor = successor; + } + /** + * 处理聚餐费用的申请 + * @param user 申请人 + * @param fee 申请的钱数 + * @return 成功或失败的具体通知 + */ + public abstract String handleFeeRequest(String user , double fee); +} \ No newline at end of file diff --git a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/ProjectManager.java b/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/ProjectManager.java new file mode 100644 index 0000000000..1a36701154 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/ProjectManager.java @@ -0,0 +1,35 @@ +package com.coderising.mydp.myResponseChain; + +/** + * Created by thomas_young on 10/8/2017. + */ +public class ProjectManager extends Handler { + + @Override + public String handleFeeRequest(String user, double fee) { + + String str = ""; + //项目经理权限比较小,只能在500以内 + if(fee < 500) + { + //为了测试,简单点,只同意张三的请求 + if("张三".equals(user)) + { + str = "成功:项目经理同意【" + user + "】的聚餐费用,金额为" + fee + "元"; + }else + { + //其他人一律不同意 + str = "失败:项目经理不同意【" + user + "】的聚餐费用,金额为" + fee + "元"; + } + }else + { + //超过500,继续传递给级别更高的人处理 + if(getSuccessor() != null) + { + return getSuccessor().handleFeeRequest(user, fee); + } + } + return str; + } + +} From 93c53730267c64169612eb89bbccfbc5f0f2386c Mon Sep 17 00:00:00 2001 From: lx520 <740707954@qq,com> Date: Thu, 10 Aug 2017 23:01:04 +0800 Subject: [PATCH 58/81] =?UTF-8?q?2017=E5=B9=B48=E6=9C=8810=E6=97=A523:00:5?= =?UTF-8?q?6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- students/740707954/pom.xml | 38 +++++++++---------- .../src/main/java/dp/bridge/BridgeTest.java | 21 ---------- .../main/java/dp/bridge/{ => v1}/Circle.java | 2 +- .../main/java/dp/bridge/{ => v1}/Drawing.java | 2 +- .../java/dp/bridge/{ => v1}/DrawingGL1.java | 2 +- .../java/dp/bridge/{ => v1}/DrawingGL2.java | 2 +- .../java/dp/bridge/{ => v1}/Retangle.java | 2 +- .../main/java/dp/bridge/{ => v1}/Shape.java | 2 +- .../src/main/java/dp/bridge/v2/Cicle.java | 26 +++++++++++++ .../src/main/java/dp/bridge/v2/Drawing.java | 10 +++++ .../main/java/dp/bridge/v2/DrawingGL1.java | 17 +++++++++ .../main/java/dp/bridge/v2/DrawingGL2.java | 17 +++++++++ .../src/main/java/dp/bridge/v2/Rectangle.java | 27 +++++++++++++ .../src/main/java/dp/bridge/v2/Shape.java | 10 +++++ .../740707954/src/test/java/BridgeTest.java | 28 ++++++++++++++ .../740707954/src/test/java/BridgeTest1.java | 20 ++++++++++ .../java}/CompositeTest.java | 3 +- .../dp/decorator => test/java}/EmailTest.java | 6 ++- .../builder => test/java}/TagBuilderTest.java | 3 +- 19 files changed, 186 insertions(+), 52 deletions(-) delete mode 100644 students/740707954/src/main/java/dp/bridge/BridgeTest.java rename students/740707954/src/main/java/dp/bridge/{ => v1}/Circle.java (91%) rename students/740707954/src/main/java/dp/bridge/{ => v1}/Drawing.java (83%) rename students/740707954/src/main/java/dp/bridge/{ => v1}/DrawingGL1.java (93%) rename students/740707954/src/main/java/dp/bridge/{ => v1}/DrawingGL2.java (93%) rename students/740707954/src/main/java/dp/bridge/{ => v1}/Retangle.java (91%) rename students/740707954/src/main/java/dp/bridge/{ => v1}/Shape.java (92%) create mode 100644 students/740707954/src/main/java/dp/bridge/v2/Cicle.java create mode 100644 students/740707954/src/main/java/dp/bridge/v2/Drawing.java create mode 100644 students/740707954/src/main/java/dp/bridge/v2/DrawingGL1.java create mode 100644 students/740707954/src/main/java/dp/bridge/v2/DrawingGL2.java create mode 100644 students/740707954/src/main/java/dp/bridge/v2/Rectangle.java create mode 100644 students/740707954/src/main/java/dp/bridge/v2/Shape.java create mode 100644 students/740707954/src/test/java/BridgeTest.java create mode 100644 students/740707954/src/test/java/BridgeTest1.java rename students/740707954/src/{main/java/dp/composite => test/java}/CompositeTest.java (95%) rename students/740707954/src/{main/java/dp/decorator => test/java}/EmailTest.java (66%) rename students/740707954/src/{main/java/dp/builder => test/java}/TagBuilderTest.java (97%) diff --git a/students/740707954/pom.xml b/students/740707954/pom.xml index d9ec615fe1..577a0f582d 100644 --- a/students/740707954/pom.xml +++ b/students/740707954/pom.xml @@ -1,25 +1,25 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - 740707954 - 740707954 - 1.0-SNAPSHOT - jar + 740707954 + 740707954 + 1.0-SNAPSHOT + jar - 740707954 - http://maven.apache.org + 740707954 + http://maven.apache.org - - UTF-8 - + + UTF-8 + - - - junit - junit - 4.11 - test - - + + + junit + junit + 4.10 + test + + diff --git a/students/740707954/src/main/java/dp/bridge/BridgeTest.java b/students/740707954/src/main/java/dp/bridge/BridgeTest.java deleted file mode 100644 index 838014f92a..0000000000 --- a/students/740707954/src/main/java/dp/bridge/BridgeTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package dp.bridge; - -import org.junit.Test; - -/** - * Created by lx on 2017/7/29. - */ -public class BridgeTest { - - @Test - public void testBridge() { - Shape shape1 = new Circle(new DrawingGL1()); - Shape shape2 = new Retangle(new DrawingGL1()); - Shape shape3 = new Circle(new DrawingGL2()); - Shape shape4 = new Retangle(new DrawingGL2()); - shape1.shape(); - shape2.shape(); - shape3.shape(); - shape4.shape(); - } -} diff --git a/students/740707954/src/main/java/dp/bridge/Circle.java b/students/740707954/src/main/java/dp/bridge/v1/Circle.java similarity index 91% rename from students/740707954/src/main/java/dp/bridge/Circle.java rename to students/740707954/src/main/java/dp/bridge/v1/Circle.java index 4224535816..5102a18211 100644 --- a/students/740707954/src/main/java/dp/bridge/Circle.java +++ b/students/740707954/src/main/java/dp/bridge/v1/Circle.java @@ -1,4 +1,4 @@ -package dp.bridge; +package dp.bridge.v1; /** * Created by lx on 2017/7/29. diff --git a/students/740707954/src/main/java/dp/bridge/Drawing.java b/students/740707954/src/main/java/dp/bridge/v1/Drawing.java similarity index 83% rename from students/740707954/src/main/java/dp/bridge/Drawing.java rename to students/740707954/src/main/java/dp/bridge/v1/Drawing.java index 1faae5781f..5011838201 100644 --- a/students/740707954/src/main/java/dp/bridge/Drawing.java +++ b/students/740707954/src/main/java/dp/bridge/v1/Drawing.java @@ -1,4 +1,4 @@ -package dp.bridge; +package dp.bridge.v1; /** * Created by lx on 2017/7/29. diff --git a/students/740707954/src/main/java/dp/bridge/DrawingGL1.java b/students/740707954/src/main/java/dp/bridge/v1/DrawingGL1.java similarity index 93% rename from students/740707954/src/main/java/dp/bridge/DrawingGL1.java rename to students/740707954/src/main/java/dp/bridge/v1/DrawingGL1.java index 8a27855227..5915eb884c 100644 --- a/students/740707954/src/main/java/dp/bridge/DrawingGL1.java +++ b/students/740707954/src/main/java/dp/bridge/v1/DrawingGL1.java @@ -1,4 +1,4 @@ -package dp.bridge; +package dp.bridge.v1; /** * 图形库1 diff --git a/students/740707954/src/main/java/dp/bridge/DrawingGL2.java b/students/740707954/src/main/java/dp/bridge/v1/DrawingGL2.java similarity index 93% rename from students/740707954/src/main/java/dp/bridge/DrawingGL2.java rename to students/740707954/src/main/java/dp/bridge/v1/DrawingGL2.java index 419a6853bc..e2c215a233 100644 --- a/students/740707954/src/main/java/dp/bridge/DrawingGL2.java +++ b/students/740707954/src/main/java/dp/bridge/v1/DrawingGL2.java @@ -1,4 +1,4 @@ -package dp.bridge; +package dp.bridge.v1; /** * 图形库2 diff --git a/students/740707954/src/main/java/dp/bridge/Retangle.java b/students/740707954/src/main/java/dp/bridge/v1/Retangle.java similarity index 91% rename from students/740707954/src/main/java/dp/bridge/Retangle.java rename to students/740707954/src/main/java/dp/bridge/v1/Retangle.java index ea869f1b46..1f4c907686 100644 --- a/students/740707954/src/main/java/dp/bridge/Retangle.java +++ b/students/740707954/src/main/java/dp/bridge/v1/Retangle.java @@ -1,4 +1,4 @@ -package dp.bridge; +package dp.bridge.v1; /** * Created by lx on 2017/7/29. diff --git a/students/740707954/src/main/java/dp/bridge/Shape.java b/students/740707954/src/main/java/dp/bridge/v1/Shape.java similarity index 92% rename from students/740707954/src/main/java/dp/bridge/Shape.java rename to students/740707954/src/main/java/dp/bridge/v1/Shape.java index 1ec254c30b..890474ce06 100644 --- a/students/740707954/src/main/java/dp/bridge/Shape.java +++ b/students/740707954/src/main/java/dp/bridge/v1/Shape.java @@ -1,4 +1,4 @@ -package dp.bridge; +package dp.bridge.v1; /** * Created by lx on 2017/7/29. diff --git a/students/740707954/src/main/java/dp/bridge/v2/Cicle.java b/students/740707954/src/main/java/dp/bridge/v2/Cicle.java new file mode 100644 index 0000000000..e738ed46d6 --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/v2/Cicle.java @@ -0,0 +1,26 @@ +package dp.bridge.v2; + +/** + * Created by Administrator on 2017/8/10 0010. + */ +public class Cicle implements Shape { + + private Drawing drawing; + private int x1, x2, r; + + public Cicle(int x1, int x2, int r) { + this.x1 = x1; + this.x2 = x2; + this.r = r; + } + + @Override + public void setDrawing(Drawing d) { + this.drawing = d; + } + + @Override + public void draw() { + drawing.drawCircle(); + } +} diff --git a/students/740707954/src/main/java/dp/bridge/v2/Drawing.java b/students/740707954/src/main/java/dp/bridge/v2/Drawing.java new file mode 100644 index 0000000000..89d1074b14 --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/v2/Drawing.java @@ -0,0 +1,10 @@ +package dp.bridge.v2; + +/** + * Created by lx on 2017/7/29. + */ +public interface Drawing { + void drawLine(); + + void drawCircle(); +} diff --git a/students/740707954/src/main/java/dp/bridge/v2/DrawingGL1.java b/students/740707954/src/main/java/dp/bridge/v2/DrawingGL1.java new file mode 100644 index 0000000000..a4d3c0bf8b --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/v2/DrawingGL1.java @@ -0,0 +1,17 @@ +package dp.bridge.v2; + +/** + * 图形库1 + * Created by lx on 2017/7/29. + */ +public class DrawingGL1 implements Drawing { + @Override + public void drawLine() { + System.out.println("图形库1画线"); + } + + @Override + public void drawCircle() { + System.out.println("图形库1画圆"); + } +} diff --git a/students/740707954/src/main/java/dp/bridge/v2/DrawingGL2.java b/students/740707954/src/main/java/dp/bridge/v2/DrawingGL2.java new file mode 100644 index 0000000000..368fe60bef --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/v2/DrawingGL2.java @@ -0,0 +1,17 @@ +package dp.bridge.v2; + +/** + * 图形库2 + * Created by lx on 2017/7/29. + */ +public class DrawingGL2 implements Drawing { + @Override + public void drawLine() { + System.out.println("图形库2画线"); + } + + @Override + public void drawCircle() { + System.out.println("图形库2画圆"); + } +} diff --git a/students/740707954/src/main/java/dp/bridge/v2/Rectangle.java b/students/740707954/src/main/java/dp/bridge/v2/Rectangle.java new file mode 100644 index 0000000000..32ce8f6f05 --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/v2/Rectangle.java @@ -0,0 +1,27 @@ +package dp.bridge.v2; + +/** + * Created by Administrator on 2017/8/10 0010. + */ +public class Rectangle implements Shape { + + private Drawing drawing; + private int x1, y1, x2, y2; + + public Rectangle(int x1, int y1, int x2, int y2) { + this.x1 = x1; + this.x2 = x2; + this.y1 = y1; + this.y2 = y2; + } + + @Override + public void setDrawing(Drawing d) { + this.drawing = d; + } + + @Override + public void draw() { + drawing.drawLine(); + } +} diff --git a/students/740707954/src/main/java/dp/bridge/v2/Shape.java b/students/740707954/src/main/java/dp/bridge/v2/Shape.java new file mode 100644 index 0000000000..8dd46ef2d7 --- /dev/null +++ b/students/740707954/src/main/java/dp/bridge/v2/Shape.java @@ -0,0 +1,10 @@ +package dp.bridge.v2; + +/** + * Created by Administrator on 2017/8/10 0010. + */ +public interface Shape { + void setDrawing(Drawing d); + + void draw(); +} diff --git a/students/740707954/src/test/java/BridgeTest.java b/students/740707954/src/test/java/BridgeTest.java new file mode 100644 index 0000000000..90fd115a40 --- /dev/null +++ b/students/740707954/src/test/java/BridgeTest.java @@ -0,0 +1,28 @@ +import dp.bridge.v2.*; +import org.junit.Test; + +/** + * Created by lx on 2017/7/29. + */ +public class BridgeTest { + + @Test + public void testBridge() { + Shape r = new Rectangle(1, 2, 3, 4); + Shape c = new Cicle(1, 2, 3); + Drawing d1 = new DrawingGL1(); + Drawing d2 = new DrawingGL2(); + + r.setDrawing(d1); + r.draw(); + + c.setDrawing(d1); + c.draw(); + + r.setDrawing(d2); + r.draw(); + + c.setDrawing(d2); + c.draw(); + } +} diff --git a/students/740707954/src/test/java/BridgeTest1.java b/students/740707954/src/test/java/BridgeTest1.java new file mode 100644 index 0000000000..bd09cdf76a --- /dev/null +++ b/students/740707954/src/test/java/BridgeTest1.java @@ -0,0 +1,20 @@ +import dp.bridge.v1.*; +import org.junit.Test; + +/** + * Created by lx on 2017/7/29. + */ +public class BridgeTest1 { + + @Test + public void testBridge() { +// Shape shape1 = new Circle(new DrawingGL1()); +// Shape shape2 = new Retangle(new DrawingGL1()); +// Shape shape3 = new Circle(new DrawingGL2()); +// Shape shape4 = new Retangle(new DrawingGL2()); +// shape1.shape(); +// shape2.shape(); +// shape3.shape(); +// shape4.shape(); + } +} diff --git a/students/740707954/src/main/java/dp/composite/CompositeTest.java b/students/740707954/src/test/java/CompositeTest.java similarity index 95% rename from students/740707954/src/main/java/dp/composite/CompositeTest.java rename to students/740707954/src/test/java/CompositeTest.java index 0b0ea0c60e..141326e1dd 100644 --- a/students/740707954/src/main/java/dp/composite/CompositeTest.java +++ b/students/740707954/src/test/java/CompositeTest.java @@ -1,5 +1,4 @@ -package dp.composite; - +import dp.composite.*; import org.junit.Test; /** diff --git a/students/740707954/src/main/java/dp/decorator/EmailTest.java b/students/740707954/src/test/java/EmailTest.java similarity index 66% rename from students/740707954/src/main/java/dp/decorator/EmailTest.java rename to students/740707954/src/test/java/EmailTest.java index 81ba464e17..624f11dffc 100644 --- a/students/740707954/src/main/java/dp/decorator/EmailTest.java +++ b/students/740707954/src/test/java/EmailTest.java @@ -1,5 +1,7 @@ -package dp.decorator; - +import dp.decorator.Email; +import dp.decorator.EmailImpl; +import dp.decorator.EncryptionEmailImpl; +import dp.decorator.OutsideEmailImpl; import org.junit.Test; /** diff --git a/students/740707954/src/main/java/dp/builder/TagBuilderTest.java b/students/740707954/src/test/java/TagBuilderTest.java similarity index 97% rename from students/740707954/src/main/java/dp/builder/TagBuilderTest.java rename to students/740707954/src/test/java/TagBuilderTest.java index 450b7fc043..1cc5388f49 100644 --- a/students/740707954/src/main/java/dp/builder/TagBuilderTest.java +++ b/students/740707954/src/test/java/TagBuilderTest.java @@ -1,5 +1,4 @@ -package dp.builder; - +import dp.builder.TagBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test; From 49d28007febc786f908a710c3619dd3e5bd9a80a Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Fri, 11 Aug 2017 00:35:03 +0800 Subject: [PATCH 59/81] =?UTF-8?q?[Homework]=20=E8=B4=A3=E4=BB=BB=E9=93=BE?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mydp/responseChain/AbstractLogger.java | 26 +++++++++++++++++++ .../coderising/mydp/responseChain/Client.java | 23 ++++++++++++++++ .../mydp/responseChain/EmailLogger.java | 15 +++++++++++ .../mydp/responseChain/FileLogger.java | 11 ++++++++ .../mydp/responseChain/StdoutLogger.java | 14 ++++++++++ .../myResponseChain/Client.java | 3 ++- .../myResponseChain/DeptManager.java | 2 +- .../myResponseChain/GeneralManager.java | 2 +- .../myResponseChain/Handler.java | 2 +- .../myResponseChain/ProjectManager.java | 2 +- 10 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 students/812350401/src/main/java/com/coderising/mydp/responseChain/AbstractLogger.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/responseChain/Client.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/responseChain/EmailLogger.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/responseChain/FileLogger.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/responseChain/StdoutLogger.java rename students/812350401/src/main/java/com/coderising/{mydp => myknowledgepoint}/myResponseChain/Client.java (90%) rename students/812350401/src/main/java/com/coderising/{mydp => myknowledgepoint}/myResponseChain/DeptManager.java (94%) rename students/812350401/src/main/java/com/coderising/{mydp => myknowledgepoint}/myResponseChain/GeneralManager.java (94%) rename students/812350401/src/main/java/com/coderising/{mydp => myknowledgepoint}/myResponseChain/Handler.java (92%) rename students/812350401/src/main/java/com/coderising/{mydp => myknowledgepoint}/myResponseChain/ProjectManager.java (94%) diff --git a/students/812350401/src/main/java/com/coderising/mydp/responseChain/AbstractLogger.java b/students/812350401/src/main/java/com/coderising/mydp/responseChain/AbstractLogger.java new file mode 100644 index 0000000000..778962e2fa --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/responseChain/AbstractLogger.java @@ -0,0 +1,26 @@ +package com.coderising.mydp.responseChain; + +/** + * Created by thomas_young on 11/8/2017. + */ +public abstract class AbstractLogger { + public static final String DEBUG = "DEBUG"; + public static final String NOTICE = "NOTICE"; + public static final String ERR = "ERR"; + + /** + * 持有下一个处理请求的对象 + */ + private AbstractLogger next = null; + + public AbstractLogger getNext() { + return next; + } + + public AbstractLogger setNext(AbstractLogger next) { + this.next = next; + return this; + } + + public abstract void message(String message, String type); +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/responseChain/Client.java b/students/812350401/src/main/java/com/coderising/mydp/responseChain/Client.java new file mode 100644 index 0000000000..30f27b4943 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/responseChain/Client.java @@ -0,0 +1,23 @@ +package com.coderising.mydp.responseChain; + +/** + * Created by thomas_young on 11/8/2017. + */ +public class Client { + + public static void main(String[] args) { + AbstractLogger logger = new StdoutLogger() + .setNext(new EmailLogger() + .setNext(new FileLogger())); + + // 由StdoutLogger处理 + logger.message("进入计算函数", AbstractLogger.DEBUG); + // 由StdoutLogger和EmailLogger处理 + System.out.println("*****************"); + logger.message("第一步已完成", AbstractLogger.NOTICE); + // 由所有logger处理 + System.out.println("*****************"); + logger.message("一个致命的错误发生了", AbstractLogger.ERR); + } + +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/responseChain/EmailLogger.java b/students/812350401/src/main/java/com/coderising/mydp/responseChain/EmailLogger.java new file mode 100644 index 0000000000..54605eba5b --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/responseChain/EmailLogger.java @@ -0,0 +1,15 @@ +package com.coderising.mydp.responseChain; + +/** + * Created by thomas_young on 11/8/2017. + */ +public class EmailLogger extends AbstractLogger { + + @Override + public void message(String message, String type) { + System.out.println("EmailLogger处理:" + message); + if (!AbstractLogger.NOTICE.equals(type)) { + getNext().message(message, type); + } + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/responseChain/FileLogger.java b/students/812350401/src/main/java/com/coderising/mydp/responseChain/FileLogger.java new file mode 100644 index 0000000000..2c6d316eea --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/responseChain/FileLogger.java @@ -0,0 +1,11 @@ +package com.coderising.mydp.responseChain; + +/** + * Created by thomas_young on 11/8/2017. + */ +public class FileLogger extends AbstractLogger { + @Override + public void message(String message, String type) { + System.out.println("FileLogger处理:" + message); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/responseChain/StdoutLogger.java b/students/812350401/src/main/java/com/coderising/mydp/responseChain/StdoutLogger.java new file mode 100644 index 0000000000..29ae7a1d19 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/responseChain/StdoutLogger.java @@ -0,0 +1,14 @@ +package com.coderising.mydp.responseChain; + +/** + * Created by thomas_young on 11/8/2017. + */ +public class StdoutLogger extends AbstractLogger { + @Override + public void message(String message, String type) { + System.out.println("StdoutLogger处理:" + message); + if (!AbstractLogger.DEBUG.equals(type)) { + getNext().message(message, type); + } + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Client.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/Client.java similarity index 90% rename from students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Client.java rename to students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/Client.java index 1c0280e00a..40aeb59765 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Client.java +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/Client.java @@ -1,7 +1,8 @@ -package com.coderising.mydp.myResponseChain; +package com.coderising.myknowledgepoint.myResponseChain; /** * Created by thomas_young on 10/8/2017. + * http://www.cnblogs.com/java-my-life/archive/2012/05/28/2516865.html */ public class Client { diff --git a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/DeptManager.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/DeptManager.java similarity index 94% rename from students/812350401/src/main/java/com/coderising/mydp/myResponseChain/DeptManager.java rename to students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/DeptManager.java index e64b5c484e..d051b7f37a 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/DeptManager.java +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/DeptManager.java @@ -1,4 +1,4 @@ -package com.coderising.mydp.myResponseChain; +package com.coderising.myknowledgepoint.myResponseChain; /** * Created by thomas_young on 10/8/2017. diff --git a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/GeneralManager.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/GeneralManager.java similarity index 94% rename from students/812350401/src/main/java/com/coderising/mydp/myResponseChain/GeneralManager.java rename to students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/GeneralManager.java index 1094d6eeaf..2d601604c1 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/GeneralManager.java +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/GeneralManager.java @@ -1,4 +1,4 @@ -package com.coderising.mydp.myResponseChain; +package com.coderising.myknowledgepoint.myResponseChain; /** * Created by thomas_young on 10/8/2017. diff --git a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Handler.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/Handler.java similarity index 92% rename from students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Handler.java rename to students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/Handler.java index 0b16a52eee..a032475bd9 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/Handler.java +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/Handler.java @@ -1,4 +1,4 @@ -package com.coderising.mydp.myResponseChain; +package com.coderising.myknowledgepoint.myResponseChain; /** * Created by thomas_young on 10/8/2017. diff --git a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/ProjectManager.java b/students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/ProjectManager.java similarity index 94% rename from students/812350401/src/main/java/com/coderising/mydp/myResponseChain/ProjectManager.java rename to students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/ProjectManager.java index 1a36701154..7fa75aa662 100644 --- a/students/812350401/src/main/java/com/coderising/mydp/myResponseChain/ProjectManager.java +++ b/students/812350401/src/main/java/com/coderising/myknowledgepoint/myResponseChain/ProjectManager.java @@ -1,4 +1,4 @@ -package com.coderising.mydp.myResponseChain; +package com.coderising.myknowledgepoint.myResponseChain; /** * Created by thomas_young on 10/8/2017. From ed6fab7e82c2389528bd8630fb705a5c6be84b27 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Fri, 11 Aug 2017 12:17:13 +0800 Subject: [PATCH 60/81] =?UTF-8?q?[Homework]:=20=E5=91=BD=E4=BB=A4=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/coderising/mydp/command/Client.java | 21 +++++++++++++++++ .../com/coderising/mydp/command/Command.java | 8 +++++++ .../com/coderising/mydp/command/Cook.java | 23 +++++++++++++++++++ .../mydp/command/OrderPorkCommand.java | 16 +++++++++++++ .../mydp/command/OrderSteakCommand.java | 16 +++++++++++++ .../com/coderising/mydp/command/Waitor.java | 20 ++++++++++++++++ 6 files changed, 104 insertions(+) create mode 100644 students/812350401/src/main/java/com/coderising/mydp/command/Client.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/command/Command.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/command/Cook.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/command/OrderPorkCommand.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/command/OrderSteakCommand.java create mode 100644 students/812350401/src/main/java/com/coderising/mydp/command/Waitor.java diff --git a/students/812350401/src/main/java/com/coderising/mydp/command/Client.java b/students/812350401/src/main/java/com/coderising/mydp/command/Client.java new file mode 100644 index 0000000000..ad8c17699e --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/command/Client.java @@ -0,0 +1,21 @@ +package com.coderising.mydp.command; + +/** + * Created by thomas_young on 11/8/2017. + * 命令模式 + */ +public class Client { + + public static void main(String[] args) { + Cook cook = new Cook(); + Waitor waitor = new Waitor(); + + Command command1 = new OrderPorkCommand(cook); + Command command2 = new OrderSteakCommand(cook); + + waitor.addOrder(command1); + waitor.addOrder(command2); + + waitor.sendOrders(); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/command/Command.java b/students/812350401/src/main/java/com/coderising/mydp/command/Command.java new file mode 100644 index 0000000000..922c774209 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/command/Command.java @@ -0,0 +1,8 @@ +package com.coderising.mydp.command; + +/** + * Created by thomas_young on 11/8/2017. + */ +public interface Command { + void execute(); +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/command/Cook.java b/students/812350401/src/main/java/com/coderising/mydp/command/Cook.java new file mode 100644 index 0000000000..940e17869d --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/command/Cook.java @@ -0,0 +1,23 @@ +package com.coderising.mydp.command; + +/** + * Created by thomas_young on 11/8/2017. + */ +public class Cook { + + public void cookSteak() { + System.out.println("Steak is ok"); + } + + public void cookPork() { + System.out.println("Pork is ok"); + } + + public static void main(String[] args) { + StringBuilder x = new StringBuilder("Hello"); + String r1 = x.append(",world").toString(); + String r2 = x.append(",world").toString(); + System.out.println(r1); + System.out.println(r2); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/command/OrderPorkCommand.java b/students/812350401/src/main/java/com/coderising/mydp/command/OrderPorkCommand.java new file mode 100644 index 0000000000..a887b6f3fa --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/command/OrderPorkCommand.java @@ -0,0 +1,16 @@ +package com.coderising.mydp.command; + +/** + * Created by thomas_young on 11/8/2017. + */ +public class OrderPorkCommand implements Command { + private Cook cook; + + public OrderPorkCommand(Cook cook) { + this.cook = cook; + } + @Override + public void execute() { + cook.cookPork(); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/command/OrderSteakCommand.java b/students/812350401/src/main/java/com/coderising/mydp/command/OrderSteakCommand.java new file mode 100644 index 0000000000..3319d141de --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/command/OrderSteakCommand.java @@ -0,0 +1,16 @@ +package com.coderising.mydp.command; + +/** + * Created by thomas_young on 11/8/2017. + */ +public class OrderSteakCommand implements Command { + private Cook cook; + public OrderSteakCommand(Cook cook) { + this.cook = cook; + } + + @Override + public void execute() { + cook.cookSteak(); + } +} diff --git a/students/812350401/src/main/java/com/coderising/mydp/command/Waitor.java b/students/812350401/src/main/java/com/coderising/mydp/command/Waitor.java new file mode 100644 index 0000000000..5bdf920fcd --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/mydp/command/Waitor.java @@ -0,0 +1,20 @@ +package com.coderising.mydp.command; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by thomas_young on 11/8/2017. + */ +public class Waitor { + List commands = new ArrayList<>(); + + public void addOrder(Command command) { + commands.add(command); + } + + public void sendOrders() { + commands.stream().forEach(Command::execute); + } + +} From f39df1c327cfe02f5dc80bd34d5804b8908c05c5 Mon Sep 17 00:00:00 2001 From: liuzengzeng Date: Fri, 11 Aug 2017 14:39:57 +0800 Subject: [PATCH 61/81] chain and command design homework --- .../java/com/coderings/dp/chain/Client.java | 18 +++++++++++ .../com/coderings/dp/chain/EmailLogger.java | 30 +++++++++++++++++++ .../com/coderings/dp/chain/FileLogger.java | 30 +++++++++++++++++++ .../java/com/coderings/dp/chain/Logger.java | 15 ++++++++++ .../com/coderings/dp/chain/StdoutLogger.java | 30 +++++++++++++++++++ .../java/com/coderings/dp/command/Client.java | 23 ++++++++++++++ .../com/coderings/dp/command/Command.java | 9 ++++++ .../java/com/coderings/dp/command/Cook.java | 15 ++++++++++ .../dp/command/OrderPorkCommand.java | 18 +++++++++++ .../dp/command/OrderSteakCommand.java | 18 +++++++++++ .../java/com/coderings/dp/command/Waiter.java | 22 ++++++++++++++ 11 files changed, 228 insertions(+) create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/Client.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/EmailLogger.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/FileLogger.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/Logger.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/StdoutLogger.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Client.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Command.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Cook.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/OrderPorkCommand.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/OrderSteakCommand.java create mode 100644 students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Waiter.java diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/Client.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/Client.java new file mode 100644 index 0000000000..2293c779b3 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/Client.java @@ -0,0 +1,18 @@ +package com.coderings.dp.chain; + + +/** + * @author nvarchar + * date 2017/8/11 + */ +public class Client { + + public static void main(String[] args) { + Logger logger = new StdoutLogger(Logger.DEBUG) + .setNext(new EmailLogger(Logger.NOTICE).setNext(new FileLogger(Logger.ERR).setNext(new EmailLogger(Logger.DEBUG)))); + + logger.message("进入计算函数", Logger.DEBUG); + logger.message("第一步已经完成", Logger.NOTICE); + logger.message("一个致命错误发生", Logger.ERR); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/EmailLogger.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/EmailLogger.java new file mode 100644 index 0000000000..6cde3435de --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/EmailLogger.java @@ -0,0 +1,30 @@ +package com.coderings.dp.chain; + +/** + * @author nvarchar + * date 2017/8/11 + */ +public class EmailLogger implements Logger{ + private int level; + private Logger next; + + public EmailLogger(int level) { + this.level = level; + } + + @Override + public void message(String context, int level) { + if (level >= this.level) { + System.out.println("email :" + context); + } + if (this.next != null) { + this.next.message(context, level); + } + } + + @Override + public Logger setNext(Logger next) { + this.next = next; + return this; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/FileLogger.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/FileLogger.java new file mode 100644 index 0000000000..651e3f0701 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/FileLogger.java @@ -0,0 +1,30 @@ +package com.coderings.dp.chain; + +/** + * @author nvarchar + * date 2017/8/11 + */ +public class FileLogger implements Logger { + private int level; + private Logger next; + + public FileLogger(int level) { + this.level = level; + } + + @Override + public void message(String context, int level) { + if (level >= this.level) { + System.out.println("file :" + context); + } + if (this.next != null) { + this.next.message(context, level); + } + } + + @Override + public Logger setNext(Logger next) { + this.next = next; + return this; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/Logger.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/Logger.java new file mode 100644 index 0000000000..2d707e2ae7 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/Logger.java @@ -0,0 +1,15 @@ +package com.coderings.dp.chain; + +/** + * @author nvarchar + * date 2017/8/11 + */ +public interface Logger { + public static final int DEBUG = 0; + public static final int NOTICE = 1; + public static final int ERR = 2; + + public void message(String context, int level); + + public Logger setNext(Logger next); +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/StdoutLogger.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/StdoutLogger.java new file mode 100644 index 0000000000..ea08e790b4 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/chain/StdoutLogger.java @@ -0,0 +1,30 @@ +package com.coderings.dp.chain; + +/** + * @author nvarchar + * date 2017/8/11 + */ +public class StdoutLogger implements Logger { + private int level; + private Logger next; + + public StdoutLogger(int level) { + this.level = level; + } + + @Override + public void message(String context, int level) { + if (level >= this.level) { + System.out.println("console :" + context); + } + if (this.next != null) { + this.next.message(context, level); + } + } + + @Override + public Logger setNext(Logger next) { + this.next = next; + return this; + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Client.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Client.java new file mode 100644 index 0000000000..8dd4ad4c76 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Client.java @@ -0,0 +1,23 @@ +package com.coderings.dp.command; + +/** + * @author nvarchar + * date 2017/8/11 + */ +public class Client { + public static void main(String[] args) { + Cook cook = new Cook(); + + Waiter waiter = new Waiter(); + + Command command1 = new OrderPorkCommand(cook); + Command command2 = new OrderSteakCommand(cook); + Command command3 = new OrderSteakCommand(cook); + + waiter.addOrder(command1); + waiter.addOrder(command2); + waiter.addOrder(command3); + + waiter.sendOrders(); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Command.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Command.java new file mode 100644 index 0000000000..ddc3465eda --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Command.java @@ -0,0 +1,9 @@ +package com.coderings.dp.command; + +/** + * @author nvarchar + * date 2017/8/11 + */ +public interface Command { + void execute(); +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Cook.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Cook.java new file mode 100644 index 0000000000..01d3934d35 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Cook.java @@ -0,0 +1,15 @@ +package com.coderings.dp.command; + +/** + * @author nvarchar + * date 2017/8/11 + */ +public class Cook { + void cookSteak() { + System.out.println("steak is ready"); + } + + void cookPork() { + System.out.println("pork is ready"); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/OrderPorkCommand.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/OrderPorkCommand.java new file mode 100644 index 0000000000..a575094089 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/OrderPorkCommand.java @@ -0,0 +1,18 @@ +package com.coderings.dp.command; + +/** + * @author nvarchar + * date 2017/8/11 + */ +public class OrderPorkCommand implements Command{ + private Cook cook; + + public OrderPorkCommand(Cook cook) { + this.cook = cook; + } + + @Override + public void execute() { + cook.cookPork(); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/OrderSteakCommand.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/OrderSteakCommand.java new file mode 100644 index 0000000000..716a2953c2 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/OrderSteakCommand.java @@ -0,0 +1,18 @@ +package com.coderings.dp.command; + +/** + * @author nvarchar + * date 2017/8/11 + */ +public class OrderSteakCommand implements Command{ + private Cook cook; + + public OrderSteakCommand(Cook cook) { + this.cook = cook; + } + + @Override + public void execute() { + cook.cookSteak(); + } +} diff --git a/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Waiter.java b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Waiter.java new file mode 100644 index 0000000000..9bce5d54c8 --- /dev/null +++ b/students/2816977791/ood/ood-assignment/src/main/java/com/coderings/dp/command/Waiter.java @@ -0,0 +1,22 @@ +package com.coderings.dp.command; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author nvarchar + * date 2017/8/11 + */ +public class Waiter { + private List commands = new ArrayList<>(); + + public void addOrder(Command command) { + commands.add(command); + } + + public void sendOrders() { + for (Command command : commands) { + command.execute(); + } + } +} From e1eb52b0f383a1e5356d464675b4f365afe68f09 Mon Sep 17 00:00:00 2001 From: jy <977996067@qq.com> Date: Sat, 12 Aug 2017 15:56:26 +0800 Subject: [PATCH 62/81] Add Command&Chain pattern homework --- .../coderising/dp/week3/command/Command.java | 16 +++++++++++ .../com/coderising/dp/week3/command/Cook.java | 12 ++++++++ .../dp/week3/command/OrderPorkCommand.java | 14 ++++++++++ .../dp/week3/command/OrderSteakCommand.java | 13 +++++++++ .../coderising/dp/week3/command/Waiter.java | 19 +++++++++++++ .../week3/responsibility/AbstractLogger.java | 28 +++++++++++++++++++ .../dp/week3/responsibility/EmailLogger.java | 20 +++++++++++++ .../dp/week3/responsibility/FileLogger.java | 20 +++++++++++++ .../dp/week3/responsibility/Logger.java | 10 +++++++ .../dp/week3/responsibility/StdoutLogger.java | 21 ++++++++++++++ .../com/coderising/dp/week3/ChainTest.java | 21 ++++++++++++++ .../com/coderising/dp/week3/CommandTest.java | 18 ++++++++++++ 12 files changed, 212 insertions(+) create mode 100644 students/977996067/src/main/java/com/coderising/dp/week3/command/Command.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week3/command/Cook.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week3/command/OrderPorkCommand.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week3/command/OrderSteakCommand.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week3/command/Waiter.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week3/responsibility/AbstractLogger.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week3/responsibility/EmailLogger.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week3/responsibility/FileLogger.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week3/responsibility/Logger.java create mode 100644 students/977996067/src/main/java/com/coderising/dp/week3/responsibility/StdoutLogger.java create mode 100644 students/977996067/src/test/java/com/coderising/dp/week3/ChainTest.java create mode 100644 students/977996067/src/test/java/com/coderising/dp/week3/CommandTest.java diff --git a/students/977996067/src/main/java/com/coderising/dp/week3/command/Command.java b/students/977996067/src/main/java/com/coderising/dp/week3/command/Command.java new file mode 100644 index 0000000000..9baa019670 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week3/command/Command.java @@ -0,0 +1,16 @@ +package com.coderising.dp.week3.command; + +public abstract class Command { + + private Cook cook; + + protected Command(Cook cook) { + this.cook = cook; + } + + public Cook getCook() { + return cook; + } + + protected abstract void cookFood(); +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week3/command/Cook.java b/students/977996067/src/main/java/com/coderising/dp/week3/command/Cook.java new file mode 100644 index 0000000000..40adb8012a --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week3/command/Cook.java @@ -0,0 +1,12 @@ +package com.coderising.dp.week3.command; + +public class Cook { + + void cookSteak() { + System.out.println("Steak is OK"); + } + + void cookPork() { + System.out.println("Pork is OK"); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week3/command/OrderPorkCommand.java b/students/977996067/src/main/java/com/coderising/dp/week3/command/OrderPorkCommand.java new file mode 100644 index 0000000000..aa2b93ad5a --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week3/command/OrderPorkCommand.java @@ -0,0 +1,14 @@ +package com.coderising.dp.week3.command; + +public class OrderPorkCommand extends Command { + + public OrderPorkCommand(Cook cook) { + super(cook); + } + + @Override + protected void cookFood() { + getCook().cookPork(); + } + +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week3/command/OrderSteakCommand.java b/students/977996067/src/main/java/com/coderising/dp/week3/command/OrderSteakCommand.java new file mode 100644 index 0000000000..91a4bc3118 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week3/command/OrderSteakCommand.java @@ -0,0 +1,13 @@ +package com.coderising.dp.week3.command; + +public class OrderSteakCommand extends Command { + + public OrderSteakCommand(Cook cook) { + super(cook); + } + + @Override + protected void cookFood() { + getCook().cookSteak(); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week3/command/Waiter.java b/students/977996067/src/main/java/com/coderising/dp/week3/command/Waiter.java new file mode 100644 index 0000000000..770ebedf9d --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week3/command/Waiter.java @@ -0,0 +1,19 @@ +package com.coderising.dp.week3.command; + +import java.util.ArrayDeque; +import java.util.Queue; + +public class Waiter { + + private Queue commandQueue = new ArrayDeque<>(); + + public synchronized void addOrder(Command command) { + commandQueue.add(command); + } + + public void sendOrders() { + while (!commandQueue.isEmpty()) { + commandQueue.poll().cookFood(); + } + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/AbstractLogger.java b/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/AbstractLogger.java new file mode 100644 index 0000000000..a1684f1dc5 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/AbstractLogger.java @@ -0,0 +1,28 @@ +package com.coderising.dp.week3.responsibility; + +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +public abstract class AbstractLogger implements Logger { + + private List loggers = new CopyOnWriteArrayList<>(); + + public AbstractLogger setNext(AbstractLogger nextLogger) { + if (!loggers.contains(this)) + loggers.add(this); + loggers.add(nextLogger); + return this; + } + + @Override + public void message(String message, int level) { + loggers + .stream() + .filter(logger -> logger.getLevel() <= level) + .forEach(logger -> logger.doMessage(message)); + } + + protected abstract int getLevel(); + + protected abstract void doMessage(String message); +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/EmailLogger.java b/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/EmailLogger.java new file mode 100644 index 0000000000..e6c4e4a7a6 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/EmailLogger.java @@ -0,0 +1,20 @@ +package com.coderising.dp.week3.responsibility; + +public class EmailLogger extends AbstractLogger { + + private int level; + + public EmailLogger(int level) { + this.level = level; + } + + @Override + public int getLevel() { + return level; + } + + @Override + protected void doMessage(String message) { + System.out.println("email to log : " + message); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/FileLogger.java b/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/FileLogger.java new file mode 100644 index 0000000000..966b8a7bd7 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/FileLogger.java @@ -0,0 +1,20 @@ +package com.coderising.dp.week3.responsibility; + +public class FileLogger extends AbstractLogger { + + private int level; + + public FileLogger(int level) { + this.level = level; + } + + @Override + protected int getLevel() { + return level; + } + + @Override + protected void doMessage(String message) { + System.out.println("log to file : " + message); + } +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/Logger.java b/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/Logger.java new file mode 100644 index 0000000000..fd88a5481b --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/Logger.java @@ -0,0 +1,10 @@ +package com.coderising.dp.week3.responsibility; + +public interface Logger { + + int DEBUG = 1; + int NOTICE = 2; + int ERR = 3; + + void message(String message, int level); +} diff --git a/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/StdoutLogger.java b/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/StdoutLogger.java new file mode 100644 index 0000000000..9d72e78616 --- /dev/null +++ b/students/977996067/src/main/java/com/coderising/dp/week3/responsibility/StdoutLogger.java @@ -0,0 +1,21 @@ +package com.coderising.dp.week3.responsibility; + +public class StdoutLogger extends AbstractLogger { + + private int level; + + public StdoutLogger(int level) { + this.level = level; + } + + @Override + protected int getLevel() { + return level; + } + + @Override + protected void doMessage(String message) { + System.out.println("stdout : " + message); + } + +} diff --git a/students/977996067/src/test/java/com/coderising/dp/week3/ChainTest.java b/students/977996067/src/test/java/com/coderising/dp/week3/ChainTest.java new file mode 100644 index 0000000000..0121489823 --- /dev/null +++ b/students/977996067/src/test/java/com/coderising/dp/week3/ChainTest.java @@ -0,0 +1,21 @@ +package com.coderising.dp.week3; + +import com.coderising.dp.week3.responsibility.EmailLogger; +import com.coderising.dp.week3.responsibility.FileLogger; +import com.coderising.dp.week3.responsibility.Logger; +import com.coderising.dp.week3.responsibility.StdoutLogger; +import org.junit.Test; + +public class ChainTest { + + @Test + public void testLoggerChain() { + Logger logger = new StdoutLogger(Logger.DEBUG) + .setNext(new EmailLogger(Logger.NOTICE)) + .setNext(new FileLogger(Logger.ERR)); + + logger.message("计入计算函数", Logger.DEBUG); + logger.message("第一步已完成", Logger.NOTICE); + logger.message("出现了一个致命的bug", Logger.ERR); + } +} diff --git a/students/977996067/src/test/java/com/coderising/dp/week3/CommandTest.java b/students/977996067/src/test/java/com/coderising/dp/week3/CommandTest.java new file mode 100644 index 0000000000..26d75e46bb --- /dev/null +++ b/students/977996067/src/test/java/com/coderising/dp/week3/CommandTest.java @@ -0,0 +1,18 @@ +package com.coderising.dp.week3; + +import com.coderising.dp.week3.command.*; +import org.junit.Test; + +public class CommandTest { + + @Test + public void testCook() { + Cook cook = new Cook(); + Waiter waiter = new Waiter(); + Command c1 = new OrderPorkCommand(cook); + Command c2 = new OrderSteakCommand(cook); + waiter.addOrder(c1); + waiter.addOrder(c2); + waiter.sendOrders(); + } +} From 1cc9400ba099ad03df32805163783ec16c9e990c Mon Sep 17 00:00:00 2001 From: lorcx <740707954@qq.com> Date: Sat, 12 Aug 2017 18:13:54 +0800 Subject: [PATCH 63/81] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dp/ChainOfResponsibility/EmailLogger.java | 43 +++++++++++++++++++ .../dp/ChainOfResponsibility/FileLogger.java | 42 ++++++++++++++++++ .../java/dp/ChainOfResponsibility/Logger.java | 15 +++++++ .../ChainOfResponsibility/StdoutLogger.java | 42 ++++++++++++++++++ .../src/main/java/dp/command/Command.java | 8 ++++ .../src/main/java/dp/command/Cook.java | 22 ++++++++++ .../java/dp/command/OrderPorkCommand.java | 18 ++++++++ .../java/dp/command/OrderSteakCommand.java | 18 ++++++++ .../src/main/java/dp/command/Waiter.java | 28 ++++++++++++ .../740707954/src/test/java/BridgeTest1.java | 20 --------- .../740707954/src/test/java/ChainTest.java | 31 +++++++++++++ .../740707954/src/test/java/CommandTest.java | 24 +++++++++++ 12 files changed, 291 insertions(+), 20 deletions(-) create mode 100644 students/740707954/src/main/java/dp/ChainOfResponsibility/EmailLogger.java create mode 100644 students/740707954/src/main/java/dp/ChainOfResponsibility/FileLogger.java create mode 100644 students/740707954/src/main/java/dp/ChainOfResponsibility/Logger.java create mode 100644 students/740707954/src/main/java/dp/ChainOfResponsibility/StdoutLogger.java create mode 100644 students/740707954/src/main/java/dp/command/Command.java create mode 100644 students/740707954/src/main/java/dp/command/Cook.java create mode 100644 students/740707954/src/main/java/dp/command/OrderPorkCommand.java create mode 100644 students/740707954/src/main/java/dp/command/OrderSteakCommand.java create mode 100644 students/740707954/src/main/java/dp/command/Waiter.java delete mode 100644 students/740707954/src/test/java/BridgeTest1.java create mode 100644 students/740707954/src/test/java/ChainTest.java create mode 100644 students/740707954/src/test/java/CommandTest.java diff --git a/students/740707954/src/main/java/dp/ChainOfResponsibility/EmailLogger.java b/students/740707954/src/main/java/dp/ChainOfResponsibility/EmailLogger.java new file mode 100644 index 0000000000..b6b5568063 --- /dev/null +++ b/students/740707954/src/main/java/dp/ChainOfResponsibility/EmailLogger.java @@ -0,0 +1,43 @@ +package dp.ChainOfResponsibility; + +/** + * Created by lx on 2017/8/12. + */ +public class EmailLogger implements Logger { + + private Logger nextLogger; + private int level; + + public EmailLogger(int level) { + this.level = level; + } + + /** + * 设置下一处理 + * @param logger + * @return + */ + @Override + public Logger setNext(Logger logger) { + nextLogger = logger; + return this; + } + + /** + * 输出日志信息 + * @param content + * @param level + */ + @Override + public void message(String content, int level) { + System.out.println("EmailLogger 处理...."); + + if (this.level >= level) { + System.out.println(content); + } + + if (null != nextLogger) { + nextLogger.message(content, level); + } + } +} diff --git a/students/740707954/src/main/java/dp/ChainOfResponsibility/FileLogger.java b/students/740707954/src/main/java/dp/ChainOfResponsibility/FileLogger.java new file mode 100644 index 0000000000..1ea9963cc0 --- /dev/null +++ b/students/740707954/src/main/java/dp/ChainOfResponsibility/FileLogger.java @@ -0,0 +1,42 @@ +package dp.ChainOfResponsibility; + +/** + * Created by lx on 2017/8/12. + */ +public class FileLogger implements Logger { + private Logger nextLogger; + private int level; + + public FileLogger(int level) { + this.level = level; + } + + /** + * 设置下一处理 + * @param logger + * @return + */ + @Override + public Logger setNext(Logger logger) { + nextLogger = logger; + return this; + } + + /** + * 输出日志信息 + * @param content + * @param level + */ + @Override + public void message(String content, int level) { + System.out.println("FileLogger 处理...."); + + if (this.level >= level) { + System.out.println(content); + } + + if (null != nextLogger) { + nextLogger.message(content, level); + } + } +} diff --git a/students/740707954/src/main/java/dp/ChainOfResponsibility/Logger.java b/students/740707954/src/main/java/dp/ChainOfResponsibility/Logger.java new file mode 100644 index 0000000000..23a3d39b31 --- /dev/null +++ b/students/740707954/src/main/java/dp/ChainOfResponsibility/Logger.java @@ -0,0 +1,15 @@ +package dp.ChainOfResponsibility; + +/** + * Created by lx on 2017/8/12. + */ +public interface Logger { + + public static final int DEBUG = 3; + public static final int NOTICE = 2; + public static final int ERR = 1; + + Logger setNext(Logger logger); + + void message(String content, int level); +} diff --git a/students/740707954/src/main/java/dp/ChainOfResponsibility/StdoutLogger.java b/students/740707954/src/main/java/dp/ChainOfResponsibility/StdoutLogger.java new file mode 100644 index 0000000000..b6c28e9d42 --- /dev/null +++ b/students/740707954/src/main/java/dp/ChainOfResponsibility/StdoutLogger.java @@ -0,0 +1,42 @@ +package dp.ChainOfResponsibility; + +/** + * Created by lx on 2017/8/12. + */ +public class StdoutLogger implements Logger { + private Logger nextLogger; + private int level; + + public StdoutLogger(int level) { + this.level = level; + } + + /** + * 设置下一处理 + * @param logger + * @return + */ + @Override + public Logger setNext(Logger logger) { + nextLogger = logger; + return this; + } + + /** + * 输出日志信息 + * @param content + * @param level + */ + @Override + public void message(String content, int level) { + System.out.println("StdoutLogger 处理...."); + + if (this.level >= level) { + System.out.println(content); + } + + if (null != nextLogger) { + nextLogger.message(content, level); + } + } +} diff --git a/students/740707954/src/main/java/dp/command/Command.java b/students/740707954/src/main/java/dp/command/Command.java new file mode 100644 index 0000000000..70a987aa3d --- /dev/null +++ b/students/740707954/src/main/java/dp/command/Command.java @@ -0,0 +1,8 @@ +package dp.command; + +/** + * Created by lx on 2017/8/12. + */ +public interface Command { + void excute(); +} diff --git a/students/740707954/src/main/java/dp/command/Cook.java b/students/740707954/src/main/java/dp/command/Cook.java new file mode 100644 index 0000000000..7125986f8c --- /dev/null +++ b/students/740707954/src/main/java/dp/command/Cook.java @@ -0,0 +1,22 @@ +package dp.command; + +/** + * 厨师 + * Created by lx on 2017/8/12. + */ +public class Cook { + + /** + * 做牛排 + */ + void cookSteak() { + System.out.println("Steak is ok"); + } + + /** + * 做猪排 + */ + void cookPork() { + System.out.println("Pork is ok"); + } +} diff --git a/students/740707954/src/main/java/dp/command/OrderPorkCommand.java b/students/740707954/src/main/java/dp/command/OrderPorkCommand.java new file mode 100644 index 0000000000..8f7f3713e7 --- /dev/null +++ b/students/740707954/src/main/java/dp/command/OrderPorkCommand.java @@ -0,0 +1,18 @@ +package dp.command; + +/** + * Created by lx on 2017/8/12. + */ +public class OrderPorkCommand implements Command { + + private Cook cook; + + public OrderPorkCommand(Cook cook) { + this.cook = cook; + } + + @Override + public void excute() { + cook.cookPork(); + } +} diff --git a/students/740707954/src/main/java/dp/command/OrderSteakCommand.java b/students/740707954/src/main/java/dp/command/OrderSteakCommand.java new file mode 100644 index 0000000000..9481545b24 --- /dev/null +++ b/students/740707954/src/main/java/dp/command/OrderSteakCommand.java @@ -0,0 +1,18 @@ +package dp.command; + +/** + * Created by lx on 2017/8/12. + */ +public class OrderSteakCommand implements Command { + + private Cook cook; + + public OrderSteakCommand(Cook cook) { + this.cook = cook; + } + + @Override + public void excute() { + cook.cookSteak(); + } +} diff --git a/students/740707954/src/main/java/dp/command/Waiter.java b/students/740707954/src/main/java/dp/command/Waiter.java new file mode 100644 index 0000000000..66690c157f --- /dev/null +++ b/students/740707954/src/main/java/dp/command/Waiter.java @@ -0,0 +1,28 @@ +package dp.command; + +import java.util.ArrayList; +import java.util.List; + +/** + * 店小二 + * Created by lx on 2017/8/12. + */ +public class Waiter { + + private List commands = new ArrayList<>(); + + /** + * 发菜单 + */ + public void sendOrders() { + commands.forEach((Command c) -> c.excute()); + } + + /** + * 添加订单 + * @param command1 + */ + public void addOrder(Command command1) { + commands.add(command1); + } +} diff --git a/students/740707954/src/test/java/BridgeTest1.java b/students/740707954/src/test/java/BridgeTest1.java deleted file mode 100644 index bd09cdf76a..0000000000 --- a/students/740707954/src/test/java/BridgeTest1.java +++ /dev/null @@ -1,20 +0,0 @@ -import dp.bridge.v1.*; -import org.junit.Test; - -/** - * Created by lx on 2017/7/29. - */ -public class BridgeTest1 { - - @Test - public void testBridge() { -// Shape shape1 = new Circle(new DrawingGL1()); -// Shape shape2 = new Retangle(new DrawingGL1()); -// Shape shape3 = new Circle(new DrawingGL2()); -// Shape shape4 = new Retangle(new DrawingGL2()); -// shape1.shape(); -// shape2.shape(); -// shape3.shape(); -// shape4.shape(); - } -} diff --git a/students/740707954/src/test/java/ChainTest.java b/students/740707954/src/test/java/ChainTest.java new file mode 100644 index 0000000000..a9c676bd90 --- /dev/null +++ b/students/740707954/src/test/java/ChainTest.java @@ -0,0 +1,31 @@ +import dp.ChainOfResponsibility.EmailLogger; +import dp.ChainOfResponsibility.FileLogger; +import dp.ChainOfResponsibility.Logger; +import dp.ChainOfResponsibility.StdoutLogger; +import org.junit.Test; + +/** + * 责任链测试 + * Created by lx on 2017/8/12. + */ +public class ChainTest { + private static Logger l = new StdoutLogger(Logger.DEBUG).setNext(new EmailLogger(Logger.NOTICE).setNext(new FileLogger(Logger.ERR))); + + @Test + public void testDebug() { + // StdoutLooger处理 + l.message("进入计算函数", Logger.DEBUG); + } + + @Test + public void testNotic() { + // StdoutLogger和EmailLogger处理 + l.message("第一步已经完成", Logger.NOTICE); + } + + @Test + public void testErr() { + // 三个都处理 + l.message("一个致命的错误发生了", Logger.ERR); + } +} diff --git a/students/740707954/src/test/java/CommandTest.java b/students/740707954/src/test/java/CommandTest.java new file mode 100644 index 0000000000..9184b55bc9 --- /dev/null +++ b/students/740707954/src/test/java/CommandTest.java @@ -0,0 +1,24 @@ +import dp.command.*; +import org.junit.Test; + +/** + * Created by lx on 2017/8/12. + */ +public class CommandTest { + + @Test + public void testCommand() { + // 创建厨师 + Cook cook = new Cook(); + + // 创建店小二 + Waiter waiter = new Waiter(); + + Command command1 = new OrderSteakCommand(cook); + Command command2 = new OrderPorkCommand(cook); + + waiter.addOrder(command1); + waiter.addOrder(command2); + waiter.sendOrders(); + } +} From 7cdd0cf50429357ac851f4bdfedb5f37be67017d Mon Sep 17 00:00:00 2001 From: akinaru-lu Date: Sun, 13 Aug 2017 19:58:30 +0900 Subject: [PATCH 64/81] assignment 0806 --- .../com/coderising/dp/command/Command.java | 11 ++++++++ .../coderising/dp/command/CommandTest.java | 22 ++++++++++++++++ .../java/com/coderising/dp/command/Cook.java | 17 ++++++++++++ .../dp/command/OrderPorkCommand.java | 19 ++++++++++++++ .../dp/command/OrderSteakCommand.java | 19 ++++++++++++++ .../com/coderising/dp/command/Waiter.java | 24 +++++++++++++++++ .../dp/interpreter/EmailLogger.java | 24 +++++++++++++++++ .../coderising/dp/interpreter/FileLogger.java | 24 +++++++++++++++++ .../com/coderising/dp/interpreter/Logger.java | 22 ++++++++++++++++ .../coderising/dp/interpreter/LoggerTest.java | 19 ++++++++++++++ .../dp/interpreter/StdoutLogger.java | 26 +++++++++++++++++++ 11 files changed, 227 insertions(+) create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Command.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/CommandTest.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Cook.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/OrderPorkCommand.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/OrderSteakCommand.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Waiter.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/EmailLogger.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/FileLogger.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/Logger.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/LoggerTest.java create mode 100644 students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/StdoutLogger.java diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Command.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Command.java new file mode 100644 index 0000000000..dd04cf6efe --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Command.java @@ -0,0 +1,11 @@ +package command; + +/** + * Created by Lu on 2017/08/13. + * @author Lu Mingming + */ +public interface Command { + + void execute(); + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/CommandTest.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/CommandTest.java new file mode 100644 index 0000000000..28f5319e3b --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/CommandTest.java @@ -0,0 +1,22 @@ +package command; + +/** + * Created by Lu on 2017/08/13. + * @author Lu Mingming + */ +public class CommandTest { + + public static void main(String[] args) { + Cook cook = new Cook(); + Waiter waiter = new Waiter(); + + Command command1 = new OrderSteakCommand(cook); + Command command2 = new OrderPorkCommand(cook); + + waiter.addOrder(command1); + waiter.addOrder(command2); + + waiter.sendOrders(); + } + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Cook.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Cook.java new file mode 100644 index 0000000000..bf6b47b77b --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Cook.java @@ -0,0 +1,17 @@ +package command; + +/** + * Created by Lu on 2017/08/13. + * @author Lu Mingming + */ +public class Cook { + + public void cookSteak() { + System.out.println("Steak is ok"); + } + + public void cookPork() { + System.out.println("Pork is ok"); + } + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/OrderPorkCommand.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/OrderPorkCommand.java new file mode 100644 index 0000000000..771588e093 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/OrderPorkCommand.java @@ -0,0 +1,19 @@ +package command; + +/** + * Created by Lu on 2017/08/13. + * @author Lu Mingming + */ +public class OrderPorkCommand implements Command { + + private Cook cook; + + public OrderPorkCommand(Cook cook) { + this.cook = cook; + } + + @Override + public void execute() { + cook.cookPork(); + } +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/OrderSteakCommand.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/OrderSteakCommand.java new file mode 100644 index 0000000000..99c399d284 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/OrderSteakCommand.java @@ -0,0 +1,19 @@ +package command; + +/** + * Created by Lu on 2017/08/13. + * @author Lu Mingming + */ +public class OrderSteakCommand implements Command { + + private Cook cook; + + public OrderSteakCommand(Cook cook) { + this.cook = cook; + } + + @Override + public void execute() { + cook.cookSteak(); + } +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Waiter.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Waiter.java new file mode 100644 index 0000000000..96cf2bcd38 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/command/Waiter.java @@ -0,0 +1,24 @@ +package command; + +import java.util.LinkedList; +import java.util.Queue; + +/** + * Created by Lu on 2017/08/13. + * @author Lu Mingming + */ +public class Waiter { + + Queue commands = new LinkedList<>(); + + public void addOrder(Command command) { + commands.add(command); + } + + public void sendOrders() { + while (!commands.isEmpty()) { + commands.poll().execute(); + } + } + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/EmailLogger.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/EmailLogger.java new file mode 100644 index 0000000000..7646017b72 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/EmailLogger.java @@ -0,0 +1,24 @@ +package interpreter; + +/** + * Created by Lu on 2017/08/13. + * @author Lu Mingming + */ +public class EmailLogger extends Logger { + + public EmailLogger(int mode) { + this.mode = mode; + } + + @Override + public void message(String msg, int mode) { + msg = "EmailLogger#" + msg; + if (mode == this.mode) { + System.out.println(msg); + return; + } + if (nextLogger != null) { + nextLogger.message(msg, mode); + } + } +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/FileLogger.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/FileLogger.java new file mode 100644 index 0000000000..7e6e09cc2d --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/FileLogger.java @@ -0,0 +1,24 @@ +package interpreter; + +/** + * Created by Lu on 2017/08/13. + * @author Lu Mingming + */ +public class FileLogger extends Logger { + + public FileLogger(int mode) { + this.mode = mode; + } + + @Override + public void message(String msg, int mode) { + msg = "FileLogger#" + msg; + if (mode == this.mode) { + System.out.println(msg); + return; + } + if (nextLogger != null) { + nextLogger.message(msg, mode); + } + } +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/Logger.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/Logger.java new file mode 100644 index 0000000000..347a5e6c5d --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/Logger.java @@ -0,0 +1,22 @@ +package interpreter; + +/** + * Created by Lu on 2017/08/13. + * @author Lu Mingming + */ +public abstract class Logger { + + public static final int DEBUG = 1; + public static final int NOTICE = 2; + public static final int ERR = 3; + + protected int mode; + protected Logger nextLogger; + + public abstract void message(String msg, int mode); + + public Logger setNext(Logger logger) { + nextLogger = logger; + return this; + } +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/LoggerTest.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/LoggerTest.java new file mode 100644 index 0000000000..fd2aa0a1f4 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/LoggerTest.java @@ -0,0 +1,19 @@ +package interpreter; + +/** + * Created by Lu on 2017/08/13. + * @author Lu Mingming + */ +public class LoggerTest { + + public static void main(String[] args) { + Logger logger = new StdoutLogger(Logger.DEBUG).setNext( + new EmailLogger(Logger.NOTICE).setNext( + new FileLogger(Logger.ERR))); + + logger.message("进入计算函数", Logger.DEBUG); + logger.message("第一步已经完成", Logger.NOTICE); + logger.message("一个致命的错误发成了", Logger.ERR); + } + +} diff --git a/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/StdoutLogger.java b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/StdoutLogger.java new file mode 100644 index 0000000000..99661de1e4 --- /dev/null +++ b/students/729770920/ood/ood-assignment/src/main/java/com/coderising/dp/interpreter/StdoutLogger.java @@ -0,0 +1,26 @@ +package interpreter; + +/** + * Created by Lu on 2017/08/13. + * @author Lu Mingming + */ +public class StdoutLogger extends Logger { + + public StdoutLogger(int mode) { + this.mode = mode; + } + + @Override + public void message(String msg, int mode) { + msg = "StdoutLogger#" + msg; + if (mode == this.mode) { + System.out.println(msg); + return; + } + if (nextLogger != null) { + nextLogger.message(msg, mode); + } + } + + +} From b8fd9344d95d9386c18f6a3fd46dadb0120b1e71 Mon Sep 17 00:00:00 2001 From: onlyliuxin <14703250@qq.com> Date: Sun, 13 Aug 2017 21:57:17 +0800 Subject: [PATCH 65/81] lite-junit v1 --- .../main/java/org/litejunit/v1/Assert.java | 225 ++++++++++++++++++ .../litejunit/v1/AssertionFailedError.java | 13 + .../java/org/litejunit/v1/Calculator.java | 22 ++ .../java/org/litejunit/v1/CalculatorTest.java | 65 +++++ .../src/main/java/org/litejunit/v1/Test.java | 6 + .../main/java/org/litejunit/v1/TestCase.java | 63 +++++ .../java/org/litejunit/v1/TestFailure.java | 39 +++ .../java/org/litejunit/v1/TestResult.java | 95 ++++++++ .../main/java/org/litejunit/v1/TestSuite.java | 130 ++++++++++ 9 files changed, 658 insertions(+) create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Assert.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/AssertionFailedError.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Calculator.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/CalculatorTest.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Test.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestCase.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestFailure.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestResult.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestSuite.java diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Assert.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Assert.java new file mode 100644 index 0000000000..07a3c1a22b --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Assert.java @@ -0,0 +1,225 @@ +package org.litejunit.v1; + +/** + * A set of assert methods. + */ + +public class Assert { + /** + * Protect constructor since it is a static only class + */ + protected Assert() { + } + + /** + * Asserts that a condition is true. If it isn't it throws + * an AssertionFailedError with the given message. + */ + static public void assertTrue(String message, boolean condition) { + if (!condition) + fail(message); + } + /** + * Asserts that a condition is true. If it isn't it throws + * an AssertionFailedError. + */ + static public void assertTrue(boolean condition) { + assertTrue(null, condition); + } + /** + * Fails a test with the given message. + */ + static public void fail(String message) { + throw new AssertionFailedError(message); + } + /** + * Fails a test with no message. + */ + static public void fail() { + fail(null); + } + /** + * Asserts that two objects are equal. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertEquals(String message, Object expected, Object actual) { + if (expected == null && actual == null) + return; + if (expected != null && expected.equals(actual)) + return; + failNotEquals(message, expected, actual); + } + /** + * Asserts that two objects are equal. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertEquals(Object expected, Object actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two doubles are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(String message, double expected, double actual, double delta) { + // handle infinity specially since subtracting to infinite values gives NaN and the + // the following test fails + if (Double.isInfinite(expected)) { + if (!(expected == actual)) + failNotEquals(message, new Double(expected), new Double(actual)); + } else if (!(Math.abs(expected-actual) <= delta)) // Because comparison with NaN always returns false + failNotEquals(message, new Double(expected), new Double(actual)); + } + /** + * Asserts that two doubles are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(double expected, double actual, double delta) { + assertEquals(null, expected, actual, delta); + } + /** + * Asserts that two floats are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(String message, float expected, float actual, float delta) { + // handle infinity specially since subtracting to infinite values gives NaN and the + // the following test fails + if (Float.isInfinite(expected)) { + if (!(expected == actual)) + failNotEquals(message, new Float(expected), new Float(actual)); + } else if (!(Math.abs(expected-actual) <= delta)) + failNotEquals(message, new Float(expected), new Float(actual)); + } + /** + * Asserts that two floats are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(float expected, float actual, float delta) { + assertEquals(null, expected, actual, delta); + } + /** + * Asserts that two longs are equal. + */ + static public void assertEquals(String message, long expected, long actual) { + assertEquals(message, new Long(expected), new Long(actual)); + } + /** + * Asserts that two longs are equal. + */ + static public void assertEquals(long expected, long actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two booleans are equal. + */ + static public void assertEquals(String message, boolean expected, boolean actual) { + assertEquals(message, new Boolean(expected), new Boolean(actual)); + } + /** + * Asserts that two booleans are equal. + */ + static public void assertEquals(boolean expected, boolean actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two bytes are equal. + */ + static public void assertEquals(String message, byte expected, byte actual) { + assertEquals(message, new Byte(expected), new Byte(actual)); + } + /** + * Asserts that two bytes are equal. + */ + static public void assertEquals(byte expected, byte actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two chars are equal. + */ + static public void assertEquals(String message, char expected, char actual) { + assertEquals(message, new Character(expected), new Character(actual)); + } + /** + * Asserts that two chars are equal. + */ + static public void assertEquals(char expected, char actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two shorts are equal. + */ + static public void assertEquals(String message, short expected, short actual) { + assertEquals(message, new Short(expected), new Short(actual)); + } + /** + * Asserts that two shorts are equal. + */ + static public void assertEquals(short expected, short actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two ints are equal. + */ + static public void assertEquals(String message, int expected, int actual) { + assertEquals(message, new Integer(expected), new Integer(actual)); + } + /** + * Asserts that two ints are equal. + */ + static public void assertEquals(int expected, int actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that an object isn't null. + */ + static public void assertNotNull(Object object) { + assertNotNull(null, object); + } + /** + * Asserts that an object isn't null. + */ + static public void assertNotNull(String message, Object object) { + assertTrue(message, object != null); + } + /** + * Asserts that an object is null. + */ + static public void assertNull(Object object) { + assertNull(null, object); + } + /** + * Asserts that an object is null. + */ + static public void assertNull(String message, Object object) { + assertTrue(message, object == null); + } + /** + * Asserts that two objects refer to the same object. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertSame(String message, Object expected, Object actual) { + if (expected == actual) + return; + failNotSame(message, expected, actual); + } + /** + * Asserts that two objects refer to the same object. If they are not + * the same an AssertionFailedError is thrown. + */ + static public void assertSame(Object expected, Object actual) { + assertSame(null, expected, actual); + } + + static private void failNotEquals(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message+" "; + fail(formatted+"expected:<"+expected+"> but was:<"+actual+">"); + } + + static private void failNotSame(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message+" "; + fail(formatted+"expected same"); + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/AssertionFailedError.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/AssertionFailedError.java new file mode 100644 index 0000000000..05e786ea47 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/AssertionFailedError.java @@ -0,0 +1,13 @@ +package org.litejunit.v1; + +/** + * Thrown when an assertion failed. + */ +public class AssertionFailedError extends Error { + + public AssertionFailedError () { + } + public AssertionFailedError (String message) { + super (message); + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Calculator.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Calculator.java new file mode 100644 index 0000000000..f1245ff3a6 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Calculator.java @@ -0,0 +1,22 @@ +package org.litejunit.v1; + +public class Calculator { + + private int result = 0; + public void add(int x){ + result += x; + } + public void subtract(int x){ + result -=x; + } + + public int getResult(){ + return this.result; + } + public static void main(String[] args){ + Calculator calculator = new Calculator(); + calculator.add(10); + calculator.subtract(5); + System.out.println(calculator.getResult()); + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/CalculatorTest.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/CalculatorTest.java new file mode 100644 index 0000000000..3460528043 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/CalculatorTest.java @@ -0,0 +1,65 @@ +package org.litejunit.v1; + + +public class CalculatorTest extends TestCase { + public CalculatorTest(String name) { + super(name); + + } + Calculator calculator =null; + public void setUp(){ + calculator = new Calculator(); + } + public void tearDown(){ + calculator = null; + } + public void testAdd(){ + + calculator.add(10); + assertEquals(10,calculator.getResult()); + } + public void testSubtract(){ + calculator.add(10); + calculator.subtract(5); + assertEquals(4,calculator.getResult()); + } + + public static void main(String[] args){ + TestSuite ts = new TestSuite(CalculatorTest.class); + TestResult tr = new TestResult(); + ts.run(tr); + System.out.println(tr.wasSuccessful()); + for(TestFailure failure : tr.failures){ + System.err.println(failure); + } + + /*{ + TestCase tc1 = new CalculatorTest("testAdd"){ + protected void runTest() { + testAdd(); + } + }; + + TestCase tc2 = new CalculatorTest("testSubtract"){ + protected void runTest() { + testSubtract(); + } + }; + tc1.run(); + tc2.run(); + } + + + TestSuite ts = new TestSuite(); + ts.addTest(new CalculatorTest("testAdd")); + ts.addTest(new CalculatorTest("testSubtract")); + + + { + TestCase tc1 = new CalculatorTest("test1"); + TestCase tc2 = new CalculatorTest("test2"); + tc1.run(); + tc2.run(); + }*/ + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Test.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Test.java new file mode 100644 index 0000000000..3d870cf637 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/Test.java @@ -0,0 +1,6 @@ +package org.litejunit.v1; + +public interface Test { + public abstract int countTestCases(); + public void run(TestResult tr); +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestCase.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestCase.java new file mode 100644 index 0000000000..d9cebd263b --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestCase.java @@ -0,0 +1,63 @@ +package org.litejunit.v1; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + + + +public abstract class TestCase extends Assert implements Test { + private String name; + + + public TestCase(String name) { + this.name = name; + } + + public int countTestCases() { + return 1; + } + + protected void runTest() throws Throwable{ + Method runMethod= null; + try { + runMethod= getClass().getMethod(name, null); + } catch (NoSuchMethodException e) { + fail("Method \""+name+"\" not found"); + } + if (!Modifier.isPublic(runMethod.getModifiers())) { + fail("Method \""+name+"\" should be public"); + } + + try { + runMethod.invoke(this, new Class[0]); + } + catch (InvocationTargetException e) { + e.fillInStackTrace(); + throw e.getTargetException(); + } + catch (IllegalAccessException e) { + e.fillInStackTrace(); + throw e; + } + } + + protected void setUp() { + } + + protected void tearDown() { + } + + public void run(TestResult tr) { + tr.run(this); + } + public void doRun() throws Throwable{ + setUp(); + try{ + runTest(); + } + finally{ + tearDown(); + } + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestFailure.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestFailure.java new file mode 100644 index 0000000000..1ac44256a4 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestFailure.java @@ -0,0 +1,39 @@ +package org.litejunit.v1; + +/** + * A TestFailure collects a failed test together with + * the caught exception. + * @see TestResult + */ +public class TestFailure { + protected Test failedTest; + protected Throwable thrownException; + + /** + * Constructs a TestFailure with the given test and exception. + */ + public TestFailure(Test failedTest, Throwable thrownException) { + this.failedTest= failedTest; + this.thrownException= thrownException; + } + /** + * Gets the failed test. + */ + public Test failedTest() { + return failedTest; + } + /** + * Gets the thrown exception. + */ + public Throwable thrownException() { + return thrownException; + } + /** + * Returns a short description of the failure. + */ + public String toString() { + StringBuffer buffer= new StringBuffer(); + buffer.append(failedTest+": "+thrownException.getMessage()); + return buffer.toString(); + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestResult.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestResult.java new file mode 100644 index 0000000000..a9e8c2b439 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestResult.java @@ -0,0 +1,95 @@ +package org.litejunit.v1; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + + + + +public class TestResult extends Object { + protected List failures; + protected List errors; + + protected int testCount; + private boolean stop; + + public TestResult() { + failures= new ArrayList<>(); + errors= new ArrayList<>(); + + testCount= 0; + stop= false; + } + + public void addError(Test test, Throwable t) { + errors.add(new TestFailure(test, t)); + } + + public void addFailure(Test test, AssertionFailedError t) { + failures.add(new TestFailure(test, t)); + } + + public void startTest(Test test) { + int count= test.countTestCases(); + testCount+= count; + } + public void endTest(Test test) { + } + + /** + * Runs a TestCase. + */ + protected void run(final TestCase test) { + startTest(test); + try { + test.doRun(); + } + catch (AssertionFailedError e) { + addFailure(test, e); + } + catch (Throwable e) { + addError(test, e); + } + + endTest(test); + } + /** + * Gets the number of run tests. + */ + public int runCount() { + return testCount; + } + + + public boolean shouldStop() { + return stop; + } + + public void stop() { + stop= true; + } + + public int errorCount() { + return errors.size(); + } + + public Iterator errors() { + return errors.iterator(); + } + + public int failureCount() { + return failures.size(); + } + + public Iterator failures() { + return failures.iterator(); + } + /** + * Returns whether the entire test was successful or not. + */ + public boolean wasSuccessful() { + return this.failureCount() == 0 && this.errorCount() == 0; + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestSuite.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestSuite.java new file mode 100644 index 0000000000..ad0af20ffd --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v1/TestSuite.java @@ -0,0 +1,130 @@ +package org.litejunit.v1; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; + +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + + + + +public class TestSuite extends Assert implements Test { + private List tests= new ArrayList<>(10); + private String name; + public TestSuite(){ + + } + public TestSuite(final Class theClass) { + this.name= theClass.getName(); + Constructor constructor= null; + try { + constructor= getConstructor(theClass); + } catch (NoSuchMethodException e) { + addTest(warning("Class "+theClass.getName()+" has no public constructor TestCase(String name)")); + return; + } + + if (!Modifier.isPublic(theClass.getModifiers())) { + addTest(warning("Class "+theClass.getName()+" is not public")); + return; + } + + Vector names= new Vector<>(); + Method[] methods= theClass.getDeclaredMethods(); + for (int i= 0; i < methods.length; i++) { + addTestMethod(methods[i], names, constructor); + } + + if (tests.size() == 0) + addTest(warning("No tests found in "+theClass.getName())); + } + + private Constructor getConstructor(Class theClass) throws NoSuchMethodException { + Class[] args= { String.class }; + return theClass.getConstructor(args); + } + private void addTestMethod(Method m, Vector names, Constructor constructor) { + String name= m.getName(); + if (names.contains(name)) + return; + if (isPublicTestMethod(m)) { + names.addElement(name); + + Object[] args= new Object[]{name}; + try { + addTest((Test)constructor.newInstance(args)); + } catch (InstantiationException e) { + addTest(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); + } catch (InvocationTargetException e) { + addTest(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); + } catch (IllegalAccessException e) { + addTest(warning("Cannot access test case: "+name+" ("+exceptionToString(e)+")")); + } + + } else { // almost a test method + if (isTestMethod(m)) + addTest(warning("Test method isn't public: "+m.getName())); + } + } + private boolean isPublicTestMethod(Method m) { + return isTestMethod(m) && Modifier.isPublic(m.getModifiers()); + } + private boolean isTestMethod(Method m) { + String name= m.getName(); + Class[] parameters= m.getParameterTypes(); + Class returnType= m.getReturnType(); + return parameters.length == 0 && name.startsWith("test") && returnType.equals(Void.TYPE); + } + public void addTest(Test test) { + tests.add(test); + } + + private Test warning(final String message) { + return new TestCase("warning") { + public void doRun() { + fail(message); + } + }; + } + private String exceptionToString(Throwable t) { + StringWriter stringWriter= new StringWriter(); + PrintWriter writer= new PrintWriter(stringWriter); + t.printStackTrace(writer); + return stringWriter.toString(); + + } + + + + @Override + public void run(TestResult result) { + for (Iterator e= tests(); e.hasNext(); ) { + if (result.shouldStop() ){ + break; + } + Test test= (Test)e.next(); + test.run(result); + } + + } + + public int countTestCases() { + int count= 0; + + for (Iterator e= tests(); e.hasNext(); ) { + Test test= e.next(); + count= count + test.countTestCases(); + } + return count; + } + public Iterator tests() { + return tests.iterator(); + } +} From 4b02dc56b32a7d0c979dbe43461f3ff8a5638890 Mon Sep 17 00:00:00 2001 From: yangzhm Date: Fri, 18 Aug 2017 08:20:44 +0800 Subject: [PATCH 66/81] add project of LiteJUnit --- students/495232796/OOD/LiteJUnit/pom.xml | 42 ++++++ .../java/com/coderising/litejunit/Assert.java | 28 ++++ .../litejunit/AssertionFailedError.java | 10 ++ .../com/coderising/litejunit/Calculator.java | 17 +++ .../coderising/litejunit/CalculatorTest.java | 39 ++++++ .../java/com/coderising/litejunit/Test.java | 6 + .../com/coderising/litejunit/TestCase.java | 71 ++++++++++ .../com/coderising/litejunit/TestFailure.java | 26 ++++ .../com/coderising/litejunit/TestResult.java | 61 +++++++++ .../com/coderising/litejunit/TestSuite.java | 128 ++++++++++++++++++ 10 files changed, 428 insertions(+) create mode 100644 students/495232796/OOD/LiteJUnit/pom.xml create mode 100644 students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Assert.java create mode 100644 students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/AssertionFailedError.java create mode 100644 students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Calculator.java create mode 100644 students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/CalculatorTest.java create mode 100644 students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Test.java create mode 100644 students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestCase.java create mode 100644 students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestFailure.java create mode 100644 students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestResult.java create mode 100644 students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestSuite.java diff --git a/students/495232796/OOD/LiteJUnit/pom.xml b/students/495232796/OOD/LiteJUnit/pom.xml new file mode 100644 index 0000000000..84bf4627e3 --- /dev/null +++ b/students/495232796/OOD/LiteJUnit/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + com.coderising + ood-assignment + 0.0.1-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + + + + jar + + ood-assignment + http://maven.apache.org + + + UTF-8 + + + + + + junit + junit + 4.12 + + + + + + aliyunmaven + http://maven.aliyun.com/nexus/content/groups/public/ + + + \ No newline at end of file diff --git a/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Assert.java b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Assert.java new file mode 100644 index 0000000000..c381fa242a --- /dev/null +++ b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Assert.java @@ -0,0 +1,28 @@ +package com.coderising.litejunit; + +public class Assert { + static public void assertEquals(int expected, int actual) { + assertEquals(null, new Integer(expected), new Integer(actual)); + } + + static public void assertEquals(String message, Object expected, Object actual) { + if (expected == null && actual == null) { + return ; + } + if (expected != null && expected.equals(actual)) { + return ; + } + failNotEquals(message, expected, actual); + } + + static public void fail(String message) { + throw new AssertionFailedError(message); + } + + static private void failNotEquals(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message+" "; + fail(formatted+"expected:<"+expected+"> but was:<"+actual+">"); + } +} diff --git a/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/AssertionFailedError.java b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/AssertionFailedError.java new file mode 100644 index 0000000000..928d0713d9 --- /dev/null +++ b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/AssertionFailedError.java @@ -0,0 +1,10 @@ +package com.coderising.litejunit; + +public class AssertionFailedError extends Error { + + public AssertionFailedError () { + } + public AssertionFailedError (String message) { + super (message); + } +} diff --git a/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Calculator.java b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Calculator.java new file mode 100644 index 0000000000..b76d82c9d2 --- /dev/null +++ b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Calculator.java @@ -0,0 +1,17 @@ +package com.coderising.litejunit; + +public class Calculator { + private int result = 0; + + public void add(int num) { + result += num; + } + + public void substract(int num) { + result -= num; + } + + public int getResult() { + return result; + } +} diff --git a/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/CalculatorTest.java b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/CalculatorTest.java new file mode 100644 index 0000000000..8e31d51766 --- /dev/null +++ b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/CalculatorTest.java @@ -0,0 +1,39 @@ +package com.coderising.litejunit; + +public class CalculatorTest extends TestCase{ + private Calculator cal = null; + + public CalculatorTest(String name) { + super(name); + // TODO Auto-generated constructor stub + } + + public void setUp() { + cal = new Calculator(); + } + + public void tearDown() { + cal = null; + } + + public void testAdd() { + cal.add(10); + Assert.assertEquals(cal.getResult(), 10); + } + + public void testSubstract() { + cal.add(10); + cal.substract(5); + assertEquals(cal.getResult(), 50); + } + + public static void main(String[] args){ + TestSuite ts = new TestSuite(CalculatorTest.class); + TestResult tr = new TestResult(); + ts.run(tr); + System.out.println(tr.wasSuccessful()); + for(TestFailure failure : tr.failures){ + System.err.println(failure); + } + } +} diff --git a/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Test.java b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Test.java new file mode 100644 index 0000000000..ffbc4b336f --- /dev/null +++ b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/Test.java @@ -0,0 +1,6 @@ +package com.coderising.litejunit; + +public interface Test { + public abstract int countTestCases(); + public void run(TestResult tr); +} diff --git a/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestCase.java b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestCase.java new file mode 100644 index 0000000000..2961924618 --- /dev/null +++ b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestCase.java @@ -0,0 +1,71 @@ +package com.coderising.litejunit; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +public class TestCase extends Assert implements Test{ + private String name; + + public TestCase(String name) { + this.name = name; + } + + @Override + public int countTestCases() { + return 1; + } + + @Override + public void run(TestResult tr) { + tr.run(this); + } + + public void doRun() throws Throwable { + setUp(); + + try { + runTest(); + } finally { + tearDown(); + } + + } + + protected void runTest() throws Throwable { + Method method = null; + + try { + method = getClass().getMethod(name, null); + } catch (NoSuchMethodException e) { + fail("method " + name + "is not found."); + } + + if (!Modifier.isPublic(method.getModifiers())) { + fail("method " + name + " is not public."); + } + + try { + method.invoke(this, new Class[0]); + } catch (IllegalArgumentException e) { + e.fillInStackTrace(); + throw e; + } catch (InvocationTargetException e) { + e.fillInStackTrace(); + throw e.getTargetException(); + } catch (IllegalAccessException e) { + e.fillInStackTrace(); + throw e; + } + + } + + protected void setUp() { + + } + + protected void tearDown() { + + } + +} diff --git a/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestFailure.java b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestFailure.java new file mode 100644 index 0000000000..340a11a2dc --- /dev/null +++ b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestFailure.java @@ -0,0 +1,26 @@ +package com.coderising.litejunit; + +public class TestFailure { + protected Test failedTest; + protected Throwable thrownException; + + public TestFailure(Test failedTest, Throwable thrownException) { + this.failedTest= failedTest; + this.thrownException= thrownException; + } + + + public Test failedTest() { + return failedTest; + } + + public Throwable thrownException() { + return thrownException; + } + + public String toString() { + StringBuffer buffer= new StringBuffer(); + buffer.append(failedTest+": "+thrownException.getMessage()); + return buffer.toString(); + } +} diff --git a/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestResult.java b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestResult.java new file mode 100644 index 0000000000..41c9887857 --- /dev/null +++ b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestResult.java @@ -0,0 +1,61 @@ +package com.coderising.litejunit; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class TestResult { + private boolean stop; + protected List failures; + protected List errors; + protected int testCount; + + public TestResult() { + failures= new ArrayList<>(); + errors= new ArrayList<>(); + + testCount= 0; + stop= false; + } + public void startTest(Test test) { + int count= test.countTestCases(); + testCount+= count; + } + + public void endTest(Test test) { + } + + public void run(TestCase tc) { + startTest(tc); + + try { + tc.doRun(); + } catch (AssertionFailedError e) { + addFailure(tc, e); + } catch (Throwable e) { + addError(tc, e); + } + + endTest(tc); + } + + public boolean shouldStop() { + return this.stop; + } + + public void addError(Test test, Throwable t) { + errors.add(new TestFailure(test, t)); + } + + public void addFailure(Test test, AssertionFailedError t) { + failures.add(new TestFailure(test, t)); + } + + public Iterator failures() { + return failures.iterator(); + } + + public boolean wasSuccessful() { + return failures.size() == 0 && errors.size() == 0; + } +} diff --git a/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestSuite.java b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestSuite.java new file mode 100644 index 0000000000..60d8f855af --- /dev/null +++ b/students/495232796/OOD/LiteJUnit/src/main/java/com/coderising/litejunit/TestSuite.java @@ -0,0 +1,128 @@ +package com.coderising.litejunit; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.List; + +public class TestSuite implements Test{ + private List tests= new ArrayList<>(); + private String name; + public TestSuite(){ + + } + + public TestSuite(final Class tClass) { + this.name = tClass.getName(); + Constructor constructor = null; + try { + constructor = getConstructor(tClass); + } catch (NoSuchMethodException e) { + addTest(warning("Class " + name + " has no public constructor TestCase(String name).")); + return ; + } + + if (!Modifier.isPublic(tClass.getModifiers())) { + addTest(warning("Class " + name + " is not public.")); + return ; + } + + List names = new ArrayList<>(); + Method[] methods = tClass.getDeclaredMethods(); + for (Method m : methods) { + addTestMethod(m, names, constructor); + } + + if (tests.size() == 0) { + addTest(warning("No testcase in Class " + name)); + } + } + + private void addTestMethod(Method m, List names, Constructor constructor) { + String name = m.getName(); + if (names.contains(name)) { + return ; + } + + if (isPublicMethod(m)) { + names.add(name); + Object[] args = new Object[]{name}; + + try { + addTest((Test)constructor.newInstance(args)); + } catch (InstantiationException e) { + addTest(warning("Method " + name + " InstantiationException:" + exceptionToString(e))); + } catch (IllegalAccessException e) { + addTest(warning("Method " + name + " IllegalAccessException:" + exceptionToString(e))); + } catch (IllegalArgumentException e) { + addTest(warning("Method " + name + " IllegalArgumentException:" + exceptionToString(e))); + } catch (InvocationTargetException e) { + addTest(warning("Method " + name + " InvocationTargetException:" + exceptionToString(e))); + } + } else { + if (isTestMethod(m)) { + addTest(warning("Test method " + name + " is not public.")); + } + } + } + + private String exceptionToString(Throwable t) { + StringWriter stringWriter= new StringWriter(); + PrintWriter writer= new PrintWriter(stringWriter); + t.printStackTrace(writer); + return stringWriter.toString(); + + } + + private boolean isPublicMethod(Method m) { + return isTestMethod(m) && Modifier.isPublic(m.getModifiers()); + } + private boolean isTestMethod(Method m) { + String name = m.getName(); + Class[] parameters = m.getParameterTypes(); + Class retType = m.getReturnType(); + + return parameters.length == 0 && name.startsWith("test") && retType.equals(Void.TYPE); + } + + private Test warning(final String message) { + return new TestCase("warning") { + public void doRun() { + fail(message); + } + }; + } + + public void addTest(Test t) { + this.tests.add(t); + } + + private Constructor getConstructor(Class theClass) throws NoSuchMethodException { + Class[] args= { String.class }; + return theClass.getConstructor(args); + } + + @Override + public int countTestCases() { + int cnt = 0; + for (Test t : tests) { + cnt += t.countTestCases(); + } + return cnt; + } + + @Override + public void run(TestResult tr) { + for (Test t : tests) { + if (tr.shouldStop()) { + break; + } + t.run(tr);; + } + } + +} From c46ab2eb569c80d91bc6e80ffc624cfce1fb5905 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Sun, 20 Aug 2017 21:44:51 +0800 Subject: [PATCH 67/81] =?UTF-8?q?[Feature]=20=E5=88=98=E8=80=81=E5=B8=88?= =?UTF-8?q?=E7=9A=84junit-v1=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myood/litejunit/liuxiuv1/Assert.java | 225 ++++++++++++++++++ .../liuxiuv1/AssertionFailedError.java | 13 + .../myood/litejunit/liuxiuv1/Calculator.java | 22 ++ .../litejunit/liuxiuv1/CalculatorTest.java | 65 +++++ .../myood/litejunit/liuxiuv1/Test.java | 6 + .../myood/litejunit/liuxiuv1/TestCase.java | 63 +++++ .../myood/litejunit/liuxiuv1/TestFailure.java | 39 +++ .../myood/litejunit/liuxiuv1/TestResult.java | 92 +++++++ .../myood/litejunit/liuxiuv1/TestSuite.java | 130 ++++++++++ 9 files changed, 655 insertions(+) create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Assert.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/AssertionFailedError.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Calculator.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Test.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestFailure.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestResult.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestSuite.java diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Assert.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Assert.java new file mode 100644 index 0000000000..78281a81b5 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Assert.java @@ -0,0 +1,225 @@ +package com.coderising.myood.litejunit.liuxiuv1; + +/** + * A set of assert methods. + */ + +public class Assert { + /** + * Protect constructor since it is a static only class + */ + protected Assert() { + } + + /** + * Asserts that a condition is true. If it isn't it throws + * an AssertionFailedError with the given message. + */ + static public void assertTrue(String message, boolean condition) { + if (!condition) + fail(message); + } + /** + * Asserts that a condition is true. If it isn't it throws + * an AssertionFailedError. + */ + static public void assertTrue(boolean condition) { + assertTrue(null, condition); + } + /** + * Fails a test with the given message. + */ + static public void fail(String message) { + throw new AssertionFailedError(message); + } + /** + * Fails a test with no message. + */ + static public void fail() { + fail(null); + } + /** + * Asserts that two objects are equal. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertEquals(String message, Object expected, Object actual) { + if (expected == null && actual == null) + return; + if (expected != null && expected.equals(actual)) + return; + failNotEquals(message, expected, actual); + } + /** + * Asserts that two objects are equal. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertEquals(Object expected, Object actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two doubles are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(String message, double expected, double actual, double delta) { + // handle infinity specially since subtracting to infinite values gives NaN and the + // the following test fails + if (Double.isInfinite(expected)) { + if (!(expected == actual)) + failNotEquals(message, new Double(expected), new Double(actual)); + } else if (!(Math.abs(expected-actual) <= delta)) // Because comparison with NaN always returns false + failNotEquals(message, new Double(expected), new Double(actual)); + } + /** + * Asserts that two doubles are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(double expected, double actual, double delta) { + assertEquals(null, expected, actual, delta); + } + /** + * Asserts that two floats are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(String message, float expected, float actual, float delta) { + // handle infinity specially since subtracting to infinite values gives NaN and the + // the following test fails + if (Float.isInfinite(expected)) { + if (!(expected == actual)) + failNotEquals(message, new Float(expected), new Float(actual)); + } else if (!(Math.abs(expected-actual) <= delta)) + failNotEquals(message, new Float(expected), new Float(actual)); + } + /** + * Asserts that two floats are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(float expected, float actual, float delta) { + assertEquals(null, expected, actual, delta); + } + /** + * Asserts that two longs are equal. + */ + static public void assertEquals(String message, long expected, long actual) { + assertEquals(message, new Long(expected), new Long(actual)); + } + /** + * Asserts that two longs are equal. + */ + static public void assertEquals(long expected, long actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two booleans are equal. + */ + static public void assertEquals(String message, boolean expected, boolean actual) { + assertEquals(message, new Boolean(expected), new Boolean(actual)); + } + /** + * Asserts that two booleans are equal. + */ + static public void assertEquals(boolean expected, boolean actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two bytes are equal. + */ + static public void assertEquals(String message, byte expected, byte actual) { + assertEquals(message, new Byte(expected), new Byte(actual)); + } + /** + * Asserts that two bytes are equal. + */ + static public void assertEquals(byte expected, byte actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two chars are equal. + */ + static public void assertEquals(String message, char expected, char actual) { + assertEquals(message, new Character(expected), new Character(actual)); + } + /** + * Asserts that two chars are equal. + */ + static public void assertEquals(char expected, char actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two shorts are equal. + */ + static public void assertEquals(String message, short expected, short actual) { + assertEquals(message, new Short(expected), new Short(actual)); + } + /** + * Asserts that two shorts are equal. + */ + static public void assertEquals(short expected, short actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two ints are equal. + */ + static public void assertEquals(String message, int expected, int actual) { + assertEquals(message, new Integer(expected), new Integer(actual)); + } + /** + * Asserts that two ints are equal. + */ + static public void assertEquals(int expected, int actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that an object isn't null. + */ + static public void assertNotNull(Object object) { + assertNotNull(null, object); + } + /** + * Asserts that an object isn't null. + */ + static public void assertNotNull(String message, Object object) { + assertTrue(message, object != null); + } + /** + * Asserts that an object is null. + */ + static public void assertNull(Object object) { + assertNull(null, object); + } + /** + * Asserts that an object is null. + */ + static public void assertNull(String message, Object object) { + assertTrue(message, object == null); + } + /** + * Asserts that two objects refer to the same object. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertSame(String message, Object expected, Object actual) { + if (expected == actual) + return; + failNotSame(message, expected, actual); + } + /** + * Asserts that two objects refer to the same object. If they are not + * the same an AssertionFailedError is thrown. + */ + static public void assertSame(Object expected, Object actual) { + assertSame(null, expected, actual); + } + + static private void failNotEquals(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message+" "; + fail(formatted+"expected:<"+expected+"> but was:<"+actual+">"); + } + + static private void failNotSame(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message+" "; + fail(formatted+"expected same"); + } +} \ No newline at end of file diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/AssertionFailedError.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/AssertionFailedError.java new file mode 100644 index 0000000000..0c7916effe --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/AssertionFailedError.java @@ -0,0 +1,13 @@ +package com.coderising.myood.litejunit.liuxiuv1; + +/** + * Thrown when an assertion failed. + */ +public class AssertionFailedError extends Error { + + public AssertionFailedError () { + } + public AssertionFailedError (String message) { + super (message); + } +} \ No newline at end of file diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Calculator.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Calculator.java new file mode 100644 index 0000000000..93ace0bae5 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Calculator.java @@ -0,0 +1,22 @@ +package com.coderising.myood.litejunit.liuxiuv1; + +public class Calculator { + + private int result = 0; + public void add(int x){ + result += x; + } + public void subtract(int x){ + result -=x; + } + + public int getResult(){ + return this.result; + } + public static void main(String[] args){ + Calculator calculator = new Calculator(); + calculator.add(10); + calculator.subtract(5); + System.out.println(calculator.getResult()); + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java new file mode 100644 index 0000000000..4bb0a770d2 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java @@ -0,0 +1,65 @@ +package com.coderising.myood.litejunit.liuxiuv1; + + +public class CalculatorTest extends TestCase { + public CalculatorTest(String name) { + super(name); + + } + Calculator calculator =null; + public void setUp(){ + calculator = new Calculator(); + } + public void tearDown(){ + calculator = null; + } + public void testAdd(){ + + calculator.add(10); + assertEquals(10,calculator.getResult()); + } + public void testSubtract(){ + calculator.add(10); + calculator.subtract(5); + assertEquals(4,calculator.getResult()); + } + + public static void main(String[] args){ + TestSuite ts = new TestSuite(CalculatorTest.class); + TestResult tr = new TestResult(); + ts.run(tr); + System.out.println(tr.wasSuccessful()); + for(TestFailure failure : tr.failures){ + System.err.println(failure); + } + + /*{ + TestCase tc1 = new CalculatorTest("testAdd"){ + protected void runTest() { + testAdd(); + } + }; + + TestCase tc2 = new CalculatorTest("testSubtract"){ + protected void runTest() { + testSubtract(); + } + }; + tc1.run(); + tc2.run(); + } + + + TestSuite ts = new TestSuite(); + ts.addTest(new CalculatorTest("testAdd")); + ts.addTest(new CalculatorTest("testSubtract")); + + + { + TestCase tc1 = new CalculatorTest("test1"); + TestCase tc2 = new CalculatorTest("test2"); + tc1.run(); + tc2.run(); + }*/ + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Test.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Test.java new file mode 100644 index 0000000000..3f7142f6e8 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Test.java @@ -0,0 +1,6 @@ +package com.coderising.myood.litejunit.liuxiuv1; + +public interface Test { + public abstract int countTestCases(); + public void run(TestResult tr); +} diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java new file mode 100644 index 0000000000..4d226926c1 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java @@ -0,0 +1,63 @@ +package com.coderising.myood.litejunit.liuxiuv1; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + + + +public abstract class TestCase extends Assert implements Test { + private String name; + + + public TestCase(String name) { + this.name = name; + } + + public int countTestCases() { + return 1; + } + + protected void runTest() throws Throwable{ + Method runMethod= null; + try { + runMethod= getClass().getMethod(name, null); + } catch (NoSuchMethodException e) { + fail("Method \""+name+"\" not found"); + } + if (!Modifier.isPublic(runMethod.getModifiers())) { + fail("Method \""+name+"\" should be public"); + } + + try { + runMethod.invoke(this, new Class[0]); + } + catch (InvocationTargetException e) { + e.fillInStackTrace(); + throw e.getTargetException(); + } + catch (IllegalAccessException e) { + e.fillInStackTrace(); + throw e; + } + } + + protected void setUp() { + } + + protected void tearDown() { + } + + public void run(TestResult tr) { + tr.run(this); + } + public void doRun() throws Throwable{ + setUp(); + try{ + runTest(); + } + finally{ + tearDown(); + } + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestFailure.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestFailure.java new file mode 100644 index 0000000000..add19e6c30 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestFailure.java @@ -0,0 +1,39 @@ +package com.coderising.myood.litejunit.liuxiuv1; + +/** + * A TestFailure collects a failed test together with + * the caught exception. + * @see TestResult + */ +public class TestFailure { + protected Test failedTest; + protected Throwable thrownException; + + /** + * Constructs a TestFailure with the given test and exception. + */ + public TestFailure(Test failedTest, Throwable thrownException) { + this.failedTest= failedTest; + this.thrownException= thrownException; + } + /** + * Gets the failed test. + */ + public Test failedTest() { + return failedTest; + } + /** + * Gets the thrown exception. + */ + public Throwable thrownException() { + return thrownException; + } + /** + * Returns a short description of the failure. + */ + public String toString() { + StringBuffer buffer= new StringBuffer(); + buffer.append(failedTest+": "+thrownException.getMessage()); + return buffer.toString(); + } +} \ No newline at end of file diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestResult.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestResult.java new file mode 100644 index 0000000000..1ebe651c4e --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestResult.java @@ -0,0 +1,92 @@ +package com.coderising.myood.litejunit.liuxiuv1; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + + +public class TestResult extends Object { + protected List failures; + protected List errors; + + protected int testCount; + private boolean stop; + + public TestResult() { + failures= new ArrayList<>(); + errors= new ArrayList<>(); + + testCount= 0; + stop= false; + } + + public void addError(Test test, Throwable t) { + errors.add(new TestFailure(test, t)); + } + + public void addFailure(Test test, AssertionFailedError t) { + failures.add(new TestFailure(test, t)); + } + + public void startTest(Test test) { + int count= test.countTestCases(); + testCount+= count; + } + public void endTest(Test test) { + } + + /** + * Runs a TestCase. + */ + protected void run(final TestCase test) { + startTest(test); + try { + test.doRun(); + } + catch (AssertionFailedError e) { + addFailure(test, e); + } + catch (Throwable e) { + addError(test, e); + } + + endTest(test); + } + /** + * Gets the number of run tests. + */ + public int runCount() { + return testCount; + } + + + public boolean shouldStop() { + return stop; + } + + public void stop() { + stop= true; + } + + public int errorCount() { + return errors.size(); + } + + public Iterator errors() { + return errors.iterator(); + } + + public int failureCount() { + return failures.size(); + } + + public Iterator failures() { + return failures.iterator(); + } + /** + * Returns whether the entire test was successful or not. + */ + public boolean wasSuccessful() { + return this.failureCount() == 0 && this.errorCount() == 0; + } +} \ No newline at end of file diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestSuite.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestSuite.java new file mode 100644 index 0000000000..e50bc66d24 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestSuite.java @@ -0,0 +1,130 @@ +package com.coderising.myood.litejunit.liuxiuv1; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; + +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + + + + +public class TestSuite extends Assert implements Test { + private List tests= new ArrayList<>(10); + private String name; + public TestSuite(){ + + } + public TestSuite(final Class theClass) { + this.name= theClass.getName(); + Constructor constructor= null; + try { + constructor= getConstructor(theClass); + } catch (NoSuchMethodException e) { + addTest(warning("Class "+theClass.getName()+" has no public constructor TestCase(String name)")); + return; + } + + if (!Modifier.isPublic(theClass.getModifiers())) { + addTest(warning("Class "+theClass.getName()+" is not public")); + return; + } + + Vector names= new Vector<>(); + Method[] methods= theClass.getDeclaredMethods(); + for (int i= 0; i < methods.length; i++) { + addTestMethod(methods[i], names, constructor); + } + + if (tests.size() == 0) + addTest(warning("No tests found in "+theClass.getName())); + } + + private Constructor getConstructor(Class theClass) throws NoSuchMethodException { + Class[] args= { String.class }; + return theClass.getConstructor(args); + } + private void addTestMethod(Method m, Vector names, Constructor constructor) { + String name= m.getName(); + if (names.contains(name)) + return; + if (isPublicTestMethod(m)) { + names.addElement(name); + + Object[] args= new Object[]{name}; + try { + addTest((Test)constructor.newInstance(args)); + } catch (InstantiationException e) { + addTest(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); + } catch (InvocationTargetException e) { + addTest(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); + } catch (IllegalAccessException e) { + addTest(warning("Cannot access test case: "+name+" ("+exceptionToString(e)+")")); + } + + } else { // almost a test method + if (isTestMethod(m)) + addTest(warning("Test method isn't public: "+m.getName())); + } + } + private boolean isPublicTestMethod(Method m) { + return isTestMethod(m) && Modifier.isPublic(m.getModifiers()); + } + private boolean isTestMethod(Method m) { + String name= m.getName(); + Class[] parameters= m.getParameterTypes(); + Class returnType= m.getReturnType(); + return parameters.length == 0 && name.startsWith("test") && returnType.equals(Void.TYPE); + } + public void addTest(Test test) { + tests.add(test); + } + + private Test warning(final String message) { + return new TestCase("warning") { + public void doRun() { + fail(message); + } + }; + } + private String exceptionToString(Throwable t) { + StringWriter stringWriter= new StringWriter(); + PrintWriter writer= new PrintWriter(stringWriter); + t.printStackTrace(writer); + return stringWriter.toString(); + + } + + + + @Override + public void run(TestResult result) { + for (Iterator e= tests(); e.hasNext(); ) { + if (result.shouldStop() ){ + break; + } + Test test= (Test)e.next(); + test.run(result); + } + + } + + public int countTestCases() { + int count= 0; + + for (Iterator e= tests(); e.hasNext(); ) { + Test test= e.next(); + count= count + test.countTestCases(); + } + return count; + } + public Iterator tests() { + return tests.iterator(); + } +} From 2e666a7716b3ae728e7fbcc6c741731dc76dc05f Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Mon, 21 Aug 2017 00:13:20 +0800 Subject: [PATCH 68/81] [Fix] add comment in liuxin lite-junit-v1 --- .../litejunit/liuxiuv1/CalculatorTest.java | 22 +++++++++++++++---- .../myood/litejunit/liuxiuv1/Test.java | 4 ++-- .../myood/litejunit/liuxiuv1/TestCase.java | 2 +- .../myood/litejunit/liuxiuv1/TestResult.java | 4 ++-- .../myood/litejunit/liuxiuv1/TestSuite.java | 4 ++-- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java index 4bb0a770d2..892109781d 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java @@ -1,10 +1,12 @@ package com.coderising.myood.litejunit.liuxiuv1; -public class CalculatorTest extends TestCase { +import java.util.Iterator; + +public class CalculatorTest extends TestCase { public CalculatorTest(String name) { super(name); - + } Calculator calculator =null; public void setUp(){ @@ -23,6 +25,10 @@ public void testSubtract(){ calculator.subtract(5); assertEquals(4,calculator.getResult()); } + + private void testXX() { + + } public static void main(String[] args){ TestSuite ts = new TestSuite(CalculatorTest.class); @@ -32,8 +38,16 @@ public static void main(String[] args){ for(TestFailure failure : tr.failures){ System.err.println(failure); } - - /*{ + /* + Iterator iterator = tr.failures(); + while(iterator.hasNext()) { + System.err.println(iterator.next()); + } + */ +// TestSuite ts2 = new TestSuite(); +// ts2.addTest(ts); +// ts2.run(tr); + /*{ TestCase tc1 = new CalculatorTest("testAdd"){ protected void runTest() { testAdd(); diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Test.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Test.java index 3f7142f6e8..4de5a17edd 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Test.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Test.java @@ -1,6 +1,6 @@ package com.coderising.myood.litejunit.liuxiuv1; public interface Test { - public abstract int countTestCases(); - public void run(TestResult tr); + public abstract int countTestCases(); // command模式,一个测试用例是一个command + public void run(TestResult tr); // 分离测试用例和测试结果,收集参数模式 } diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java index 4d226926c1..a77e6cdbc3 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java @@ -9,7 +9,7 @@ public abstract class TestCase extends Assert implements Test { private String name; - + TestCase() {} public TestCase(String name) { this.name = name; } diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestResult.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestResult.java index 1ebe651c4e..6750c6e456 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestResult.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestResult.java @@ -6,8 +6,8 @@ public class TestResult extends Object { - protected List failures; - protected List errors; + protected List failures; // 存储assert失败 + protected List errors; // 存储业务代码异常,比如空指针 protected int testCount; private boolean stop; diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestSuite.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestSuite.java index e50bc66d24..7b14e1aee9 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestSuite.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestSuite.java @@ -16,7 +16,7 @@ public class TestSuite extends Assert implements Test { - private List tests= new ArrayList<>(10); + private List tests= new ArrayList<>(10); // 组合模式 private String name; public TestSuite(){ @@ -39,7 +39,7 @@ public TestSuite(final Class theClass) { Vector names= new Vector<>(); Method[] methods= theClass.getDeclaredMethods(); for (int i= 0; i < methods.length; i++) { - addTestMethod(methods[i], names, constructor); + addTestMethod(methods[i], names, constructor); // 该方法挺重要的 } if (tests.size() == 0) From 207d4618e6f3f1223540a757af864833de04a8d0 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Mon, 21 Aug 2017 01:26:43 +0800 Subject: [PATCH 69/81] =?UTF-8?q?[Homework]=20=E5=AE=8C=E6=88=90v1?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9A=84TestCase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 注:需要继续完成TestSuite --- .../litejunit/liuxiuv1/CalculatorTest.java | 2 - .../myood/litejunit/liuxiuv1/TestCase.java | 2 +- .../coderising/myood/litejunit/v1/Assert.java | 226 ++++++++++++++++++ .../litejunit/v1/AssertionFailedError.java | 13 + .../myood/litejunit/v1/Calculator.java | 22 ++ .../myood/litejunit/v1/CalculatorTest.java | 31 +++ .../myood/litejunit/v1/ClientToTest.java | 26 ++ .../coderising/myood/litejunit/v1/Test.java | 7 + .../myood/litejunit/v1/TestCase.java | 69 ++++++ .../myood/litejunit/v1/TestFailure.java | 40 ++++ .../myood/litejunit/v1/TestResult.java | 81 +++++++ 11 files changed, 516 insertions(+), 3 deletions(-) create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Assert.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/v1/AssertionFailedError.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Calculator.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Test.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestCase.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestFailure.java create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestResult.java diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java index 892109781d..66959c3dc3 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java @@ -1,8 +1,6 @@ package com.coderising.myood.litejunit.liuxiuv1; -import java.util.Iterator; - public class CalculatorTest extends TestCase { public CalculatorTest(String name) { super(name); diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java index a77e6cdbc3..78881def35 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java @@ -18,7 +18,7 @@ public int countTestCases() { return 1; } - protected void runTest() throws Throwable{ + protected void runTest() throws Throwable { Method runMethod= null; try { runMethod= getClass().getMethod(name, null); diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Assert.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Assert.java new file mode 100644 index 0000000000..8afbd15679 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Assert.java @@ -0,0 +1,226 @@ +package com.coderising.myood.litejunit.v1; + + +/** + * A set of assert methods. + */ + +public class Assert { + /** + * Protect constructor since it is a static only class + */ + protected Assert() { + } + + /** + * Asserts that a condition is true. If it isn't it throws + * an AssertionFailedError with the given message. + */ + static public void assertTrue(String message, boolean condition) { + if (!condition) + fail(message); + } + /** + * Asserts that a condition is true. If it isn't it throws + * an AssertionFailedError. + */ + static public void assertTrue(boolean condition) { + assertTrue(null, condition); + } + /** + * Fails a test with the given message. + */ + static public void fail(String message) { + throw new AssertionFailedError(message); + } + /** + * Fails a test with no message. + */ + static public void fail() { + fail(null); + } + /** + * Asserts that two objects are equal. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertEquals(String message, Object expected, Object actual) { + if (expected == null && actual == null) + return; + if (expected != null && expected.equals(actual)) + return; + failNotEquals(message, expected, actual); + } + /** + * Asserts that two objects are equal. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertEquals(Object expected, Object actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two doubles are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(String message, double expected, double actual, double delta) { + // handle infinity specially since subtracting to infinite values gives NaN and the + // the following test fails + if (Double.isInfinite(expected)) { + if (!(expected == actual)) + failNotEquals(message, new Double(expected), new Double(actual)); + } else if (!(Math.abs(expected-actual) <= delta)) // Because comparison with NaN always returns false + failNotEquals(message, new Double(expected), new Double(actual)); + } + /** + * Asserts that two doubles are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(double expected, double actual, double delta) { + assertEquals(null, expected, actual, delta); + } + /** + * Asserts that two floats are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(String message, float expected, float actual, float delta) { + // handle infinity specially since subtracting to infinite values gives NaN and the + // the following test fails + if (Float.isInfinite(expected)) { + if (!(expected == actual)) + failNotEquals(message, new Float(expected), new Float(actual)); + } else if (!(Math.abs(expected-actual) <= delta)) + failNotEquals(message, new Float(expected), new Float(actual)); + } + /** + * Asserts that two floats are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(float expected, float actual, float delta) { + assertEquals(null, expected, actual, delta); + } + /** + * Asserts that two longs are equal. + */ + static public void assertEquals(String message, long expected, long actual) { + assertEquals(message, new Long(expected), new Long(actual)); + } + /** + * Asserts that two longs are equal. + */ + static public void assertEquals(long expected, long actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two booleans are equal. + */ + static public void assertEquals(String message, boolean expected, boolean actual) { + assertEquals(message, new Boolean(expected), new Boolean(actual)); + } + /** + * Asserts that two booleans are equal. + */ + static public void assertEquals(boolean expected, boolean actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two bytes are equal. + */ + static public void assertEquals(String message, byte expected, byte actual) { + assertEquals(message, new Byte(expected), new Byte(actual)); + } + /** + * Asserts that two bytes are equal. + */ + static public void assertEquals(byte expected, byte actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two chars are equal. + */ + static public void assertEquals(String message, char expected, char actual) { + assertEquals(message, new Character(expected), new Character(actual)); + } + /** + * Asserts that two chars are equal. + */ + static public void assertEquals(char expected, char actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two shorts are equal. + */ + static public void assertEquals(String message, short expected, short actual) { + assertEquals(message, new Short(expected), new Short(actual)); + } + /** + * Asserts that two shorts are equal. + */ + static public void assertEquals(short expected, short actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two ints are equal. + */ + static public void assertEquals(String message, int expected, int actual) { + assertEquals(message, new Integer(expected), new Integer(actual)); + } + /** + * Asserts that two ints are equal. + */ + static public void assertEquals(int expected, int actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that an object isn't null. + */ + static public void assertNotNull(Object object) { + assertNotNull(null, object); + } + /** + * Asserts that an object isn't null. + */ + static public void assertNotNull(String message, Object object) { + assertTrue(message, object != null); + } + /** + * Asserts that an object is null. + */ + static public void assertNull(Object object) { + assertNull(null, object); + } + /** + * Asserts that an object is null. + */ + static public void assertNull(String message, Object object) { + assertTrue(message, object == null); + } + /** + * Asserts that two objects refer to the same object. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertSame(String message, Object expected, Object actual) { + if (expected == actual) + return; + failNotSame(message, expected, actual); + } + /** + * Asserts that two objects refer to the same object. If they are not + * the same an AssertionFailedError is thrown. + */ + static public void assertSame(Object expected, Object actual) { + assertSame(null, expected, actual); + } + + static private void failNotEquals(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message+" "; + fail(formatted+"expected:<"+expected+"> but was:<"+actual+">"); + } + + static private void failNotSame(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message+" "; + fail(formatted+"expected same"); + } +} \ No newline at end of file diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/AssertionFailedError.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/AssertionFailedError.java new file mode 100644 index 0000000000..3de657c3bd --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/AssertionFailedError.java @@ -0,0 +1,13 @@ +package com.coderising.myood.litejunit.v1; + +/** + * Thrown when an assertion failed. + */ +public class AssertionFailedError extends Error { + + public AssertionFailedError() { + } + public AssertionFailedError(String message) { + super (message); + } +} \ No newline at end of file diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Calculator.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Calculator.java new file mode 100644 index 0000000000..fba48eb1ed --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Calculator.java @@ -0,0 +1,22 @@ +package com.coderising.myood.litejunit.v1; + +public class Calculator { + + private int result = 0; + public void add(int x){ + result += x; + } + public void subtract(int x){ + result -=x; + } + + public int getResult(){ + return this.result; + } + public static void main(String[] args){ + Calculator calculator = new Calculator(); + calculator.add(10); + calculator.subtract(5); + System.out.println(calculator.getResult()); + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java new file mode 100644 index 0000000000..c09920d3a2 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java @@ -0,0 +1,31 @@ +package com.coderising.myood.litejunit.v1; + + +public class CalculatorTest extends TestCase { + public CalculatorTest(String name) { + super(name); + + } + Calculator calculator =null; + public void setUp(){ + calculator = new Calculator(); + } + public void tearDown(){ + calculator = null; + } + public void testAdd(){ + + calculator.add(10); + assertEquals(10,calculator.getResult()); + } + public void testSubtract(){ + calculator.add(10); + calculator.subtract(5); + assertEquals(4,calculator.getResult()); + } + + private void testXX() { + + } + +} diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java new file mode 100644 index 0000000000..5291263f4b --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java @@ -0,0 +1,26 @@ +package com.coderising.myood.litejunit.v1; + + +/** + * Created by thomas_young on 21/8/2017. + */ +public class ClientToTest { + + public static void main(String[] args) { + TestResult tr = new TestResult(); + + Test cs1 = new CalculatorTest("testAdd"); + test(cs1, tr); + Test cs2 = new CalculatorTest("testSubtract"); + test(cs2, tr); + } + + private static void test(Test test, TestResult tr) { + test.run(tr); + System.out.println(tr.wasSuccessful()); + for (TestFailure failure: tr.failures) { + System.err.println(failure); + } + System.out.println("runCount=" + tr.runCount()); + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Test.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Test.java new file mode 100644 index 0000000000..842b067796 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Test.java @@ -0,0 +1,7 @@ +package com.coderising.myood.litejunit.v1; + + +public interface Test { + public abstract int countTestCases(); // command模式,一个测试用例是一个command + public void run(TestResult tr); // 分离测试用例和测试结果,收集参数模式 +} diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestCase.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestCase.java new file mode 100644 index 0000000000..5c6ba60b80 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestCase.java @@ -0,0 +1,69 @@ +package com.coderising.myood.litejunit.v1; + + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +/** + * Created by thomas_young on 21/8/2017. + */ +public abstract class TestCase extends Assert implements Test { + private String name; + protected TestCase(String name) { + this.name = name; + } + @Override + public int countTestCases() { + return 1; + } + + @Override + public void run(TestResult tr) { + tr.run(this); + } + + public void doRun() throws Throwable { + setUp(); + try{ + runTest(); + } + finally{ + tearDown(); + } + } + + private void runTest() throws Throwable { + Method method = null; + try { + method = getClass().getMethod(name, null); + } catch (NoSuchMethodException e) { + fail("Method \""+name+"\" not found"); + } + if (!Modifier.isPublic(method.getModifiers())) { + fail("Method \""+name+"\" should be public"); + } + try { + method.invoke(this, null); + } catch (IllegalAccessException e) { + e.fillInStackTrace(); + throw e; + } catch (InvocationTargetException e) { + e.fillInStackTrace(); + throw e.getTargetException(); + } + } + + protected void setUp() { + } + + protected void tearDown() { + } + + @Override + public String toString() { + return "TestCase{" + + "name='" + getClass().getName() + "." + name + '\'' + + '}'; + } +} diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestFailure.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestFailure.java new file mode 100644 index 0000000000..9f4455f43c --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestFailure.java @@ -0,0 +1,40 @@ +package com.coderising.myood.litejunit.v1; + + +/** + * A TestFailure collects a failed test together with + * the caught exception. + * @see TestResult + */ +public class TestFailure { + protected Test failedTest; + protected Throwable thrownException; + + /** + * Constructs a TestFailure with the given test and exception. + */ + public TestFailure(Test failedTest, Throwable thrownException) { + this.failedTest= failedTest; + this.thrownException= thrownException; + } + /** + * Gets the failed test. + */ + public Test failedTest() { + return failedTest; + } + /** + * Gets the thrown exception. + */ + public Throwable thrownException() { + return thrownException; + } + /** + * Returns a short description of the failure. + */ + public String toString() { + StringBuffer buffer= new StringBuffer(); + buffer.append(failedTest+": "+thrownException.getMessage()); + return buffer.toString(); + } +} \ No newline at end of file diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestResult.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestResult.java new file mode 100644 index 0000000000..96144144e0 --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestResult.java @@ -0,0 +1,81 @@ +package com.coderising.myood.litejunit.v1; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Created by thomas_young on 21/8/2017. + */ +public class TestResult { + protected List failures; // 存储assert失败 + protected List errors; // 存储业务代码异常,比如空指针 + private int testCount; + private boolean stop; + + public TestResult() { + failures= new ArrayList<>(); + errors= new ArrayList<>(); + + testCount= 0; + stop= false; + } + + public void run(TestCase testCase) { + startTest(testCase); + try { + testCase.doRun(); + } catch (AssertionFailedError e) { + failures.add(new TestFailure(testCase, e)); + } catch (Throwable e) { + errors.add(new TestFailure(testCase, e)); + } + endTest(testCase); + } + + private void startTest(TestCase testCase) { + int count= testCase.countTestCases(); + testCount+= count; + } + + private void endTest(TestCase testCase) { + } + /** + * Gets the number of run tests. + */ + public int runCount() { + return testCount; + } + + + public boolean shouldStop() { + return stop; + } + + public void stop() { + stop= true; + } + + public int errorCount() { + return errors.size(); + } + + public Iterator errors() { + return errors.iterator(); + } + + public int failureCount() { + return failures.size(); + } + + public Iterator failures() { + return failures.iterator(); + } + /** + * Returns whether the entire test was successful or not. + */ + public boolean wasSuccessful() { + return this.failureCount() == 0 && this.errorCount() == 0; + } + +} From 197b2195e275c97fb2f8c3a02be6e5fe983da590 Mon Sep 17 00:00:00 2001 From: onlyliuxin <14703250@qq.com> Date: Mon, 21 Aug 2017 09:35:58 +0800 Subject: [PATCH 70/81] lite-junit v2,v3 --- .../org/litejunit/extension/RepeatedTest.java | 32 +++ .../litejunit/extension/TestDecorator.java | 40 +++ .../org/litejunit/extension/TestSetup.java | 39 +++ .../java/org/litejunit/sample/AllTest.java | 43 +++ .../java/org/litejunit/sample/PersonTest.java | 38 +++ .../sample/calculator/Calculator.java | 22 ++ .../sample/calculator/CalculatorSuite.java | 12 + .../sample/calculator/CalculatorTest.java | 59 ++++ .../main/java/org/litejunit/v2/Assert.java | 243 ++++++++++++++++ .../litejunit/v2/AssertionFailedError.java | 13 + .../java/org/litejunit/v2/Protectable.java | 14 + .../src/main/java/org/litejunit/v2/Test.java | 6 + .../main/java/org/litejunit/v2/TestCase.java | 64 +++++ .../java/org/litejunit/v2/TestFailure.java | 39 +++ .../java/org/litejunit/v2/TestListener.java | 15 + .../java/org/litejunit/v2/TestResult.java | 121 ++++++++ .../main/java/org/litejunit/v2/TestSuite.java | 137 +++++++++ .../litejunit/v2/runner/BaseTestRunner.java | 85 ++++++ .../org/litejunit/v2/textui/TestRunner.java | 202 +++++++++++++ .../src/main/java/org/litejunit/v3/After.java | 12 + .../java/org/litejunit/v3/AfterClass.java | 13 + .../main/java/org/litejunit/v3/Assert.java | 269 ++++++++++++++++++ .../main/java/org/litejunit/v3/Before.java | 13 + .../java/org/litejunit/v3/BeforeClass.java | 11 + .../org/litejunit/v3/ComparisonFailure.java | 124 ++++++++ .../main/java/org/litejunit/v3/Ignore.java | 31 ++ .../src/main/java/org/litejunit/v3/Test.java | 62 ++++ .../litejunit/v3/notification/Failure.java | 78 +++++ .../v3/notification/RunListener.java | 53 ++++ .../v3/notification/RunNotifier.java | 139 +++++++++ .../notification/StoppedByUserException.java | 11 + .../litejunit/v3/requests/ClassRequest.java | 48 ++++ .../org/litejunit/v3/runner/Description.java | 127 +++++++++ .../org/litejunit/v3/runner/JUnitCore.java | 167 +++++++++++ .../java/org/litejunit/v3/runner/Request.java | 86 ++++++ .../java/org/litejunit/v3/runner/Result.java | 98 +++++++ .../litejunit/v3/runner/ResultPrinter.java | 72 +++++ .../java/org/litejunit/v3/runner/RunWith.java | 24 ++ .../java/org/litejunit/v3/runner/Runner.java | 24 ++ .../v3/runners/BeforeAndAfterRunner.java | 76 +++++ .../v3/runners/InitializationError.java | 25 ++ .../v3/runners/TestClassMethodsRunner.java | 100 +++++++ .../litejunit/v3/runners/TestClassRunner.java | 53 ++++ .../v3/runners/TestIntrospector.java | 82 ++++++ .../v3/runners/TestMethodRunner.java | 122 ++++++++ .../litejunit/v3/runners/TextListener.java | 106 +++++++ .../org/litejunit/v3/sample/Calculator.java | 22 ++ .../litejunit/v3/sample/CalculatorTest.java | 48 ++++ 48 files changed, 3320 insertions(+) create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/RepeatedTest.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/TestDecorator.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/TestSetup.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/AllTest.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/PersonTest.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/Calculator.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorSuite.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorTest.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Assert.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/AssertionFailedError.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Protectable.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Test.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestCase.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestFailure.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestListener.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestResult.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestSuite.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/runner/BaseTestRunner.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/textui/TestRunner.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/After.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/AfterClass.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Assert.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Before.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/BeforeClass.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/ComparisonFailure.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Ignore.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Test.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/Failure.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/RunListener.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/RunNotifier.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/StoppedByUserException.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/requests/ClassRequest.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Description.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/JUnitCore.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Request.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Result.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/ResultPrinter.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/RunWith.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Runner.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/BeforeAndAfterRunner.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/InitializationError.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestClassMethodsRunner.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestClassRunner.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestIntrospector.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestMethodRunner.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TextListener.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/Calculator.java create mode 100644 liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/CalculatorTest.java diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/RepeatedTest.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/RepeatedTest.java new file mode 100644 index 0000000000..f6250ee426 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/RepeatedTest.java @@ -0,0 +1,32 @@ +package org.litejunit.extension; + +import org.litejunit.v2.Test; +import org.litejunit.v2.TestResult; + +/** + * A Decorator that runs a test repeatedly. + * + */ +public class RepeatedTest extends TestDecorator { + private int fTimesRepeat; + + public RepeatedTest(Test test, int repeat) { + super(test); + if (repeat < 0) + throw new IllegalArgumentException("Repetition count must be > 0"); + fTimesRepeat= repeat; + } + public int countTestCases() { + return super.countTestCases()*fTimesRepeat; + } + public void run(TestResult result) { + for (int i= 0; i < fTimesRepeat; i++) { + if (result.shouldStop()) + break; + super.run(result); + } + } + public String toString() { + return super.toString()+"(repeated)"; + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/TestDecorator.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/TestDecorator.java new file mode 100644 index 0000000000..556d05cbbb --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/TestDecorator.java @@ -0,0 +1,40 @@ +package org.litejunit.extension; + +import org.litejunit.v2.Assert; +import org.litejunit.v2.Test; +import org.litejunit.v2.TestResult; + +/** + * A Decorator for Tests. Use TestDecorator as the base class + * for defining new test decorators. Test decorator subclasses + * can be introduced to add behaviour before or after a test + * is run. + * + */ +public class TestDecorator extends Assert implements Test { + protected Test test; + + public TestDecorator(Test test) { + this.test= test; + } + /** + * The basic run behaviour. + */ + public void basicRun(TestResult result) { + test.run(result); + } + public int countTestCases() { + return test.countTestCases(); + } + public void run(TestResult result) { + basicRun(result); + } + + public String toString() { + return test.toString(); + } + + public Test getTest() { + return test; + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/TestSetup.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/TestSetup.java new file mode 100644 index 0000000000..7a133a798c --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/extension/TestSetup.java @@ -0,0 +1,39 @@ +package org.litejunit.extension; + +import org.litejunit.v2.Protectable; +import org.litejunit.v2.Test; +import org.litejunit.v2.TestResult; + +/** + * A Decorator to set up and tear down additional fixture state. + * Subclass TestSetup and insert it into your tests when you want + * to set up additional state once before the tests are run. + */ +public class TestSetup extends TestDecorator { + + public TestSetup(Test test) { + super(test); + } + public void run(final TestResult result) { + Protectable p= new Protectable() { + public void protect() throws Exception { + setUp(); + basicRun(result); + tearDown(); + } + }; + result.runProtected(this, p); + } + /** + * Sets up the fixture. Override to set up additional fixture + * state. + */ + protected void setUp() throws Exception { + } + /** + * Tears down the fixture. Override to tear down the additional + * fixture state. + */ + protected void tearDown() throws Exception { + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/AllTest.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/AllTest.java new file mode 100644 index 0000000000..2c4d6b3dca --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/AllTest.java @@ -0,0 +1,43 @@ +package org.litejunit.sample; + +import org.litejunit.extension.RepeatedTest; +import org.litejunit.extension.TestSetup; +import org.litejunit.sample.calculator.CalculatorSuite; +import org.litejunit.v2.Test; +import org.litejunit.v2.TestSuite; + + +public class AllTest { + /*public static Test suite(){ + + TestSuite suite= new TestSuite("All Test"); + suite.addTest(CalculatorSuite.suite()); + suite.addTestSuite(PersonTest.class); + return suite; + + }*/ + + public static Test suite(){ + + TestSuite suite= new TestSuite("All Test"); + suite.addTest(CalculatorSuite.suite()); + suite.addTest(new RepeatedTest(new TestSuite(PersonTest.class), 2)); + return new OverallTestSetup(suite); + } + + + static class OverallTestSetup extends TestSetup{ + + public OverallTestSetup(Test test) { + super(test); + + } + protected void setUp() throws Exception { + System.out.println("this is overall testsetup"); + } + protected void tearDown() throws Exception { + System.out.println("this is overall teardown"); + } + + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/PersonTest.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/PersonTest.java new file mode 100644 index 0000000000..2e76ea26ae --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/PersonTest.java @@ -0,0 +1,38 @@ +package org.litejunit.sample; + +import org.litejunit.v2.TestCase; + +public class PersonTest extends TestCase { + + Person p = null; + protected void setUp() { + p = new Person("andy",30); + } + public PersonTest(String name) { + super(name); + } + public void testAge(){ + this.assertEquals(30, p.getAge()); + } + public void testName(){ + this.assertEquals("andy", p.getName()); + } +} +class Person{ + private String name; + private int age; + + public Person(String name, int age) { + + this.name = name; + this.age = age; + } + public String getName() { + return name; + } + public int getAge() { + return age; + } + + +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/Calculator.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/Calculator.java new file mode 100644 index 0000000000..ed0a69959a --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/Calculator.java @@ -0,0 +1,22 @@ +package org.litejunit.sample.calculator; + +public class Calculator { + + private int result = 0; + public void add(int x){ + result += x; + } + public void subtract(int x){ + result -=x; + } + + public int getResult(){ + return this.result; + } + public static void main(String[] args){ + Calculator calculator = new Calculator(); + calculator.add(10); + calculator.subtract(5); + System.out.println(calculator.getResult()); + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorSuite.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorSuite.java new file mode 100644 index 0000000000..1deec69c52 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorSuite.java @@ -0,0 +1,12 @@ +package org.litejunit.sample.calculator; + +import org.litejunit.v2.Test; +import org.litejunit.v2.TestSuite; + +public class CalculatorSuite { + public static Test suite(){ + TestSuite suite= new TestSuite("Calculator All Test"); + suite.addTestSuite(CalculatorTest.class); + return suite; + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorTest.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorTest.java new file mode 100644 index 0000000000..39f1d2433b --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorTest.java @@ -0,0 +1,59 @@ +package org.litejunit.sample.calculator; + +import org.litejunit.v2.TestCase; + +public class CalculatorTest extends TestCase { + public CalculatorTest(String name) { + super(name); + + } + Calculator calculator =null; + public void setUp(){ + calculator = new Calculator(); + } + public void tearDown(){ + calculator = null; + } + public void testAdd(){ + + calculator.add(10); + assertEquals(5,calculator.getResult()); + } + public void testSubtract(){ + calculator.add(10); + calculator.subtract(5); + throw new RuntimeException("this is a test"); + //assertEquals(5,calculator.getResult()); + } + + public static void main(String[] args){ + /*{ + TestCase tc1 = new CalculatorTest("testAdd"){ + protected void runTest() { + testAdd(); + } + }; + + TestCase tc2 = new CalculatorTest("testSubtract"){ + protected void runTest() { + testSubtract(); + } + }; + tc1.run(); + tc2.run(); + } + + + TestSuite ts = new TestSuite(); + ts.addTest(new CalculatorTest("testAdd")); + ts.addTest(new CalculatorTest("testSubtract")); + + + { + TestCase tc1 = new CalculatorTest("test1"); + TestCase tc2 = new CalculatorTest("test2"); + tc1.run(); + tc2.run(); + }*/ + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Assert.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Assert.java new file mode 100644 index 0000000000..4e5a9920bd --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Assert.java @@ -0,0 +1,243 @@ +package org.litejunit.v2; + +/** + * A set of assert methods. + */ + +public class Assert { + /** + * Protect constructor since it is a static only class + */ + protected Assert() { + } + /** + * Asserts that a condition is true. If it isn't it throws + * an AssertionFailedError with the given message. + * @deprecated use assertTrue + */ + /*static public void assert(String message, boolean condition) { + if (!condition) + fail(message); + }*/ + /** + * Asserts that a condition is true. If it isn't it throws + * an AssertionFailedError. + * @deprecated use assertTrue + * + */ + /*static public void assert(boolean condition) { + assert(null, condition); + } +*/ + /** + * Asserts that a condition is true. If it isn't it throws + * an AssertionFailedError with the given message. + */ + static public void assertTrue(String message, boolean condition) { + if (!condition) + fail(message); + } + /** + * Asserts that a condition is true. If it isn't it throws + * an AssertionFailedError. + */ + static public void assertTrue(boolean condition) { + assertTrue(null, condition); + } + /** + * Fails a test with the given message. + */ + static public void fail(String message) { + throw new AssertionFailedError(message); + } + /** + * Fails a test with no message. + */ + static public void fail() { + fail(null); + } + /** + * Asserts that two objects are equal. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertEquals(String message, Object expected, Object actual) { + if (expected == null && actual == null) + return; + if (expected != null && expected.equals(actual)) + return; + failNotEquals(message, expected, actual); + } + /** + * Asserts that two objects are equal. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertEquals(Object expected, Object actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two doubles are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(String message, double expected, double actual, double delta) { + // handle infinity specially since subtracting to infinite values gives NaN and the + // the following test fails + if (Double.isInfinite(expected)) { + if (!(expected == actual)) + failNotEquals(message, new Double(expected), new Double(actual)); + } else if (!(Math.abs(expected-actual) <= delta)) // Because comparison with NaN always returns false + failNotEquals(message, new Double(expected), new Double(actual)); + } + /** + * Asserts that two doubles are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(double expected, double actual, double delta) { + assertEquals(null, expected, actual, delta); + } + /** + * Asserts that two floats are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(String message, float expected, float actual, float delta) { + // handle infinity specially since subtracting to infinite values gives NaN and the + // the following test fails + if (Float.isInfinite(expected)) { + if (!(expected == actual)) + failNotEquals(message, new Float(expected), new Float(actual)); + } else if (!(Math.abs(expected-actual) <= delta)) + failNotEquals(message, new Float(expected), new Float(actual)); + } + /** + * Asserts that two floats are equal concerning a delta. If the expected + * value is infinity then the delta value is ignored. + */ + static public void assertEquals(float expected, float actual, float delta) { + assertEquals(null, expected, actual, delta); + } + /** + * Asserts that two longs are equal. + */ + static public void assertEquals(String message, long expected, long actual) { + assertEquals(message, new Long(expected), new Long(actual)); + } + /** + * Asserts that two longs are equal. + */ + static public void assertEquals(long expected, long actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two booleans are equal. + */ + static public void assertEquals(String message, boolean expected, boolean actual) { + assertEquals(message, new Boolean(expected), new Boolean(actual)); + } + /** + * Asserts that two booleans are equal. + */ + static public void assertEquals(boolean expected, boolean actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two bytes are equal. + */ + static public void assertEquals(String message, byte expected, byte actual) { + assertEquals(message, new Byte(expected), new Byte(actual)); + } + /** + * Asserts that two bytes are equal. + */ + static public void assertEquals(byte expected, byte actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two chars are equal. + */ + static public void assertEquals(String message, char expected, char actual) { + assertEquals(message, new Character(expected), new Character(actual)); + } + /** + * Asserts that two chars are equal. + */ + static public void assertEquals(char expected, char actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two shorts are equal. + */ + static public void assertEquals(String message, short expected, short actual) { + assertEquals(message, new Short(expected), new Short(actual)); + } + /** + * Asserts that two shorts are equal. + */ + static public void assertEquals(short expected, short actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that two ints are equal. + */ + static public void assertEquals(String message, int expected, int actual) { + assertEquals(message, new Integer(expected), new Integer(actual)); + } + /** + * Asserts that two ints are equal. + */ + static public void assertEquals(int expected, int actual) { + assertEquals(null, expected, actual); + } + /** + * Asserts that an object isn't null. + */ + static public void assertNotNull(Object object) { + assertNotNull(null, object); + } + /** + * Asserts that an object isn't null. + */ + static public void assertNotNull(String message, Object object) { + assertTrue(message, object != null); + } + /** + * Asserts that an object is null. + */ + static public void assertNull(Object object) { + assertNull(null, object); + } + /** + * Asserts that an object is null. + */ + static public void assertNull(String message, Object object) { + assertTrue(message, object == null); + } + /** + * Asserts that two objects refer to the same object. If they are not + * an AssertionFailedError is thrown. + */ + static public void assertSame(String message, Object expected, Object actual) { + if (expected == actual) + return; + failNotSame(message, expected, actual); + } + /** + * Asserts that two objects refer to the same object. If they are not + * the same an AssertionFailedError is thrown. + */ + static public void assertSame(Object expected, Object actual) { + assertSame(null, expected, actual); + } + + static private void failNotEquals(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message+" "; + fail(formatted+"expected:<"+expected+"> but was:<"+actual+">"); + } + + static private void failNotSame(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message+" "; + fail(formatted+"expected same"); + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/AssertionFailedError.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/AssertionFailedError.java new file mode 100644 index 0000000000..49ebf0955e --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/AssertionFailedError.java @@ -0,0 +1,13 @@ +package org.litejunit.v2; + +/** + * Thrown when an assertion failed. + */ +public class AssertionFailedError extends Error { + + public AssertionFailedError () { + } + public AssertionFailedError (String message) { + super (message); + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Protectable.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Protectable.java new file mode 100644 index 0000000000..f43f7d8e01 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Protectable.java @@ -0,0 +1,14 @@ +package org.litejunit.v2; + +/** + * A Protectable can be run and can throw a Throwable. + * + * @see TestResult + */ +public interface Protectable { + + /** + * Run the the following method protected. + */ + public abstract void protect() throws Throwable; +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Test.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Test.java new file mode 100644 index 0000000000..73de6a2e25 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/Test.java @@ -0,0 +1,6 @@ +package org.litejunit.v2; + +public interface Test { + public abstract int countTestCases(); + public void run(TestResult tr); +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestCase.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestCase.java new file mode 100644 index 0000000000..4f704d2866 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestCase.java @@ -0,0 +1,64 @@ +package org.litejunit.v2; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + + + +public abstract class TestCase extends Assert implements Test { + private String name; + + + public TestCase(String name) { + this.name = name; + } + + + public int countTestCases() { + return 1; + } + + protected void runTest() throws Throwable{ + Method runMethod= null; + try { + runMethod= getClass().getMethod(name, null); + } catch (NoSuchMethodException e) { + fail("Method \""+name+"\" not found"); + } + if (!Modifier.isPublic(runMethod.getModifiers())) { + fail("Method \""+name+"\" should be public"); + } + + try { + runMethod.invoke(this, new Class[0]); + } + catch (InvocationTargetException e) { + e.fillInStackTrace(); + throw e.getTargetException(); + } + catch (IllegalAccessException e) { + e.fillInStackTrace(); + throw e; + } + } + + protected void setUp() { + } + + protected void tearDown() { + } + + public void run(TestResult tr) { + tr.run(this); + } + public void doRun() throws Throwable{ + setUp(); + try{ + runTest(); + } + finally{ + tearDown(); + } + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestFailure.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestFailure.java new file mode 100644 index 0000000000..c40f6f89e0 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestFailure.java @@ -0,0 +1,39 @@ +package org.litejunit.v2; + +/** + * A TestFailure collects a failed test together with + * the caught exception. + * @see TestResult + */ +public class TestFailure { + protected Test failedTest; + protected Throwable thrownException; + + /** + * Constructs a TestFailure with the given test and exception. + */ + public TestFailure(Test failedTest, Throwable thrownException) { + this.failedTest= failedTest; + this.thrownException= thrownException; + } + /** + * Gets the failed test. + */ + public Test failedTest() { + return failedTest; + } + /** + * Gets the thrown exception. + */ + public Throwable thrownException() { + return thrownException; + } + /** + * Returns a short description of the failure. + */ + public String toString() { + StringBuffer buffer= new StringBuffer(); + buffer.append(failedTest+": "+thrownException.getMessage()); + return buffer.toString(); + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestListener.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestListener.java new file mode 100644 index 0000000000..412febcc55 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestListener.java @@ -0,0 +1,15 @@ +package org.litejunit.v2; + +/** + * A Listener for test progress + */ +public interface TestListener { + + public void addError(Test test, Throwable t); + + public void addFailure(Test test, AssertionFailedError t); + + public void endTest(Test test); + + public void startTest(Test test); +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestResult.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestResult.java new file mode 100644 index 0000000000..6fb789a495 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestResult.java @@ -0,0 +1,121 @@ +package org.litejunit.v2; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + + +public class TestResult extends Object { + protected List failures; + protected List errors; + protected List listeners; + protected int testCount; + private boolean stop; + + public TestResult() { + failures= new ArrayList<>(); + errors= new ArrayList<>(); + listeners = new ArrayList<>(); + testCount= 0; + stop= false; + } + + public void addError(Test test, Throwable t) { + errors.add(new TestFailure(test, t)); + for(TestListener listener: listeners){ + listener.addError(test, t); + } + } + + public void addFailure(Test test, AssertionFailedError t) { + failures.add(new TestFailure(test, t)); + for(TestListener listener: listeners){ + listener.addFailure(test, t); + } + } + + public void startTest(Test test) { + int count= test.countTestCases(); + testCount+= count; + for(TestListener listener: listeners){ + listener.startTest(test); + } + } + public void endTest(Test test) { + for(TestListener listener: listeners){ + listener.endTest(test); + } + } + + /** + * Runs a TestCase. + */ + protected void run(final TestCase test) { + startTest(test); + try { + test.doRun(); + } + catch (AssertionFailedError e) { + addFailure(test, e); + } + catch (Throwable e) { + addError(test, e); + } + + endTest(test); + } + /** + * Gets the number of run tests. + */ + public int runCount() { + return testCount; + } + public void runProtected(final Test test, Protectable p) { + try { + p.protect(); + } + catch (AssertionFailedError e) { + addFailure(test, e); + } + catch (Throwable e) { + addError(test, e); + } + } + + public boolean shouldStop() { + return stop; + } + + public void stop() { + stop= true; + } + + public int errorCount() { + return errors.size(); + } + + public Iterator errors() { + return errors.iterator(); + } + + public int failureCount() { + return failures.size(); + } + + public Iterator failures() { + return failures.iterator(); + } + /** + * Returns whether the entire test was successful or not. + */ + public boolean wasSuccessful() { + return this.failureCount() == 0 && this.errorCount() == 0; + } + public void addListener(TestListener listener) { + listeners.add(listener); + } + + public void removeListener(TestListener listener) { + listeners.remove(listener); + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestSuite.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestSuite.java new file mode 100644 index 0000000000..9ad0a05433 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/TestSuite.java @@ -0,0 +1,137 @@ +package org.litejunit.v2; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; + +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + + + + + + +public class TestSuite extends Assert implements Test { + private List tests= new ArrayList<>(10); + private String name; + public TestSuite(){ + + } + public TestSuite(final Class theClass) { + this.name= theClass.getName(); + Constructor constructor= null; + try { + constructor= getConstructor(theClass); + } catch (NoSuchMethodException e) { + addTest(warning("Class "+theClass.getName()+" has no public constructor TestCase(String name)")); + return; + } + + if (!Modifier.isPublic(theClass.getModifiers())) { + addTest(warning("Class "+theClass.getName()+" is not public")); + return; + } + + Vector names= new Vector<>(); + Method[] methods= theClass.getDeclaredMethods(); + for (int i= 0; i < methods.length; i++) { + addTestMethod(methods[i], names, constructor); + } + + if (tests.size() == 0) + addTest(warning("No tests found in "+theClass.getName())); + } + + public TestSuite(String name) { + this.name = name; + } + private Constructor getConstructor(Class theClass) throws NoSuchMethodException { + Class[] args= { String.class }; + return theClass.getConstructor(args); + } + private void addTestMethod(Method m, Vector names, Constructor constructor) { + String name= m.getName(); + if (names.contains(name)) + return; + if (isPublicTestMethod(m)) { + names.addElement(name); + + Object[] args= new Object[]{name}; + try { + addTest((Test)constructor.newInstance(args)); + } catch (InstantiationException e) { + addTest(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); + } catch (InvocationTargetException e) { + addTest(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); + } catch (IllegalAccessException e) { + addTest(warning("Cannot access test case: "+name+" ("+exceptionToString(e)+")")); + } + + } else { // almost a test method + if (isTestMethod(m)) + addTest(warning("Test method isn't public: "+m.getName())); + } + } + private boolean isPublicTestMethod(Method m) { + return isTestMethod(m) && Modifier.isPublic(m.getModifiers()); + } + private boolean isTestMethod(Method m) { + String name= m.getName(); + Class[] parameters= m.getParameterTypes(); + Class returnType= m.getReturnType(); + return parameters.length == 0 && name.startsWith("test") && returnType.equals(Void.TYPE); + } + public void addTest(Test test) { + tests.add(test); + } + public void addTestSuite(Class testClass) { + addTest(new TestSuite(testClass)); + } + private Test warning(final String message) { + return new TestCase("warning") { + public void doRun() { + fail(message); + } + }; + } + private String exceptionToString(Throwable t) { + StringWriter stringWriter= new StringWriter(); + PrintWriter writer= new PrintWriter(stringWriter); + t.printStackTrace(writer); + return stringWriter.toString(); + + } + + + + @Override + public void run(TestResult result) { + for (Iterator e= tests(); e.hasNext(); ) { + if (result.shouldStop() ){ + break; + } + Test test= (Test)e.next(); + test.run(result); + } + + } + + public int countTestCases() { + int count= 0; + + for (Iterator e= tests(); e.hasNext(); ) { + Test test= e.next(); + count= count + test.countTestCases(); + } + return count; + } + public Iterator tests() { + return tests.iterator(); + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/runner/BaseTestRunner.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/runner/BaseTestRunner.java new file mode 100644 index 0000000000..b6ff184b69 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/runner/BaseTestRunner.java @@ -0,0 +1,85 @@ +package org.litejunit.v2.runner; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.text.NumberFormat; + +import org.litejunit.v2.Test; +import org.litejunit.v2.TestListener; +import org.litejunit.v2.TestSuite; + + +public abstract class BaseTestRunner implements TestListener { + public static final String SUITE_METHODNAME= "suite"; + /** + * Returns a filtered stack trace + */ + public static String getFilteredTrace(Throwable t) { + StringWriter stringWriter= new StringWriter(); + PrintWriter writer= new PrintWriter(stringWriter); + t.printStackTrace(writer); + StringBuffer buffer= stringWriter.getBuffer(); + String trace= buffer.toString(); + return trace; + //return BaseTestRunner.filterStack(trace); + } + + public Test getTest(String suiteClassName) { + if (suiteClassName.length() <= 0) { + return null; + } + Class testClass= null; + try { + testClass= loadSuiteClass(suiteClassName); + } catch (ClassNotFoundException e) { + String clazz= e.getMessage(); + if (clazz == null) + clazz= suiteClassName; + runFailed("Class not found \""+clazz+"\""); + return null; + } catch(Exception e) { + runFailed("Error: "+e.toString()); + return null; + } + Method suiteMethod= null; + try { + suiteMethod= testClass.getMethod(SUITE_METHODNAME, new Class[0]); + } catch(Exception e) { + // try to extract a test suite automatically + //clearStatus(); + return new TestSuite(testClass); + } + Test test= null; + try { + test= (Test)suiteMethod.invoke(null, new Class[0]); // static method + if (test == null) + return test; + } + catch (InvocationTargetException e) { + runFailed("Failed to invoke suite():" + e.getTargetException().toString()); + return null; + } + catch (IllegalAccessException e) { + runFailed("Failed to invoke suite():" + e.toString()); + return null; + } + + //clearStatus(); + return test; + } + protected Class loadSuiteClass(String suiteClassName) throws ClassNotFoundException { + + //TODO + return Class.forName(suiteClassName); + + + //return getLoader().load(suiteClassName); + } + protected abstract void runFailed(String message); + + public String elapsedTimeAsString(long runTime) { + return NumberFormat.getInstance().format((double)runTime/1000); + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/textui/TestRunner.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/textui/TestRunner.java new file mode 100644 index 0000000000..0ffab6b747 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v2/textui/TestRunner.java @@ -0,0 +1,202 @@ +package org.litejunit.v2.textui; + + +import java.lang.reflect.*; +import java.text.NumberFormat; +import java.util.*; + +import org.litejunit.v2.AssertionFailedError; +import org.litejunit.v2.Test; +import org.litejunit.v2.TestFailure; +import org.litejunit.v2.TestResult; +import org.litejunit.v2.TestSuite; +import org.litejunit.v2.runner.BaseTestRunner; + +import java.io.PrintStream; + + +public class TestRunner extends BaseTestRunner { + PrintStream writer= System.out; + int column= 0; + + /** + * Constructs a TestRunner. + */ + public TestRunner() { + } + + + /** + * Always use the StandardTestSuiteLoader. Overridden from + * BaseTestRunner. + */ + /*public TestSuiteLoader getLoader() { + return new StandardTestSuiteLoader(); + }*/ + + public synchronized void addError(Test test, Throwable t) { + writer().print("E"); + } + + public synchronized void addFailure(Test test, AssertionFailedError t) { + writer().print("F"); + } + + + + public TestResult doRun(Test suite) { + TestResult result= new TestResult(); + result.addListener(this); + long startTime= System.currentTimeMillis(); + suite.run(result); + long endTime= System.currentTimeMillis(); + long runTime= endTime-startTime; + writer().println(); + writer().println("Time: "+elapsedTimeAsString(runTime)); + print(result); + + writer().println(); + + + return result; + } + + + + public synchronized void startTest(Test test) { + writer().print("."); + if (column++ >= 40) { + writer().println(); + column= 0; + } + } + + public void endTest(Test test) { + } + + public static void main(String args[]) { + TestRunner testRunner= new TestRunner(); + try { + TestResult r= testRunner.start(args); + if (!r.wasSuccessful()) + System.exit(-1); + System.exit(0); + } catch(Exception e) { + System.err.println(e.getMessage()); + System.exit(-2); + } + } + /** + * Prints failures to the standard output + */ + public synchronized void print(TestResult result) { + printErrors(result); + printFailures(result); + printHeader(result); + } + /** + * Prints the errors to the standard output + */ + public void printErrors(TestResult result) { + if (result.errorCount() != 0) { + if (result.errorCount() == 1) + writer().println("There was "+result.errorCount()+" error:"); + else + writer().println("There were "+result.errorCount()+" errors:"); + + int i= 1; + for (Iterator e= result.errors(); e.hasNext(); i++) { + TestFailure failure= e.next(); + writer().println(i+") "+failure.failedTest()); + writer().print(getFilteredTrace(failure.thrownException())); + } + } + } + /** + * Prints failures to the standard output + */ + public void printFailures(TestResult result) { + if (result.failureCount() != 0) { + if (result.failureCount() == 1) + writer().println("There was " + result.failureCount() + " failure:"); + else + writer().println("There were " + result.failureCount() + " failures:"); + int i = 1; + for (Iterator e= result.failures(); e.hasNext(); i++) { + TestFailure failure= (TestFailure) e.next(); + writer().print(i + ") " + failure.failedTest()); + Throwable t= failure.thrownException(); + writer().print(getFilteredTrace(failure.thrownException())); + } + } + } + /** + * Prints the header of the report + */ + public void printHeader(TestResult result) { + if (result.wasSuccessful()) { + writer().println(); + writer().print("OK"); + writer().println (" (" + result.runCount() + " tests)"); + + } else { + writer().println(); + writer().println("FAILURES!!!"); + writer().println("Tests run: "+result.runCount()+ + ", Failures: "+result.failureCount()+ + ", Errors: "+result.errorCount()); + } + } + + + /** + * Starts a test run. Analyzes the command line arguments + * and runs the given test suite. + */ + protected TestResult start(String args[]) throws Exception { + if(args.length == 0){ + throw new Exception("Usage: TestRunner testCaseName"); + } + String testCase= args[0]; + + try { + Test suite= getTest(testCase); + return doRun(suite); + } + catch(Exception e) { + throw new Exception("Could not create and run test suite: "+e); + } + } + + protected void runFailed(String message) { + System.err.println(message); + System.exit(-1); + } + + /** + * Runs a suite extracted from a TestCase subclass. + */ + static public void run(Class testClass) { + run(new TestSuite(testClass)); + } + /** + * Runs a single test and collects its results. + * This method can be used to start a test run + * from your program. + *
+	 * public static void main (String[] args) {
+	 *     test.textui.TestRunner.run(suite());
+	 * }
+	 * 
+ */ + static public void run(Test suite) { + TestRunner aTestRunner= new TestRunner(); + aTestRunner.doRun(suite); + } + + protected PrintStream writer() { + return writer; + } + + +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/After.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/After.java new file mode 100644 index 0000000000..f27496b8e1 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/After.java @@ -0,0 +1,12 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface After { +} + diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/AfterClass.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/AfterClass.java new file mode 100644 index 0000000000..82618d7afc --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/AfterClass.java @@ -0,0 +1,13 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface AfterClass { +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Assert.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Assert.java new file mode 100644 index 0000000000..6d1b7689f9 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Assert.java @@ -0,0 +1,269 @@ +package org.litejunit.v3; + +/** + * A set of assertion methods useful for writing tests. Only failed assertions are recorded. + * These methods can be used directly: Assert.assertEquals(...), however, they + * read better if they are referenced through static import:
+ * + * import static org.junit.Assert.*;
+ * ...
+ *   assertEquals(...);
+ *
+ */ + +public class Assert { + /** + * Protect constructor since it is a static only class + */ + protected Assert() { + } + + /** + * Asserts that a condition is true. If it isn't it throws an + * AssertionError with the given message. + */ + static public void assertTrue(String message, boolean condition) { + if (!condition) + fail(message); + } + + /** + * Asserts that a condition is true. If it isn't it throws an + * AssertionError. + */ + static public void assertTrue(boolean condition) { + assertTrue(null, condition); + } + + /** + * Asserts that a condition is false. If it isn't it throws an + * AssertionError with the given message. + */ + static public void assertFalse(String message, boolean condition) { + assertTrue(message, !condition); + } + + /** + * Asserts that a condition is false. If it isn't it throws an + * AssertionError. + */ + static public void assertFalse(boolean condition) { + assertFalse(null, condition); + } + + /** + * Fails a test with the given message. + */ + static public void fail(String message) { + throw new AssertionError(message); + } + + /** + * Fails a test with no message. + */ + static public void fail() { + fail(null); + } + + /** + * Asserts that two objects are equal. If they are not, an + * AssertionError is thrown with the given message. + */ + static public void assertEquals(String message, Object expected, Object actual) { + if (expected == null && actual == null) + return; + if (expected != null && expected.equals(actual)) + return; + if (expected instanceof String && actual instanceof String) + throw new ComparisonFailure(message, (String)expected, (String)actual); + else + failNotEquals(message, expected, actual); + } + + /** + * Asserts that two objects are equal. If they are not, an + * AssertionError is thrown. + */ + static public void assertEquals(Object expected, Object actual) { + assertEquals(null, expected, actual); + } + + /** + * Asserts that two object arrays are equal. If they are not, an + * AssertionError is thrown with the given message. + */ + public static void assertEquals(String message, Object[] expecteds, Object[] actuals) { + if (expecteds == actuals) + return; + String header = message == null ? "" : message + ": "; + if (expecteds == null) + fail(header + "expected array was null"); + if (actuals == null) + fail(header + "actual array was null"); + if (actuals.length != expecteds.length) + fail(header + "array lengths differed, expected.length=" + expecteds.length + " actual.length=" + actuals.length); + + for (int i= 0; i < expecteds.length; i++) { + Object o1= expecteds[i]; + Object o2= actuals[i]; + if (o1.getClass().isArray() && o2.getClass().isArray()) { + Object[] expected= (Object[]) o1; + Object[] actual= (Object[]) o2; + assertEquals(header + "arrays first differed at element " + i + ";", expected, actual); + } else + assertEquals(header + "arrays first differed at element [" + i + "];", o1, o2); + } + } + + /** + * Asserts that two object arrays are equal. If they are not, an + * AssertionError is thrown. + */ + public static void assertEquals(Object[] expecteds, Object[] actuals) { + assertEquals(null, expecteds, actuals); + } + + /** + * Asserts that two doubles are equal to within a positive delta. If they + * are not, an AssertionError is thrown with the given message. If the + * expected value is infinity then the delta value is ignored. NaNs are + * considered equal: + * assertEquals(Double.NaN, Double.NaN, *) passes + */ + static public void assertEquals(String message, double expected, double actual, double delta) { + if (Double.compare(expected, actual) == 0) + return; + if (!(Math.abs(expected - actual) <= delta)) + failNotEquals(message, new Double(expected), new Double(actual)); + } + + /** + * Asserts that two doubles are equal to within a positive delta. If they + * are not, an AssertionError is thrown. If the + * expected value is infinity then the delta value is ignored.NaNs are + * considered equal: + * assertEquals(Double.NaN, Double.NaN, *) passes + */ + static public void assertEquals(double expected, double actual, double delta) { + assertEquals(null, expected, actual, delta); + } + + /** + * Asserts that two floats are equal to within a positive delta. If they + * are not, an AssertionError is thrown with the given message. If the + * expected value is infinity then the delta value is ignored.NaNs are + * considered equal: + * assertEquals(Float.NaN, Float.NaN, *) passes + */ + static public void assertEquals(String message, float expected, float actual, float delta) { + if (Float.compare(expected, actual) == 0) + return; + if (!(Math.abs(expected - actual) <= delta)) + failNotEquals(message, new Float(expected), new Float(actual)); + } + + /** + * Asserts that two floats are equal to within a positive delta. If they + * are not, an AssertionError is thrown. If the + * expected value is infinity then the delta value is ignored.NaNs are + * considered equal: + * assertEquals(Float.NaN, Float.NaN, *) passes + */ + static public void assertEquals(float expected, float actual, float delta) { + assertEquals(null, expected, actual, delta); + } + + /** + * Asserts that an object isn't null. If it is an AssertionError is + * thrown with the given message. + */ + static public void assertNotNull(String message, Object object) { + assertTrue(message, object != null); + } + + /** + * Asserts that an object isn't null. If it is an AssertionError is + * thrown. + */ + static public void assertNotNull(Object object) { + assertNotNull(null, object); + } + + /** + * Asserts that an object is null. If it is not, an AssertionError is + * thrown with the given message. + */ + static public void assertNull(String message, Object object) { + assertTrue(message, object == null); + } + + /** + * Asserts that an object is null. If it isn't an AssertionError is + * thrown. + */ + static public void assertNull(Object object) { + assertNull(null, object); + } + + /** + * Asserts that two objects refer to the same object. If they are not, an + * AssertionError is thrown with the given message. + */ + static public void assertSame(String message, Object expected, Object actual) { + if (expected == actual) + return; + failNotSame(message, expected, actual); + } + + /** + * Asserts that two objects refer to the same object. If they are not the + * same, an AssertionError is thrown. + */ + static public void assertSame(Object expected, Object actual) { + assertSame(null, expected, actual); + } + + /** + * Asserts that two objects do not refer to the same object. If they do + * refer to the same object, an AssertionError is thrown with the given + * message. + */ + static public void assertNotSame(String message, Object expected, Object actual) { + if (expected == actual) + failSame(message); + } + + /** + * Asserts that two objects do not refer to the same object. If they do + * refer to the same object, an AssertionError is thrown. + */ + static public void assertNotSame(Object expected, Object actual) { + assertNotSame(null, expected, actual); + } + + static private void failSame(String message) { + String formatted= ""; + if (message != null) + formatted= message + " "; + fail(formatted + "expected not same"); + } + + static private void failNotSame(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message + " "; + fail(formatted + "expected same:<" + expected + "> was not:<" + actual + ">"); + } + + static private void failNotEquals(String message, Object expected, Object actual) { + fail(format(message, expected, actual)); + } + + static String format(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message + " "; + return formatted + "expected:<" + expected + "> but was:<" + actual + ">"; + } + +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Before.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Before.java new file mode 100644 index 0000000000..72e0e3beb2 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Before.java @@ -0,0 +1,13 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Before { +} + diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/BeforeClass.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/BeforeClass.java new file mode 100644 index 0000000000..6334ab45b2 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/BeforeClass.java @@ -0,0 +1,11 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface BeforeClass { +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/ComparisonFailure.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/ComparisonFailure.java new file mode 100644 index 0000000000..77f9ea6f5f --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/ComparisonFailure.java @@ -0,0 +1,124 @@ +package org.litejunit.v3; + +/** + * Thrown when an assertEquals(String, String) fails. Create and throw + * a ComparisonFailure manually if you want to show users the difference between two complex + * strings. + * + * Inspired by a patch from Alex Chaffee (alex@purpletech.com) + */ +public class ComparisonFailure extends AssertionError { + private static final int MAX_CONTEXT_LENGTH= 20; + private static final long serialVersionUID= 1L; + + private String fExpected; + private String fActual; + + /** + * Constructs a comparison failure. + * @param message the identifying message or null + * @param expected the expected string value + * @param actual the actual string value + */ + public ComparisonFailure (String message, String expected, String actual) { + super (message); + fExpected= expected; + fActual= actual; + } + + /** + * Returns "..." in place of common prefix and "..." in + * place of common suffix between expected and actual. + * + * @see java.lang.Throwable#getMessage() + */ + @Override + public String getMessage() { + return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage()); + } + + /** + * Returns the actual value + * @return the actual string value + */ + public String getActual() { + return fActual; + } + /** + * Returns the expected value + * @return the expected string value + */ + public String getExpected() { + return fExpected; + } + + private static class ComparisonCompactor { + private static final String ELLIPSIS= "..."; + private static final String DELTA_END= "]"; + private static final String DELTA_START= "["; + + private int fContextLength; + private String fExpected; + private String fActual; + private int fPrefix; + private int fSuffix; + + public ComparisonCompactor(int contextLength, String expected, String actual) { + fContextLength= contextLength; + fExpected= expected; + fActual= actual; + } + + public String compact(String message) { + if (fExpected == null || fActual == null || areStringsEqual()) + return Assert.format(message, fExpected, fActual); + + findCommonPrefix(); + findCommonSuffix(); + String expected= compactString(fExpected); + String actual= compactString(fActual); + return Assert.format(message, expected, actual); + } + + private String compactString(String source) { + String result= DELTA_START + source.substring(fPrefix, source.length() - fSuffix + 1) + DELTA_END; + if (fPrefix > 0) + result= computeCommonPrefix() + result; + if (fSuffix > 0) + result= result + computeCommonSuffix(); + return result; + } + + private void findCommonPrefix() { + fPrefix= 0; + int end= Math.min(fExpected.length(), fActual.length()); + for (; fPrefix < end; fPrefix++) { + if (fExpected.charAt(fPrefix) != fActual.charAt(fPrefix)) + break; + } + } + + private void findCommonSuffix() { + int expectedSuffix= fExpected.length() - 1; + int actualSuffix= fActual.length() - 1; + for (; actualSuffix >= fPrefix && expectedSuffix >= fPrefix; actualSuffix--, expectedSuffix--) { + if (fExpected.charAt(expectedSuffix) != fActual.charAt(actualSuffix)) + break; + } + fSuffix= fExpected.length() - expectedSuffix; + } + + private String computeCommonPrefix() { + return (fPrefix > fContextLength ? ELLIPSIS : "") + fExpected.substring(Math.max(0, fPrefix - fContextLength), fPrefix); + } + + private String computeCommonSuffix() { + int end= Math.min(fExpected.length() - fSuffix + 1 + fContextLength, fExpected.length()); + return fExpected.substring(fExpected.length() - fSuffix + 1, end) + (fExpected.length() - fSuffix + 1 < fExpected.length() - fContextLength ? ELLIPSIS : ""); + } + + private boolean areStringsEqual() { + return fExpected.equals(fActual); + } + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Ignore.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Ignore.java new file mode 100644 index 0000000000..1652ac2431 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Ignore.java @@ -0,0 +1,31 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Sometimes you want to temporarily disable a test. Methods annotated with @Test + * that are also annotated with @Ignore will not be executed as tests. Native JUnit 4 test runners + * should report the number of ignored tests along with the number of tests that ran and the + * number of tests that failed. + *

+ * For example:
+ * + *   @Ignore @Test public void something() { ...
+ *
+ * @Ignore takes an optional default parameter if you want to record why a test is being ignored:
+ * + *   @Ignore("not ready yet") @Test public void something() { ...
+ *
+ * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Ignore { + /** + * The optional reason why the test is ignored. + */ + String value() default ""; +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Test.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Test.java new file mode 100644 index 0000000000..f390d10671 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/Test.java @@ -0,0 +1,62 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * The Test annotation tells JUnit that the public void method + * to which it is attached can be run as a test case. To run the method, + * JUnit first constructs a fresh instance of the class then invokes the + * annotated method. Any exceptions thrown by the test will be reported + * by JUnit as a failure. If no exceptions are thrown, the test is assumed + * to have succeeded. + *

+ * A simple test looks like this:
+ * + * public class Example {
+ *   @Test public void method() {
+ *     System.out.println("Hello");
+ *   }
+ * } + *
+ *

+ * The Test annotation supports two optional parameters. + * The first, expected, declares that a test method should throw + * an exception. If it doesn't throw an exception or if it throws a different exception + * than the one declared, the test fails. For example, the following test succeeds:
+ * + *   @Test(expected=IndexOutOfBoundsException.class) public void outOfBounds() {
+ *     new ArrayList<Object>().get(1);
+ *   }
+ *
+ *

+ * The second optional parameter, timeout, causes a test to fail if it takes longer than a specified + * amount of clock time (measured in milliseconds). The following test fails:
+ * + *   @Test(timeout=100) public void infinity() {
+ *     for(;;);
+ *   }
+ *
+ */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Test { + static class None extends Throwable { + private static final long serialVersionUID= 1L; + private None() { + } + } + + /** + * Optionally specify expected, a Throwable, to cause a test method to succeed iff + * an exception of the specified class is thrown by the method. + */ + Class expected() default None.class; + + /** + * Optionally specify timeout in milliseconds to cause a test method to fail if it + * takes longer than that number of milliseconds.*/ + long timeout() default 0L; +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/Failure.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/Failure.java new file mode 100644 index 0000000000..2eb516b75f --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/Failure.java @@ -0,0 +1,78 @@ +package org.litejunit.v3.notification; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.litejunit.v3.runner.Description; + + +/** + * A Failure holds a description of the failed test and the + * exception that was thrown while running it. In most cases the Description + * will be of a single test. However, if problems are encountered while constructing the + * test (for example, if a @BeforeClass method is not static), it may describe + * something other than a single test. + */ +public class Failure { + private final Description fDescription; + private Throwable fThrownException; + + /** + * Constructs a Failure with the given description and exception. + * @param description a Description of the test that failed + * @param thrownException the exception that was thrown while running the test + */ + public Failure(Description description, Throwable thrownException) { + fThrownException = thrownException; + fDescription= description; + } + + /** + * @return a user-understandable label for the test + */ + public String getTestHeader() { + return fDescription.getDisplayName(); + } + + /** + * @return the raw description of the context of the failure. + */ + public Description getDescription() { + return fDescription; + } + + /** + * @return the exception thrown + */ + + public Throwable getException() { + return fThrownException; + } + + @Override + public String toString() { + StringBuffer buffer= new StringBuffer(); + buffer.append(getTestHeader() + ": "+fThrownException.getMessage()); + return buffer.toString(); + } + + /** + * Convenience method + * @return the printed form of the exception + */ + public String getTrace() { + StringWriter stringWriter= new StringWriter(); + PrintWriter writer= new PrintWriter(stringWriter); + getException().printStackTrace(writer); + StringBuffer buffer= stringWriter.getBuffer(); + return buffer.toString(); + } + + /** + * Convenience method + * @return the message of the thrown exception + */ + public String getMessage() { + return getException().getMessage(); + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/RunListener.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/RunListener.java new file mode 100644 index 0000000000..aa30aa9abf --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/RunListener.java @@ -0,0 +1,53 @@ +package org.litejunit.v3.notification; + +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Result; + + +public class RunListener { + + /** + * Called before any tests have been run. + * @param description describes the tests to be run + */ + public void testRunStarted(Description description) throws Exception { + } + + /** + * Called when all tests have finished + * @param result the summary of the test run, including all the tests that failed + */ + public void testRunFinished(Result result) throws Exception { + } + + /** + * Called when an atomic test is about to be started. + * @param description the description of the test that is about to be run (generally a class and method name) + */ + public void testStarted(Description description) throws Exception { + } + + /** + * Called when an atomic test has finished, whether the test succeeds or fails. + * @param description the description of the test that just ran + */ + public void testFinished(Description description) throws Exception { + } + + /** + * Called when an atomic test fails. + * @param failure describes the test that failed and the exception that was thrown + */ + public void testFailure(Failure failure) throws Exception { + } + + /** + * Called when a test will not be run, generally because a test method is annotated with @Ignored. + * @param description describes the test that will not be run + */ + public void testIgnored(Description description) throws Exception { + } + +} + + diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/RunNotifier.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/RunNotifier.java new file mode 100644 index 0000000000..d7d16e0677 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/RunNotifier.java @@ -0,0 +1,139 @@ +package org.litejunit.v3.notification; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Result; + + + +/** + * If you write custom runners, you may need to notify JUnit of your progress running tests. + * Do this by invoking the RunNotifier passed to your implementation of + * Runner.run(RunNotifier notifier). Future evolution of this class is likely to + * move fireTestRunStarted() and fireTestRunFinished() + * to a separate class since they should only be called once per run. + */ +public class RunNotifier { + private List fListeners= new ArrayList(); + private boolean fPleaseStop= false; + + /** Internal use only + */ + public void addListener(RunListener listener) { + fListeners.add(listener); + } + + /** Internal use only + */ + public void removeListener(RunListener listener) { + fListeners.remove(listener); + } + + private abstract class SafeNotifier { + void run() { + for (Iterator all= fListeners.iterator(); all.hasNext();) { + try { + notifyListener(all.next()); + } catch (Exception e) { + all.remove(); // Remove the offending listener first to avoid an infinite loop + fireTestFailure(new Failure(Description.TEST_MECHANISM, e)); + } + } + } + + abstract protected void notifyListener(RunListener each) throws Exception; + } + + /** + * Do not invoke. + */ + public void fireTestRunStarted(final Description description) { + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testRunStarted(description); + }; + }.run(); + } + + /** + * Do not invoke. + */ + public void fireTestRunFinished(final Result result) { + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testRunFinished(result); + }; + }.run(); + } + + /** + * Invoke to tell listeners that an atomic test is about to start. + * @param description the description of the atomic test (generally a class and method name) + * @throws StoppedByUserException thrown if a user has requested that the test run stop + */ + public void fireTestStarted(final Description description) throws StoppedByUserException { + if (fPleaseStop) + throw new StoppedByUserException(); + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testStarted(description); + }; + }.run(); + } + + /** + * Invoke to tell listeners that an atomic test failed. + * @param failure the description of the test that failed and the exception thrown + */ + public void fireTestFailure(final Failure failure) { + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testFailure(failure); + }; + }.run(); + } + + /** + * Invoke to tell listeners that an atomic test was ignored. + * @param description the description of the ignored test + */ + public void fireTestIgnored(final Description description) { + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testIgnored(description); + }; + }.run(); + } + + /** + * Invoke to tell listeners that an atomic test finished. Always invoke fireTestFinished() + * if you invoke fireTestStarted() as listeners are likely to expect them to come in pairs. + * @param description the description of the test that finished + */ + public void fireTestFinished(final Description description) { + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testFinished(description); + }; + }.run(); + } + + /** + * Ask that the tests run stop before starting the next test. Phrased politely because + * the test currently running will not be interrupted. It seems a little odd to put this + * functionality here, but the RunNotifier is the only object guaranteed + * to be shared amongst the many runners involved. + */ + public void pleaseStop() { + fPleaseStop= true; + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/StoppedByUserException.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/StoppedByUserException.java new file mode 100644 index 0000000000..829462445c --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/notification/StoppedByUserException.java @@ -0,0 +1,11 @@ +package org.litejunit.v3.notification; + +/** + * Thrown when a user has requested that the test run stop. Writers of + * test running GUIs should be prepared to catch a StoppedByUserException. + * + * @see org.junit.runner.notification.RunNotifier + */ +public class StoppedByUserException extends RuntimeException { + private static final long serialVersionUID= 1L; +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/requests/ClassRequest.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/requests/ClassRequest.java new file mode 100644 index 0000000000..315bbb6482 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/requests/ClassRequest.java @@ -0,0 +1,48 @@ +/** + * + */ +package org.litejunit.v3.requests; + +import java.lang.reflect.Constructor; + +import org.litejunit.v3.runner.Request; +import org.litejunit.v3.runner.Runner; +import org.litejunit.v3.runners.TestClassRunner; + + +public class ClassRequest extends Request { + private final Class fTestClass; + + public ClassRequest(Class each) { + fTestClass= each; + } + + @Override + public Runner getRunner() { + Class runnerClass= getRunnerClass(fTestClass); + try { + Constructor constructor= runnerClass.getConstructor(Class.class); // TODO good error message if no such constructor + Runner runner= (Runner) constructor + .newInstance(new Object[] { fTestClass }); + return runner; + } catch (Exception e) { + return null; + //return Request.errorReport(fTestClass, e).getRunner(); + } + } + + Class getRunnerClass(Class testClass) { + /*RunWith annotation= testClass.getAnnotation(RunWith.class); + if (annotation != null) { + return annotation.value(); + } else if (isPre4Test(testClass)) { + return OldTestClassRunner.class; + } else {*/ + return TestClassRunner.class; + /*}*/ + } + + /*boolean isPre4Test(Class testClass) { + return junit.framework.TestCase.class.isAssignableFrom(testClass); + }*/ +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Description.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Description.java new file mode 100644 index 0000000000..db3610fd3f --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Description.java @@ -0,0 +1,127 @@ +package org.litejunit.v3.runner; + +import java.util.ArrayList; + +/** + * A Description describes a test which is to be run or has been run. Descriptions can + * be atomic (a single test) or compound (containing children tests). Descriptions are used + * to provide feedback about the tests that are about to run (for example, the tree view + * visible in many IDEs) or tests that have been run (for example, the failures view).

+ * Descriptions are implemented as a single class rather than a Composite because + * they are entirely informational. They contain no logic aside from counting their tests.

+ * In the past, we used the raw junit.framework.TestCases and junit.framework.TestSuites + * to display the tree of tests. This was no longer viable in JUnit 4 because atomic tests no longer have a superclass below Object. + * We needed a way to pass a class and name together. Description emerged from this. + * + * @see org.junit.runner.Request + * @see org.junit.runner.Runner + */ +public class Description { + + /** + * Create a Description named name. + * Generally, you will add children to this Description. + * @param name The name of the Description + * @return A Description named name + */ + public static Description createSuiteDescription(String name) { + return new Description(name); + } + + /** + * Create a Description of a single test named name in the class clazz. + * Generally, this will be a leaf Description. + * @param clazz The class of the test + * @param name The name of the test (a method name for test annotated with @Test) + * @return A Description named name + */ + public static Description createTestDescription(Class clazz, String name) { + return new Description(String.format("%s(%s)", name, clazz.getName())); + } + + /** + * Create a generic Description that says there are tests in testClass. + * This is used as a last resort when you cannot precisely describe the individual tests in the class. + * @param testClass A Class containing tests + * @return A Description of testClass + */ + public static Description createSuiteDescription(Class testClass) { + return new Description(testClass.getName()); + } + + public static Description TEST_MECHANISM = new Description("Test mechanism"); + private final ArrayList fChildren= new ArrayList(); + private final String fDisplayName; + + //TODO we seem to be using the static factories exclusively + private Description(final String displayName) { + fDisplayName= displayName; + } + + /** + * @return a user-understandable label + */ + public String getDisplayName() { + return fDisplayName; + } + + /** + * Add description as a child of the receiver. + * @param description The soon-to-be child. + */ + public void addChild(Description description) { + getChildren().add(description); + } + + /** + * @return the receiver's children, if any + */ + public ArrayList getChildren() { + return fChildren; + } + + /** + * @return true if the receiver is a suite + */ + public boolean isSuite() { + return !isTest(); + } + + /** + * @return true if the receiver is an atomic test + */ + public boolean isTest() { + return getChildren().isEmpty(); + } + + /** + * @return the total number of atomic tests in the receiver + */ + public int testCount() { + if (isTest()) + return 1; + int result= 0; + for (Description child : getChildren()) + result+= child.testCount(); + return result; + } + + @Override + public int hashCode() { + return getDisplayName().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Description)) + return false; + Description d = (Description) obj; + return getDisplayName().equals(d.getDisplayName()) + && getChildren().equals(d.getChildren()); + } + + @Override + public String toString() { + return getDisplayName(); + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/JUnitCore.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/JUnitCore.java new file mode 100644 index 0000000000..662f5ffd0c --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/JUnitCore.java @@ -0,0 +1,167 @@ +package org.litejunit.v3.runner; + +import java.util.ArrayList; +import java.util.List; + +import org.litejunit.v3.notification.RunListener; +import org.litejunit.v3.notification.RunNotifier; +import org.litejunit.v3.runners.InitializationError; +import org.litejunit.v3.runners.TestClassRunner; +import org.litejunit.v3.runners.TextListener; + + + +/** + * JUnitCore is a facade for running tests. It supports running JUnit 4 tests, + * JUnit 3.8.2 tests, and mixtures. To run tests from the command line, run java org.junit.runner.JUnitCore TestClass1 TestClass2 .... + * For one-shot test runs, use the static method runClasses(Class... classes) + * . If you want to add special listeners, + * create an instance of JUnitCore first and use it to run the tests. + * + * @see org.junit.runner.Result + * @see org.junit.runner.notification.RunListener + * @see org.junit.runner.Request + */ +public class JUnitCore { + + private RunNotifier notifier; + + /** + * Create a new JUnitCore to run tests. + */ + public JUnitCore() { + notifier= new RunNotifier(); + } + + /** + * Run the tests contained in the classes named in the args. + * If all tests run successfully, exit with a status of 0. Otherwise exit with a status of 1. + * Write feedback while tests are running and write + * stack traces for all failed tests after the tests all complete. + * @param args names of classes in which to find tests to run + */ + /*public static void main(String... args) { + Class clz = null; + try { + clz = Class.forName(args[0]); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + return; + } + + Request request = Request.aClass(clz); + + new JUnitCore().run(request); + + Result result= new JUnitCore().runMain(args); + killAllThreads(result); + }*/ + public static void runClass(Class clz){ + try { + TestClassRunner runner = new TestClassRunner(clz); + JUnitCore core = new JUnitCore(); + core.addListener(new TextListener()); + Result result = core.run(runner); + + } catch (InitializationError e) { + + e.printStackTrace(); + } + + } + /*private static void killAllThreads(Result result) { + System.exit(result.wasSuccessful() ? 0 : 1); + }*/ + + /** + * Run the tests contained in classes. Write feedback while the tests + * are running and write stack traces for all failed tests after all tests complete. This is + * similar to main(), but intended to be used programmatically. + * @param classes Classes in which to find tests + * @return a Result describing the details of the test run and the failed tests. + */ + /*public static Result runClasses(Class... classes) { + return new JUnitCore().run(classes); + }*/ + + /** + * Do not use. Testing purposes only. + */ + /*public Result runMain(String... args) { + + List classes= new ArrayList(); + for (String each : args) + try { + classes.add(Class.forName(each)); + } catch (ClassNotFoundException e) { + System.out.println("Could not find class: " + each); + } + RunListener listener= new TextListener(); + addListener(listener); + return run(classes.toArray(new Class[0])); + }*/ + + + + /** + * Run all the tests in classes. + * @param classes the classes containing tests + * @return a Result describing the details of the test run and the failed tests. + */ + /*public Result run(Class... classes) { + return run(Request.classes("All", classes)); + }*/ + + /** + * Run all the tests contained in request. + * @param request the request describing tests + * @return a Result describing the details of the test run and the failed tests. + */ + /*public Result run(Request request) { + return run(request.getRunner()); + }*/ + + /** + * Run all the tests contained in JUnit 3.8.x test. Here for backward compatibility. + * @param test the old-style test + * @return a Result describing the details of the test run and the failed tests. + */ + /*public Result run(junit.framework.Test test) { + return run(new OldTestClassRunner(test)); + } + */ + /** + * Do not use. Testing purposes only. + */ + public Result run(Runner runner) { + Result result= new Result(); + RunListener listener= result.createListener(); + addListener(listener); + + try { + notifier.fireTestRunStarted(runner.getDescription()); + runner.run(notifier); + notifier.fireTestRunFinished(result); + } finally { + removeListener(listener); + } + return result; + } + + /** + * Add a listener to be notified as the tests run. + * @param listener the listener + * @see org.junit.runner.notification.RunListener + */ + public void addListener(RunListener listener) { + notifier.addListener(listener); + } + + /** + * Remove a listener. + * @param listener the listener to remove + */ + public void removeListener(RunListener listener) { + notifier.removeListener(listener); + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Request.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Request.java new file mode 100644 index 0000000000..02db808bb7 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Request.java @@ -0,0 +1,86 @@ +package org.litejunit.v3.runner; + +import org.litejunit.v3.requests.ClassRequest; + + + +/** + * A Request is an abstract description of tests to be run. Older versions of + * JUnit did not need such a concept--tests to be run were described either by classes containing + * tests or a tree of Tests. However, we want to support filtering and sorting, + * so we need a more abstract specification than the tests themselves and a richer + * specification than just the classes. + *

+ * The flow when JUnit runs tests is that a Request specifies some tests to be run -> + * a Runner is created for each class implied by the Request -> the Runner + * returns a detailed Description which is a tree structure of the tests to be run. + */ +public abstract class Request { + /** + * Create a Request that, when processed, will run a single test. + * This is done by filtering out all other tests. This method is used to support rerunning + * single tests. + * @param clazz the class of the test + * @param methodName the name of the test + * @return a Request that will cause a single test be run + */ + /*public static Request method(Class clazz, String methodName) { + Description method= Description.createTestDescription(clazz, methodName); + return Request.aClass(clazz).filterWith(method); + }*/ + + /** + * Create a Request that, when processed, will run all the tests + * in a class. The odd name is necessary because class is a reserved word. + * @param clazz the class containing the tests + * @return a Request that will cause all tests in the class to be run + */ + public static Request aClass(Class clazz) { + return new ClassRequest(clazz); + } + + /** + * Create a Request that, when processed, will run all the tests + * in a set of classes. + * @param collectionName a name to identify this suite of tests + * @param classes the classes containing the tests + * @return a Request that will cause all tests in the classes to be run + */ + /*public static Request classes(String collectionName, Class... classes) { + return new ClassesRequest(collectionName, classes); + }*/ + + /*public static Request errorReport(Class klass, Throwable cause) { + return new ErrorReportingRequest(klass, cause); + }*/ + + public abstract Runner getRunner(); + + /*public Request filterWith(Filter filter) { + return new FilterRequest(this, filter); + } + + public Request filterWith(final Description desiredDescription) { + return filterWith(new Filter() { + @Override + public boolean shouldRun(Description description) { + // TODO: test for equality even if we have children? + if (description.isTest()) + return desiredDescription.equals(description); + for (Description each : description.getChildren()) + if (shouldRun(each)) + return true; + return false; + } + + @Override + public String describe() { + return String.format("Method %s", desiredDescription.getDisplayName()); + } + }); + } + + public Request sortWith(Comparator comparator) { + return new SortingRequest(this, comparator); + }*/ +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Result.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Result.java new file mode 100644 index 0000000000..591d083f71 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Result.java @@ -0,0 +1,98 @@ +package org.litejunit.v3.runner; + +import java.util.ArrayList; +import java.util.List; + +import org.litejunit.v3.notification.Failure; +import org.litejunit.v3.notification.RunListener; + + +/** + * A Result collects and summarizes information from running multiple + * tests. Since tests are expected to run correctly, successful tests are only noted in + * the count of tests that ran. + */ +public class Result { + private int fCount= 0; + private int fIgnoreCount= 0; + private List fFailures= new ArrayList(); + private long fRunTime= 0; + private long fStartTime; + + /** + * @return the number of tests run + */ + public int getRunCount() { + return fCount; + } + + /** + * @return the number of tests that failed during the run + */ + public int getFailureCount() { + return fFailures.size(); + } + + /** + * @return the number of milliseconds it took to run the entire suite to run + */ + public long getRunTime() { + return fRunTime; + } + + /** + * @return the Failures describing tests that failed and the problems they encountered + */ + public List getFailures() { + return fFailures; + } + + /** + * @return the number of tests ignored during the run + */ + public int getIgnoreCount() { + return fIgnoreCount; + } + + /** + * @return true if all tests succeeded + */ + public boolean wasSuccessful() { + return getFailureCount() == 0; + } + + private class Listener extends RunListener { + @Override + public void testRunStarted(Description description) throws Exception { + fStartTime= System.currentTimeMillis(); + } + + @Override + public void testRunFinished(Result result) throws Exception { + long endTime= System.currentTimeMillis(); + fRunTime+= endTime - fStartTime; + } + + @Override + public void testStarted(Description description) throws Exception { + fCount++; + } + + @Override + public void testFailure(Failure failure) throws Exception { + fFailures.add(failure); + } + + @Override + public void testIgnored(Description description) throws Exception { + fIgnoreCount++; + } + } + + /** + * Internal use only. + */ + public RunListener createListener() { + return new Listener(); + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/ResultPrinter.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/ResultPrinter.java new file mode 100644 index 0000000000..de8a41717c --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/ResultPrinter.java @@ -0,0 +1,72 @@ +package org.litejunit.v3.runner; + +import java.io.PrintStream; +import java.text.NumberFormat; + +import org.litejunit.v3.notification.Failure; + +public class ResultPrinter { + + private final PrintStream fWriter; + + public ResultPrinter(){ + fWriter = System.out; + } + + public void print(Result result) { + printHeader(result.getRunTime()); + printFailures(result); + printFooter(result); + } + protected void printHeader(long runTime) { + getWriter().println(); + getWriter().println("Time: " + elapsedTimeAsString(runTime)); + } + + protected void printFailures(Result result) { + if (result.getFailureCount() == 0) + return; + if (result.getFailureCount() == 1) + getWriter().println("There was " + result.getFailureCount() + " failure:"); + else + getWriter().println("There were " + result.getFailureCount() + " failures:"); + int i= 1; + for (Failure each : result.getFailures()) + printFailure(each, i++); + } + + protected void printFailure(Failure failure, int count) { + printFailureHeader(failure, count); + printFailureTrace(failure); + } + + protected void printFailureHeader(Failure failure, int count) { + getWriter().println(count + ") " + failure.getTestHeader()); + } + + protected void printFailureTrace(Failure failure) { + getWriter().print(failure.getTrace()); + } + + protected void printFooter(Result result) { + if (result.wasSuccessful()) { + getWriter().println(); + getWriter().print("OK"); + getWriter().println(" (" + result.getRunCount() + " test" + (result.getRunCount() == 1 ? "" : "s") + ")"); + + } else { + getWriter().println(); + getWriter().println("FAILURES!!!"); + getWriter().println("Tests run: " + result.getRunCount() + ", Failures: " + result.getFailureCount()); + } + getWriter().println(); + } + protected String elapsedTimeAsString(long runTime) { + return NumberFormat.getInstance().format((double) runTime / 1000); + } + private PrintStream getWriter() { + return fWriter; + } + + +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/RunWith.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/RunWith.java new file mode 100644 index 0000000000..c8ed3d4ff5 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/RunWith.java @@ -0,0 +1,24 @@ +package org.litejunit.v3.runner; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +//TODO add simple exampel +/** + * When you annotate a class with @RunWith, JUnit will invoke + * the class it references to run the tests in that class instead of the runner + * built into JUnit. We added this feature late in development. While it + * seems powerful we expect the runner API to change as we learn how people + * really use it. Some of the classes that are currently internal will likely be refined + * and become public. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface RunWith { + /** + * @return a Runner class (must have a constructor that takes a single Class to run) + */ + Class value(); +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Runner.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Runner.java new file mode 100644 index 0000000000..57ef0faf97 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Runner.java @@ -0,0 +1,24 @@ +package org.litejunit.v3.runner; + +import org.litejunit.v3.notification.RunNotifier; + + +public abstract class Runner { + /** + * @return a Description showing the tests to be run by the receiver + */ + public abstract Description getDescription(); + + /** + * Run the tests for this runner. + * @param notifier will be notified of events while tests are being run--tests being started, finishing, and failing + */ + public abstract void run(RunNotifier notifier); + + /** + * @return the number of tests to be run by the receiver + */ + public int testCount() { + return getDescription().testCount(); + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/BeforeAndAfterRunner.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/BeforeAndAfterRunner.java new file mode 100644 index 0000000000..1bcbf40d79 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/BeforeAndAfterRunner.java @@ -0,0 +1,76 @@ +package org.litejunit.v3.runners; + +import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; + +public abstract class BeforeAndAfterRunner { + private static class FailedBefore extends Exception { + private static final long serialVersionUID= 1L; + } + + private final Class beforeAnnotation; + + private final Class afterAnnotation; + + private TestIntrospector testIntrospector; + + private Object test; + + public BeforeAndAfterRunner(Class testClass, + Class beforeAnnotation, + Class afterAnnotation, + Object test) { + this.beforeAnnotation= beforeAnnotation; + this.afterAnnotation= afterAnnotation; + this.testIntrospector= new TestIntrospector(testClass); + this.test= test; + } + + public void runProtected() { + try { + runBefores(); + runUnprotected(); + } catch (FailedBefore e) { + } finally { + runAfters(); + } + } + + protected abstract void runUnprotected(); + + protected abstract void addFailure(Throwable targetException); + + // Stop after first failed @Before + private void runBefores() throws FailedBefore { + try { + List befores= testIntrospector.getTestMethods(beforeAnnotation); + for (Method before : befores) + invokeMethod(before); + } catch (InvocationTargetException e) { + addFailure(e.getTargetException()); + throw new FailedBefore(); + } catch (Throwable e) { + addFailure(e); + throw new FailedBefore(); + } + } + + // Try to run all @Afters regardless + private void runAfters() { + List afters= testIntrospector.getTestMethods(afterAnnotation); + for (Method after : afters) + try { + invokeMethod(after); + } catch (InvocationTargetException e) { + addFailure(e.getTargetException()); + } catch (Throwable e) { + addFailure(e); // Untested, but seems impossible + } + } + + private void invokeMethod(Method method) throws Exception { + method.invoke(test); + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/InitializationError.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/InitializationError.java new file mode 100644 index 0000000000..76e21d02e4 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/InitializationError.java @@ -0,0 +1,25 @@ +package org.litejunit.v3.runners; + +import java.util.Arrays; +import java.util.List; + +public class InitializationError extends Exception { + private static final long serialVersionUID= 1L; + private final List fErrors; + + public InitializationError(List errors) { + fErrors= errors; + } + + public InitializationError(Throwable... errors) { + this(Arrays.asList(errors)); + } + + public InitializationError(String string) { + this(new Exception(string)); + } + + public List getCauses() { + return fErrors; + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestClassMethodsRunner.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestClassMethodsRunner.java new file mode 100644 index 0000000000..adf3b9c40d --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestClassMethodsRunner.java @@ -0,0 +1,100 @@ +package org.litejunit.v3.runners; + +import java.lang.reflect.Method; +import java.util.List; + +import org.litejunit.v3.Test; +import org.litejunit.v3.notification.Failure; +import org.litejunit.v3.notification.RunNotifier; +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Runner; + + + +public class TestClassMethodsRunner extends Runner { + private final List testMethods; + private final Class testClass; + + public TestClassMethodsRunner(Class klass) { + testClass= klass; + testMethods= new TestIntrospector(testClass).getTestMethods(Test.class); + } + + @Override + public void run(RunNotifier notifier) { + /*if (testMethods.isEmpty()) + testAborted(notifier, getDescription());*/ + for (Method method : testMethods) + invokeTestMethod(method, notifier); + } + + /*private void testAborted(RunNotifier notifier, Description description) { + // TODO: duped! + // TODO: envious + notifier.fireTestStarted(description); + notifier.fireTestFailure(new Failure(description, new Exception("No runnable methods"))); + notifier.fireTestFinished(description); + }*/ + + @Override + public Description getDescription() { + Description spec= Description.createSuiteDescription(getName()); + List testMethods= this.testMethods; + for (Method method : testMethods) + spec.addChild(methodDescription(method)); + return spec; + } + + protected String getName() { + return getTestClass().getName(); + } + + protected Object createTest() throws Exception { + return getTestClass().getConstructor().newInstance(); + } + + protected void invokeTestMethod(Method method, RunNotifier notifier) { + Object test; + try { + test= createTest(); + } catch (Exception e) { + //testAborted(notifier, methodDescription(method)); + return; + } + createMethodRunner(test, method, notifier).run(); + } + + protected TestMethodRunner createMethodRunner(Object test, Method method, RunNotifier notifier) { + return new TestMethodRunner(test, method, notifier, methodDescription(method)); + } + + protected String testName(Method method) { + return method.getName(); + } + + protected Description methodDescription(Method method) { + return Description.createTestDescription(getTestClass(), testName(method)); + } + + /*public void filter(Filter filter) throws NoTestsRemainException { + for (Iterator iter= fTestMethods.iterator(); iter.hasNext();) { + Method method= (Method) iter.next(); + if (!filter.shouldRun(methodDescription(method))) + iter.remove(); + } + if (fTestMethods.isEmpty()) + throw new NoTestsRemainException(); + } + + public void sort(final Sorter sorter) { + Collections.sort(fTestMethods, new Comparator() { + public int compare(Method o1, Method o2) { + return sorter.compare(methodDescription(o1), methodDescription(o2)); + } + }); + }*/ + + protected Class getTestClass() { + return testClass; + } +} \ No newline at end of file diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestClassRunner.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestClassRunner.java new file mode 100644 index 0000000000..84c2a072ef --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestClassRunner.java @@ -0,0 +1,53 @@ +package org.litejunit.v3.runners; + +import org.litejunit.v3.AfterClass; +import org.litejunit.v3.BeforeClass; +import org.litejunit.v3.notification.Failure; +import org.litejunit.v3.notification.RunNotifier; +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Runner; + +public class TestClassRunner extends Runner { + protected final Runner enclosedRunner; + private final Class testClass; + + public TestClassRunner(Class klass) throws InitializationError { + this(klass, new TestClassMethodsRunner(klass)); + } + + public TestClassRunner(Class klass, Runner runner) throws InitializationError { + testClass= klass; + enclosedRunner= runner; + + } + + + + @Override + public void run(final RunNotifier notifier) { + BeforeAndAfterRunner runner = new BeforeAndAfterRunner(getTestClass(), + BeforeClass.class, AfterClass.class, null) { + @Override + protected void runUnprotected() { + enclosedRunner.run(notifier); + } + + // TODO: looks very similar to other method of BeforeAfter, now + @Override + protected void addFailure(Throwable targetException) { + notifier.fireTestFailure(new Failure(getDescription(), targetException)); + } + }; + + runner.runProtected(); + } + + @Override + public Description getDescription() { + return enclosedRunner.getDescription(); + } + + protected Class getTestClass() { + return testClass; + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestIntrospector.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestIntrospector.java new file mode 100644 index 0000000000..1dda424d7f --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestIntrospector.java @@ -0,0 +1,82 @@ +package org.litejunit.v3.runners; + + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.litejunit.v3.Before; +import org.litejunit.v3.BeforeClass; +import org.litejunit.v3.Ignore; +import org.litejunit.v3.Test; +import org.litejunit.v3.Test.None; + + + +public class TestIntrospector { + private final Class< ?> testClass; + + public TestIntrospector(Class testClass) { + this.testClass= testClass; + } + + public List getTestMethods(Class annotationClass) { + List results= new ArrayList(); + + //for (Class eachClass : getSuperClasses(testClass)) { + Method[] methods= testClass.getDeclaredMethods(); + for (Method method : methods) { + Annotation annotation= method.getAnnotation(annotationClass); + if (annotation != null && ! isShadowed(method, results)) + results.add(method); + } + //} + if (runsTopToBottom(annotationClass)) + Collections.reverse(results); + return results; + } + + public boolean isIgnored(Method eachMethod) { + return eachMethod.getAnnotation(Ignore.class) != null; + } + + private boolean runsTopToBottom(Class< ? extends Annotation> annotation) { + return annotation.equals(Before.class) || annotation.equals(BeforeClass.class); + } + + private boolean isShadowed(Method method, List results) { + for (Method m : results) { + if (m.getName().equals(method.getName())) + return true; + } + return false; + } + + /*private List getSuperClasses(Class< ?> testClass) { + ArrayList results= new ArrayList(); + Class current= testClass; + while (current != null) { + results.add(current); + current= current.getSuperclass(); + } + return results; + }*/ + + long getTimeout(Method method) { + Test annotation= method.getAnnotation(Test.class); + long timeout= annotation.timeout(); + return timeout; + } + + Class expectedException(Method method) { + Test annotation= method.getAnnotation(Test.class); + if (annotation.expected() == None.class) + return null; + else + return annotation.expected(); + } + +} + diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestMethodRunner.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestMethodRunner.java new file mode 100644 index 0000000000..7034a4c812 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TestMethodRunner.java @@ -0,0 +1,122 @@ +package org.litejunit.v3.runners; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.litejunit.v3.After; +import org.litejunit.v3.Before; +import org.litejunit.v3.notification.Failure; +import org.litejunit.v3.notification.RunNotifier; +import org.litejunit.v3.runner.Description; + + + +public class TestMethodRunner extends BeforeAndAfterRunner { + private final Object test; + private final Method method; + private final RunNotifier notifier; + private final TestIntrospector testIntrospector; + private final Description description; + + public TestMethodRunner(Object test, Method method, RunNotifier notifier, Description description) { + super(test.getClass(), Before.class, After.class, test); + this.test= test; + this.method= method; + this.notifier= notifier; + testIntrospector= new TestIntrospector(test.getClass()); + this.description= description; + } + + public void run() { + /*if (testIntrospector.isIgnored(method)) { + notifier.fireTestIgnored(description); + return; + }*/ + notifier.fireTestStarted(description); + try { + /*long timeout= testIntrospector.getTimeout(method); + if (timeout > 0) + runWithTimeout(timeout); + else*/ + runMethod(); + } finally { + notifier.fireTestFinished(description); + } + } + + /*private void runWithTimeout(long timeout) { + ExecutorService service= Executors.newSingleThreadExecutor(); + Callable callable= new Callable() { + public Object call() throws Exception { + runMethod(); + return null; + } + }; + Future result= service.submit(callable); + service.shutdown(); + try { + boolean terminated= service.awaitTermination(timeout, + TimeUnit.MILLISECONDS); + if (!terminated) + service.shutdownNow(); + result.get(timeout, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation + } catch (TimeoutException e) { + addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); + } catch (Exception e) { + addFailure(e); + } + }*/ + + private void runMethod() { + runProtected(); + } + + @Override + protected void runUnprotected() { + try { + executeMethodBody(); + /*if (expectsException()) + addFailure(new AssertionError("Expected exception: " + expectedException().getName()));*/ + } catch (InvocationTargetException e) { + addFailure(e); + /*Throwable actual= e.getTargetException(); + if (!expectsException()) + addFailure(actual); + else if (isUnexpected(actual)) { + String message= "Unexpected exception, expected<" + expectedException().getName() + "> but was<" + + actual.getClass().getName() + ">"; + addFailure(new Exception(message, actual)); + }*/ + } catch (Throwable e) { + addFailure(e); + } + } + + protected void executeMethodBody() throws IllegalAccessException, InvocationTargetException { + method.invoke(test); + } + + @Override + protected void addFailure(Throwable e) { + notifier.fireTestFailure(new Failure(description, e)); + } + + /*private boolean expectsException() { + return expectedException() != null; + } + + private Class expectedException() { + return testIntrospector.expectedException(method); + }*/ + + /*private boolean isUnexpected(Throwable exception) { + return ! expectedException().isAssignableFrom(exception.getClass()); + }*/ +} + diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TextListener.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TextListener.java new file mode 100644 index 0000000000..53cab12ad2 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/TextListener.java @@ -0,0 +1,106 @@ +package org.litejunit.v3.runners; + +import java.io.PrintStream; +import java.text.NumberFormat; + +import org.litejunit.v3.notification.Failure; +import org.litejunit.v3.notification.RunListener; +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Result; + + + +public class TextListener extends RunListener { + + private final PrintStream writer; + + public TextListener() { + this(System.out); + } + + public TextListener(PrintStream writer) { + this.writer= writer; + } + + @Override + public void testRunFinished(Result result) { + printHeader(result.getRunTime()); + printFailures(result); + printFooter(result); + } + + @Override + public void testStarted(Description description) { + writer.append('.'); + } + + @Override + public void testFailure(Failure failure) { + writer.append('E'); + } + + @Override + public void testIgnored(Description description) { + writer.append('I'); + } + + /* + * Internal methods + */ + + private PrintStream getWriter() { + return writer; + } + + protected void printHeader(long runTime) { + getWriter().println(); + getWriter().println("Time: " + elapsedTimeAsString(runTime)); + } + + protected void printFailures(Result result) { + if (result.getFailureCount() == 0) + return; + if (result.getFailureCount() == 1) + getWriter().println("There was " + result.getFailureCount() + " failure:"); + else + getWriter().println("There were " + result.getFailureCount() + " failures:"); + int i= 1; + for (Failure each : result.getFailures()) + printFailure(each, i++); + } + + protected void printFailure(Failure failure, int count) { + printFailureHeader(failure, count); + printFailureTrace(failure); + } + + protected void printFailureHeader(Failure failure, int count) { + getWriter().println(count + ") " + failure.getTestHeader()); + } + + protected void printFailureTrace(Failure failure) { + getWriter().print(failure.getTrace()); + } + + protected void printFooter(Result result) { + if (result.wasSuccessful()) { + getWriter().println(); + getWriter().print("OK"); + getWriter().println(" (" + result.getRunCount() + " test" + (result.getRunCount() == 1 ? "" : "s") + ")"); + + } else { + getWriter().println(); + getWriter().println("FAILURES!!!"); + getWriter().println("Tests run: " + result.getRunCount() + ", Failures: " + result.getFailureCount()); + } + getWriter().println(); + } + + /** + * Returns the formatted string of the elapsed time. Duplicated from + * BaseTestRunner. Fix it. + */ + protected String elapsedTimeAsString(long runTime) { + return NumberFormat.getInstance().format((double) runTime / 1000); + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/Calculator.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/Calculator.java new file mode 100644 index 0000000000..eaf42c77a6 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/Calculator.java @@ -0,0 +1,22 @@ +package org.litejunit.v3.sample; + +public class Calculator { + + private int result = 0; + public void add(int x){ + result += x; + } + public void subtract(int x){ + result -=x; + } + + public int getResult(){ + return this.result; + } + public static void main(String[] args){ + Calculator calculator = new Calculator(); + calculator.add(10); + calculator.subtract(5); + System.out.println(calculator.getResult()); + } +} diff --git a/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/CalculatorTest.java b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/CalculatorTest.java new file mode 100644 index 0000000000..cae2673ac2 --- /dev/null +++ b/liuxin/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/CalculatorTest.java @@ -0,0 +1,48 @@ +package org.litejunit.v3.sample; + +import org.litejunit.v3.After; +import org.litejunit.v3.AfterClass; +import org.litejunit.v3.Before; +import org.litejunit.v3.BeforeClass; +import org.litejunit.v3.Test; +import org.litejunit.v3.runner.JUnitCore; +import static org.litejunit.v3.Assert.*; + +public class CalculatorTest { + + Calculator calculator =null; + @Before + public void prepare(){ + calculator = new Calculator(); + } + @After + public void clean(){ + calculator = null; + } + @Test + public void testAdd(){ + + calculator.add(10); + assertEquals(15,calculator.getResult()); + } + @Test + public void testSubtract(){ + calculator.add(10); + calculator.subtract(5); + assertEquals(5,calculator.getResult()); + } + @BeforeClass + public static void prepareGlobalResouce(){ + System.err.println("prepare global resource"); + } + @AfterClass + public static void cleanGlobalResouce(){ + System.err.println("clean global resource"); + } + + + public static void main(String[] args){ + JUnitCore.runClass(CalculatorTest.class); + + } +} From dcc72f2984ded2eb9102ae3b5f497fadd3367718 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Tue, 22 Aug 2017 08:03:48 +0800 Subject: [PATCH 71/81] [Feature] test v1 done --- .../{liuxiuv1 => liuxinv1}/Assert.java | 2 +- .../AssertionFailedError.java | 2 +- .../{liuxiuv1 => liuxinv1}/Calculator.java | 2 +- .../CalculatorTest.java | 2 +- .../{liuxiuv1 => liuxinv1}/Test.java | 2 +- .../{liuxiuv1 => liuxinv1}/TestCase.java | 2 +- .../{liuxiuv1 => liuxinv1}/TestFailure.java | 2 +- .../{liuxiuv1 => liuxinv1}/TestResult.java | 2 +- .../{liuxiuv1 => liuxinv1}/TestSuite.java | 4 +- .../myood/litejunit/v1/CalculatorTest.java | 6 + .../myood/litejunit/v1/ClientToTest.java | 18 ++- .../coderising/myood/litejunit/v1/Test.java | 4 +- .../myood/litejunit/v1/TestResult.java | 7 + .../myood/litejunit/v1/TestSuite.java | 123 ++++++++++++++++++ 14 files changed, 161 insertions(+), 17 deletions(-) rename students/812350401/src/main/java/com/coderising/myood/litejunit/{liuxiuv1 => liuxinv1}/Assert.java (99%) rename students/812350401/src/main/java/com/coderising/myood/litejunit/{liuxiuv1 => liuxinv1}/AssertionFailedError.java (80%) rename students/812350401/src/main/java/com/coderising/myood/litejunit/{liuxiuv1 => liuxinv1}/Calculator.java (88%) rename students/812350401/src/main/java/com/coderising/myood/litejunit/{liuxiuv1 => liuxinv1}/CalculatorTest.java (96%) rename students/812350401/src/main/java/com/coderising/myood/litejunit/{liuxiuv1 => liuxinv1}/Test.java (81%) rename students/812350401/src/main/java/com/coderising/myood/litejunit/{liuxiuv1 => liuxinv1}/TestCase.java (95%) rename students/812350401/src/main/java/com/coderising/myood/litejunit/{liuxiuv1 => liuxinv1}/TestFailure.java (94%) rename students/812350401/src/main/java/com/coderising/myood/litejunit/{liuxiuv1 => liuxinv1}/TestResult.java (97%) rename students/812350401/src/main/java/com/coderising/myood/litejunit/{liuxiuv1 => liuxinv1}/TestSuite.java (97%) create mode 100644 students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestSuite.java diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Assert.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/Assert.java similarity index 99% rename from students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Assert.java rename to students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/Assert.java index 78281a81b5..d542213642 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Assert.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/Assert.java @@ -1,4 +1,4 @@ -package com.coderising.myood.litejunit.liuxiuv1; +package com.coderising.myood.litejunit.liuxinv1; /** * A set of assert methods. diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/AssertionFailedError.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/AssertionFailedError.java similarity index 80% rename from students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/AssertionFailedError.java rename to students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/AssertionFailedError.java index 0c7916effe..9724d5bd99 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/AssertionFailedError.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/AssertionFailedError.java @@ -1,4 +1,4 @@ -package com.coderising.myood.litejunit.liuxiuv1; +package com.coderising.myood.litejunit.liuxinv1; /** * Thrown when an assertion failed. diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Calculator.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/Calculator.java similarity index 88% rename from students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Calculator.java rename to students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/Calculator.java index 93ace0bae5..7ff741ee8b 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Calculator.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/Calculator.java @@ -1,4 +1,4 @@ -package com.coderising.myood.litejunit.liuxiuv1; +package com.coderising.myood.litejunit.liuxinv1; public class Calculator { diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/CalculatorTest.java similarity index 96% rename from students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java rename to students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/CalculatorTest.java index 66959c3dc3..cb2d8cd2c5 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/CalculatorTest.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/CalculatorTest.java @@ -1,4 +1,4 @@ -package com.coderising.myood.litejunit.liuxiuv1; +package com.coderising.myood.litejunit.liuxinv1; public class CalculatorTest extends TestCase { diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Test.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/Test.java similarity index 81% rename from students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Test.java rename to students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/Test.java index 4de5a17edd..c2e3903826 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/Test.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/Test.java @@ -1,4 +1,4 @@ -package com.coderising.myood.litejunit.liuxiuv1; +package com.coderising.myood.litejunit.liuxinv1; public interface Test { public abstract int countTestCases(); // command模式,一个测试用例是一个command diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestCase.java similarity index 95% rename from students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java rename to students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestCase.java index 78881def35..1a0887f2a1 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestCase.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestCase.java @@ -1,4 +1,4 @@ -package com.coderising.myood.litejunit.liuxiuv1; +package com.coderising.myood.litejunit.liuxinv1; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestFailure.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestFailure.java similarity index 94% rename from students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestFailure.java rename to students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestFailure.java index add19e6c30..08d75a5e90 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestFailure.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestFailure.java @@ -1,4 +1,4 @@ -package com.coderising.myood.litejunit.liuxiuv1; +package com.coderising.myood.litejunit.liuxinv1; /** * A TestFailure collects a failed test together with diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestResult.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestResult.java similarity index 97% rename from students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestResult.java rename to students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestResult.java index 6750c6e456..69b09b8920 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestResult.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestResult.java @@ -1,4 +1,4 @@ -package com.coderising.myood.litejunit.liuxiuv1; +package com.coderising.myood.litejunit.liuxinv1; import java.util.ArrayList; import java.util.Iterator; diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestSuite.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestSuite.java similarity index 97% rename from students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestSuite.java rename to students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestSuite.java index 7b14e1aee9..2add661d08 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxiuv1/TestSuite.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestSuite.java @@ -1,4 +1,4 @@ -package com.coderising.myood.litejunit.liuxiuv1; +package com.coderising.myood.litejunit.liuxinv1; import java.io.PrintWriter; import java.io.StringWriter; @@ -109,7 +109,7 @@ public void run(TestResult result) { if (result.shouldStop() ){ break; } - Test test= (Test)e.next(); + Test test= e.next(); test.run(result); } diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java index c09920d3a2..52f84804c8 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java @@ -8,9 +8,11 @@ public CalculatorTest(String name) { } Calculator calculator =null; public void setUp(){ + System.out.println("init a calculator instance"); calculator = new Calculator(); } public void tearDown(){ + System.out.println("destroy a calculator instance"); calculator = null; } public void testAdd(){ @@ -24,6 +26,10 @@ public void testSubtract(){ assertEquals(4,calculator.getResult()); } + public void haha() { + System.out.println("this is not test case"); + } + private void testXX() { } diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java index 5291263f4b..03cc06c115 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java @@ -9,13 +9,21 @@ public class ClientToTest { public static void main(String[] args) { TestResult tr = new TestResult(); - Test cs1 = new CalculatorTest("testAdd"); - test(cs1, tr); - Test cs2 = new CalculatorTest("testSubtract"); - test(cs2, tr); +// Test cs1 = new CalculatorTest("testAdd"); +// tryTest(cs1, tr); +// Test cs2 = new CalculatorTest("testSubtract"); +// tryTest(cs2, tr); + + System.out.println("---------------------------------"); + tr.clearResult(); + Test ts = new TestSuite(CalculatorTest.class); + ((TestSuite)ts).addTest(new CalculatorTest("haha")); + ((TestSuite)ts).addTest(new TestSuite(CalculatorTest.class)); + tryTest(ts, tr); + } - private static void test(Test test, TestResult tr) { + private static void tryTest(Test test, TestResult tr) { test.run(tr); System.out.println(tr.wasSuccessful()); for (TestFailure failure: tr.failures) { diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Test.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Test.java index 842b067796..07c74cce4e 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Test.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/Test.java @@ -2,6 +2,6 @@ public interface Test { - public abstract int countTestCases(); // command模式,一个测试用例是一个command - public void run(TestResult tr); // 分离测试用例和测试结果,收集参数模式 + int countTestCases(); // command模式,一个测试用例是一个command + void run(TestResult tr); // 分离测试用例和测试结果,收集参数模式 } diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestResult.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestResult.java index 96144144e0..0a6d967402 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestResult.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestResult.java @@ -78,4 +78,11 @@ public boolean wasSuccessful() { return this.failureCount() == 0 && this.errorCount() == 0; } + public void clearResult() { + failures.clear(); + errors.clear(); + testCount = 0; + stop= false; + } + } diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestSuite.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestSuite.java new file mode 100644 index 0000000000..afc906656e --- /dev/null +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestSuite.java @@ -0,0 +1,123 @@ +package com.coderising.myood.litejunit.v1; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.*; + +/** + * Created by thomas_young on 21/8/2017. + */ +public class TestSuite implements Test { + private String name; + private List tests = new ArrayList<>(10); + + @Override + public int countTestCases() { + int totalCount = 0; + for (Test test: tests) { + totalCount += test.countTestCases(); + } + return totalCount; + } + + // 把某个测试类中的所有pulic的test方法构造成对象,塞入tests + public TestSuite(final Class theClass) { + this.name = theClass.getName(); + Constructor constructor = null; + try { + constructor = getConstructor(theClass); + } catch (NoSuchMethodException e) { + addTest(warning("Class "+theClass.getName()+" has no public constructor TestCase(String name)")); + } + + if (!Modifier.isPublic(theClass.getModifiers())) { + addTest(warning("Class "+theClass.getName()+" is not public")); + return; + } + + Method[] methods = theClass.getDeclaredMethods(); + Set names = new TreeSet<>(); + for (Method method: methods) { + addTestInstance(method, names, constructor); + } + + if (tests.size() == 0) + addTest(warning("No tests found in "+theClass.getName())); + } + + private Constructor getConstructor(Class theClass) throws NoSuchMethodException { + Class[] args = {String.class}; + return theClass.getConstructor(args); + } + + @Override + public void run(TestResult tr) { + for (Test test: tests) { + if (tr.shouldStop()) break; + test.run(tr); + } + } + + public void addTest(Test test) { + tests.add(test); + } + + public Iterator tests() { + return tests.iterator(); + } + + // --------------------- private --------------------------- + private void addTestInstance(Method method, Set names, Constructor constructor) { + String name = method.getName(); + if (names.contains(name)) { + return; + } + if (!isTestMethod(method)) { + return; + } + if (!Modifier.isPublic(method.getModifiers())) { + addTest(warning("Test method isn't public: "+name)); + return; + } + + names.add(name); + Object[] args= new Object[]{name}; + try { + addTest((Test)constructor.newInstance(args)); + } catch (InstantiationException e) { + addTest(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); + } catch (InvocationTargetException e) { + addTest(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); + } catch (IllegalAccessException e) { + addTest(warning("Cannot access test case: "+name+" ("+exceptionToString(e)+")")); + } + } + + private boolean isTestMethod(Method method) { + String methodName = method.getName(); + int paraCount = method.getParameterCount(); + Class returnType = method.getReturnType(); + return paraCount == 0 && returnType.equals(Void.TYPE) && methodName.startsWith("test"); + } + + private Test warning(final String message) { + return new TestCase("warning") { + public void doRun() { + fail(message); + } + }; + } + + private String exceptionToString(Throwable t) { + StringWriter stringWriter= new StringWriter(); + PrintWriter writer= new PrintWriter(stringWriter); + t.printStackTrace(writer); + return stringWriter.toString(); + + } + +} From 91391719581cb1a82cc7ca5a351a27fcc4243128 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Wed, 23 Aug 2017 00:34:43 +0800 Subject: [PATCH 72/81] [Fix] add subtle --- .../com/coderising/myood/litejunit/liuxinv1/TestSuite.java | 2 +- .../com/coderising/myood/litejunit/v1/CalculatorTest.java | 2 +- .../java/com/coderising/myood/litejunit/v1/ClientToTest.java | 2 +- .../java/com/coderising/myood/litejunit/v1/TestSuite.java | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestSuite.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestSuite.java index 2add661d08..32ff05d934 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestSuite.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/liuxinv1/TestSuite.java @@ -16,7 +16,7 @@ public class TestSuite extends Assert implements Test { - private List tests= new ArrayList<>(10); // 组合模式 + private List tests= new ArrayList<>(10); // 组合模式,可以放TestSuite,也可以放TestCase private String name; public TestSuite(){ diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java index 52f84804c8..5cf83e3187 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/CalculatorTest.java @@ -27,7 +27,7 @@ public void testSubtract(){ } public void haha() { - System.out.println("this is not test case"); + System.out.println("haha is not test case"); } private void testXX() { diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java index 03cc06c115..fc321f1cec 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/ClientToTest.java @@ -16,7 +16,7 @@ public static void main(String[] args) { System.out.println("---------------------------------"); tr.clearResult(); - Test ts = new TestSuite(CalculatorTest.class); + Test ts = new TestSuite("AllTest"); ((TestSuite)ts).addTest(new CalculatorTest("haha")); ((TestSuite)ts).addTest(new TestSuite(CalculatorTest.class)); tryTest(ts, tr); diff --git a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestSuite.java b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestSuite.java index afc906656e..19ee4caf16 100644 --- a/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestSuite.java +++ b/students/812350401/src/main/java/com/coderising/myood/litejunit/v1/TestSuite.java @@ -24,6 +24,10 @@ public int countTestCases() { return totalCount; } + public TestSuite(String name) { + this.name = name; + } + // 把某个测试类中的所有pulic的test方法构造成对象,塞入tests public TestSuite(final Class theClass) { this.name = theClass.getName(); From 1cb1d92ae45aaea2377d3cb856d410d2deeb4adb Mon Sep 17 00:00:00 2001 From: johnChnia Date: Sat, 2 Sep 2017 03:51:45 +0800 Subject: [PATCH 73/81] =?UTF-8?q?=E5=AE=8C=E6=88=90V1=E7=89=88junit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sample/calculator/Calculator.java | 28 +++ .../sample/calculator/CalculatorTest.java | 55 ++++++ .../main/java/org/litejunit/v1/Assert.java | 164 ++++++++++++++++++ .../litejunit/v1/AssertionFailedError.java | 14 ++ .../src/main/java/org/litejunit/v1/Test.java | 12 ++ .../main/java/org/litejunit/v1/TestCase.java | 57 ++++++ .../java/org/litejunit/v1/TestFailure.java | 39 +++++ .../java/org/litejunit/v1/TestResult.java | 85 +++++++++ .../main/java/org/litejunit/v1/TestSuite.java | 120 +++++++++++++ ...47\224\250\344\276\213\345\233\276.gliffy" | 1 + ...46\227\266\345\272\217\345\233\276.gliffy" | 1 + ...46\210\217\347\261\273\345\233\276.gliffy" | 1 + 12 files changed, 577 insertions(+) create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/Calculator.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorTest.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/Assert.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/AssertionFailedError.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/Test.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestCase.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestFailure.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestResult.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestSuite.java create mode 100644 "students/315863321/uml/\350\264\255\347\211\251\347\275\221\347\253\231\347\224\250\344\276\213\345\233\276.gliffy" create mode 100644 "students/315863321/uml/\351\252\260\345\255\220\346\270\270\346\210\217\346\227\266\345\272\217\345\233\276.gliffy" create mode 100644 "students/315863321/uml/\351\252\260\345\255\220\346\270\270\346\210\217\347\261\273\345\233\276.gliffy" diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/Calculator.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/Calculator.java new file mode 100644 index 0000000000..00a31b795b --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/Calculator.java @@ -0,0 +1,28 @@ +package org.litejunit.sample.calculator; + +/** + * Created by john on 2017/8/29. + */ +public class Calculator { + + private int result = 0; + + public void add(int x) { + result += x; + } + + public void subtract(int x) { + result -= x; + } + + public int getResult() { + return this.result; + } + + public static void main(String[] args) { + Calculator calculator = new Calculator(); + calculator.add(10); + calculator.subtract(5); + System.out.println(calculator.getResult()); + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorTest.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorTest.java new file mode 100644 index 0000000000..a502082b63 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/sample/calculator/CalculatorTest.java @@ -0,0 +1,55 @@ +package org.litejunit.sample.calculator; + + +import org.litejunit.v1.TestCase; +import org.litejunit.v1.TestResult; +import org.litejunit.v1.TestSuite; + +import static org.litejunit.v1.Assert.assertEquals; + +/** + * Created by john on 2017/8/29. + */ +public class CalculatorTest extends TestCase { + public CalculatorTest(String name) { + super(name); + + } + + Calculator calculator = null; + + public void setUp() { + calculator = new Calculator(); + } + + public void tearDown() { + calculator = null; + } + + public void testAdd() { + + calculator.add(10); +// System.out.println("CalculatorTest.testAdd"); + assertEquals(5,calculator.getResult()); + } + + public void testSubtract() { + calculator.add(10); + calculator.subtract(5); +// System.out.println("CalculatorTest.testSubtract"); +// throw new RuntimeException("this is a test"); + assertEquals(5,calculator.getResult()); + } + + public static void main(String[] args) { +// CalculatorTest c1 = new CalculatorTest("testAdd"); +// CalculatorTest c2 = new CalculatorTest("testSubtract"); +// c1.run(); +// c2.run(); + TestResult tr = new TestResult(); + TestSuite ts = new TestSuite(CalculatorTest.class); + ts.run(tr); + + System.out.println(tr.failures().next().thrownException()); + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/Assert.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/Assert.java new file mode 100644 index 0000000000..75fe0457f2 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/Assert.java @@ -0,0 +1,164 @@ +package org.litejunit.v1; + + +/** + * Created by john on 2017/9/2. + */ +public class Assert { + protected Assert() { + } + + + public static void assertEquals(byte expected, byte actual) { + assertEquals((String) null, (byte) expected, (byte) actual); + } + + public static void assertEquals(char expected, char actual) { + assertEquals((String) null, (char) expected, (char) actual); + } + + public static void assertEquals(double expected, double actual, double delta) { + assertEquals((String) null, expected, actual, delta); + } + + public static void assertEquals(float expected, float actual, float delta) { + assertEquals((String) null, expected, actual, delta); + } + + public static void assertEquals(int expected, int actual) { + assertEquals((String) null, (int) expected, (int) actual); + } + + public static void assertEquals(long expected, long actual) { + assertEquals((String) null, expected, actual); + } + + public static void assertEquals(Object expected, Object actual) { + assertEquals((String) null, expected, actual); + } + + public static void assertEquals(String message, byte expected, byte actual) { + assertEquals(message, new Byte(expected), new Byte(actual)); + } + + public static void assertEquals(String message, char expected, char actual) { + assertEquals(message, new Character(expected), new Character(actual)); + } + + public static void assertEquals(String message, double expected, double actual, double delta) { + if (Double.isInfinite(expected)) { + if (expected != actual) { + failNotEquals(message, new Double(expected), new Double(actual)); + } + } else if (Math.abs(expected - actual) > delta) { + failNotEquals(message, new Double(expected), new Double(actual)); + } + + } + + public static void assertEquals(String message, float expected, float actual, float delta) { + if (Float.isInfinite(expected)) { + if (expected != actual) { + failNotEquals(message, new Float(expected), new Float(actual)); + } + } else if (Math.abs(expected - actual) > delta) { + failNotEquals(message, new Float(expected), new Float(actual)); + } + + } + + public static void assertEquals(String message, int expected, int actual) { + assertEquals(message, new Integer(expected), new Integer(actual)); + } + + public static void assertEquals(String message, long expected, long actual) { + assertEquals(message, new Long(expected), new Long(actual)); + } + + public static void assertEquals(String message, Object expected, Object actual) { + if (expected != null || actual != null) { + if (expected == null || !expected.equals(actual)) { + failNotEquals(message, expected, actual); + } + } + } + + public static void assertEquals(String message, short expected, short actual) { + assertEquals(message, new Short(expected), new Short(actual)); + } + + public static void assertEquals(String message, boolean expected, boolean actual) { + assertEquals(message, new Boolean(expected), new Boolean(actual)); + } + + public static void assertEquals(short expected, short actual) { + assertEquals((String) null, (short) expected, (short) actual); + } + + public static void assertEquals(boolean expected, boolean actual) { + assertEquals((String) null, expected, actual); + } + + public static void assertNotNull(Object object) { + assertNotNull((String) null, object); + } + + public static void assertNotNull(String message, Object object) { + assertTrue(message, object != null); + } + + public static void assertNull(Object object) { + assertNull((String) null, object); + } + + public static void assertNull(String message, Object object) { + assertTrue(message, object == null); + } + + public static void assertSame(Object expected, Object actual) { + assertSame((String) null, expected, actual); + } + + public static void assertSame(String message, Object expected, Object actual) { + if (expected != actual) { + failNotSame(message, expected, actual); + } + } + + public static void assertTrue(String message, boolean condition) { + if (!condition) { + fail(message); + } + + } + + public static void assertTrue(boolean condition) { + assertTrue((String) null, condition); + } + + public static void fail() { + fail((String) null); + } + + public static void fail(String message) { + throw new AssertionFailedError(message); + } + + private static void failNotEquals(String message, Object expected, Object actual) { + String formatted = ""; + if (message != null) { + formatted = message + " "; + } + + fail(formatted + "expected:<" + expected + "> but was:<" + actual + ">"); + } + + private static void failNotSame(String message, Object expected, Object actual) { + String formatted = ""; + if (message != null) { + formatted = message + " "; + } + + fail(formatted + "expected same"); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/AssertionFailedError.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/AssertionFailedError.java new file mode 100644 index 0000000000..86f89c81c5 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/AssertionFailedError.java @@ -0,0 +1,14 @@ +package org.litejunit.v1; + +/** + * Created by john on 2017/9/2. + */ +public class AssertionFailedError extends Error{ + public AssertionFailedError() { + + } + + public AssertionFailedError(String message) { + super(message); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/Test.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/Test.java new file mode 100644 index 0000000000..f57b8d9e3e --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/Test.java @@ -0,0 +1,12 @@ +package org.litejunit.v1; + + +/** + * Created by john on 2017/8/30. + */ + +public interface Test { + int countTestCases(); + + void run(TestResult tr); +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestCase.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestCase.java new file mode 100644 index 0000000000..9cf4ac7137 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestCase.java @@ -0,0 +1,57 @@ +package org.litejunit.v1; + + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * Created by john on 2017/8/30. + */ +public abstract class TestCase implements Test { + private String name; + + TestCase() { + name = null; + } + + public TestCase(String name) { + this.name = name; + } + + @Override + public int countTestCases() { + return 1; + } + + @Override + public void run(TestResult tr) { + tr.run(this); + } + + protected void doRun() throws Throwable{ + setUp(); + try { + runTest(); + } finally { + tearDown(); + } + } + + protected void runTest() throws Throwable { + Method runMethod = getClass().getMethod(name, null); + try { + runMethod.invoke(this, new Class[0]); + } catch (InvocationTargetException e) { + e.fillInStackTrace(); + throw e.getTargetException(); + } + } + + protected void setUp() { + + } + + protected void tearDown() { + + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestFailure.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestFailure.java new file mode 100644 index 0000000000..ec4ec484b1 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestFailure.java @@ -0,0 +1,39 @@ +package org.litejunit.v1; + +/** + * Created by john on 2017/9/2. + */ +public class TestFailure { + + protected Test failedTest; + protected Throwable thrownException; + + /** + * Constructs a TestFailure with the given test and exception. + */ + public TestFailure(Test failedTest, Throwable thrownException) { + this.failedTest= failedTest; + this.thrownException= thrownException; + } + /** + * Gets the failed test. + */ + public Test failedTest() { + return failedTest; + } + /** + * Gets the thrown exception. + */ + public Throwable thrownException() { + return thrownException; + } + /** + * Returns a short description of the failure. + */ + public String toString() { + StringBuffer buffer= new StringBuffer(); + buffer.append(failedTest+": "+thrownException.getMessage()); + return buffer.toString(); + } + +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestResult.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestResult.java new file mode 100644 index 0000000000..5126aea9c3 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestResult.java @@ -0,0 +1,85 @@ +package org.litejunit.v1; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Created by john on 2017/9/2. + */ +public class TestResult { + protected List failures; + protected List errors; + + protected int testCount; + private boolean stop; + + public TestResult() { + failures = new ArrayList<>(); + errors = new ArrayList<>(); + + testCount = 0; + stop = false; + } + + public void addError(Test test, Throwable t) { + errors.add(new TestFailure(test, t)); + } + + public void addFailure(Test test, AssertionFailedError t) { + failures.add(new TestFailure(test, t)); + } + + + public void startTest(Test test) { + int count = test.countTestCases(); + testCount += count; + } + + public void endTest(Test test) { + } + + protected void run(final TestCase test) { + startTest(test); + try { + test.doRun(); + } catch (AssertionFailedError e) { + addFailure(test, e); + } catch (Throwable e) { + addError(test, e); + } + + endTest(test); + } + + public boolean shouldStop() { + return stop; + } + + public void stop() { + stop = true; + } + + public int errorCount() { + return errors.size(); + } + + public Iterator errors() { + return errors.iterator(); + } + + public int failureCount() { + return failures.size(); + } + + public Iterator failures() { + return failures.iterator(); + } + + /** + * Returns whether the entire test was successful or not. + */ + public boolean wasSuccessful() { + return this.failureCount() == 0 && this.errorCount() == 0; + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestSuite.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestSuite.java new file mode 100644 index 0000000000..1193692a15 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v1/TestSuite.java @@ -0,0 +1,120 @@ +package org.litejunit.v1; + + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +/** + * Created by john on 2017/8/30. + */ +public class TestSuite implements Test { + private List tests = new ArrayList<>(10); + private String name; + + + public TestSuite(final Class theClass) { + this.name = theClass.getName(); + Constructor constructor = null; + try { + constructor = getConstructor(theClass); + } catch (NoSuchMethodException e) { +// addTest(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name)")); + return; + } + + if (!Modifier.isPublic(theClass.getModifiers())) { +// addTest(warning("Class " + theClass.getName() + " is not public")); + return; + } + + Vector names = new Vector<>(); + Method[] methods = theClass.getDeclaredMethods(); + for (int i = 0; i < methods.length; i++) { + addTestMethod(methods[i], names, constructor); + } + + if (tests.size() == 0) { +// addTest(warning("No tests found in " + theClass.getName())); + } + } + + + private Constructor getConstructor(Class theClass) throws NoSuchMethodException { + Class[] args = new Class[]{String.class}; + return theClass.getConstructor(args); + } + + + @Override + public void run(TestResult result) { + for (Iterator e = tests(); e.hasNext(); ) { + if (result.shouldStop()) { + break; + } + Test test = (Test) e.next(); + test.run(result); + } + + } + + public Iterator tests() { + return tests.iterator(); + } + + private void addTestMethod(Method m, Vector names, Constructor constructor) { + String name = m.getName(); + if (names.contains(name)) + return; + if (isPublicTestMethod(m)) { + names.addElement(name); + + Object[] args = new Object[]{name}; + try { + addTest((Test) constructor.newInstance(args)); + } catch (InstantiationException e) { +// addTest(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); + } catch (InvocationTargetException e) { +// addTest(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); + } catch (IllegalAccessException e) { +// addTest(warning("Cannot access test case: "+name+" ("+exceptionToString(e)+")")); + } + + } else { // almost a test method + if (isTestMethod(m)) { +// addTest(warning("Test method isn't public: "+m.getName())); + } + } + } + + private boolean isPublicTestMethod(Method m) { + return isTestMethod(m) && Modifier.isPublic(m.getModifiers()); + } + + private boolean isTestMethod(Method m) { + String name = m.getName(); + Class[] parameters = m.getParameterTypes(); + Class returnType = m.getReturnType(); + return parameters.length == 0 && name.startsWith("test") && returnType.equals(Void.TYPE); + } + + public void addTest(Test test) { + tests.add(test); + } + + @Override + public int countTestCases() { + int count= 0; + + for (Iterator e= tests(); e.hasNext(); ) { + Test test= e.next(); + count= count + test.countTestCases(); + } + return count; + } +} diff --git "a/students/315863321/uml/\350\264\255\347\211\251\347\275\221\347\253\231\347\224\250\344\276\213\345\233\276.gliffy" "b/students/315863321/uml/\350\264\255\347\211\251\347\275\221\347\253\231\347\224\250\344\276\213\345\233\276.gliffy" new file mode 100644 index 0000000000..18e02de5b7 --- /dev/null +++ "b/students/315863321/uml/\350\264\255\347\211\251\347\275\221\347\253\231\347\224\250\344\276\213\345\233\276.gliffy" @@ -0,0 +1 @@ +{"contentType":"application/gliffy+json","version":"1.1","metadata":{"title":"untitled","revision":0,"exportBorder":false},"embeddedResources":{"index":0,"resources":[]},"stage":{"objects":[{"x":610,"y":359,"rotation":0,"id":33,"uid":"com.gliffy.shape.uml.uml_v1.default.use_case","width":115,"height":58,"lockAspectRatio":true,"lockShape":false,"order":25,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.ellipse.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":2,"y":0,"rotation":0,"id":35,"uid":null,"width":111,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

下订单

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":613,"y":210,"rotation":0,"id":29,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":21,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"4.0,4.0","startArrow":0,"endArrow":1,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[54.5,49],[54.5,22],[54.5,-5],[54.5,-32]],"lockSegments":{}}},"children":[{"x":0,"y":0,"rotation":0,"id":30,"uid":null,"width":64,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"both","vposition":"none","hposition":"none","html":"

<<extend>>

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":23,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":21,"px":0.5,"py":1}}},"linkMap":[]},{"x":468,"y":187,"rotation":0,"id":25,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":19,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"4.0,4.0","startArrow":0,"endArrow":1,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[142,-38],[77,-38],[12,-38],[-53,-38]],"lockSegments":{}}},"children":[{"x":0,"y":0,"rotation":0,"id":26,"uid":null,"width":64,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"both","vposition":"none","hposition":"none","html":"

<<extend>>

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":21,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":2,"px":1,"py":0.5}}},"linkMap":[]},{"x":610,"y":259,"rotation":0,"id":23,"uid":"com.gliffy.shape.uml.uml_v1.default.use_case","width":115,"height":58,"lockAspectRatio":true,"lockShape":false,"order":17,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.ellipse.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":2,"y":0,"rotation":0,"id":28,"uid":null,"width":111,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

加入购物车

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":610,"y":120,"rotation":0,"id":21,"uid":"com.gliffy.shape.uml.uml_v1.default.use_case","width":115,"height":58,"lockAspectRatio":true,"lockShape":false,"order":15,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.ellipse.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":2,"y":0,"rotation":0,"id":27,"uid":null,"width":111,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

查看产品详情

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":306,"y":437,"rotation":0,"id":19,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":13,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"4.0,4.0","startArrow":0,"endArrow":1,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[51.5,33],[51.5,5.666666666666686],[51.5,-21.666666666666686],[51.5,-49]],"lockSegments":{}}},"children":[{"x":0,"y":0,"rotation":0,"id":20,"uid":null,"width":64,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"both","vposition":"none","hposition":"none","html":"

<<extend>>

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":8,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":6,"px":0.5,"py":1}}},"linkMap":[]},{"x":171,"y":448,"rotation":0,"id":18,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":12,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-9,-100],[129,51]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":8,"px":0,"py":0.5}}},"linkMap":[]},{"x":166,"y":321,"rotation":0,"id":17,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":11,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[0,0],[134,38]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":6,"px":0,"py":0.5}}},"linkMap":[]},{"x":177,"y":267,"rotation":0,"id":16,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":10,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-0.06502346320826291,-8],[40.956651024527844,-8],[81.9783255122639,-8],[123,-8]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":4,"px":0,"py":0.5}}},"linkMap":[]},{"x":173,"y":230,"rotation":0,"id":15,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":9,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-17,7],[127,-81]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":2,"px":0,"py":0.5}}},"linkMap":[]},{"x":300,"y":470,"rotation":0,"id":8,"uid":"com.gliffy.shape.uml.uml_v1.default.use_case","width":115,"height":58,"lockAspectRatio":true,"lockShape":false,"order":7,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.ellipse.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":2,"y":0,"rotation":0,"id":13,"uid":null,"width":111,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

注册

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":300,"y":330,"rotation":0,"id":6,"uid":"com.gliffy.shape.uml.uml_v1.default.use_case","width":115,"height":58,"lockAspectRatio":true,"lockShape":false,"order":5,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.ellipse.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":2,"y":0,"rotation":0,"id":12,"uid":null,"width":111,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

登录

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":300,"y":230,"rotation":0,"id":4,"uid":"com.gliffy.shape.uml.uml_v1.default.use_case","width":115,"height":58,"lockAspectRatio":true,"lockShape":false,"order":3,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.ellipse.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":2,"y":0,"rotation":0,"id":11,"uid":null,"width":111,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

显示购物车

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":300,"y":120,"rotation":0,"id":2,"uid":"com.gliffy.shape.uml.uml_v1.default.use_case","width":115,"height":58,"lockAspectRatio":true,"lockShape":false,"order":1,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.ellipse.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":2,"y":0,"rotation":0,"id":10,"uid":null,"width":111,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

搜索产品

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":90,"y":238,"rotation":0,"id":0,"uid":"com.gliffy.shape.uml.uml_v1.default.actor","width":63,"height":100,"lockAspectRatio":true,"lockShape":false,"order":0,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.actor.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":453,"y":174,"rotation":0,"id":31,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":23,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"4.0,4.0","startArrow":0,"endArrow":1,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[157,114],[-38,-25]],"lockSegments":{}}},"children":[{"x":0,"y":0,"rotation":0,"id":32,"uid":null,"width":64,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"both","vposition":"none","hposition":"none","html":"

<<extend>>

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":23,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":2,"px":1,"py":0.5}}},"linkMap":[]},{"x":478,"y":291,"rotation":0,"id":36,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":27,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"4.0,4.0","startArrow":0,"endArrow":1,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[132,97],[-63,-32]],"lockSegments":{}}},"children":[{"x":0,"y":0,"rotation":0,"id":37,"uid":null,"width":64,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"both","vposition":"none","hposition":"none","html":"

<<extend>>

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":33,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":4,"px":1,"py":0.5}}},"linkMap":[]},{"x":446,"y":356,"rotation":0,"id":38,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":30,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"4.0,4.0","startArrow":0,"endArrow":1,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[164,32],[-31,3]],"lockSegments":{}}},"children":[{"x":0,"y":0,"rotation":0,"id":39,"uid":null,"width":66,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"both","vposition":"none","hposition":"none","html":"

<<include>>

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":33,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":6,"px":1,"py":0.5}}},"linkMap":[]}],"background":"#FFFFFF","width":725,"height":528,"maxWidth":5000,"maxHeight":5000,"nodeIndex":40,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file diff --git "a/students/315863321/uml/\351\252\260\345\255\220\346\270\270\346\210\217\346\227\266\345\272\217\345\233\276.gliffy" "b/students/315863321/uml/\351\252\260\345\255\220\346\270\270\346\210\217\346\227\266\345\272\217\345\233\276.gliffy" new file mode 100644 index 0000000000..02b057e1e7 --- /dev/null +++ "b/students/315863321/uml/\351\252\260\345\255\220\346\270\270\346\210\217\346\227\266\345\272\217\345\233\276.gliffy" @@ -0,0 +1 @@ +{"contentType":"application/gliffy+json","version":"1.1","metadata":{"title":"untitled","revision":0,"exportBorder":false},"embeddedResources":{"index":0,"resources":[]},"stage":{"objects":[{"x":585,"y":414,"rotation":0,"id":58,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":58,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

showResult

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":413,"y":430,"rotation":0,"id":57,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":57,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-3.0008912634656326,1.1368683772161603e-13],[558.0008960566282,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":228,"y":463,"rotation":0,"id":55,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":55,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"1.0,1.0","startArrow":1,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-18.002746817932916,-1.1368683772161603e-13],[164.0274367293472,0]],"lockSegments":{}}},"children":[],"linkMap":[]},{"x":971.5,"y":425,"rotation":0,"id":53,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":30,"lockAspectRatio":false,"lockShape":false,"order":53,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":451,"y":320,"rotation":0,"id":52,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":73,"height":14,"lockAspectRatio":false,"lockShape":false,"order":52,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

checkIfWin

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":410.5,"y":320,"rotation":0,"id":50,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":50,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":410.5,"y":211,"rotation":0,"id":48,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":48,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

v2=roll()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":791.5,"y":225,"rotation":0,"id":47,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":20,"lockAspectRatio":false,"lockShape":false,"order":47,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":444,"y":230,"rotation":0,"id":46,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":46,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-34.00373129133379,2.842170943040401e-14],[350.0013020684737,2.842170943040401e-14]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":424,"y":154,"rotation":0,"id":44,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":44,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

v1=roll()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":432,"y":170,"rotation":0,"id":43,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":43,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-22,0],[162.01086924418348,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":240,"y":169,"rotation":0,"id":42,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":42,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-29.00276236699139,0],[152.00280890398182,-2.842170943040401e-14]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":591.5,"y":168,"rotation":0,"id":39,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":24,"lockAspectRatio":false,"lockShape":false,"order":39,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":204,"y":148,"rotation":0,"id":37,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":37,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

play

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":391.5,"y":165,"rotation":0,"id":36,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":310,"lockAspectRatio":false,"lockShape":false,"order":36,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":191.5,"y":165,"rotation":0,"id":31,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":310,"lockAspectRatio":false,"lockShape":false,"order":31,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":140,"y":70,"rotation":0,"id":11,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":430,"lockAspectRatio":false,"lockShape":false,"order":0,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":12,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":13,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:Player

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":13,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":14,"uid":null,"width":120,"height":412,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":11,"magnitude":1},{"id":12,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":12,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":12,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":340,"y":70,"rotation":0,"id":15,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":429.99999999999994,"lockAspectRatio":false,"lockShape":false,"order":4,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":16,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":17,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:DiceGame

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":17,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":18,"uid":null,"width":120,"height":411.99999999999994,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":15,"magnitude":1},{"id":16,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":16,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":16,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":540,"y":70,"rotation":0,"id":19,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":429.99999999999994,"lockAspectRatio":false,"lockShape":false,"order":8,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":20,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":21,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

dice1:Dice

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":21,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":22,"uid":null,"width":120,"height":411.99999999999994,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":19,"magnitude":1},{"id":20,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":20,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":20,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":740,"y":70,"rotation":0,"id":23,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":429.99999999999994,"lockAspectRatio":false,"lockShape":false,"order":12,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":24,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":25,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

dice2:Dice

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":25,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":26,"uid":null,"width":120,"height":411.99999999999994,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":23,"magnitude":1},{"id":24,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":24,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":24,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":920,"y":70,"rotation":0,"id":27,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":429.99999999999994,"lockAspectRatio":false,"lockShape":false,"order":19,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":28,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":29,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:Display

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":29,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":30,"uid":null,"width":120,"height":411.99999999999994,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":27,"magnitude":1},{"id":28,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":28,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":28,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]}],"background":"#FFFFFF","width":1042,"height":500,"maxWidth":5000,"maxHeight":5000,"nodeIndex":60,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file diff --git "a/students/315863321/uml/\351\252\260\345\255\220\346\270\270\346\210\217\347\261\273\345\233\276.gliffy" "b/students/315863321/uml/\351\252\260\345\255\220\346\270\270\346\210\217\347\261\273\345\233\276.gliffy" new file mode 100644 index 0000000000..30980d2428 --- /dev/null +++ "b/students/315863321/uml/\351\252\260\345\255\220\346\270\270\346\210\217\347\261\273\345\233\276.gliffy" @@ -0,0 +1 @@ +{"contentType":"application/gliffy+json","version":"1.1","metadata":{"title":"untitled","revision":0,"exportBorder":false},"embeddedResources":{"index":0,"resources":[]},"stage":{"objects":[{"x":330,"y":257,"rotation":0,"id":63,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":30,"height":14,"lockAspectRatio":false,"lockShape":false,"order":34,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

1

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":290,"y":257,"rotation":0,"id":62,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":20,"height":14,"lockAspectRatio":false,"lockShape":false,"order":33,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

1

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":586,"y":257,"rotation":0,"id":60,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":20,"height":14,"lockAspectRatio":false,"lockShape":false,"order":32,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

2

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":548,"y":257,"rotation":0,"id":59,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":80,"height":14,"lockAspectRatio":false,"lockShape":false,"order":31,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

1

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":445,"y":328,"rotation":0,"id":53,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":30,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[5,-57],[5,-27.666666666666686],[5,1.6666666666666856],[5,31]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":18,"px":0.5,"py":1}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":46,"px":0.5,"py":0}}},"linkMap":[]},{"x":564,"y":243,"rotation":0,"id":45,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":22,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":5,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-44,-2.5],[-6.333333333333371,-2.5],[31.33333333333337,-2.5],[69,-2.5]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":18,"px":1,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":38,"px":0,"py":0.5}}},"linkMap":[]},{"x":271,"y":246,"rotation":0,"id":25,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":14,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-1,-5.5],[35.666666666666686,-5.5],[72.33333333333331,-5.5],[109,-5.5]],"lockSegments":{}}},"children":[],"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":0,"px":1,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":18,"px":0,"py":0.5}}},"linkMap":[]},{"x":130,"y":210,"rotation":0,"id":0,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":61,"lockAspectRatio":false,"lockShape":false,"order":0,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":1,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":2,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Player

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":2,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":3,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":4,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":1,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":4,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":5,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":6,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":0,"magnitude":1},{"id":1,"magnitude":-1},{"id":3,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":3,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":1,"magnitude":1},{"id":3,"magnitude":1},{"id":6,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":380,"y":210,"rotation":0,"id":18,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":61,"lockAspectRatio":false,"lockShape":false,"order":7,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":19,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":20,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

DiceGame

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":20,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":21,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":22,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":19,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":22,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":23,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":24,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+play()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":18,"magnitude":1},{"id":19,"magnitude":-1},{"id":21,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":21,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":19,"magnitude":1},{"id":21,"magnitude":1},{"id":24,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":633,"y":203,"rotation":0,"id":38,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":75,"lockAspectRatio":false,"lockShape":false,"order":15,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":39,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":40,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Dice

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":40,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":41,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":42,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":39,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":42,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":43,"uid":null,"width":140,"height":53,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":44,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+roll()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":38,"magnitude":1},{"id":39,"magnitude":-1},{"id":41,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":41,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":39,"magnitude":1},{"id":41,"magnitude":1},{"id":44,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":380,"y":359,"rotation":0,"id":46,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":75,"lockAspectRatio":false,"lockShape":false,"order":23,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":47,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":48,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Display

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":48,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":49,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":50,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":47,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":50,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":51,"uid":null,"width":140,"height":53,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":52,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+showResult()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":46,"magnitude":1},{"id":47,"magnitude":-1},{"id":49,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":49,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":47,"magnitude":1},{"id":49,"magnitude":1},{"id":52,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":470,"y":290,"rotation":0,"id":64,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":20,"height":14,"lockAspectRatio":false,"lockShape":false,"order":35,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

1

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":472,"y":330,"rotation":0,"id":65,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":20,"height":14,"lockAspectRatio":false,"lockShape":false,"order":36,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

1

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]}],"background":"#FFFFFF","width":775,"height":434,"maxWidth":5000,"maxHeight":5000,"nodeIndex":66,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file From e6d45dff204ba36a1404528e1793883d9b40c43c Mon Sep 17 00:00:00 2001 From: johnChnia Date: Sun, 3 Sep 2017 19:15:47 +0800 Subject: [PATCH 74/81] =?UTF-8?q?lite-junitV2=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/litejunit/v2/Assert.java | 164 +++++++++++++++ .../litejunit/v2/AssertionFailedError.java | 14 ++ .../src/main/java/org/litejunit/v2/Test.java | 12 ++ .../main/java/org/litejunit/v2/TestCase.java | 57 +++++ .../java/org/litejunit/v2/TestFailure.java | 39 ++++ .../java/org/litejunit/v2/TestListener.java | 16 ++ .../java/org/litejunit/v2/TestResult.java | 112 ++++++++++ .../main/java/org/litejunit/v2/TestSuite.java | 127 ++++++++++++ .../litejunit/v2/runner/BaseTestRunner.java | 89 ++++++++ .../org/litejunit/v2/textui/TestRunner.java | 194 ++++++++++++++++++ students/315863321/uml/junit.gliffy | 1 + 11 files changed, 825 insertions(+) create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/Assert.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/AssertionFailedError.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/Test.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestCase.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestFailure.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestListener.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestResult.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestSuite.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/runner/BaseTestRunner.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/textui/TestRunner.java create mode 100644 students/315863321/uml/junit.gliffy diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/Assert.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/Assert.java new file mode 100644 index 0000000000..f66d9076a9 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/Assert.java @@ -0,0 +1,164 @@ +package org.litejunit.v2; + + +/** + * Created by john on 2017/9/2. + */ +public class Assert { + protected Assert() { + } + + + public static void assertEquals(byte expected, byte actual) { + assertEquals((String) null, (byte) expected, (byte) actual); + } + + public static void assertEquals(char expected, char actual) { + assertEquals((String) null, (char) expected, (char) actual); + } + + public static void assertEquals(double expected, double actual, double delta) { + assertEquals((String) null, expected, actual, delta); + } + + public static void assertEquals(float expected, float actual, float delta) { + assertEquals((String) null, expected, actual, delta); + } + + public static void assertEquals(int expected, int actual) { + assertEquals((String) null, (int) expected, (int) actual); + } + + public static void assertEquals(long expected, long actual) { + assertEquals((String) null, expected, actual); + } + + public static void assertEquals(Object expected, Object actual) { + assertEquals((String) null, expected, actual); + } + + public static void assertEquals(String message, byte expected, byte actual) { + assertEquals(message, new Byte(expected), new Byte(actual)); + } + + public static void assertEquals(String message, char expected, char actual) { + assertEquals(message, new Character(expected), new Character(actual)); + } + + public static void assertEquals(String message, double expected, double actual, double delta) { + if (Double.isInfinite(expected)) { + if (expected != actual) { + failNotEquals(message, new Double(expected), new Double(actual)); + } + } else if (Math.abs(expected - actual) > delta) { + failNotEquals(message, new Double(expected), new Double(actual)); + } + + } + + public static void assertEquals(String message, float expected, float actual, float delta) { + if (Float.isInfinite(expected)) { + if (expected != actual) { + failNotEquals(message, new Float(expected), new Float(actual)); + } + } else if (Math.abs(expected - actual) > delta) { + failNotEquals(message, new Float(expected), new Float(actual)); + } + + } + + public static void assertEquals(String message, int expected, int actual) { + assertEquals(message, new Integer(expected), new Integer(actual)); + } + + public static void assertEquals(String message, long expected, long actual) { + assertEquals(message, new Long(expected), new Long(actual)); + } + + public static void assertEquals(String message, Object expected, Object actual) { + if (expected != null || actual != null) { + if (expected == null || !expected.equals(actual)) { + failNotEquals(message, expected, actual); + } + } + } + + public static void assertEquals(String message, short expected, short actual) { + assertEquals(message, new Short(expected), new Short(actual)); + } + + public static void assertEquals(String message, boolean expected, boolean actual) { + assertEquals(message, new Boolean(expected), new Boolean(actual)); + } + + public static void assertEquals(short expected, short actual) { + assertEquals((String) null, (short) expected, (short) actual); + } + + public static void assertEquals(boolean expected, boolean actual) { + assertEquals((String) null, expected, actual); + } + + public static void assertNotNull(Object object) { + assertNotNull((String) null, object); + } + + public static void assertNotNull(String message, Object object) { + assertTrue(message, object != null); + } + + public static void assertNull(Object object) { + assertNull((String) null, object); + } + + public static void assertNull(String message, Object object) { + assertTrue(message, object == null); + } + + public static void assertSame(Object expected, Object actual) { + assertSame((String) null, expected, actual); + } + + public static void assertSame(String message, Object expected, Object actual) { + if (expected != actual) { + failNotSame(message, expected, actual); + } + } + + public static void assertTrue(String message, boolean condition) { + if (!condition) { + fail(message); + } + + } + + public static void assertTrue(boolean condition) { + assertTrue((String) null, condition); + } + + public static void fail() { + fail((String) null); + } + + public static void fail(String message) { + throw new AssertionFailedError(message); + } + + private static void failNotEquals(String message, Object expected, Object actual) { + String formatted = ""; + if (message != null) { + formatted = message + " "; + } + + fail(formatted + "expected:<" + expected + "> but was:<" + actual + ">"); + } + + private static void failNotSame(String message, Object expected, Object actual) { + String formatted = ""; + if (message != null) { + formatted = message + " "; + } + + fail(formatted + "expected same"); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/AssertionFailedError.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/AssertionFailedError.java new file mode 100644 index 0000000000..7831ffe5f8 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/AssertionFailedError.java @@ -0,0 +1,14 @@ +package org.litejunit.v2; + +/** + * Created by john on 2017/9/2. + */ +public class AssertionFailedError extends Error{ + public AssertionFailedError() { + + } + + public AssertionFailedError(String message) { + super(message); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/Test.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/Test.java new file mode 100644 index 0000000000..41121e5b64 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/Test.java @@ -0,0 +1,12 @@ +package org.litejunit.v2; + + +/** + * Created by john on 2017/8/30. + */ + +public interface Test { + int countTestCases(); + + void run(TestResult tr); +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestCase.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestCase.java new file mode 100644 index 0000000000..06441571e7 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestCase.java @@ -0,0 +1,57 @@ +package org.litejunit.v2; + + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * Created by john on 2017/8/30. + */ +public abstract class TestCase extends Assert implements Test { + private String name; + + TestCase() { + name = null; + } + + public TestCase(String name) { + this.name = name; + } + + @Override + public int countTestCases() { + return 1; + } + + @Override + public void run(TestResult tr) { + tr.run(this); + } + + protected void doRun() throws Throwable { + setUp(); + try { + runTest(); + } finally { + tearDown(); + } + } + + protected void runTest() throws Throwable { + Method runMethod = getClass().getMethod(name, null); + try { + runMethod.invoke(this, new Class[0]); + } catch (InvocationTargetException e) { + e.fillInStackTrace(); + throw e.getTargetException(); + } + } + + protected void setUp() { + + } + + protected void tearDown() { + + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestFailure.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestFailure.java new file mode 100644 index 0000000000..4fed21c84a --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestFailure.java @@ -0,0 +1,39 @@ +package org.litejunit.v2; + +/** + * Created by john on 2017/9/2. + */ +public class TestFailure { + + protected Test failedTest; + protected Throwable thrownException; + + /** + * Constructs a TestFailure with the given test and exception. + */ + public TestFailure(Test failedTest, Throwable thrownException) { + this.failedTest= failedTest; + this.thrownException= thrownException; + } + /** + * Gets the failed test. + */ + public Test failedTest() { + return failedTest; + } + /** + * Gets the thrown exception. + */ + public Throwable thrownException() { + return thrownException; + } + /** + * Returns a short description of the failure. + */ + public String toString() { + StringBuffer buffer= new StringBuffer(); + buffer.append(failedTest+": "+thrownException.getMessage()); + return buffer.toString(); + } + +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestListener.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestListener.java new file mode 100644 index 0000000000..6d29b2729a --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestListener.java @@ -0,0 +1,16 @@ +package org.litejunit.v2; + +/** + * Created by john on 2017/9/2. + * + */ +public interface TestListener { + + void addError(Test test, Throwable t); + + void addFailure(Test test, AssertionFailedError t); + + void endTest(Test test); + + void startTest(Test test); +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestResult.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestResult.java new file mode 100644 index 0000000000..e1a06eab1a --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestResult.java @@ -0,0 +1,112 @@ +package org.litejunit.v2; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Created by john on 2017/9/2. + */ +public class TestResult { + protected List failures; + protected List errors; + protected List listeners; + + + protected int testCount; + private boolean stop; + + public TestResult() { + failures = new ArrayList<>(); + errors = new ArrayList<>(); + listeners = new ArrayList<>(); + + testCount = 0; + stop = false; + } + + public void addError(Test test, Throwable t) { + errors.add(new TestFailure(test, t)); + for (TestListener listener : listeners) { + listener.addError(test, t); + } + } + + public void addFailure(Test test, AssertionFailedError t) { + failures.add(new TestFailure(test, t)); + for (TestListener listener : listeners) { + listener.addFailure(test, t); + } + } + + + public void startTest(Test test) { + int count = test.countTestCases(); + testCount += count; + for (TestListener listener : listeners) { + listener.startTest(test); + } + } + + public void endTest(Test test) { + for (TestListener listener : listeners) { + listener.endTest(test); + } + } + + protected void run(final TestCase test) { + startTest(test); + try { + test.doRun(); + } catch (AssertionFailedError e) { + addFailure(test, e); + } catch (Throwable e) { + addError(test, e); + } + + endTest(test); + } + + public boolean shouldStop() { + return stop; + } + + public void stop() { + stop = true; + } + + public int errorCount() { + return errors.size(); + } + + public Iterator errors() { + return errors.iterator(); + } + + public int failureCount() { + return failures.size(); + } + + public Iterator failures() { + return failures.iterator(); + } + + /** + * Returns whether the entire test was successful or not. + */ + public boolean wasSuccessful() { + return this.failureCount() == 0 && this.errorCount() == 0; + } + + public void addListener(TestListener listener) { + listeners.add(listener); + } + + public void removeListener(TestListener listener) { + listeners.remove(listener); + } + + public int runCount() { + return testCount; + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestSuite.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestSuite.java new file mode 100644 index 0000000000..b0e8eb6b41 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/TestSuite.java @@ -0,0 +1,127 @@ +package org.litejunit.v2; + + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +/** + * Created by john on 2017/8/30. + */ +public class TestSuite implements Test { + private List tests = new ArrayList<>(10); + private String name; + + public TestSuite(String name) { + this.name = name; + } + + public TestSuite(final Class theClass) { + this.name = theClass.getName(); + Constructor constructor = null; + try { + constructor = getConstructor(theClass); + } catch (NoSuchMethodException e) { +// addTest(warning("Class " + theClass.getName() + " has no public constructor TestCase(String name)")); + return; + } + + if (!Modifier.isPublic(theClass.getModifiers())) { +// addTest(warning("Class " + theClass.getName() + " is not public")); + return; + } + + Vector names = new Vector<>(); + Method[] methods = theClass.getDeclaredMethods(); + for (int i = 0; i < methods.length; i++) { + addTestMethod(methods[i], names, constructor); + } + + if (tests.size() == 0) { +// addTest(warning("No tests found in " + theClass.getName())); + } + } + + + private Constructor getConstructor(Class theClass) throws NoSuchMethodException { + Class[] args = new Class[]{String.class}; + return theClass.getConstructor(args); + } + + + @Override + public void run(TestResult result) { + for (Iterator e = tests(); e.hasNext(); ) { + if (result.shouldStop()) { + break; + } + Test test = (Test) e.next(); + test.run(result); + } + + } + + public Iterator tests() { + return tests.iterator(); + } + + private void addTestMethod(Method m, Vector names, Constructor constructor) { + String name = m.getName(); + if (names.contains(name)) + return; + if (isPublicTestMethod(m)) { + names.addElement(name); + + Object[] args = new Object[]{name}; + try { + addTest((Test) constructor.newInstance(args)); + } catch (InstantiationException e) { +// addTest(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); + } catch (InvocationTargetException e) { +// addTest(warning("Exception in constructor: "+name+" ("+exceptionToString(e.getTargetException())+")")); + } catch (IllegalAccessException e) { +// addTest(warning("Cannot access test case: "+name+" ("+exceptionToString(e)+")")); + } + + } else { // almost a test method + if (isTestMethod(m)) { +// addTest(warning("Test method isn't public: "+m.getName())); + } + } + } + + private boolean isPublicTestMethod(Method m) { + return isTestMethod(m) && Modifier.isPublic(m.getModifiers()); + } + + private boolean isTestMethod(Method m) { + String name = m.getName(); + Class[] parameters = m.getParameterTypes(); + Class returnType = m.getReturnType(); + return parameters.length == 0 && name.startsWith("test") && returnType.equals(Void.TYPE); + } + + public void addTest(Test test) { + tests.add(test); + } + + public void addTestSuite(Class testClass) { + this.addTest(new TestSuite(testClass)); + } + + @Override + public int countTestCases() { + int count= 0; + + for (Iterator e = tests(); e.hasNext(); ) { + Test test= e.next(); + count= count + test.countTestCases(); + } + return count; + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/runner/BaseTestRunner.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/runner/BaseTestRunner.java new file mode 100644 index 0000000000..70ed118850 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/runner/BaseTestRunner.java @@ -0,0 +1,89 @@ +package org.litejunit.v2.runner; + +/** + * Created by john on 2017/9/2. + */ + +import org.litejunit.v2.Test; +import org.litejunit.v2.TestListener; +import org.litejunit.v2.TestSuite; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.text.NumberFormat; + +public abstract class BaseTestRunner implements TestListener { + public static final String SUITE_METHODNAME = "suite"; + + /** + * Returns a filtered stack trace + */ + public static String getFilteredTrace(Throwable t) { + StringWriter stringWriter = new StringWriter(); + PrintWriter writer = new PrintWriter(stringWriter); + t.printStackTrace(writer); + StringBuffer buffer = stringWriter.getBuffer(); + String trace = buffer.toString(); + return trace; + //return BaseTestRunner.filterStack(trace); + } + + public Test getTest(String suiteClassName) { + if (suiteClassName.length() <= 0) { + return null; + } + Class testClass = null; + try { + testClass = loadSuiteClass(suiteClassName); + } catch (ClassNotFoundException e) { + String clazz = e.getMessage(); + if (clazz == null) + clazz = suiteClassName; + runFailed("Class not found \"" + clazz + "\""); + return null; + } catch (Exception e) { + runFailed("Error: " + e.toString()); + return null; + } + Method suiteMethod = null; + try { + suiteMethod = testClass.getMethod(SUITE_METHODNAME, new Class[0]); + } catch (Exception e) { + // try to extract a test suite automatically + //clearStatus(); + return new TestSuite(testClass); + } + Test test = null; + try { + test = (Test) suiteMethod.invoke(null, new Class[0]); // static method + if (test == null) + return test; + } catch (InvocationTargetException e) { + runFailed("Failed to invoke suite():" + e.getTargetException().toString()); + return null; + } catch (IllegalAccessException e) { + runFailed("Failed to invoke suite():" + e.toString()); + return null; + } + + //clearStatus(); + return test; + } + + protected Class loadSuiteClass(String suiteClassName) throws ClassNotFoundException { + + //TODO + return Class.forName(suiteClassName); + + + //return getLoader().load(suiteClassName); + } + + protected abstract void runFailed(String message); + + public String elapsedTimeAsString(long runTime) { + return NumberFormat.getInstance().format((double) runTime / 1000); + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/textui/TestRunner.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/textui/TestRunner.java new file mode 100644 index 0000000000..ff1bf38027 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v2/textui/TestRunner.java @@ -0,0 +1,194 @@ +package org.litejunit.v2.textui; + + +import org.litejunit.v2.*; +import org.litejunit.v2.runner.BaseTestRunner; + +import java.io.PrintStream; +import java.util.Iterator; + +public class TestRunner extends BaseTestRunner { + PrintStream writer= System.out; + int column= 0; + + /** + * Constructs a TestRunner. + */ + public TestRunner() { + } + + + /** + * Always use the StandardTestSuiteLoader. Overridden from + * BaseTestRunner. + */ + /*public TestSuiteLoader getLoader() { + return new StandardTestSuiteLoader(); + }*/ + + public synchronized void addError(Test test, Throwable t) { + writer().print("E"); + } + + public synchronized void addFailure(Test test, AssertionFailedError t) { + writer().print("F"); + } + + + + public TestResult doRun(Test suite) { + TestResult result= new TestResult(); + result.addListener(this); + long startTime= System.currentTimeMillis(); + suite.run(result); + long endTime= System.currentTimeMillis(); + long runTime= endTime-startTime; + writer().println(); + writer().println("Time: "+elapsedTimeAsString(runTime)); + print(result); + + writer().println(); + + + return result; + } + + + + public synchronized void startTest(Test test) { + writer().print("."); + if (column++ >= 40) { + writer().println(); + column= 0; + } + } + + public void endTest(Test test) { + } + + public static void main(String args[]) { + TestRunner testRunner= new TestRunner(); + try { + TestResult r= testRunner.start(args); + if (!r.wasSuccessful()) + System.exit(-1); + System.exit(0); + } catch(Exception e) { + System.err.println(e.getMessage()); + System.exit(-2); + } + } + /** + * Prints failures to the standard output + */ + public synchronized void print(TestResult result) { + printErrors(result); + printFailures(result); + printHeader(result); + } + /** + * Prints the errors to the standard output + */ + public void printErrors(TestResult result) { + if (result.errorCount() != 0) { + if (result.errorCount() == 1) + writer().println("There was "+result.errorCount()+" error:"); + else + writer().println("There were "+result.errorCount()+" errors:"); + + int i= 1; + for (Iterator e = result.errors(); e.hasNext(); i++) { + TestFailure failure= e.next(); + writer().println(i+") "+failure.failedTest()); + writer().print(getFilteredTrace(failure.thrownException())); + } + } + } + /** + * Prints failures to the standard output + */ + public void printFailures(TestResult result) { + if (result.failureCount() != 0) { + if (result.failureCount() == 1) + writer().println("There was " + result.failureCount() + " failure:"); + else + writer().println("There were " + result.failureCount() + " failures:"); + int i = 1; + for (Iterator e= result.failures(); e.hasNext(); i++) { + TestFailure failure= (TestFailure) e.next(); + writer().print(i + ") " + failure.failedTest()); + Throwable t= failure.thrownException(); + writer().print(getFilteredTrace(failure.thrownException())); + } + } + } + /** + * Prints the header of the report + */ + public void printHeader(TestResult result) { + if (result.wasSuccessful()) { + writer().println(); + writer().print("OK"); + writer().println (" (" + result.runCount() + " tests)"); + + } else { + writer().println(); + writer().println("FAILURES!!!"); + writer().println("Tests run: "+result.runCount()+ + ", Failures: "+result.failureCount()+ + ", Errors: "+result.errorCount()); + } + } + + + /** + * Starts a test run. Analyzes the command line arguments + * and runs the given test suite. + */ + protected TestResult start(String args[]) throws Exception { + if(args.length == 0){ + throw new Exception("Usage: TestRunner testCaseName"); + } + String testCase= args[0]; + + try { + Test suite= getTest(testCase); + return doRun(suite); + } + catch(Exception e) { + throw new Exception("Could not create and run test suite: "+e); + } + } + + protected void runFailed(String message) { + System.err.println(message); + System.exit(-1); + } + + /** + * Runs a suite extracted from a TestCase subclass. + */ + static public void run(Class testClass) { + run(new TestSuite(testClass)); + } + /** + * Runs a single test and collects its results. + * This method can be used to start a test run + * from your program. + *
+     * public static void main (String[] args) {
+     *     test.textui.TestRunner.run(suite());
+     * }
+     * 
+ */ + static public void run(Test suite) { + TestRunner aTestRunner= new TestRunner(); + aTestRunner.doRun(suite); + } + + protected PrintStream writer() { + return writer; + } + + +} diff --git a/students/315863321/uml/junit.gliffy b/students/315863321/uml/junit.gliffy new file mode 100644 index 0000000000..6497806282 --- /dev/null +++ b/students/315863321/uml/junit.gliffy @@ -0,0 +1 @@ +{"contentType":"application/gliffy+json","version":"1.1","metadata":{"title":"untitled","revision":0,"exportBorder":false},"embeddedResources":{"index":0,"resources":[]},"stage":{"objects":[{"x":69.64285714285715,"y":79.39285714285714,"rotation":0,"id":175,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":175,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[3.357142857142847,207.60714285714286],[3.357142857142847,92.47362920476345],[70.35714285714288,92.47362920476345]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":168,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":60,"px":1.1102230246251563e-16,"py":0.2928932188134525}}},"linkMap":[]},{"x":1019.6923076923077,"y":745,"rotation":0,"id":165,"uid":"com.gliffy.shape.uml.uml_v1.default.note","width":250.30769230769238,"height":170,"lockAspectRatio":false,"lockShape":false,"order":90,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.note.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":5.006153846153847,"y":0,"rotation":0,"id":176,"uid":null,"width":240.29538461538462,"height":98,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

Command模式:表达一个测试用例\n

模板方法模式:实现数据的准备和清理\n

组合模式:屏蔽一个和多个的差别\n

收集参数模式:隔离测试用例和测试结果\n

观察者模式:隔离测试结果和UI层\n

装饰器模式:装饰测试用例使得它可以重复运行\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":1051.6071428571427,"y":459.64285714285717,"rotation":0,"id":162,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":89,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-96.60714285714266,-1.6428571428571672],[-96.60714285714266,-21.154885329441584],[-96.60714285714266,-40.66691351602594],[-96.60714285714266,-60.17894170261036]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":151,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":144,"px":0.5,"py":1}}},"linkMap":[]},{"x":1107.3214285714287,"y":310.60714285714283,"rotation":0,"id":161,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":88,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-515.3214285714287,-248.6401514461339],[-17.32142857142867,-248.6401514461339],[-17.32142857142867,32.6248148629806],[-57.32142857142867,32.6248148629806]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":36,"px":1,"py":0.29289321881345237}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":144,"px":1,"py":0.5}}},"linkMap":[]},{"x":940.3653846153845,"y":229.75549450549448,"rotation":0,"id":160,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":87,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[14.634615384615472,57.24450549450552],[14.634615384615472,-28.755494505494482],[-418.3653846153845,-28.755494505494482],[-418.3653846153845,-114.75549450549448]],"lockSegments":{"1":true}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":144,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":36,"px":0.5,"py":1}}},"linkMap":[]},{"x":121,"y":794,"rotation":0,"id":136,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":72,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[23,66],[23,52.66666666666663],[23,39.33333333333337],[23,26]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":129,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":113,"px":0.5,"py":1}}},"linkMap":[]},{"x":147,"y":632,"rotation":0,"id":128,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":64,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-3,38],[-3,10.666666666666629],[-3,-16.66666666666663],[-3,-44]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":113,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":94,"px":0.5,"py":1}}},"linkMap":[]},{"x":18,"y":478,"rotation":0,"id":94,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":252,"height":110,"lockAspectRatio":false,"lockShape":false,"order":47,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":95,"uid":null,"width":252,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":96,"uid":null,"width":252,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestListener

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":96,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":97,"uid":null,"width":252,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":98,"uid":null,"width":252,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":95,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":98,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":99,"uid":null,"width":252,"height":88,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":100,"uid":null,"width":252,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void addError(Test, Throwable)\n

+ void addFailure(Test, AssertionFailedError)\n

+ void endTest(Test)\n

+void startTest(Test)\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":94,"magnitude":1},{"id":95,"magnitude":-1},{"id":97,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":97,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":95,"magnitude":1},{"id":97,"magnitude":1},{"id":100,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":265,"y":526,"rotation":0,"id":111,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":56,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[4.844931234147168,1],[43.563287489431445,1],[82.28164374471572,1],[121,1]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":94,"px":1,"py":0.5}}},"linkMap":[]},{"x":720,"y":672,"rotation":0,"id":102,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":55,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[3,23],[-29,23],[-29,-85],[-61,-85]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":76,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":69,"px":1,"py":0.5}}},"linkMap":[]},{"x":796,"y":288,"rotation":0,"id":101,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":54,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-204,-194.96699141100893],[-26,-194.96699141100893],[-26,54],[-66,54]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":36,"px":0.9999999999999998,"py":0.7071067811865475}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":52,"px":1,"py":0.5}}},"linkMap":[]},{"x":194,"y":530,"rotation":0,"id":93,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":46,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[466,-133],[466,-85.5],[328,-85.5],[328,-40]],"lockSegments":{"1":true}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":52,"px":0.5,"py":1}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":69,"px":0.5,"py":0}}},"linkMap":[]},{"x":223,"y":448,"rotation":0,"id":92,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":45,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[187,-37],[187,-3.5],[299,-3.5],[299,42]],"lockSegments":{"1":true}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":43,"px":0.5,"py":1}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":69,"px":0.5,"py":0}}},"linkMap":[]},{"x":723,"y":645,"rotation":0,"id":76,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":160,"height":100,"lockAspectRatio":false,"lockShape":false,"order":38,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":77,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":78,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestFailure

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":78,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":79,"uid":null,"width":160,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":80,"uid":null,"width":160,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- Test failedTest\n

- Throwable thrownException

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":77,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":80,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":81,"uid":null,"width":160,"height":50,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":82,"uid":null,"width":160,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":76,"magnitude":1},{"id":77,"magnitude":-1},{"id":79,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":79,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":77,"magnitude":1},{"id":79,"magnitude":1},{"id":82,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":385,"y":490,"rotation":0,"id":69,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":274,"height":194,"lockAspectRatio":false,"lockShape":false,"order":31,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":70,"uid":null,"width":274,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":71,"uid":null,"width":274,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestResult

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":71,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":72,"uid":null,"width":274,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":73,"uid":null,"width":274,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- List<TestFailure> failures\n

- List<TestFailure> errors\n

- List<TestListener> listeners

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":70,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":73,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":64,"rotation":0,"id":74,"uid":null,"width":274,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":75,"uid":null,"width":274,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void startTest(Test)\n

+ void endTest(Test)\n

+ void addError(Test, Throwable)\n

+ void addFailure(Test, AssertionFailedError)\n

+ void run(TestCase)\n

+ boolean wasSuccessful()\n

+ int errorCount()\n

+ int failureCount()\n

+ int runCount()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":69,"magnitude":1},{"id":70,"magnitude":-1},{"id":72,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":72,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":70,"magnitude":1},{"id":72,"magnitude":1},{"id":75,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":183,"y":338,"rotation":0,"id":68,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":30,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[157,11],[37,11],[37,-123]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":43,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":60,"px":0.5,"py":1}}},"linkMap":[]},{"x":140,"y":154,"rotation":0,"id":60,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":160,"height":61,"lockAspectRatio":false,"lockShape":false,"order":23,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":61,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":62,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Assert

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":62,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":63,"uid":null,"width":160,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":64,"uid":null,"width":160,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":61,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":64,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":65,"uid":null,"width":160,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":66,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

void assertEquals()\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":60,"magnitude":1},{"id":61,"magnitude":-1},{"id":63,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":63,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":61,"magnitude":1},{"id":63,"magnitude":1},{"id":66,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":649,"y":234,"rotation":0,"id":59,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":22,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[11,53],[11,-33],[-127,-33],[-127,-119]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":52,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":36,"px":0.5,"py":1}}},"linkMap":[]},{"x":590,"y":287,"rotation":0,"id":52,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":110,"lockAspectRatio":false,"lockShape":false,"order":15,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":53,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":54,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestSuite

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":54,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":55,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":56,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- String name\n

- List<Test> tests

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":53,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":56,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":57,"uid":null,"width":140,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":58,"uid":null,"width":140,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void run(TestResult)\n

+ void addTest(Test)\n

+ void addTestSuite(Test)\n

+ int countTestCases()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":52,"magnitude":1},{"id":53,"magnitude":-1},{"id":55,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":55,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":53,"magnitude":1},{"id":55,"magnitude":1},{"id":58,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":455,"y":269,"rotation":0,"id":50,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":14,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-45,18],[-45,-68],[67,-68],[67,-154]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":43,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":36,"px":0.5,"py":1}}},"linkMap":[]},{"x":340,"y":287,"rotation":0,"id":43,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":124,"lockAspectRatio":false,"lockShape":false,"order":7,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":44,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":45,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestCase

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":45,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":46,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":47,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- String name

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":44,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":47,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":48,"uid":null,"width":140,"height":88,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":49,"uid":null,"width":140,"height":88,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ int countTestCases()\n

+ void run(TestResult)\n

# void doRun()\n

# void runTest()\n

# void setUp()\n

# void tearDown()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":43,"magnitude":1},{"id":44,"magnitude":-1},{"id":46,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":46,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":44,"magnitude":1},{"id":46,"magnitude":1},{"id":49,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":452,"y":40,"rotation":0,"id":36,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":75,"lockAspectRatio":false,"lockShape":false,"order":0,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":37,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":38,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

<<interface>>\n

Test

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":38,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":32,"rotation":0,"id":39,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":40,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":37,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":40,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":41,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":42,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ int countTestCases()\n

+ void run(TestResult)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":36,"magnitude":1},{"id":37,"magnitude":-1},{"id":39,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":39,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":37,"magnitude":1},{"id":39,"magnitude":1},{"id":42,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":32,"y":670,"rotation":0,"id":113,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":224.00000000000003,"height":150,"lockAspectRatio":false,"lockShape":false,"order":57,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":114,"uid":null,"width":224.00000000000003,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":115,"uid":null,"width":224.00000000000003,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

BaseTestRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":115,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":116,"uid":null,"width":224.00000000000003,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":117,"uid":null,"width":224.00000000000003,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":114,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":117,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":118,"uid":null,"width":224.00000000000003,"height":128,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":119,"uid":null,"width":224.00000000000003,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ Test getTest(String suiteClassName)\n

# Class loadSuiteClass(String suiteClassName)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":113,"magnitude":1},{"id":114,"magnitude":-1},{"id":116,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":116,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":114,"magnitude":1},{"id":116,"magnitude":1},{"id":119,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":29,"y":860,"rotation":0,"id":129,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":229.99999999999997,"height":152,"lockAspectRatio":false,"lockShape":false,"order":65,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":130,"uid":null,"width":229.99999999999997,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":131,"uid":null,"width":229.99999999999997,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":131,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":132,"uid":null,"width":229.99999999999997,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":133,"uid":null,"width":229.99999999999997,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":130,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":133,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":134,"uid":null,"width":229.99999999999997,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":135,"uid":null,"width":229.99999999999997,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void addError(Test, Throwable)\n

+ void addFailure(Test, AssertionFailedError)\n

+ void endTest(Test)\n

+ void startTest(Test)\n

+ void static main(String args[])\n

# TestResult start(String args[])\n

+ TestResult doRun(Test)\n

........

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":129,"magnitude":1},{"id":130,"magnitude":-1},{"id":132,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":132,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":130,"magnitude":1},{"id":132,"magnitude":1},{"id":135,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":860,"y":287,"rotation":0,"id":144,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":190,"height":112.46391544024681,"lockAspectRatio":false,"lockShape":false,"order":73,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":145,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":146,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestDecorator

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":146,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":147,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":148,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

# Test

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":145,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":148,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":149,"uid":null,"width":190,"height":76.46391544024681,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":150,"uid":null,"width":190,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void basicRun(TestResult)\n

+ void run(TestResult)\n

+ int countTestCases()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":144,"magnitude":1},{"id":145,"magnitude":-1},{"id":147,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":147,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":145,"magnitude":1},{"id":147,"magnitude":1},{"id":150,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":885,"y":458,"rotation":0,"id":151,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":61,"lockAspectRatio":false,"lockShape":false,"order":80,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":152,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":153,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

RepeatedTest

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":153,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":154,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":155,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":152,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":155,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":156,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":157,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void run(TestResult)\n

+ int countTestCases()\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":151,"magnitude":1},{"id":152,"magnitude":-1},{"id":154,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":154,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":152,"magnitude":1},{"id":154,"magnitude":1},{"id":157,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":3,"y":287,"rotation":0,"id":168,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":61,"lockAspectRatio":false,"lockShape":false,"order":97,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":169,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":170,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

AssertionFailedError

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":170,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":171,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":172,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":169,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":172,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":173,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":174,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":168,"magnitude":1},{"id":169,"magnitude":-1},{"id":171,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":171,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":169,"magnitude":1},{"id":171,"magnitude":1},{"id":174,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]}],"background":"#FFFFFF","width":1270,"height":1014,"maxWidth":5000,"maxHeight":5000,"nodeIndex":177,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file From a920b5657c410e9652db4d16ce77d9807110c0c1 Mon Sep 17 00:00:00 2001 From: johnChnia Date: Mon, 4 Sep 2017 15:56:42 +0800 Subject: [PATCH 75/81] =?UTF-8?q?JUnit3=E7=B1=BB=E5=9B=BE=E5=92=8C?= =?UTF-8?q?=E6=97=B6=E5=BA=8F=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uml/JUnit3\346\227\266\345\272\217\345\233\276.gliffy" | 1 + "students/315863321/uml/JUnit3\347\261\273\345\233\276.gliffy" | 1 + 2 files changed, 2 insertions(+) create mode 100644 "students/315863321/uml/JUnit3\346\227\266\345\272\217\345\233\276.gliffy" create mode 100644 "students/315863321/uml/JUnit3\347\261\273\345\233\276.gliffy" diff --git "a/students/315863321/uml/JUnit3\346\227\266\345\272\217\345\233\276.gliffy" "b/students/315863321/uml/JUnit3\346\227\266\345\272\217\345\233\276.gliffy" new file mode 100644 index 0000000000..8b14c85b29 --- /dev/null +++ "b/students/315863321/uml/JUnit3\346\227\266\345\272\217\345\233\276.gliffy" @@ -0,0 +1 @@ +{"contentType":"application/gliffy+json","version":"1.1","metadata":{"title":"untitled","revision":0,"exportBorder":false},"embeddedResources":{"index":0,"resources":[]},"stage":{"objects":[{"x":501.97802197802207,"y":663.7362637362638,"rotation":0,"id":93,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":39,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[127.47252747252753,-1.758241758241752],[53.1868131868132,-1.758241758241752],[53.1868131868132,-1.758241758241752],[-21.09890109890108,-1.758241758241752]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":641,"y":620.5,"rotation":0,"id":77,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":38,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

endTest()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":650.5,"y":616,"rotation":0,"id":75,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":37,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":480.5,"y":529.5,"rotation":0,"id":72,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":36,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

tearDown()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":480.5,"y":529.5,"rotation":0,"id":70,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":35,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":471,"y":470,"rotation":0,"id":68,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":34,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

runTest()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":480.5,"y":470,"rotation":0,"id":66,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":33,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":466,"y":418,"rotation":0,"id":64,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":32,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

setUp()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":480.5,"y":410,"rotation":0,"id":61,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":31,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":464,"y":364,"rotation":0,"id":60,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":30,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

doRun()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":488,"y":539,"rotation":0,"id":59,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":29,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[140,-157],[-9.030198282093124,-157]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":461.5,"y":381,"rotation":0,"id":58,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":280,"lockAspectRatio":false,"lockShape":false,"order":28,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":479,"y":200,"rotation":0,"id":51,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":25,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(this)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":502,"y":215,"rotation":0,"id":50,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":24,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-20,0],[131,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":291,"y":199,"rotation":0,"id":47,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":22,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(TestResult)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":310,"y":215,"rotation":0,"id":46,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":21,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-8,0],[150.07909412695915,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":461.5,"y":211,"rotation":0,"id":45,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":85,"lockAspectRatio":false,"lockShape":false,"order":20,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":281.5,"y":176,"rotation":0,"id":40,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":480,"lockAspectRatio":false,"lockShape":false,"order":18,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":99.5,"y":176,"rotation":0,"id":39,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":480,"lockAspectRatio":false,"lockShape":false,"order":17,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":48,"y":126,"rotation":0,"id":18,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":600.0000000000001,"lockAspectRatio":false,"lockShape":false,"order":0,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":19,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":20,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":20,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":21,"uid":null,"width":120,"height":582.0000000000001,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":18,"magnitude":1},{"id":19,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":19,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":19,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":230,"y":126,"rotation":0,"id":22,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":600,"lockAspectRatio":false,"lockShape":false,"order":4,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":23,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":24,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestSuite\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":24,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":25,"uid":null,"width":120,"height":582,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":22,"magnitude":1},{"id":23,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":23,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":23,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":410,"y":126,"rotation":0,"id":26,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":600,"lockAspectRatio":false,"lockShape":false,"order":8,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":27,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":28,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestCase

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":28,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":29,"uid":null,"width":120,"height":582,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":26,"magnitude":1},{"id":27,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":27,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":27,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":580,"y":126,"rotation":0,"id":30,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":600,"lockAspectRatio":false,"lockShape":false,"order":12,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":31,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":32,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestResult\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":32,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":33,"uid":null,"width":120,"height":582,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":30,"magnitude":1},{"id":31,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":31,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":31,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":641,"y":219,"rotation":0,"id":55,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":27,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

startTest()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":650.5,"y":214,"rotation":0,"id":53,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":32,"lockAspectRatio":false,"lockShape":false,"order":26,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":631.5,"y":211,"rotation":0,"id":49,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":450,"lockAspectRatio":false,"lockShape":false,"order":23,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":147,"y":177,"rotation":0,"id":38,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":16,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-31,0],[134.0030302752043,1.1368683772161603e-13]],"lockSegments":{}}},"children":[],"linkMap":[]},{"x":111,"y":164,"rotation":0,"id":42,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":19,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(TestResult)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":511.97802197802207,"y":673.7362637362638,"rotation":0,"id":94,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":40,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-31.97802197802207,-64.50549450549454],[44.065934065934016,-64.50549450549454],[44.065934065934016,-64.50549450549454],[120.10989010988999,-64.50549450549454]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":330.879120879121,"y":661.4285714285716,"rotation":0,"id":95,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":41,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[127.47252747252753,-1.758241758241752],[48.626373626373606,-1.758241758241752],[48.626373626373606,-2.087912087912173],[-30.21978021978032,-2.087912087912173]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":150.43956043956044,"y":655.054945054945,"rotation":0,"id":96,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":42,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[127.47252747252753,-1.758241758241752],[48.626373626373606,-1.758241758241752],[48.626373626373606,-2.087912087912173],[-30.21978021978032,-2.087912087912173]],"lockSegments":{}}},"children":null,"linkMap":[]}],"background":"#FFFFFF","width":789,"height":727,"maxWidth":5000,"maxHeight":5000,"nodeIndex":97,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file diff --git "a/students/315863321/uml/JUnit3\347\261\273\345\233\276.gliffy" "b/students/315863321/uml/JUnit3\347\261\273\345\233\276.gliffy" new file mode 100644 index 0000000000..6497806282 --- /dev/null +++ "b/students/315863321/uml/JUnit3\347\261\273\345\233\276.gliffy" @@ -0,0 +1 @@ +{"contentType":"application/gliffy+json","version":"1.1","metadata":{"title":"untitled","revision":0,"exportBorder":false},"embeddedResources":{"index":0,"resources":[]},"stage":{"objects":[{"x":69.64285714285715,"y":79.39285714285714,"rotation":0,"id":175,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":175,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[3.357142857142847,207.60714285714286],[3.357142857142847,92.47362920476345],[70.35714285714288,92.47362920476345]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":168,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":60,"px":1.1102230246251563e-16,"py":0.2928932188134525}}},"linkMap":[]},{"x":1019.6923076923077,"y":745,"rotation":0,"id":165,"uid":"com.gliffy.shape.uml.uml_v1.default.note","width":250.30769230769238,"height":170,"lockAspectRatio":false,"lockShape":false,"order":90,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.note.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":5.006153846153847,"y":0,"rotation":0,"id":176,"uid":null,"width":240.29538461538462,"height":98,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

Command模式:表达一个测试用例\n

模板方法模式:实现数据的准备和清理\n

组合模式:屏蔽一个和多个的差别\n

收集参数模式:隔离测试用例和测试结果\n

观察者模式:隔离测试结果和UI层\n

装饰器模式:装饰测试用例使得它可以重复运行\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":1051.6071428571427,"y":459.64285714285717,"rotation":0,"id":162,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":89,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-96.60714285714266,-1.6428571428571672],[-96.60714285714266,-21.154885329441584],[-96.60714285714266,-40.66691351602594],[-96.60714285714266,-60.17894170261036]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":151,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":144,"px":0.5,"py":1}}},"linkMap":[]},{"x":1107.3214285714287,"y":310.60714285714283,"rotation":0,"id":161,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":88,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-515.3214285714287,-248.6401514461339],[-17.32142857142867,-248.6401514461339],[-17.32142857142867,32.6248148629806],[-57.32142857142867,32.6248148629806]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":36,"px":1,"py":0.29289321881345237}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":144,"px":1,"py":0.5}}},"linkMap":[]},{"x":940.3653846153845,"y":229.75549450549448,"rotation":0,"id":160,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":87,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[14.634615384615472,57.24450549450552],[14.634615384615472,-28.755494505494482],[-418.3653846153845,-28.755494505494482],[-418.3653846153845,-114.75549450549448]],"lockSegments":{"1":true}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":144,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":36,"px":0.5,"py":1}}},"linkMap":[]},{"x":121,"y":794,"rotation":0,"id":136,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":72,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[23,66],[23,52.66666666666663],[23,39.33333333333337],[23,26]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":129,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":113,"px":0.5,"py":1}}},"linkMap":[]},{"x":147,"y":632,"rotation":0,"id":128,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":64,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-3,38],[-3,10.666666666666629],[-3,-16.66666666666663],[-3,-44]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":113,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":94,"px":0.5,"py":1}}},"linkMap":[]},{"x":18,"y":478,"rotation":0,"id":94,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":252,"height":110,"lockAspectRatio":false,"lockShape":false,"order":47,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":95,"uid":null,"width":252,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":96,"uid":null,"width":252,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestListener

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":96,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":97,"uid":null,"width":252,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":98,"uid":null,"width":252,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":95,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":98,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":99,"uid":null,"width":252,"height":88,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":100,"uid":null,"width":252,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void addError(Test, Throwable)\n

+ void addFailure(Test, AssertionFailedError)\n

+ void endTest(Test)\n

+void startTest(Test)\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":94,"magnitude":1},{"id":95,"magnitude":-1},{"id":97,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":97,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":95,"magnitude":1},{"id":97,"magnitude":1},{"id":100,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":265,"y":526,"rotation":0,"id":111,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":56,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[4.844931234147168,1],[43.563287489431445,1],[82.28164374471572,1],[121,1]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":94,"px":1,"py":0.5}}},"linkMap":[]},{"x":720,"y":672,"rotation":0,"id":102,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":55,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[3,23],[-29,23],[-29,-85],[-61,-85]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":76,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":69,"px":1,"py":0.5}}},"linkMap":[]},{"x":796,"y":288,"rotation":0,"id":101,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":54,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-204,-194.96699141100893],[-26,-194.96699141100893],[-26,54],[-66,54]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":36,"px":0.9999999999999998,"py":0.7071067811865475}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":52,"px":1,"py":0.5}}},"linkMap":[]},{"x":194,"y":530,"rotation":0,"id":93,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":46,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[466,-133],[466,-85.5],[328,-85.5],[328,-40]],"lockSegments":{"1":true}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":52,"px":0.5,"py":1}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":69,"px":0.5,"py":0}}},"linkMap":[]},{"x":223,"y":448,"rotation":0,"id":92,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":45,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[187,-37],[187,-3.5],[299,-3.5],[299,42]],"lockSegments":{"1":true}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":43,"px":0.5,"py":1}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":69,"px":0.5,"py":0}}},"linkMap":[]},{"x":723,"y":645,"rotation":0,"id":76,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":160,"height":100,"lockAspectRatio":false,"lockShape":false,"order":38,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":77,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":78,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestFailure

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":78,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":79,"uid":null,"width":160,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":80,"uid":null,"width":160,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- Test failedTest\n

- Throwable thrownException

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":77,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":80,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":81,"uid":null,"width":160,"height":50,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":82,"uid":null,"width":160,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":76,"magnitude":1},{"id":77,"magnitude":-1},{"id":79,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":79,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":77,"magnitude":1},{"id":79,"magnitude":1},{"id":82,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":385,"y":490,"rotation":0,"id":69,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":274,"height":194,"lockAspectRatio":false,"lockShape":false,"order":31,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":70,"uid":null,"width":274,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":71,"uid":null,"width":274,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestResult

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":71,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":72,"uid":null,"width":274,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":73,"uid":null,"width":274,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- List<TestFailure> failures\n

- List<TestFailure> errors\n

- List<TestListener> listeners

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":70,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":73,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":64,"rotation":0,"id":74,"uid":null,"width":274,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":75,"uid":null,"width":274,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void startTest(Test)\n

+ void endTest(Test)\n

+ void addError(Test, Throwable)\n

+ void addFailure(Test, AssertionFailedError)\n

+ void run(TestCase)\n

+ boolean wasSuccessful()\n

+ int errorCount()\n

+ int failureCount()\n

+ int runCount()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":69,"magnitude":1},{"id":70,"magnitude":-1},{"id":72,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":72,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":70,"magnitude":1},{"id":72,"magnitude":1},{"id":75,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":183,"y":338,"rotation":0,"id":68,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":30,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[157,11],[37,11],[37,-123]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":43,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":60,"px":0.5,"py":1}}},"linkMap":[]},{"x":140,"y":154,"rotation":0,"id":60,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":160,"height":61,"lockAspectRatio":false,"lockShape":false,"order":23,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":61,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":62,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Assert

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":62,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":63,"uid":null,"width":160,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":64,"uid":null,"width":160,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":61,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":64,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":65,"uid":null,"width":160,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":66,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

void assertEquals()\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":60,"magnitude":1},{"id":61,"magnitude":-1},{"id":63,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":63,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":61,"magnitude":1},{"id":63,"magnitude":1},{"id":66,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":649,"y":234,"rotation":0,"id":59,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":22,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[11,53],[11,-33],[-127,-33],[-127,-119]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":52,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":36,"px":0.5,"py":1}}},"linkMap":[]},{"x":590,"y":287,"rotation":0,"id":52,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":110,"lockAspectRatio":false,"lockShape":false,"order":15,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":53,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":54,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestSuite

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":54,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":55,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":56,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- String name\n

- List<Test> tests

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":53,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":56,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":57,"uid":null,"width":140,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":58,"uid":null,"width":140,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void run(TestResult)\n

+ void addTest(Test)\n

+ void addTestSuite(Test)\n

+ int countTestCases()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":52,"magnitude":1},{"id":53,"magnitude":-1},{"id":55,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":55,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":53,"magnitude":1},{"id":55,"magnitude":1},{"id":58,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":455,"y":269,"rotation":0,"id":50,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":14,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-45,18],[-45,-68],[67,-68],[67,-154]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":43,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":36,"px":0.5,"py":1}}},"linkMap":[]},{"x":340,"y":287,"rotation":0,"id":43,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":124,"lockAspectRatio":false,"lockShape":false,"order":7,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":44,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":45,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestCase

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":45,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":46,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":47,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- String name

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":44,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":47,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":48,"uid":null,"width":140,"height":88,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":49,"uid":null,"width":140,"height":88,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ int countTestCases()\n

+ void run(TestResult)\n

# void doRun()\n

# void runTest()\n

# void setUp()\n

# void tearDown()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":43,"magnitude":1},{"id":44,"magnitude":-1},{"id":46,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":46,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":44,"magnitude":1},{"id":46,"magnitude":1},{"id":49,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":452,"y":40,"rotation":0,"id":36,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":75,"lockAspectRatio":false,"lockShape":false,"order":0,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":37,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":38,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

<<interface>>\n

Test

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":38,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":32,"rotation":0,"id":39,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":40,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":37,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":40,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":41,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":42,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ int countTestCases()\n

+ void run(TestResult)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":36,"magnitude":1},{"id":37,"magnitude":-1},{"id":39,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":39,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":37,"magnitude":1},{"id":39,"magnitude":1},{"id":42,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":32,"y":670,"rotation":0,"id":113,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":224.00000000000003,"height":150,"lockAspectRatio":false,"lockShape":false,"order":57,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":114,"uid":null,"width":224.00000000000003,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":115,"uid":null,"width":224.00000000000003,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

BaseTestRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":115,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":116,"uid":null,"width":224.00000000000003,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":117,"uid":null,"width":224.00000000000003,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":114,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":117,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":118,"uid":null,"width":224.00000000000003,"height":128,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":119,"uid":null,"width":224.00000000000003,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ Test getTest(String suiteClassName)\n

# Class loadSuiteClass(String suiteClassName)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":113,"magnitude":1},{"id":114,"magnitude":-1},{"id":116,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":116,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":114,"magnitude":1},{"id":116,"magnitude":1},{"id":119,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":29,"y":860,"rotation":0,"id":129,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":229.99999999999997,"height":152,"lockAspectRatio":false,"lockShape":false,"order":65,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":130,"uid":null,"width":229.99999999999997,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":131,"uid":null,"width":229.99999999999997,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":131,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":132,"uid":null,"width":229.99999999999997,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":133,"uid":null,"width":229.99999999999997,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":130,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":133,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":134,"uid":null,"width":229.99999999999997,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":135,"uid":null,"width":229.99999999999997,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void addError(Test, Throwable)\n

+ void addFailure(Test, AssertionFailedError)\n

+ void endTest(Test)\n

+ void startTest(Test)\n

+ void static main(String args[])\n

# TestResult start(String args[])\n

+ TestResult doRun(Test)\n

........

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":129,"magnitude":1},{"id":130,"magnitude":-1},{"id":132,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":132,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":130,"magnitude":1},{"id":132,"magnitude":1},{"id":135,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":860,"y":287,"rotation":0,"id":144,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":190,"height":112.46391544024681,"lockAspectRatio":false,"lockShape":false,"order":73,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":145,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":146,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestDecorator

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":146,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":147,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":148,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

# Test

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":145,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":148,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":149,"uid":null,"width":190,"height":76.46391544024681,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":150,"uid":null,"width":190,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void basicRun(TestResult)\n

+ void run(TestResult)\n

+ int countTestCases()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":144,"magnitude":1},{"id":145,"magnitude":-1},{"id":147,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":147,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":145,"magnitude":1},{"id":147,"magnitude":1},{"id":150,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":885,"y":458,"rotation":0,"id":151,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":61,"lockAspectRatio":false,"lockShape":false,"order":80,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":152,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":153,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

RepeatedTest

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":153,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":154,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":155,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":152,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":155,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":156,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":157,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void run(TestResult)\n

+ int countTestCases()\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":151,"magnitude":1},{"id":152,"magnitude":-1},{"id":154,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":154,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":152,"magnitude":1},{"id":154,"magnitude":1},{"id":157,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":3,"y":287,"rotation":0,"id":168,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":61,"lockAspectRatio":false,"lockShape":false,"order":97,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":169,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":170,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

AssertionFailedError

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":170,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":171,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":172,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":169,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":172,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":173,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":174,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":168,"magnitude":1},{"id":169,"magnitude":-1},{"id":171,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":171,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":169,"magnitude":1},{"id":171,"magnitude":1},{"id":174,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]}],"background":"#FFFFFF","width":1270,"height":1014,"maxWidth":5000,"maxHeight":5000,"nodeIndex":177,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file From 966ccbba9e72a6eb3dcaa286ece48a704ece8c6b Mon Sep 17 00:00:00 2001 From: johnChnia Date: Wed, 6 Sep 2017 19:16:26 +0800 Subject: [PATCH 76/81] =?UTF-8?q?litejunitV3=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/litejunit/v3/After.java | 39 +++ .../java/org/litejunit/v3/AfterClass.java | 41 +++ .../main/java/org/litejunit/v3/Assert.java | 269 ++++++++++++++++++ .../main/java/org/litejunit/v3/Before.java | 37 +++ .../java/org/litejunit/v3/BeforeClass.java | 36 +++ .../org/litejunit/v3/ComparisonFailure.java | 124 ++++++++ .../main/java/org/litejunit/v3/Ignore.java | 31 ++ .../src/main/java/org/litejunit/v3/Test.java | 62 ++++ .../v3/internal/requests/ClassRequest.java | 50 ++++ .../v3/internal/requests/ClassesRequest.java | 30 ++ .../requests/ErrorReportingRequest.java | 45 +++ .../v3/internal/requests/FilterRequest.java | 33 +++ .../v3/internal/requests/SortingRequest.java | 26 ++ .../runners/BeforeAndAfterRunner.java | 76 +++++ .../v3/internal/runners/CompositeRunner.java | 70 +++++ .../runners/ErrorReportingRunner.java | 34 +++ .../internal/runners/InitializationError.java | 25 ++ .../v3/internal/runners/MethodValidator.java | 74 +++++ .../runners/TestClassMethodsRunner.java | 103 +++++++ .../v3/internal/runners/TestClassRunner.java | 70 +++++ .../v3/internal/runners/TestIntrospector.java | 78 +++++ .../v3/internal/runners/TestMethodRunner.java | 114 ++++++++ .../v3/internal/runners/TextListener.java | 105 +++++++ .../org/litejunit/v3/runner/Description.java | 127 +++++++++ .../org/litejunit/v3/runner/JUnitCore.java | 152 ++++++++++ .../java/org/litejunit/v3/runner/Request.java | 87 ++++++ .../java/org/litejunit/v3/runner/Result.java | 97 +++++++ .../java/org/litejunit/v3/runner/RunWith.java | 25 ++ .../java/org/litejunit/v3/runner/Runner.java | 34 +++ .../v3/runner/manipulation/Filter.java | 50 ++++ .../v3/runner/manipulation/Filterable.java | 16 ++ .../manipulation/NoTestsRemainException.java | 8 + .../v3/runner/manipulation/Sortable.java | 13 + .../v3/runner/manipulation/Sorter.java | 31 ++ .../v3/runner/notification/Failure.java | 77 +++++ .../v3/runner/notification/RunListener.java | 79 +++++ .../v3/runner/notification/RunNotifier.java | 137 +++++++++ .../notification/StoppedByUserException.java | 11 + .../litejunit/v3/runners/Parameterized.java | 146 ++++++++++ .../java/org/litejunit/v3/runners/Suite.java | 50 ++++ .../java/org/litejunit/v3/sample/AllTest.java | 40 +++ .../org/litejunit/v3/sample/Calculator.java | 25 ++ .../litejunit/v3/sample/CalculatorTest.java | 50 ++++ .../litejunit/v3/sample/ParametTestUnit.java | 54 ++++ .../org/litejunit/v3/sample/PersonTest.java | 48 ++++ 45 files changed, 2929 insertions(+) create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/After.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/AfterClass.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Assert.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Before.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/BeforeClass.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/ComparisonFailure.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Ignore.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Test.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ClassRequest.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ClassesRequest.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ErrorReportingRequest.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/FilterRequest.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/SortingRequest.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/BeforeAndAfterRunner.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/CompositeRunner.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/ErrorReportingRunner.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/InitializationError.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/MethodValidator.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestClassMethodsRunner.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestClassRunner.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestIntrospector.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestMethodRunner.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TextListener.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Description.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/JUnitCore.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Request.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Result.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/RunWith.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Runner.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Filter.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Filterable.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/NoTestsRemainException.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Sortable.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Sorter.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/Failure.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/RunListener.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/RunNotifier.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/StoppedByUserException.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/Parameterized.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/Suite.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/AllTest.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/Calculator.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/CalculatorTest.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/ParametTestUnit.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/PersonTest.java diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/After.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/After.java new file mode 100644 index 0000000000..cef97c4aed --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/After.java @@ -0,0 +1,39 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * If you allocate external resources in a @Before method you need to release them + * after the test runs. Annotating a public void method + * with @After causes that method to be run after the @Test method. All @After + * methods are guaranteed to run even if a @Before or @Test method throws an + * exception. The @After methods declared in superclasses will be run after those of the current + * class. + *

+ * Here is a simple example:
+* + * public class Example {
+ *   File output;
+ *   @Before public void createOutputFile() {
+ *     output= new File(...);
+ *   }
+ *   @Test public void something() {
+ *     ...
+ *   }
+ *   @After public void deleteOutputFile() {
+ *     output.delete();
+ *   }
+ * }
+ *
+ * + * @see Before + */ + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface After { +} + diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/AfterClass.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/AfterClass.java new file mode 100644 index 0000000000..8dc15454be --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/AfterClass.java @@ -0,0 +1,41 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * If you allocate expensive external resources in a @BeforeClass method you need to release them + * after all the tests in the class have run. Annotating a public static void method + * with @AfterClass causes that method to be run after all the tests in the class have been run. All @AfterClass + * methods are guaranteed to run even if a @BeforeClass method throws an + * exception. The @AfterClass methods declared in superclasses will be run after those of the current + * class. + *

+ * Here is a simple example:
+* + * public class Example {
+ *   DatabaseConnection database;
+ *   @BeforeClass public void login() {
+ *     database= ...;
+ *   }
+ *   @Test public void something() {
+ *     ...
+ *   }
+ *   @Test public void somethingElse() {
+ *     ...
+ *   }
+ *   @AfterClass public void logout() {
+ *     database.logout();
+ *   }
+ * }
+ *
+ * + * @see BeforeClass + */ + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface AfterClass { +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Assert.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Assert.java new file mode 100644 index 0000000000..6ae8e11544 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Assert.java @@ -0,0 +1,269 @@ +package org.litejunit.v3; + +/** + * A set of assertion methods useful for writing tests. Only failed assertions are recorded. + * These methods can be used directly: Assert.assertEquals(...), however, they + * read better if they are referenced through static import:
+ * + * import static org.junit.Assert.*;
+ * ...
+ *   assertEquals(...);
+ *
+ */ + +public class Assert { + /** + * Protect constructor since it is a static only class + */ + protected Assert() { + } + + /** + * Asserts that a condition is true. If it isn't it throws an + * AssertionError with the given message. + */ + static public void assertTrue(String message, boolean condition) { + if (!condition) + fail(message); + } + + /** + * Asserts that a condition is true. If it isn't it throws an + * AssertionError. + */ + static public void assertTrue(boolean condition) { + assertTrue(null, condition); + } + + /** + * Asserts that a condition is false. If it isn't it throws an + * AssertionError with the given message. + */ + static public void assertFalse(String message, boolean condition) { + assertTrue(message, !condition); + } + + /** + * Asserts that a condition is false. If it isn't it throws an + * AssertionError. + */ + static public void assertFalse(boolean condition) { + assertFalse(null, condition); + } + + /** + * Fails a test with the given message. + */ + static public void fail(String message) { + throw new AssertionError(message); + } + + /** + * Fails a test with no message. + */ + static public void fail() { + fail(null); + } + + /** + * Asserts that two objects are equal. If they are not, an + * AssertionError is thrown with the given message. + */ + static public void assertEquals(String message, Object expected, Object actual) { + if (expected == null && actual == null) + return; + if (expected != null && expected.equals(actual)) + return; + if (expected instanceof String && actual instanceof String) + throw new ComparisonFailure(message, (String)expected, (String)actual); + else + failNotEquals(message, expected, actual); + } + + /** + * Asserts that two objects are equal. If they are not, an + * AssertionError is thrown. + */ + static public void assertEquals(Object expected, Object actual) { + assertEquals(null, expected, actual); + } + + /** + * Asserts that two object arrays are equal. If they are not, an + * AssertionError is thrown with the given message. + */ + public static void assertEquals(String message, Object[] expecteds, Object[] actuals) { + if (expecteds == actuals) + return; + String header = message == null ? "" : message + ": "; + if (expecteds == null) + fail(header + "expected array was null"); + if (actuals == null) + fail(header + "actual array was null"); + if (actuals.length != expecteds.length) + fail(header + "array lengths differed, expected.length=" + expecteds.length + " actual.length=" + actuals.length); + + for (int i= 0; i < expecteds.length; i++) { + Object o1= expecteds[i]; + Object o2= actuals[i]; + if (o1.getClass().isArray() && o2.getClass().isArray()) { + Object[] expected= (Object[]) o1; + Object[] actual= (Object[]) o2; + assertEquals(header + "arrays first differed at element " + i + ";", expected, actual); + } else + assertEquals(header + "arrays first differed at element [" + i + "];", o1, o2); + } + } + + /** + * Asserts that two object arrays are equal. If they are not, an + * AssertionError is thrown. + */ + public static void assertEquals(Object[] expecteds, Object[] actuals) { + assertEquals(null, expecteds, actuals); + } + + /** + * Asserts that two doubles are equal to within a positive delta. If they + * are not, an AssertionError is thrown with the given message. If the + * expected value is infinity then the delta value is ignored. NaNs are + * considered equal: + * assertEquals(Double.NaN, Double.NaN, *) passes + */ + static public void assertEquals(String message, double expected, double actual, double delta) { + if (Double.compare(expected, actual) == 0) + return; + if (!(Math.abs(expected - actual) <= delta)) + failNotEquals(message, new Double(expected), new Double(actual)); + } + + /** + * Asserts that two doubles are equal to within a positive delta. If they + * are not, an AssertionError is thrown. If the + * expected value is infinity then the delta value is ignored.NaNs are + * considered equal: + * assertEquals(Double.NaN, Double.NaN, *) passes + */ + static public void assertEquals(double expected, double actual, double delta) { + assertEquals(null, expected, actual, delta); + } + + /** + * Asserts that two floats are equal to within a positive delta. If they + * are not, an AssertionError is thrown with the given message. If the + * expected value is infinity then the delta value is ignored.NaNs are + * considered equal: + * assertEquals(Float.NaN, Float.NaN, *) passes + */ + static public void assertEquals(String message, float expected, float actual, float delta) { + if (Float.compare(expected, actual) == 0) + return; + if (!(Math.abs(expected - actual) <= delta)) + failNotEquals(message, new Float(expected), new Float(actual)); + } + + /** + * Asserts that two floats are equal to within a positive delta. If they + * are not, an AssertionError is thrown. If the + * expected value is infinity then the delta value is ignored.NaNs are + * considered equal: + * assertEquals(Float.NaN, Float.NaN, *) passes + */ + static public void assertEquals(float expected, float actual, float delta) { + assertEquals(null, expected, actual, delta); + } + + /** + * Asserts that an object isn't null. If it is an AssertionError is + * thrown with the given message. + */ + static public void assertNotNull(String message, Object object) { + assertTrue(message, object != null); + } + + /** + * Asserts that an object isn't null. If it is an AssertionError is + * thrown. + */ + static public void assertNotNull(Object object) { + assertNotNull(null, object); + } + + /** + * Asserts that an object is null. If it is not, an AssertionError is + * thrown with the given message. + */ + static public void assertNull(String message, Object object) { + assertTrue(message, object == null); + } + + /** + * Asserts that an object is null. If it isn't an AssertionError is + * thrown. + */ + static public void assertNull(Object object) { + assertNull(null, object); + } + + /** + * Asserts that two objects refer to the same object. If they are not, an + * AssertionError is thrown with the given message. + */ + static public void assertSame(String message, Object expected, Object actual) { + if (expected == actual) + return; + failNotSame(message, expected, actual); + } + + /** + * Asserts that two objects refer to the same object. If they are not the + * same, an AssertionError is thrown. + */ + static public void assertSame(Object expected, Object actual) { + assertSame(null, expected, actual); + } + + /** + * Asserts that two objects do not refer to the same object. If they do + * refer to the same object, an AssertionError is thrown with the given + * message. + */ + static public void assertNotSame(String message, Object expected, Object actual) { + if (expected == actual) + failSame(message); + } + + /** + * Asserts that two objects do not refer to the same object. If they do + * refer to the same object, an AssertionError is thrown. + */ + static public void assertNotSame(Object expected, Object actual) { + assertNotSame(null, expected, actual); + } + + static private void failSame(String message) { + String formatted= ""; + if (message != null) + formatted= message + " "; + fail(formatted + "expected not same"); + } + + static private void failNotSame(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message + " "; + fail(formatted + "expected same:<" + expected + "> was not:<" + actual + ">"); + } + + static private void failNotEquals(String message, Object expected, Object actual) { + fail(format(message, expected, actual)); + } + + static String format(String message, Object expected, Object actual) { + String formatted= ""; + if (message != null) + formatted= message + " "; + return formatted + "expected:<" + expected + "> but was:<" + actual + ">"; + } + +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Before.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Before.java new file mode 100644 index 0000000000..0d66765427 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Before.java @@ -0,0 +1,37 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * When writing tests, it is common to find that several tests need similar + * objects created before they can run. Annotating a public void method + * with @Before causes that method to be run before the @Test method. + * The @Before methods of superclasses will be run before those of the current class. + *

+ * Here is a simple example: +* + * public class Example {
+ *   List empty;
+ *   @Before public static void initialize() {
+ *     empty= new ArrayList();
+ *   }
+ *   @Test public void size() {
+ *     ...
+ *   }
+ *   @Test public void remove() {
+ *     ...
+ *   }
+ * }
+ *
+ * + * @see BeforeClass + * @see After + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Before { +} + diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/BeforeClass.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/BeforeClass.java new file mode 100644 index 0000000000..d686f45c37 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/BeforeClass.java @@ -0,0 +1,36 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Sometimes several tests need to share computationally expensive setup + * (like logging into a database). While this can compromise the independence of + * tests, sometimes it is a necessary optimization. Annotating a public static void no-arg method + * with @BeforeClass causes it to be run once before any of + * the test methods in the class. The @BeforeClass methods of superclasses + * will be run before those the current class. + *

+ * For example:
+ * + * + * public class Example {
+ *   @BeforeClass public static void onlyOnce() {
+ *     ...
+ *   }
+ *   @Test public void one() {
+ *     ...
+ *   }
+ *   @Test public void two() {
+ *     ...
+ *   }
+ * }
+ *
+ * @see AfterClass + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface BeforeClass { +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/ComparisonFailure.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/ComparisonFailure.java new file mode 100644 index 0000000000..8a71e1f698 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/ComparisonFailure.java @@ -0,0 +1,124 @@ +package org.litejunit.v3; + +/** + * Thrown when an assertEquals(String, String) fails. Create and throw + * a ComparisonFailure manually if you want to show users the difference between two complex + * strings. + * + * Inspired by a patch from Alex Chaffee (alex@purpletech.com) + */ +public class ComparisonFailure extends AssertionError { + private static final int MAX_CONTEXT_LENGTH= 20; + private static final long serialVersionUID= 1L; + + private String fExpected; + private String fActual; + + /** + * Constructs a comparison failure. + * @param message the identifying message or null + * @param expected the expected string value + * @param actual the actual string value + */ + public ComparisonFailure (String message, String expected, String actual) { + super (message); + fExpected= expected; + fActual= actual; + } + + /** + * Returns "..." in place of common prefix and "..." in + * place of common suffix between expected and actual. + * + * @see Throwable#getMessage() + */ + @Override + public String getMessage() { + return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage()); + } + + /** + * Returns the actual value + * @return the actual string value + */ + public String getActual() { + return fActual; + } + /** + * Returns the expected value + * @return the expected string value + */ + public String getExpected() { + return fExpected; + } + + private static class ComparisonCompactor { + private static final String ELLIPSIS= "..."; + private static final String DELTA_END= "]"; + private static final String DELTA_START= "["; + + private int fContextLength; + private String fExpected; + private String fActual; + private int fPrefix; + private int fSuffix; + + public ComparisonCompactor(int contextLength, String expected, String actual) { + fContextLength= contextLength; + fExpected= expected; + fActual= actual; + } + + public String compact(String message) { + if (fExpected == null || fActual == null || areStringsEqual()) + return Assert.format(message, fExpected, fActual); + + findCommonPrefix(); + findCommonSuffix(); + String expected= compactString(fExpected); + String actual= compactString(fActual); + return Assert.format(message, expected, actual); + } + + private String compactString(String source) { + String result= DELTA_START + source.substring(fPrefix, source.length() - fSuffix + 1) + DELTA_END; + if (fPrefix > 0) + result= computeCommonPrefix() + result; + if (fSuffix > 0) + result= result + computeCommonSuffix(); + return result; + } + + private void findCommonPrefix() { + fPrefix= 0; + int end= Math.min(fExpected.length(), fActual.length()); + for (; fPrefix < end; fPrefix++) { + if (fExpected.charAt(fPrefix) != fActual.charAt(fPrefix)) + break; + } + } + + private void findCommonSuffix() { + int expectedSuffix= fExpected.length() - 1; + int actualSuffix= fActual.length() - 1; + for (; actualSuffix >= fPrefix && expectedSuffix >= fPrefix; actualSuffix--, expectedSuffix--) { + if (fExpected.charAt(expectedSuffix) != fActual.charAt(actualSuffix)) + break; + } + fSuffix= fExpected.length() - expectedSuffix; + } + + private String computeCommonPrefix() { + return (fPrefix > fContextLength ? ELLIPSIS : "") + fExpected.substring(Math.max(0, fPrefix - fContextLength), fPrefix); + } + + private String computeCommonSuffix() { + int end= Math.min(fExpected.length() - fSuffix + 1 + fContextLength, fExpected.length()); + return fExpected.substring(fExpected.length() - fSuffix + 1, end) + (fExpected.length() - fSuffix + 1 < fExpected.length() - fContextLength ? ELLIPSIS : ""); + } + + private boolean areStringsEqual() { + return fExpected.equals(fActual); + } + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Ignore.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Ignore.java new file mode 100644 index 0000000000..ecf3048b44 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Ignore.java @@ -0,0 +1,31 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Sometimes you want to temporarily disable a test. Methods annotated with @Test + * that are also annotated with @Ignore will not be executed as tests. Native JUnit 4 test runners + * should report the number of ignored tests along with the number of tests that ran and the + * number of tests that failed. + *

+ * For example:
+ * + *   @Ignore @Test public void something() { ...
+ *
+ * @Ignore takes an optional default parameter if you want to record why a test is being ignored:
+ * + *   @Ignore("not ready yet") @Test public void something() { ...
+ *
+ * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Ignore { + /** + * The optional reason why the test is ignored. + */ + String value() default ""; +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Test.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Test.java new file mode 100644 index 0000000000..d3fcacaf57 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/Test.java @@ -0,0 +1,62 @@ +package org.litejunit.v3; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * The Test annotation tells JUnit that the public void method + * to which it is attached can be run as a test case. To run the method, + * JUnit first constructs a fresh instance of the class then invokes the + * annotated method. Any exceptions thrown by the test will be reported + * by JUnit as a failure. If no exceptions are thrown, the test is assumed + * to have succeeded. + *

+ * A simple test looks like this:
+ * + * public class Example {
+ *   @Test public void method() {
+ *     System.out.println("Hello");
+ *   }
+ * } + *
+ *

+ * The Test annotation supports two optional parameters. + * The first, expected, declares that a test method should throw + * an exception. If it doesn't throw an exception or if it throws a different exception + * than the one declared, the test fails. For example, the following test succeeds:
+ * + *   @Test(expected=IndexOutOfBoundsException.class) public void outOfBounds() {
+ *     new ArrayList<Object>().get(1);
+ *   }
+ *
+ *

+ * The second optional parameter, timeout, causes a test to fail if it takes longer than a specified + * amount of clock time (measured in milliseconds). The following test fails:
+ * + *   @Test(timeout=100) public void infinity() {
+ *     for(;;);
+ *   }
+ *
+ */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface Test { + static class None extends Throwable { + private static final long serialVersionUID= 1L; + private None() { + } + } + + /** + * Optionally specify expected, a Throwable, to cause a test method to succeed iff + * an exception of the specified class is thrown by the method. + */ + Class expected() default None.class; + + /** + * Optionally specify timeout in milliseconds to cause a test method to fail if it + * takes longer than that number of milliseconds.*/ + long timeout() default 0L; +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ClassRequest.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ClassRequest.java new file mode 100644 index 0000000000..4de36b0140 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ClassRequest.java @@ -0,0 +1,50 @@ +/** + * + */ +package org.litejunit.v3.internal.requests; + + +import org.litejunit.v3.internal.runners.TestClassRunner; +import org.litejunit.v3.runner.Request; +import org.litejunit.v3.runner.RunWith; +import org.litejunit.v3.runner.Runner; + +import java.lang.reflect.Constructor; + +public class ClassRequest extends Request { + private final Class fTestClass; + + public ClassRequest(Class each) { + fTestClass = each; + } + + @Override + public Runner getRunner() { + Class runnerClass = getRunnerClass(fTestClass); + try { + Constructor constructor = runnerClass.getConstructor(Class.class); // TODO good error message if no such constructor + Runner runner = (Runner) constructor + .newInstance(new Object[]{fTestClass}); + return runner; + } catch (Exception e) { + return Request.errorReport(fTestClass, e).getRunner(); + } + } + + Class getRunnerClass(Class testClass) { + RunWith annotation = testClass.getAnnotation(RunWith.class); + if (annotation != null) { + return annotation.value(); + } else if (isPre4Test(testClass)) { + return null; +// return OldTestClassRunner.class; + } else { + return TestClassRunner.class; + } + } + + boolean isPre4Test(Class testClass) { + return false; +// return junit.framework.TestCase.class.isAssignableFrom(testClass); + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ClassesRequest.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ClassesRequest.java new file mode 100644 index 0000000000..6da79c26e6 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ClassesRequest.java @@ -0,0 +1,30 @@ +/** + * + */ +package org.litejunit.v3.internal.requests; + + +import org.litejunit.v3.internal.runners.CompositeRunner; +import org.litejunit.v3.runner.Request; +import org.litejunit.v3.runner.Runner; + +public class ClassesRequest extends Request { + private final Class[] fClasses; + private final String fName; + + public ClassesRequest(String name, Class... classes) { + fClasses= classes; + fName= name; + } + + @Override + public Runner getRunner() { + CompositeRunner runner= new CompositeRunner(fName); + for (Class each : fClasses) { + Runner childRunner= Request.aClass(each).getRunner(); + if (childRunner != null) + runner.add(childRunner); + } + return runner; + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ErrorReportingRequest.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ErrorReportingRequest.java new file mode 100644 index 0000000000..f7b3396b6e --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/ErrorReportingRequest.java @@ -0,0 +1,45 @@ +package org.litejunit.v3.internal.requests; + + +import org.litejunit.v3.internal.runners.CompositeRunner; +import org.litejunit.v3.internal.runners.ErrorReportingRunner; +import org.litejunit.v3.internal.runners.InitializationError; +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Request; +import org.litejunit.v3.runner.Runner; + +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.List; + +public class ErrorReportingRequest extends Request { + + private final Class fClass; + private final Throwable fCause; + + public ErrorReportingRequest(Class klass, Throwable cause) { + fClass= klass; + fCause= cause; + } + + @Override + public Runner getRunner() { + List goofs= getCauses(fCause); + CompositeRunner runner= new CompositeRunner(fClass.getName()); + for (int i= 0; i < goofs.size(); i++) { + final Description description= Description.createTestDescription(fClass, "initializationError" + i); + final Throwable throwable= goofs.get(i); + runner.add(new ErrorReportingRunner(description, throwable)); + } + return runner; + } + + private List getCauses(Throwable cause) { + if (cause instanceof InvocationTargetException) + return getCauses(cause.getCause()); + if (cause instanceof InitializationError) + return ((InitializationError) cause).getCauses(); + // TODO: untested + return Arrays.asList(cause); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/FilterRequest.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/FilterRequest.java new file mode 100644 index 0000000000..00464f3955 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/FilterRequest.java @@ -0,0 +1,33 @@ +/** + * + */ +package org.litejunit.v3.internal.requests; + + +import org.litejunit.v3.runner.Request; +import org.litejunit.v3.runner.Runner; +import org.litejunit.v3.runner.manipulation.Filter; +import org.litejunit.v3.runner.manipulation.NoTestsRemainException; + +public final class FilterRequest extends Request { + private final Request fRequest; + private final Filter fFilter; + + public FilterRequest(Request classRequest, Filter filter) { + fRequest= classRequest; + fFilter= filter; + } + + @Override + public Runner getRunner() { + try { + Runner runner= fRequest.getRunner(); + fFilter.apply(runner); + return runner; + } catch (NoTestsRemainException e) { + return Request.errorReport(Filter.class, new Exception(String + .format("No tests found matching %s from %s", fFilter + .describe(), fRequest.toString()))).getRunner(); + } + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/SortingRequest.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/SortingRequest.java new file mode 100644 index 0000000000..512301cc99 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/requests/SortingRequest.java @@ -0,0 +1,26 @@ +package org.litejunit.v3.internal.requests; + + +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Request; +import org.litejunit.v3.runner.Runner; +import org.litejunit.v3.runner.manipulation.Sorter; + +import java.util.Comparator; + +public class SortingRequest extends Request { + private final Request fRequest; + private final Comparator fComparator; + + public SortingRequest(Request request, Comparator comparator) { + fRequest= request; + fComparator= comparator; + } + + @Override + public Runner getRunner() { + Runner runner= fRequest.getRunner(); + new Sorter(fComparator).apply(runner); + return runner; + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/BeforeAndAfterRunner.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/BeforeAndAfterRunner.java new file mode 100644 index 0000000000..d54e5b4e23 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/BeforeAndAfterRunner.java @@ -0,0 +1,76 @@ +package org.litejunit.v3.internal.runners; + +import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; + +public abstract class BeforeAndAfterRunner { + private static class FailedBefore extends Exception { + private static final long serialVersionUID= 1L; + } + + private final Class fBeforeAnnotation; + + private final Class fAfterAnnotation; + + private TestIntrospector fTestIntrospector; + + private Object fTest; + + public BeforeAndAfterRunner(Class testClass, + Class beforeAnnotation, + Class afterAnnotation, + Object test) { + fBeforeAnnotation= beforeAnnotation; + fAfterAnnotation= afterAnnotation; + fTestIntrospector= new TestIntrospector(testClass); + fTest= test; + } + + public void runProtected() { + try { + runBefores(); + runUnprotected(); + } catch (FailedBefore e) { + } finally { + runAfters(); + } + } + + protected abstract void runUnprotected(); + + protected abstract void addFailure(Throwable targetException); + + // Stop after first failed @Before + private void runBefores() throws FailedBefore { + try { + List befores= fTestIntrospector.getTestMethods(fBeforeAnnotation); + for (Method before : befores) + invokeMethod(before); + } catch (InvocationTargetException e) { + addFailure(e.getTargetException()); + throw new FailedBefore(); + } catch (Throwable e) { + addFailure(e); + throw new FailedBefore(); + } + } + + // Try to run all @Afters regardless + private void runAfters() { + List afters= fTestIntrospector.getTestMethods(fAfterAnnotation); + for (Method after : afters) + try { + invokeMethod(after); + } catch (InvocationTargetException e) { + addFailure(e.getTargetException()); + } catch (Throwable e) { + addFailure(e); // Untested, but seems impossible + } + } + + private void invokeMethod(Method method) throws Exception { + method.invoke(fTest); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/CompositeRunner.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/CompositeRunner.java new file mode 100644 index 0000000000..c19303bba6 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/CompositeRunner.java @@ -0,0 +1,70 @@ +package org.litejunit.v3.internal.runners; + +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Runner; +import org.litejunit.v3.runner.manipulation.*; +import org.litejunit.v3.runner.notification.RunNotifier; + +import java.util.*; + +public class CompositeRunner extends Runner implements Filterable, Sortable { + private final List fRunners= new ArrayList(); + private final String fName; + + public CompositeRunner(String name) { + fName= name; + } + + @Override + public void run(RunNotifier notifier) { + for (Runner each : fRunners) + each.run(notifier); + } + + @Override + public Description getDescription() { + Description spec= Description.createSuiteDescription(fName); + for (Runner runner : fRunners) { + spec.addChild(runner.getDescription()); + } + return spec; + } + + public List getRunners() { + return fRunners; + } + + public void addAll(List runners) { + fRunners.addAll(runners); + } + + public void add(Runner runner) { + fRunners.add(runner); + } + + public void filter(Filter filter) throws NoTestsRemainException { + for (Iterator iter= fRunners.iterator(); iter.hasNext();) { + Runner runner= (Runner) iter.next(); + if (filter.shouldRun(runner.getDescription())) { + filter.apply(runner); + } else { + iter.remove(); + } + } + } + + protected String getName() { + return fName; + } + + public void sort(final Sorter sorter) { + Collections.sort(fRunners, new Comparator() { + public int compare(Runner o1, Runner o2) { + return sorter.compare(o1.getDescription(), o2.getDescription()); + } + }); + for (Runner each : fRunners) { + sorter.apply(each); + } + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/ErrorReportingRunner.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/ErrorReportingRunner.java new file mode 100644 index 0000000000..51ef6ae20b --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/ErrorReportingRunner.java @@ -0,0 +1,34 @@ +/** + * + */ +package org.litejunit.v3.internal.runners; + + +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Runner; +import org.litejunit.v3.runner.notification.Failure; +import org.litejunit.v3.runner.notification.RunNotifier; + +public class ErrorReportingRunner extends Runner { + private final Description fDescription; + + private final Throwable fCause; + + public ErrorReportingRunner(Description description, Throwable cause) { + fDescription= description; + fCause= cause; + } + + @Override + public Description getDescription() { + return fDescription; + } + + // TODO: this is duplicated in TestClassMethodsRunner + @Override + public void run(RunNotifier notifier) { + notifier.fireTestStarted(fDescription); + notifier.fireTestFailure(new Failure(fDescription, fCause)); + notifier.fireTestFinished(fDescription); + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/InitializationError.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/InitializationError.java new file mode 100644 index 0000000000..b3965291d8 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/InitializationError.java @@ -0,0 +1,25 @@ +package org.litejunit.v3.internal.runners; + +import java.util.Arrays; +import java.util.List; + +public class InitializationError extends Exception { + private static final long serialVersionUID= 1L; + private final List fErrors; + + public InitializationError(List errors) { + fErrors= errors; + } + + public InitializationError(Throwable... errors) { + this(Arrays.asList(errors)); + } + + public InitializationError(String string) { + this(new Exception(string)); + } + + public List getCauses() { + return fErrors; + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/MethodValidator.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/MethodValidator.java new file mode 100644 index 0000000000..cd00bbf080 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/MethodValidator.java @@ -0,0 +1,74 @@ +package org.litejunit.v3.internal.runners; + +import org.litejunit.v3.*; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.List; + +public class MethodValidator { + private final TestIntrospector fIntrospector; + + private final List fErrors= new ArrayList(); + + private final Class fTestClass; + + public MethodValidator(Class testClass) { + fTestClass= testClass; + fIntrospector= new TestIntrospector(testClass); + } + + public void validateInstanceMethods() { + validateTestMethods(After.class, false); + validateTestMethods(Before.class, false); + validateTestMethods(Test.class, false); + } + + public void validateStaticMethods() { + validateTestMethods(BeforeClass.class, true); + validateTestMethods(AfterClass.class, true); + } + + public List validateAllMethods() { + validateNoArgConstructor(); + validateStaticMethods(); + validateInstanceMethods(); + return fErrors; + } + + public void assertValid() throws InitializationError { + if (!fErrors.isEmpty()) + throw new InitializationError(fErrors); + } + + public void validateNoArgConstructor() { + try { + fTestClass.getConstructor(); + } catch (Exception e) { + fErrors.add(new Exception("Test class should have public zero-argument constructor", e)); + } + } + + private void validateTestMethods(Class annotation, + boolean isStatic) { + List methods= fIntrospector.getTestMethods(annotation); + for (Method each : methods) { + if (Modifier.isStatic(each.getModifiers()) != isStatic) { + String state= isStatic ? "should" : "should not"; + fErrors.add(new Exception("Method " + each.getName() + "() " + + state + " be static")); + } + if (!Modifier.isPublic(each.getModifiers())) + fErrors.add(new Exception("Method " + each.getName() + + " should be public")); + if (each.getReturnType() != Void.TYPE) + fErrors.add(new Exception("Method " + each.getName() + + " should be void")); + if (each.getParameterTypes().length != 0) + fErrors.add(new Exception("Method " + each.getName() + + " should have no parameters")); + } + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestClassMethodsRunner.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestClassMethodsRunner.java new file mode 100644 index 0000000000..bf9e36b8a8 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestClassMethodsRunner.java @@ -0,0 +1,103 @@ +package org.litejunit.v3.internal.runners; + +import org.litejunit.v3.Test; +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Runner; +import org.litejunit.v3.runner.manipulation.*; +import org.litejunit.v3.runner.notification.Failure; +import org.litejunit.v3.runner.notification.RunNotifier; + +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; + +public class TestClassMethodsRunner extends Runner implements Filterable, Sortable { + private final List fTestMethods; + private final Class fTestClass; + + // This assumes that some containing runner will perform validation of the test methods + public TestClassMethodsRunner(Class klass) { + fTestClass= klass; + fTestMethods= new TestIntrospector(getTestClass()).getTestMethods(Test.class); + } + + @Override + public void run(RunNotifier notifier) { + if (fTestMethods.isEmpty()) + testAborted(notifier, getDescription()); + for (Method method : fTestMethods) + invokeTestMethod(method, notifier); + } + + private void testAborted(RunNotifier notifier, Description description) { + // TODO: duped! + // TODO: envious + notifier.fireTestStarted(description); + notifier.fireTestFailure(new Failure(description, new Exception("No runnable methods"))); + notifier.fireTestFinished(description); + } + + @Override + public Description getDescription() { + Description spec= Description.createSuiteDescription(getName()); + List testMethods= fTestMethods; + for (Method method : testMethods) + spec.addChild(methodDescription(method)); + return spec; + } + + protected String getName() { + return getTestClass().getName(); + } + + protected Object createTest() throws Exception { + return getTestClass().getConstructor().newInstance(); + } + + protected void invokeTestMethod(Method method, RunNotifier notifier) { + Object test; + try { + test= createTest(); + } catch (Exception e) { + testAborted(notifier, methodDescription(method)); + return; + } + createMethodRunner(test, method, notifier).run(); + } + + protected TestMethodRunner createMethodRunner(Object test, Method method, RunNotifier notifier) { + return new TestMethodRunner(test, method, notifier, methodDescription(method)); + } + + protected String testName(Method method) { + return method.getName(); + } + + protected Description methodDescription(Method method) { + return Description.createTestDescription(getTestClass(), testName(method)); + } + + public void filter(Filter filter) throws NoTestsRemainException { + for (Iterator iter= fTestMethods.iterator(); iter.hasNext();) { + Method method= (Method) iter.next(); + if (!filter.shouldRun(methodDescription(method))) + iter.remove(); + } + if (fTestMethods.isEmpty()) + throw new NoTestsRemainException(); + } + + public void sort(final Sorter sorter) { + Collections.sort(fTestMethods, new Comparator() { + public int compare(Method o1, Method o2) { + return sorter.compare(methodDescription(o1), methodDescription(o2)); + } + }); + } + + protected Class getTestClass() { + return fTestClass; + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestClassRunner.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestClassRunner.java new file mode 100644 index 0000000000..b2feee7cb1 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestClassRunner.java @@ -0,0 +1,70 @@ +package org.litejunit.v3.internal.runners; + +import org.litejunit.v3.AfterClass; +import org.litejunit.v3.BeforeClass; +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Runner; +import org.litejunit.v3.runner.manipulation.*; +import org.litejunit.v3.runner.notification.Failure; +import org.litejunit.v3.runner.notification.RunNotifier; + +public class TestClassRunner extends Runner implements Filterable, Sortable { + protected final Runner fEnclosedRunner; + private final Class fTestClass; + + public TestClassRunner(Class klass) throws InitializationError { + this(klass, new TestClassMethodsRunner(klass)); + } + + public TestClassRunner(Class klass, Runner runner) throws InitializationError { + fTestClass= klass; + fEnclosedRunner= runner; + MethodValidator methodValidator= new MethodValidator(klass); + validate(methodValidator); + methodValidator.assertValid(); + } + + // TODO: this is parallel to passed-in runner + protected void validate(MethodValidator methodValidator) { + methodValidator.validateAllMethods(); + } + + @Override + public void run(final RunNotifier notifier) { + BeforeAndAfterRunner runner = new BeforeAndAfterRunner(getTestClass(), + BeforeClass.class, AfterClass.class, null) { + @Override + protected void runUnprotected() { + fEnclosedRunner.run(notifier); + } + + // TODO: looks very similar to other method of BeforeAfter, now + @Override + protected void addFailure(Throwable targetException) { + notifier.fireTestFailure(new Failure(getDescription(), targetException)); + } + }; + + runner.runProtected(); + } + + @Override + public Description getDescription() { + return fEnclosedRunner.getDescription(); + } + + // TODO: good behavior when createTest fails + + // TODO: dup? + public void filter(Filter filter) throws NoTestsRemainException { + filter.apply(fEnclosedRunner); + } + + public void sort(Sorter sorter) { + sorter.apply(fEnclosedRunner); + } + + protected Class getTestClass() { + return fTestClass; + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestIntrospector.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestIntrospector.java new file mode 100644 index 0000000000..8e278282a0 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestIntrospector.java @@ -0,0 +1,78 @@ +package org.litejunit.v3.internal.runners; + +import org.litejunit.v3.Before; +import org.litejunit.v3.BeforeClass; +import org.litejunit.v3.Ignore; +import org.litejunit.v3.Test; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + +public class TestIntrospector { + private final Class< ?> fTestClass; + + public TestIntrospector(Class testClass) { + fTestClass= testClass; + } + + public List getTestMethods(Class annotationClass) { + List results= new ArrayList(); + for (Class eachClass : getSuperClasses(fTestClass)) { + Method[] methods= eachClass.getDeclaredMethods(); + for (Method eachMethod : methods) { + Annotation annotation= eachMethod.getAnnotation(annotationClass); + if (annotation != null && ! isShadowed(eachMethod, results)) + results.add(eachMethod); + } + } + if (runsTopToBottom(annotationClass)) + Collections.reverse(results); + return results; + } + + public boolean isIgnored(Method eachMethod) { + return eachMethod.getAnnotation(Ignore.class) != null; + } + + private boolean runsTopToBottom(Class< ? extends Annotation> annotation) { + return annotation.equals(Before.class) || annotation.equals(BeforeClass.class); + } + + private boolean isShadowed(Method method, List results) { + for (Method each : results) { + if (each.getName().equals(method.getName())) + return true; + } + return false; + } + + private List getSuperClasses(Class< ?> testClass) { + ArrayList results= new ArrayList(); + Class current= testClass; + while (current != null) { + results.add(current); + current= current.getSuperclass(); + } + return results; + } + + long getTimeout(Method method) { + Test annotation= method.getAnnotation(Test.class); + long timeout= annotation.timeout(); + return timeout; + } + + Class expectedException(Method method) { + Test annotation= method.getAnnotation(Test.class); + if (annotation.expected() == Test.None.class) + return null; + else + return annotation.expected(); + } + +} + diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestMethodRunner.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestMethodRunner.java new file mode 100644 index 0000000000..eded6d6ff6 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TestMethodRunner.java @@ -0,0 +1,114 @@ +package org.litejunit.v3.internal.runners; + +import org.litejunit.v3.After; +import org.litejunit.v3.Before; +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.notification.Failure; +import org.litejunit.v3.runner.notification.RunNotifier; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.concurrent.*; + +public class TestMethodRunner extends BeforeAndAfterRunner { + private final Object fTest; + private final Method fMethod; + private final RunNotifier fNotifier; + private final TestIntrospector fTestIntrospector; + private final Description fDescription; + + public TestMethodRunner(Object test, Method method, RunNotifier notifier, Description description) { + super(test.getClass(), Before.class, After.class, test); + fTest= test; + fMethod= method; + fNotifier= notifier; + fTestIntrospector= new TestIntrospector(test.getClass()); + fDescription= description; + } + + public void run() { + if (fTestIntrospector.isIgnored(fMethod)) { + fNotifier.fireTestIgnored(fDescription); + return; + } + fNotifier.fireTestStarted(fDescription); + try { + long timeout= fTestIntrospector.getTimeout(fMethod); + if (timeout > 0) + runWithTimeout(timeout); + else + runMethod(); + } finally { + fNotifier.fireTestFinished(fDescription); + } + } + + private void runWithTimeout(long timeout) { + ExecutorService service= Executors.newSingleThreadExecutor(); + Callable callable= new Callable() { + public Object call() throws Exception { + runMethod(); + return null; + } + }; + Future result= service.submit(callable); + service.shutdown(); + try { + boolean terminated= service.awaitTermination(timeout, + TimeUnit.MILLISECONDS); + if (!terminated) + service.shutdownNow(); + result.get(timeout, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation + } catch (TimeoutException e) { + addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); + } catch (Exception e) { + addFailure(e); + } + } + + private void runMethod() { + runProtected(); + } + + @Override + protected void runUnprotected() { + try { + executeMethodBody(); + if (expectsException()) + addFailure(new AssertionError("Expected exception: " + expectedException().getName())); + } catch (InvocationTargetException e) { + Throwable actual= e.getTargetException(); + if (!expectsException()) + addFailure(actual); + else if (isUnexpected(actual)) { + String message= "Unexpected exception, expected<" + expectedException().getName() + "> but was<" + + actual.getClass().getName() + ">"; + addFailure(new Exception(message, actual)); + } + } catch (Throwable e) { + addFailure(e); + } + } + + protected void executeMethodBody() throws IllegalAccessException, InvocationTargetException { + fMethod.invoke(fTest); + } + + @Override + protected void addFailure(Throwable e) { + fNotifier.fireTestFailure(new Failure(fDescription, e)); + } + + private boolean expectsException() { + return expectedException() != null; + } + + private Class expectedException() { + return fTestIntrospector.expectedException(fMethod); + } + + private boolean isUnexpected(Throwable exception) { + return ! expectedException().isAssignableFrom(exception.getClass()); + } +} + diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TextListener.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TextListener.java new file mode 100644 index 0000000000..5d4d099c97 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/internal/runners/TextListener.java @@ -0,0 +1,105 @@ +package org.litejunit.v3.internal.runners; + + +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Result; +import org.litejunit.v3.runner.notification.Failure; +import org.litejunit.v3.runner.notification.RunListener; + +import java.io.PrintStream; +import java.text.NumberFormat; + +public class TextListener extends RunListener { + + private final PrintStream fWriter; + + public TextListener() { + this(System.out); + } + + public TextListener(PrintStream writer) { + this.fWriter= writer; + } + + @Override + public void testRunFinished(Result result) { + printHeader(result.getRunTime()); + printFailures(result); + printFooter(result); + } + + @Override + public void testStarted(Description description) { + fWriter.append('.'); + } + + @Override + public void testFailure(Failure failure) { + fWriter.append('E'); + } + + @Override + public void testIgnored(Description description) { + fWriter.append('I'); + } + + /* + * Internal methods + */ + + private PrintStream getWriter() { + return fWriter; + } + + protected void printHeader(long runTime) { + getWriter().println(); + getWriter().println("Time: " + elapsedTimeAsString(runTime)); + } + + protected void printFailures(Result result) { + if (result.getFailureCount() == 0) + return; + if (result.getFailureCount() == 1) + getWriter().println("There was " + result.getFailureCount() + " failure:"); + else + getWriter().println("There were " + result.getFailureCount() + " failures:"); + int i= 1; + for (Failure each : result.getFailures()) + printFailure(each, i++); + } + + protected void printFailure(Failure failure, int count) { + printFailureHeader(failure, count); + printFailureTrace(failure); + } + + protected void printFailureHeader(Failure failure, int count) { + getWriter().println(count + ") " + failure.getTestHeader()); + } + + protected void printFailureTrace(Failure failure) { + getWriter().print(failure.getTrace()); + } + + protected void printFooter(Result result) { + if (result.wasSuccessful()) { + getWriter().println(); + getWriter().print("OK"); + getWriter().println(" (" + result.getRunCount() + " test" + (result.getRunCount() == 1 ? "" : "s") + ")"); + + } else { + getWriter().println(); + getWriter().println("FAILURES!!!"); + getWriter().println("Tests run: " + result.getRunCount() + ", Failures: " + result.getFailureCount()); + } + getWriter().println(); + } + + /** + * Returns the formatted string of the elapsed time. Duplicated from + * BaseTestRunner. Fix it. + */ + protected String elapsedTimeAsString(long runTime) { + return NumberFormat.getInstance().format((double) runTime / 1000); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Description.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Description.java new file mode 100644 index 0000000000..55f401c2c2 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Description.java @@ -0,0 +1,127 @@ +package org.litejunit.v3.runner; + +import java.util.ArrayList; + +/** + * A Description describes a test which is to be run or has been run. Descriptions can + * be atomic (a single test) or compound (containing children tests). Descriptions are used + * to provide feedback about the tests that are about to run (for example, the tree view + * visible in many IDEs) or tests that have been run (for example, the failures view).

+ * Descriptions are implemented as a single class rather than a Composite because + * they are entirely informational. They contain no logic aside from counting their tests.

+ * In the past, we used the raw junit.framework.TestCases and junit.framework.TestSuites + * to display the tree of tests. This was no longer viable in JUnit 4 because atomic tests no longer have a superclass below Object. + * We needed a way to pass a class and name together. Description emerged from this. + * + * @see Request + * @see Runner + */ +public class Description { + + /** + * Create a Description named name. + * Generally, you will add children to this Description. + * @param name The name of the Description + * @return A Description named name + */ + public static Description createSuiteDescription(String name) { + return new Description(name); + } + + /** + * Create a Description of a single test named name in the class clazz. + * Generally, this will be a leaf Description. + * @param clazz The class of the test + * @param name The name of the test (a method name for test annotated with @Test) + * @return A Description named name + */ + public static Description createTestDescription(Class clazz, String name) { + return new Description(String.format("%s(%s)", name, clazz.getName())); + } + + /** + * Create a generic Description that says there are tests in testClass. + * This is used as a last resort when you cannot precisely describe the individual tests in the class. + * @param testClass A Class containing tests + * @return A Description of testClass + */ + public static Description createSuiteDescription(Class testClass) { + return new Description(testClass.getName()); + } + + public static Description TEST_MECHANISM = new Description("Test mechanism"); + private final ArrayList fChildren= new ArrayList(); + private final String fDisplayName; + + //TODO we seem to be using the static factories exclusively + private Description(final String displayName) { + fDisplayName= displayName; + } + + /** + * @return a user-understandable label + */ + public String getDisplayName() { + return fDisplayName; + } + + /** + * Add description as a child of the receiver. + * @param description The soon-to-be child. + */ + public void addChild(Description description) { + getChildren().add(description); + } + + /** + * @return the receiver's children, if any + */ + public ArrayList getChildren() { + return fChildren; + } + + /** + * @return true if the receiver is a suite + */ + public boolean isSuite() { + return !isTest(); + } + + /** + * @return true if the receiver is an atomic test + */ + public boolean isTest() { + return getChildren().isEmpty(); + } + + /** + * @return the total number of atomic tests in the receiver + */ + public int testCount() { + if (isTest()) + return 1; + int result= 0; + for (Description child : getChildren()) + result+= child.testCount(); + return result; + } + + @Override + public int hashCode() { + return getDisplayName().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Description)) + return false; + Description d = (Description) obj; + return getDisplayName().equals(d.getDisplayName()) + && getChildren().equals(d.getChildren()); + } + + @Override + public String toString() { + return getDisplayName(); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/JUnitCore.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/JUnitCore.java new file mode 100644 index 0000000000..8e99a2c904 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/JUnitCore.java @@ -0,0 +1,152 @@ +package org.litejunit.v3.runner; + +import org.litejunit.v2.Test; +import org.litejunit.v3.internal.runners.TextListener; +import org.litejunit.v3.runner.notification.RunListener; +import org.litejunit.v3.runner.notification.RunNotifier; + +import java.util.ArrayList; +import java.util.List; + +/** + * JUnitCore is a facade for running tests. It supports running JUnit 4 tests, + * JUnit 3.8.2 tests, and mixtures. To run tests from the command line, run java org.junit.runner.JUnitCore TestClass1 TestClass2 .... + * For one-shot test runs, use the static method runClasses(Class... classes) + * . If you want to add special listeners, + * create an instance of JUnitCore first and use it to run the tests. + * + * @see Result + * @see RunListener + * @see Request + */ +public class JUnitCore { + + private RunNotifier fNotifier; + + /** + * Create a new JUnitCore to run tests. + */ + public JUnitCore() { + fNotifier = new RunNotifier(); + } + + /** + * Run the tests contained in the classes named in the args. + * If all tests run successfully, exit with a status of 0. Otherwise exit with a status of 1. + * Write feedback while tests are running and write + * stack traces for all failed tests after the tests all complete. + * + * @param args names of classes in which to find tests to run + */ + public static void main(String... args) { + Result result = new JUnitCore().runMain(args); + killAllThreads(result); + } + + private static void killAllThreads(Result result) { + System.exit(result.wasSuccessful() ? 0 : 1); + } + + /** + * Run the tests contained in classes. Write feedback while the tests + * are running and write stack traces for all failed tests after all tests complete. This is + * similar to main(), but intended to be used programmatically. + * + * @param classes Classes in which to find tests + * @return a Result describing the details of the test run and the failed tests. + */ + public static Result runClasses(Class... classes) { + return new JUnitCore().run(classes); + } + + /** + * Do not use. Testing purposes only. + */ + public Result runMain(String... args) { + System.out.println("JUnit version " + "4.0"); + List classes = new ArrayList(); + for (String each : args) + try { + classes.add(Class.forName(each)); + } catch (ClassNotFoundException e) { + System.out.println("Could not find class: " + each); + } + RunListener listener = new TextListener(); + addListener(listener); + return run(classes.toArray(new Class[0])); + } + + /** + * @return the version number of this release + */ + public String getVersion() { + return "4.0"; + } + + /** + * Run all the tests in classes. + * + * @param classes the classes containing tests + * @return a Result describing the details of the test run and the failed tests. + */ + public Result run(Class... classes) { + return run(Request.classes("All", classes)); + } + + /** + * Run all the tests contained in request. + * + * @param request the request describing tests + * @return a Result describing the details of the test run and the failed tests. + */ + public Result run(Request request) { + return run(request.getRunner()); + } + + /** + * Run all the tests contained in JUnit 3.8.x test. Here for backward compatibility. + * + * @param test the old-style test + * @return a Result describing the details of the test run and the failed tests. + */ + public Result run(Test test) { +// return run(new OldTestClassRunner(test)); + return null; + } + + /** + * Do not use. Testing purposes only. + */ + public Result run(Runner runner) { + Result result = new Result(); + RunListener listener = result.createListener(); + addListener(listener); + try { + fNotifier.fireTestRunStarted(runner.getDescription()); + runner.run(fNotifier); + fNotifier.fireTestRunFinished(result); + } finally { + removeListener(listener); + } + return result; + } + + /** + * Add a listener to be notified as the tests run. + * + * @param listener the listener + * @see RunListener + */ + public void addListener(RunListener listener) { + fNotifier.addListener(listener); + } + + /** + * Remove a listener. + * + * @param listener the listener to remove + */ + public void removeListener(RunListener listener) { + fNotifier.removeListener(listener); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Request.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Request.java new file mode 100644 index 0000000000..da1019f868 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Request.java @@ -0,0 +1,87 @@ +package org.litejunit.v3.runner; + +import org.litejunit.v3.internal.requests.*; +import org.litejunit.v3.runner.manipulation.Filter; + +import java.util.Comparator; + +/** + * A Request is an abstract description of tests to be run. Older versions of + * JUnit did not need such a concept--tests to be run were described either by classes containing + * tests or a tree of Tests. However, we want to support filtering and sorting, + * so we need a more abstract specification than the tests themselves and a richer + * specification than just the classes. + *

+ * The flow when JUnit runs tests is that a Request specifies some tests to be run -> + * a Runner is created for each class implied by the Request -> the Runner + * returns a detailed Description which is a tree structure of the tests to be run. + */ +public abstract class Request { + /** + * Create a Request that, when processed, will run a single test. + * This is done by filtering out all other tests. This method is used to support rerunning + * single tests. + * @param clazz the class of the test + * @param methodName the name of the test + * @return a Request that will cause a single test be run + */ + public static Request method(Class clazz, String methodName) { + Description method= Description.createTestDescription(clazz, methodName); + return Request.aClass(clazz).filterWith(method); + } + + /** + * Create a Request that, when processed, will run all the tests + * in a class. The odd name is necessary because class is a reserved word. + * @param clazz the class containing the tests + * @return a Request that will cause all tests in the class to be run + */ + public static Request aClass(Class clazz) { + return new ClassRequest(clazz); + } + + /** + * Create a Request that, when processed, will run all the tests + * in a set of classes. + * @param collectionName a name to identify this suite of tests + * @param classes the classes containing the tests + * @return a Request that will cause all tests in the classes to be run + */ + public static Request classes(String collectionName, Class... classes) { + return new ClassesRequest(collectionName, classes); + } + + public static Request errorReport(Class klass, Throwable cause) { + return new ErrorReportingRequest(klass, cause); + } + + public abstract Runner getRunner(); + + public Request filterWith(Filter filter) { + return new FilterRequest(this, filter); + } + + public Request filterWith(final Description desiredDescription) { + return filterWith(new Filter() { + @Override + public boolean shouldRun(Description description) { + // TODO: test for equality even if we have children? + if (description.isTest()) + return desiredDescription.equals(description); + for (Description each : description.getChildren()) + if (shouldRun(each)) + return true; + return false; + } + + @Override + public String describe() { + return String.format("Method %s", desiredDescription.getDisplayName()); + } + }); + } + + public Request sortWith(Comparator comparator) { + return new SortingRequest(this, comparator); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Result.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Result.java new file mode 100644 index 0000000000..67a92f1b6a --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Result.java @@ -0,0 +1,97 @@ +package org.litejunit.v3.runner; + +import org.litejunit.v3.runner.notification.Failure; +import org.litejunit.v3.runner.notification.RunListener; + +import java.util.ArrayList; +import java.util.List; + +/** + * A Result collects and summarizes information from running multiple + * tests. Since tests are expected to run correctly, successful tests are only noted in + * the count of tests that ran. + */ +public class Result { + private int fCount= 0; + private int fIgnoreCount= 0; + private List fFailures= new ArrayList(); + private long fRunTime= 0; + private long fStartTime; + + /** + * @return the number of tests run + */ + public int getRunCount() { + return fCount; + } + + /** + * @return the number of tests that failed during the run + */ + public int getFailureCount() { + return fFailures.size(); + } + + /** + * @return the number of milliseconds it took to run the entire suite to run + */ + public long getRunTime() { + return fRunTime; + } + + /** + * @return the Failures describing tests that failed and the problems they encountered + */ + public List getFailures() { + return fFailures; + } + + /** + * @return the number of tests ignored during the run + */ + public int getIgnoreCount() { + return fIgnoreCount; + } + + /** + * @return true if all tests succeeded + */ + public boolean wasSuccessful() { + return getFailureCount() == 0; + } + + private class Listener extends RunListener { + @Override + public void testRunStarted(Description description) throws Exception { + fStartTime= System.currentTimeMillis(); + } + + @Override + public void testRunFinished(Result result) throws Exception { + long endTime= System.currentTimeMillis(); + fRunTime+= endTime - fStartTime; + } + + @Override + public void testStarted(Description description) throws Exception { + fCount++; + } + + @Override + public void testFailure(Failure failure) throws Exception { + fFailures.add(failure); + } + + @Override + public void testIgnored(Description description) throws Exception { + fIgnoreCount++; + } + } + + /** + * Internal use only. + */ + public RunListener createListener() { + return new Listener(); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/RunWith.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/RunWith.java new file mode 100644 index 0000000000..d69d030f20 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/RunWith.java @@ -0,0 +1,25 @@ +package org.litejunit.v3.runner; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +//TODO add simple exampel + +/** + * When you annotate a class with @RunWith, JUnit will invoke + * the class it references to run the tests in that class instead of the runner + * built into JUnit. We added this feature late in development. While it + * seems powerful we expect the runner API to change as we learn how people + * really use it. Some of the classes that are currently internal will likely be refined + * and become public. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface RunWith { + /** + * @return a Runner class (must have a constructor that takes a single Class to run) + */ + Class value(); +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Runner.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Runner.java new file mode 100644 index 0000000000..96f0fc3581 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/Runner.java @@ -0,0 +1,34 @@ +package org.litejunit.v3.runner; + +import org.litejunit.v3.runner.notification.RunNotifier; + +/** + * A Runner runs tests and notifies a RunNotifier + * of significant events as it does so. You will need to subclass Runner + * when using @RunWith to invoke a custom runner. When creating + * a custom runner, in addition to implementing the abstract methods here you must + * also provide a constructor that takes as an argument the Class containing + * the tests. + * + * @see Description + * @see RunWith + */ +public abstract class Runner { + /** + * @return a Description showing the tests to be run by the receiver + */ + public abstract Description getDescription(); + + /** + * Run the tests for this runner. + * @param notifier will be notified of events while tests are being run--tests being started, finishing, and failing + */ + public abstract void run(RunNotifier notifier); + + /** + * @return the number of tests to be run by the receiver + */ + public int testCount() { + return getDescription().testCount(); + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Filter.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Filter.java new file mode 100644 index 0000000000..eaca8b8c98 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Filter.java @@ -0,0 +1,50 @@ +package org.litejunit.v3.runner.manipulation; + +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Runner; + +/** + * The canonical case of filtering is when you want to run a single test method in a class. Rather + * than introduce runner API just for that one case, JUnit provides a general filtering mechanism. + * If you want to filter the tests to be run, extend Filter and apply an instance of + * your filter to the Request before running it (see JUnitCore.run(Request request)). + * Alternatively, apply a Filter to a Runner before running + * tests (for example, in conjunction with @RunWith. + */ +public abstract class Filter { + /** + * A null Filter that passes all tests through. + */ + public static Filter ALL= new Filter() { + @Override + public boolean shouldRun(Description description) { + return true; + } + + @Override + public String describe() { + return "all tests"; + } + }; + + /** + * @param description the description of the test to be run + * @return true if the test should be run + */ + public abstract boolean shouldRun(Description description); + + /** + * Invoke with a Runner to cause all tests it intends to run + * to first be checked with the filter. Only those that pass the filter will be run. + * @param runner the runner to be filtered by the receiver + * @throws NoTestsRemainException if the receiver removes all tests + */ + public void apply(Runner runner) throws NoTestsRemainException { + if (runner instanceof Filterable) { + Filterable filterable= (Filterable)runner; + filterable.filter(this); + } + } + + public abstract String describe(); +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Filterable.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Filterable.java new file mode 100644 index 0000000000..a1dbc96b8b --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Filterable.java @@ -0,0 +1,16 @@ +package org.litejunit.v3.runner.manipulation; + +/** + * Runners that allow filtering should implement this interface. Implement filter() + * to remove tests that don't pass the filter. + */ +public interface Filterable { + + /** + * Remove tests that don't pass filter. + * @param filter the filter to apply + * @throws NoTestsRemainException if all tests are filtered out + */ + void filter(Filter filter) throws NoTestsRemainException; + +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/NoTestsRemainException.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/NoTestsRemainException.java new file mode 100644 index 0000000000..bacf9fffc0 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/NoTestsRemainException.java @@ -0,0 +1,8 @@ +package org.litejunit.v3.runner.manipulation; + +/** + * Thrown when a filter removes all tests from a runner. + */ +public class NoTestsRemainException extends Exception { + private static final long serialVersionUID = 1L; +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Sortable.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Sortable.java new file mode 100644 index 0000000000..3c96dcdf7e --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Sortable.java @@ -0,0 +1,13 @@ +package org.litejunit.v3.runner.manipulation; + +/** + * Interface for runners that allow sorting of tests. By sorting tests based on when they last failed, most recently + * failed first, you can reduce the average time to the first test failing. Test sorting should not be used to + * cope with order dependencies between tests. Tests that are isolated from each other are less + * expensive to maintain and can be run individually. + */ +public interface Sortable { + + public void sort(Sorter sorter); + +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Sorter.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Sorter.java new file mode 100644 index 0000000000..e759861060 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/manipulation/Sorter.java @@ -0,0 +1,31 @@ +package org.litejunit.v3.runner.manipulation; + +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Runner; + +import java.util.Comparator; + +//TODO add an example + +/** + * A Sorter orders tests. In general you will not need + * to use a Sorter directly. Instead, use Request.sortWith(Comparator). + */ +public class Sorter implements Comparator { + private final Comparator fComparator; + + public Sorter(Comparator comparator) { + fComparator= comparator; + } + + public void apply(Runner runner) { + if (runner instanceof Sortable) { + Sortable sortable= (Sortable) runner; + sortable.sort(this); + } + } + + public int compare(Description o1, Description o2) { + return fComparator.compare(o1, o2); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/Failure.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/Failure.java new file mode 100644 index 0000000000..aaffd9ee39 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/Failure.java @@ -0,0 +1,77 @@ +package org.litejunit.v3.runner.notification; + +import org.litejunit.v3.runner.Description; + +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * A Failure holds a description of the failed test and the + * exception that was thrown while running it. In most cases the Description + * will be of a single test. However, if problems are encountered while constructing the + * test (for example, if a @BeforeClass method is not static), it may describe + * something other than a single test. + */ +public class Failure { + private final Description fDescription; + private Throwable fThrownException; + + /** + * Constructs a Failure with the given description and exception. + * @param description a Description of the test that failed + * @param thrownException the exception that was thrown while running the test + */ + public Failure(Description description, Throwable thrownException) { + fThrownException = thrownException; + fDescription= description; + } + + /** + * @return a user-understandable label for the test + */ + public String getTestHeader() { + return fDescription.getDisplayName(); + } + + /** + * @return the raw description of the context of the failure. + */ + public Description getDescription() { + return fDescription; + } + + /** + * @return the exception thrown + */ + + public Throwable getException() { + return fThrownException; + } + + @Override + public String toString() { + StringBuffer buffer= new StringBuffer(); + buffer.append(getTestHeader() + ": "+fThrownException.getMessage()); + return buffer.toString(); + } + + /** + * Convenience method + * @return the printed form of the exception + */ + public String getTrace() { + StringWriter stringWriter= new StringWriter(); + PrintWriter writer= new PrintWriter(stringWriter); + getException().printStackTrace(writer); + StringBuffer buffer= stringWriter.getBuffer(); + return buffer.toString(); + } + + /** + * Convenience method + * @return the message of the thrown exception + */ + public String getMessage() { + return getException().getMessage(); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/RunListener.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/RunListener.java new file mode 100644 index 0000000000..4af71678a1 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/RunListener.java @@ -0,0 +1,79 @@ +package org.litejunit.v3.runner.notification; + +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.JUnitCore; +import org.litejunit.v3.runner.Result; + +/** + * If you need to respond to the events during a test run, extend RunListener + * and override the appropriate methods. If a listener throws an exception while processing a + * test event, it will be removed for the remainder of the test run. + *

+ * For example, suppose you have a Cowbell + * class that you want to make a noise whenever a test fails. You could write:
+ * + * public class RingingListener extends RunListener { + * %nbsp;%nbsp;public void testFailure(Failure failure) { + * %nbsp;%nbsp;%nbsp;%nbsp;Cowbell.ring(); + * %nbsp;%nbsp;} + * } + * + *

+ * To invoke your listener, you need to run your tests through JUnitCore.
+ * + * public void main(String... args) { + * %nbsp;%nbsp;JUnitCore core= new JUnitCore(); + * %nbsp;%nbsp;core.addListener(new RingingListener()); + * %nbsp;%nbsp; + * core.run(MyTestClass.class); + * } + * + * @see JUnitCore + */ +public class RunListener { + + /** + * Called before any tests have been run. + * @param description describes the tests to be run + */ + public void testRunStarted(Description description) throws Exception { + } + + /** + * Called when all tests have finished + * @param result the summary of the test run, including all the tests that failed + */ + public void testRunFinished(Result result) throws Exception { + } + + /** + * Called when an atomic test is about to be started. + * @param description the description of the test that is about to be run (generally a class and method name) + */ + public void testStarted(Description description) throws Exception { + } + + /** + * Called when an atomic test has finished, whether the test succeeds or fails. + * @param description the description of the test that just ran + */ + public void testFinished(Description description) throws Exception { + } + + /** + * Called when an atomic test fails. + * @param failure describes the test that failed and the exception that was thrown + */ + public void testFailure(Failure failure) throws Exception { + } + + /** + * Called when a test will not be run, generally because a test method is annotated with @Ignored. + * @param description describes the test that will not be run + */ + public void testIgnored(Description description) throws Exception { + } + +} + + diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/RunNotifier.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/RunNotifier.java new file mode 100644 index 0000000000..74b6e688b1 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/RunNotifier.java @@ -0,0 +1,137 @@ +package org.litejunit.v3.runner.notification; + +import org.litejunit.v3.runner.Description; +import org.litejunit.v3.runner.Result; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * If you write custom runners, you may need to notify JUnit of your progress running tests. + * Do this by invoking the RunNotifier passed to your implementation of + * Runner.run(RunNotifier notifier). Future evolution of this class is likely to + * move fireTestRunStarted() and fireTestRunFinished() + * to a separate class since they should only be called once per run. + */ +public class RunNotifier { + private List fListeners= new ArrayList(); + private boolean fPleaseStop= false; + + /** Internal use only + */ + public void addListener(RunListener listener) { + fListeners.add(listener); + } + + /** Internal use only + */ + public void removeListener(RunListener listener) { + fListeners.remove(listener); + } + + private abstract class SafeNotifier { + void run() { + for (Iterator all= fListeners.iterator(); all.hasNext();) { + try { + notifyListener(all.next()); + } catch (Exception e) { + all.remove(); // Remove the offending listener first to avoid an infinite loop + fireTestFailure(new Failure(Description.TEST_MECHANISM, e)); + } + } + } + + abstract protected void notifyListener(RunListener each) throws Exception; + } + + /** + * Do not invoke. + */ + public void fireTestRunStarted(final Description description) { + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testRunStarted(description); + }; + }.run(); + } + + /** + * Do not invoke. + */ + public void fireTestRunFinished(final Result result) { + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testRunFinished(result); + }; + }.run(); + } + + /** + * Invoke to tell listeners that an atomic test is about to start. + * @param description the description of the atomic test (generally a class and method name) + * @throws StoppedByUserException thrown if a user has requested that the test run stop + */ + public void fireTestStarted(final Description description) throws StoppedByUserException { + if (fPleaseStop) + throw new StoppedByUserException(); + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testStarted(description); + }; + }.run(); + } + + /** + * Invoke to tell listeners that an atomic test failed. + * @param failure the description of the test that failed and the exception thrown + */ + public void fireTestFailure(final Failure failure) { + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testFailure(failure); + }; + }.run(); + } + + /** + * Invoke to tell listeners that an atomic test was ignored. + * @param description the description of the ignored test + */ + public void fireTestIgnored(final Description description) { + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testIgnored(description); + }; + }.run(); + } + + /** + * Invoke to tell listeners that an atomic test finished. Always invoke fireTestFinished() + * if you invoke fireTestStarted() as listeners are likely to expect them to come in pairs. + * @param description the description of the test that finished + */ + public void fireTestFinished(final Description description) { + new SafeNotifier() { + @Override + protected void notifyListener(RunListener each) throws Exception { + each.testFinished(description); + }; + }.run(); + } + + /** + * Ask that the tests run stop before starting the next test. Phrased politely because + * the test currently running will not be interrupted. It seems a little odd to put this + * functionality here, but the RunNotifier is the only object guaranteed + * to be shared amongst the many runners involved. + */ + public void pleaseStop() { + fPleaseStop= true; + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/StoppedByUserException.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/StoppedByUserException.java new file mode 100644 index 0000000000..f7c0bb3ae2 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runner/notification/StoppedByUserException.java @@ -0,0 +1,11 @@ +package org.litejunit.v3.runner.notification; + +/** + * Thrown when a user has requested that the test run stop. Writers of + * test running GUIs should be prepared to catch a StoppedByUserException. + * + * @see RunNotifier + */ +public class StoppedByUserException extends RuntimeException { + private static final long serialVersionUID= 1L; +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/Parameterized.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/Parameterized.java new file mode 100644 index 0000000000..8305522176 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/Parameterized.java @@ -0,0 +1,146 @@ +package org.litejunit.v3.runners; + + +import org.litejunit.v3.internal.runners.CompositeRunner; +import org.litejunit.v3.internal.runners.MethodValidator; +import org.litejunit.v3.internal.runners.TestClassMethodsRunner; +import org.litejunit.v3.internal.runners.TestClassRunner; + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.litejunit.v2.Assert.assertEquals; + + +/** The custom runner Parameterized implements parameterized + * tests. When running a parameterized test class, instances are created for the + * cross-product of the test methods and the test data elements.
+ *

+ * For example, to test a Fibonacci function, write: + * + *  
@RunWith(Parameterized.class)
+ * public class FibonacciTest {
+ *   @Parameters
+ *   public static Collection data() {
+ *     return Arrays.asList(new Object[][] { { 0, 0 }, { 1, 1 }, { 2, 1 },
+ *       { 3, 2 }, { 4, 3 }, { 5, 5 }, { 6, 8 } });
+ *   }
+ *
+ *   private int fInput;
+ *   private int fExpected;
+ *
+ *   public FibonacciTest(int input, int expected) {
+ *     fInput= input;
+ *     fExpected= expected;
+ *   }
+ *
+ *   @Test public void test() {
+ *     assertEquals(fExpected, Fibonacci.compute(fInput));
+ *   }
+ * }
+ *
+ *

+ * Each instance of FibonacciTest will be constructed using the two-argument + * constructor and the data values in the @Parameters method. + */ +public class Parameterized extends TestClassRunner { + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public static @interface Parameters { + } + + public static Collection eachOne(Object... params) { + List results= new ArrayList(); + for (Object param : params) + results.add(new Object[] { param }); + return results; + } + + // TODO: single-class this extension + + private static class TestClassRunnerForParameters extends TestClassMethodsRunner { + private final Object[] fParameters; + + private final int fParameterSetNumber; + + private final Constructor fConstructor; + + private TestClassRunnerForParameters(Class klass, Object[] parameters, int i) { + super(klass); + fParameters= parameters; + fParameterSetNumber= i; + fConstructor= getOnlyConstructor(); + } + + @Override + protected Object createTest() throws Exception { + return fConstructor.newInstance(fParameters); + } + + @Override + protected String getName() { + return String.format("[%s]", fParameterSetNumber); + } + + @Override + protected String testName(final Method method) { + return String.format("%s[%s]", method.getName(), fParameterSetNumber); + } + + private Constructor getOnlyConstructor() { + Constructor[] constructors= getTestClass().getConstructors(); + assertEquals(1, constructors.length); + return constructors[0]; + } + } + + // TODO: I think this now eagerly reads parameters, which was never the point. + + public static class RunAllParameterMethods extends CompositeRunner { + private final Class fKlass; + + public RunAllParameterMethods(Class klass) throws Exception { + super(klass.getName()); + fKlass= klass; + int i= 0; + for (final Object[] parameters : getParametersList()) { + super.add(new TestClassRunnerForParameters(klass, parameters, i++)); + } + } + + @SuppressWarnings("unchecked") + private Collection getParametersList() throws IllegalAccessException, InvocationTargetException, Exception { + return (Collection) getParametersMethod().invoke(null); + } + + private Method getParametersMethod() throws Exception { + for (Method each : fKlass.getMethods()) { + if (Modifier.isStatic(each.getModifiers())) { + Annotation[] annotations= each.getAnnotations(); + for (Annotation annotation : annotations) { + if (annotation.annotationType() == Parameters.class) + return each; + } + } + } + throw new Exception("No public static parameters method on class " + + getName()); + } + } + + public Parameterized(final Class klass) throws Exception { + super(klass, new RunAllParameterMethods(klass)); + } + + @Override + protected void validate(MethodValidator methodValidator) { + methodValidator.validateStaticMethods(); + methodValidator.validateInstanceMethods(); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/Suite.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/Suite.java new file mode 100644 index 0000000000..23869ee08c --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/runners/Suite.java @@ -0,0 +1,50 @@ +package org.litejunit.v3.runners; + +import org.litejunit.v3.internal.runners.InitializationError; +import org.litejunit.v3.internal.runners.TestClassRunner; +import org.litejunit.v3.runner.Request; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Using Suite as a runner allows you to manually + * build a suite containing tests from many classes. It is the JUnit 4 equivalent of the JUnit 3.8.x + * static junit.framework.Test suite() method. To use it, annotate a class + * with @RunWith(Suite.class) and SuiteClasses(TestClass1.class, ...). + * When you run this class, it will run all the tests in all the suite classes. + */ +public class Suite extends TestClassRunner { + /** + * The SuiteClasses annotation specifies the classes to be run when a class + * annotated with @RunWith(Suite.class) is run. + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public @interface SuiteClasses { + public Class[] value(); + } + + /** + * Internal use only. + */ + public Suite(Class klass) throws InitializationError { + this(klass, getAnnotatedClasses(klass)); + } + + /** + * Internal use only. + */ + public Suite(Class klass, Class[] annotatedClasses) throws InitializationError { + super(klass, Request.classes(klass.getName(), annotatedClasses).getRunner()); + } + + private static Class[] getAnnotatedClasses(Class klass) throws InitializationError { + SuiteClasses annotation= klass.getAnnotation(SuiteClasses.class); + if (annotation == null) + throw new InitializationError(String.format("class '%s' must have a SuiteClasses annotation", klass.getName())); + return annotation.value(); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/AllTest.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/AllTest.java new file mode 100644 index 0000000000..7b29bbe30a --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/AllTest.java @@ -0,0 +1,40 @@ +package org.litejunit.v3.sample; + + +import org.litejunit.v3.runner.RunWith; +import org.litejunit.v3.runners.Suite; + +/** + * Created by john on 2017/9/2. + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + CalculatorTest.class, + PersonTest.class +}) +public class AllTest { +// public static Test suite() { +// +// TestSuite suite = new TestSuite("All Test"); +// suite.addTest(CalculatorSuite.suite()); +// suite.addTestSuite(PersonTest.class); +// return suite; +// +// } + + +// static class OverallTestSetup extends TestSetup { +// +// public OverallTestSetup(Test test) { +// super(test); +// +// } +// protected void setUp() throws Exception { +// System.out.println("this is overall testsetup"); +// } +// protected void tearDown() throws Exception { +// System.out.println("this is overall teardown"); +// } +// +// } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/Calculator.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/Calculator.java new file mode 100644 index 0000000000..9627671885 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/Calculator.java @@ -0,0 +1,25 @@ +package org.litejunit.v3.sample; + +/** + * Created by john on 2017/9/4. + */ +public class Calculator { + + private int result = 0; + public void add(int x){ + result += x; + } + public void subtract(int x){ + result -=x; + } + + public int getResult(){ + return this.result; + } + public static void main(String[] args){ + Calculator calculator = new Calculator(); + calculator.add(10); + calculator.subtract(5); + System.out.println(calculator.getResult()); + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/CalculatorTest.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/CalculatorTest.java new file mode 100644 index 0000000000..578a3aa844 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/CalculatorTest.java @@ -0,0 +1,50 @@ +package org.litejunit.v3.sample; + + +import org.litejunit.v3.*; +import org.litejunit.v3.runner.JUnitCore; + +import static org.litejunit.v3.Assert.assertEquals; + +/** + * Created by john on 2017/9/4. + */ +public class CalculatorTest { + + Calculator calculator =null; + @Before + public void prepare(){ + calculator = new Calculator(); + } + @After + public void clean(){ + calculator = null; + } + @Test + public void testAdd(){ + + calculator.add(10); + assertEquals(15,calculator.getResult()); + } + @Test + public void testSubtract(){ + calculator.add(10); + calculator.subtract(5); + assertEquals(5,calculator.getResult()); + } + @BeforeClass + public static void prepareGlobalResouce(){ + System.err.println("prepare global resource"); + } + @AfterClass + public static void cleanGlobalResouce(){ + System.err.println("clean global resource"); + } + + + public static void main(String[] args){ + JUnitCore.main("org.litejunit.v3.sample.CalculatorTest"); +// JUnitCore.runClasses(CalculatorTest.class); + + } +} \ No newline at end of file diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/ParametTestUnit.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/ParametTestUnit.java new file mode 100644 index 0000000000..e7e86aa71e --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/ParametTestUnit.java @@ -0,0 +1,54 @@ +package org.litejunit.v3.sample; + + +import org.litejunit.v3.Test; +import org.litejunit.v3.runner.RunWith; +import org.litejunit.v3.runners.Parameterized; + +import java.util.Arrays; +import java.util.Collection; + +import static org.litejunit.v3.Assert.assertEquals; + + +/** + * Created by john on 2017/9/6. + */ +@RunWith(Parameterized.class)//1.必须 +public class ParametTestUnit { + private int input; + private boolean expected;//expected result + + /** + * 2.public 构造器赋值一组测试数据 + */ + public ParametTestUnit(int input, boolean expected) { + this.input = input; + this.expected = expected; + } + + /** + * 3.由@Parameterized.Parameters修饰一个 + * public static Collection xxx() + */ + @Parameterized.Parameters + public static Collection data() { + return Arrays.asList(new Object[][]{ + {1, true}, + {3, true},// + {6, false}, + {11, true}, + {22, false}, + {23, true} + }); + } + + /** + * 4.JUnit循环地使用各组数据 + */ + @Test + public void testOdd() { + System.out.println("Parameterized Number is : " + input); + assertEquals(expected, input % 2 != 0); + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/PersonTest.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/PersonTest.java new file mode 100644 index 0000000000..82ea9a1bbb --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/v3/sample/PersonTest.java @@ -0,0 +1,48 @@ +package org.litejunit.v3.sample; + + +import org.litejunit.v3.Before; +import org.litejunit.v3.Test; + +import static org.litejunit.v3.Assert.assertEquals; + +/** + * Created by john on 2017/9/2. + */ +public class PersonTest{ + + Person p = null; + @Before + public void setUp() { + p = new Person("andy",30); + } + + @Test + public void testAge(){ + assertEquals(30, p.getAge()); + } + + @Test + public void testName(){ + assertEquals("andy", p.getName()); + } +} + +class Person{ + private String name; + private int age; + + public Person(String name, int age) { + + this.name = name; + this.age = age; + } + public String getName() { + return name; + } + public int getAge() { + return age; + } + + +} \ No newline at end of file From f30c364cc86e8afda8bc9233b608aacd45656425 Mon Sep 17 00:00:00 2001 From: johnChnia Date: Wed, 6 Sep 2017 19:22:01 +0800 Subject: [PATCH 77/81] =?UTF-8?q?JUnit4.0=E7=B1=BB=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "students/315863321/uml/Junit4\347\261\273\345\233\276.gliffy" | 1 + 1 file changed, 1 insertion(+) create mode 100644 "students/315863321/uml/Junit4\347\261\273\345\233\276.gliffy" diff --git "a/students/315863321/uml/Junit4\347\261\273\345\233\276.gliffy" "b/students/315863321/uml/Junit4\347\261\273\345\233\276.gliffy" new file mode 100644 index 0000000000..e4454a6826 --- /dev/null +++ "b/students/315863321/uml/Junit4\347\261\273\345\233\276.gliffy" @@ -0,0 +1 @@ +{"contentType":"application/gliffy+json","version":"1.1","metadata":{"title":"untitled","revision":0,"exportBorder":false},"embeddedResources":{"index":0,"resources":[]},"stage":{"objects":[{"x":427,"y":720,"rotation":0,"id":218,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":218,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-57,-5],[235,14]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":141,"px":0,"py":0.5}}},"linkMap":[]},{"x":488,"y":704,"rotation":0,"id":217,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":217,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-62.08150064683048,-109.35575679172052],[174,30]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":141,"px":0,"py":0.5}}},"linkMap":[]},{"x":874,"y":472,"rotation":0,"id":216,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":216,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-3,40.5],[-3,-8.25],[-213,-8.25],[-213,-57]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":209,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":169,"px":0.5,"py":1}}},"linkMap":[]},{"x":801,"y":512.5,"rotation":0,"id":209,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":75,"lockAspectRatio":false,"lockShape":false,"order":158,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":210,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":211,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Parameterized

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":211,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":212,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":213,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Attribute

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":210,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":213,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":214,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":215,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Method

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":209,"magnitude":1},{"id":210,"magnitude":-1},{"id":212,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":212,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":210,"magnitude":1},{"id":212,"magnitude":1},{"id":215,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":653,"y":437,"rotation":0,"id":208,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":151,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-50.125,75.5],[-50.125,26.75],[8,26.75],[8,-22]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":201,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":169,"px":0.5,"py":1}}},"linkMap":[]},{"x":474.75,"y":512.5,"rotation":0,"id":201,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":256.25,"height":96,"lockAspectRatio":false,"lockShape":false,"order":144,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":202,"uid":null,"width":256.25,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":203,"uid":null,"width":256.25,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Suite\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":203,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":204,"uid":null,"width":256.25,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":205,"uid":null,"width":256.25,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Attribute

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":202,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":205,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":206,"uid":null,"width":256.25,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":207,"uid":null,"width":256.25,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

\n

- static Class[] getAnnotatedClasses(Class)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":201,"magnitude":1},{"id":202,"magnitude":-1},{"id":204,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":204,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":202,"magnitude":1},{"id":204,"magnitude":1},{"id":207,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":144.00000000000003,"y":564,"rotation":0,"id":200,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":143,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-20.71978021978022,-131.65109890109898],[-20.71978021978022,168.58073580374355],[56.99999999999997,168.58073580374355]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":156,"px":0,"py":0.7071067811865475}}},"linkMap":[]},{"x":533,"y":440,"rotation":0,"id":197,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":142,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-43.02468759581859,-75],[-16.016458397212432,-75],[10.99177080139384,-75],[38,-75]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":176,"px":1,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":169,"px":0,"py":0.5}}},"linkMap":[]},{"x":324,"y":231,"rotation":0,"id":196,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":141,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-34,74],[-34,21.5],[463.5,21.5],[463.5,-31]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":176,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":95,"px":0.5,"py":1}}},"linkMap":[]},{"x":638,"y":225,"rotation":0,"id":194,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":140,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[256,-70],[418,-70],[418,140],[378,140]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":95,"px":1,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":102,"px":1,"py":0.5}}},"linkMap":[]},{"x":543,"y":267,"rotation":0,"id":193,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":139,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[365.5,38],[365.5,-14.5],[244.5,-14.5],[244.5,-67]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":102,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":95,"px":0.5,"py":1}}},"linkMap":[]},{"x":363,"y":323,"rotation":0,"id":191,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":138,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[298,-8],[298,-70.5],[424.5,-70.5],[424.5,-123]],"lockSegments":{"1":true}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":169,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":95,"px":0.5,"py":1}}},"linkMap":[]},{"x":89.99999999999997,"y":305,"rotation":0,"id":176,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":400.00000000000006,"height":124,"lockAspectRatio":false,"lockShape":false,"order":131,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":177,"uid":null,"width":400.00000000000006,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":178,"uid":null,"width":400.00000000000006,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestClassMethodsRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":178,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":179,"uid":null,"width":400.00000000000006,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":180,"uid":null,"width":400.00000000000006,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- List<Method> fTestMethods\n

- Class<?> fTestClass

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":177,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":180,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":181,"uid":null,"width":400.00000000000006,"height":74,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":182,"uid":null,"width":400.00000000000006,"height":74,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void run(RunNotifier notifier)\n

# void invokeTestMethod(Method, RunNotifier)\n

# Object createTest()\n

# TestMethodRunner createMethodRunner(Object, Method, RunNotifier)\n

+ Description getDescription()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":176,"magnitude":1},{"id":177,"magnitude":-1},{"id":179,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":179,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":177,"magnitude":1},{"id":179,"magnitude":1},{"id":182,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":571,"y":315,"rotation":0,"id":169,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":180,"height":100,"lockAspectRatio":false,"lockShape":false,"order":124,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":170,"uid":null,"width":180,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":171,"uid":null,"width":180,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestClassRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":171,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":172,"uid":null,"width":180,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":173,"uid":null,"width":180,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- Class<?> fTestClass\n

# Runner fEnclosedRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":170,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":173,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":174,"uid":null,"width":180,"height":50,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":175,"uid":null,"width":180,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void run(RunNotifier notifier)\n

+ Description getDescription()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":169,"magnitude":1},{"id":170,"magnitude":-1},{"id":172,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":172,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":170,"magnitude":1},{"id":172,"magnitude":1},{"id":175,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":627.5,"y":802,"rotation":0,"id":163,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":123,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-341.5,-167],[-341.5,-180.5],[-341.5,-194],[-341.5,-207.5]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":156,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":149,"px":0.5,"py":1}}},"linkMap":[]},{"x":201,"y":635,"rotation":0,"id":156,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":170,"height":138,"lockAspectRatio":false,"lockShape":false,"order":116,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":157,"uid":null,"width":170,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":158,"uid":null,"width":170,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestMethodRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":158,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":159,"uid":null,"width":170,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":160,"uid":null,"width":170,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- Object fTest\n

- Method\n

- RunNotifier \n

- TestIntrospector

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":157,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":160,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":78,"rotation":0,"id":161,"uid":null,"width":170,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":162,"uid":null,"width":170,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void run()\n

· void runMethod()\n

# void runUnprotected()\n

# void executeMethodBody()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":156,"magnitude":1},{"id":157,"magnitude":-1},{"id":159,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":159,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":157,"magnitude":1},{"id":159,"magnitude":1},{"id":162,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":146,"y":442.5,"rotation":0,"id":149,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":280,"height":152,"lockAspectRatio":false,"lockShape":false,"order":109,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":150,"uid":null,"width":280,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":151,"uid":null,"width":280,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

BeforeAndAfterRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":151,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":152,"uid":null,"width":280,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":153,"uid":null,"width":280,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- Class<? extends Annotation> fBeforeAnnotation\n

- Class<? extends Annotation> fAfterAnnotation\n

- TestIntrospector\n

- Object fTest

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":150,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":153,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":78,"rotation":0,"id":154,"uid":null,"width":280,"height":74,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":155,"uid":null,"width":280,"height":74,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void runProtected()\n

# abstract void runUnprotected()\n

- void runAfters()\n

- void runBefores()\n

+ abstract void addFailure(Throwable)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":149,"magnitude":1},{"id":150,"magnitude":-1},{"id":152,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":152,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":150,"magnitude":1},{"id":152,"magnitude":1},{"id":155,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":662,"y":693,"rotation":0,"id":141,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":404,"height":82,"lockAspectRatio":false,"lockShape":false,"order":102,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":142,"uid":null,"width":404,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":143,"uid":null,"width":404,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestIntrospector

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":143,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":144,"uid":null,"width":404,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":145,"uid":null,"width":404,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- Class< ?> fTestClass

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":142,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":145,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":146,"uid":null,"width":404,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":147,"uid":null,"width":404,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ List<Method> getTestMethods(Class<? extends Annotation>)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":141,"magnitude":1},{"id":142,"magnitude":-1},{"id":144,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":144,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":142,"magnitude":1},{"id":144,"magnitude":1},{"id":147,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":801,"y":305,"rotation":0,"id":102,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":214.99999999999997,"height":120,"lockAspectRatio":false,"lockShape":false,"order":95,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":103,"uid":null,"width":214.99999999999997,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":104,"uid":null,"width":214.99999999999997,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

CompositeRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":104,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":105,"uid":null,"width":214.99999999999997,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":106,"uid":null,"width":214.99999999999997,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- List<Runner> fRunners\n

- String fName

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":103,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":106,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":107,"uid":null,"width":214.99999999999997,"height":70,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":108,"uid":null,"width":214.99999999999997,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void run(RunNotifier notifier)\n

+ void add(Runner)\n

+ void addAll(List<? extends Runner>)\n

+ Description getDescription()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":102,"magnitude":1},{"id":103,"magnitude":-1},{"id":105,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":105,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":103,"magnitude":1},{"id":105,"magnitude":1},{"id":108,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":681,"y":110,"rotation":0,"id":95,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":213,"height":90,"lockAspectRatio":false,"lockShape":false,"order":88,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":96,"uid":null,"width":213,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":97,"uid":null,"width":213,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Runner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":97,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":98,"uid":null,"width":213,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":99,"uid":null,"width":213,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Attribute

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":96,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":99,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":100,"uid":null,"width":213,"height":54,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":101,"uid":null,"width":213,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ abstract void run(RunNotifier notifier)\n

+ abstract Description getDescription()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":95,"magnitude":1},{"id":96,"magnitude":-1},{"id":98,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":98,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":96,"magnitude":1},{"id":98,"magnitude":1},{"id":101,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]}],"background":"#FFFFFF","width":1068,"height":775,"maxWidth":5000,"maxHeight":5000,"nodeIndex":223,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file From 80015144406d0018adcaec2feca5908e34cb4c7f Mon Sep 17 00:00:00 2001 From: johnChnia Date: Sat, 9 Sep 2017 01:34:11 +0800 Subject: [PATCH 78/81] =?UTF-8?q?=E4=BF=AE=E6=94=B9JUnit3=E6=97=B6?= =?UTF-8?q?=E5=BA=8F=E5=9B=BE=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=88=9B=E5=BB=BA?= =?UTF-8?q?TestSuite=E5=8A=A8=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uml/JUnit3\346\227\266\345\272\217\345\233\276.gliffy" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/students/315863321/uml/JUnit3\346\227\266\345\272\217\345\233\276.gliffy" "b/students/315863321/uml/JUnit3\346\227\266\345\272\217\345\233\276.gliffy" index 8b14c85b29..52737f00ca 100644 --- "a/students/315863321/uml/JUnit3\346\227\266\345\272\217\345\233\276.gliffy" +++ "b/students/315863321/uml/JUnit3\346\227\266\345\272\217\345\233\276.gliffy" @@ -1 +1 @@ -{"contentType":"application/gliffy+json","version":"1.1","metadata":{"title":"untitled","revision":0,"exportBorder":false},"embeddedResources":{"index":0,"resources":[]},"stage":{"objects":[{"x":501.97802197802207,"y":663.7362637362638,"rotation":0,"id":93,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":39,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[127.47252747252753,-1.758241758241752],[53.1868131868132,-1.758241758241752],[53.1868131868132,-1.758241758241752],[-21.09890109890108,-1.758241758241752]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":641,"y":620.5,"rotation":0,"id":77,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":38,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

endTest()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":650.5,"y":616,"rotation":0,"id":75,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":37,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":480.5,"y":529.5,"rotation":0,"id":72,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":36,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

tearDown()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":480.5,"y":529.5,"rotation":0,"id":70,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":35,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":471,"y":470,"rotation":0,"id":68,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":34,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

runTest()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":480.5,"y":470,"rotation":0,"id":66,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":33,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":466,"y":418,"rotation":0,"id":64,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":32,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

setUp()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":480.5,"y":410,"rotation":0,"id":61,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":31,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":464,"y":364,"rotation":0,"id":60,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":30,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

doRun()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":488,"y":539,"rotation":0,"id":59,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":29,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[140,-157],[-9.030198282093124,-157]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":461.5,"y":381,"rotation":0,"id":58,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":280,"lockAspectRatio":false,"lockShape":false,"order":28,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":479,"y":200,"rotation":0,"id":51,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":25,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(this)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":502,"y":215,"rotation":0,"id":50,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":24,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-20,0],[131,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":291,"y":199,"rotation":0,"id":47,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":22,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(TestResult)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":310,"y":215,"rotation":0,"id":46,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":21,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-8,0],[150.07909412695915,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":461.5,"y":211,"rotation":0,"id":45,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":85,"lockAspectRatio":false,"lockShape":false,"order":20,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":281.5,"y":176,"rotation":0,"id":40,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":480,"lockAspectRatio":false,"lockShape":false,"order":18,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":99.5,"y":176,"rotation":0,"id":39,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":480,"lockAspectRatio":false,"lockShape":false,"order":17,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":48,"y":126,"rotation":0,"id":18,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":600.0000000000001,"lockAspectRatio":false,"lockShape":false,"order":0,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":19,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":20,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":20,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":21,"uid":null,"width":120,"height":582.0000000000001,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":18,"magnitude":1},{"id":19,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":19,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":19,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":230,"y":126,"rotation":0,"id":22,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":600,"lockAspectRatio":false,"lockShape":false,"order":4,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":23,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":24,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestSuite\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":24,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":25,"uid":null,"width":120,"height":582,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":22,"magnitude":1},{"id":23,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":23,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":23,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":410,"y":126,"rotation":0,"id":26,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":600,"lockAspectRatio":false,"lockShape":false,"order":8,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":27,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":28,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestCase

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":28,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":29,"uid":null,"width":120,"height":582,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":26,"magnitude":1},{"id":27,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":27,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":27,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":580,"y":126,"rotation":0,"id":30,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":600,"lockAspectRatio":false,"lockShape":false,"order":12,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":31,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":32,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestResult\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":32,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":33,"uid":null,"width":120,"height":582,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":30,"magnitude":1},{"id":31,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":31,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":31,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":641,"y":219,"rotation":0,"id":55,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":27,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

startTest()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":650.5,"y":214,"rotation":0,"id":53,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":32,"lockAspectRatio":false,"lockShape":false,"order":26,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":631.5,"y":211,"rotation":0,"id":49,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":450,"lockAspectRatio":false,"lockShape":false,"order":23,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":147,"y":177,"rotation":0,"id":38,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":16,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-31,0],[134.0030302752043,1.1368683772161603e-13]],"lockSegments":{}}},"children":[],"linkMap":[]},{"x":111,"y":164,"rotation":0,"id":42,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":19,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(TestResult)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":511.97802197802207,"y":673.7362637362638,"rotation":0,"id":94,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":40,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-31.97802197802207,-64.50549450549454],[44.065934065934016,-64.50549450549454],[44.065934065934016,-64.50549450549454],[120.10989010988999,-64.50549450549454]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":330.879120879121,"y":661.4285714285716,"rotation":0,"id":95,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":41,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[127.47252747252753,-1.758241758241752],[48.626373626373606,-1.758241758241752],[48.626373626373606,-2.087912087912173],[-30.21978021978032,-2.087912087912173]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":150.43956043956044,"y":655.054945054945,"rotation":0,"id":96,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":42,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[127.47252747252753,-1.758241758241752],[48.626373626373606,-1.758241758241752],[48.626373626373606,-2.087912087912173],[-30.21978021978032,-2.087912087912173]],"lockSegments":{}}},"children":null,"linkMap":[]}],"background":"#FFFFFF","width":789,"height":727,"maxWidth":5000,"maxHeight":5000,"nodeIndex":97,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file +{"contentType":"application/gliffy+json","version":"1.1","metadata":{"title":"untitled","revision":0,"exportBorder":false},"embeddedResources":{"index":0,"resources":[]},"stage":{"objects":[{"x":749,"y":860,"rotation":0,"id":142,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":54,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":617,"y":881,"rotation":0,"id":141,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":53,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-65,-37],[21,-37],[21,-37],[107,-37]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":549,"y":787,"rotation":0,"id":138,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":51,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":549,"y":740,"rotation":0,"id":135,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":49,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":549,"y":691,"rotation":0,"id":132,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":47,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":619,"y":676,"rotation":0,"id":130,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":45,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[106.00520819205587,-34],[-64.04705087092816,-33.999999999999886]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":749,"y":600,"rotation":0,"id":127,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":43,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":730,"y":600,"rotation":0,"id":125,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":300,"lockAspectRatio":false,"lockShape":false,"order":41,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":137,"y":556,"rotation":0,"id":120,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":37,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(TestResult)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":128,"y":569,"rotation":0,"id":119,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":36,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-6,0],[209.0023923308056,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":340.5,"y":564,"rotation":0,"id":118,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":336,"lockAspectRatio":false,"lockShape":false,"order":35,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":570,"y":520,"rotation":0,"id":117,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":34,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[159,-26],[-146,-26],[-146,-25],[-451,-25]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":135,"y":410,"rotation":0,"id":115,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":33,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

result= new TestResult()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":207.17582417582418,"y":451.1098901098901,"rotation":0,"id":114,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":32,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-84.3973759210142,-23.912087912087884],[474.021978021978,-23.912087912087884]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":204,"y":419,"rotation":0,"id":113,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":31,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[134,-59],[24,-59],[24,-59],[-86,-59]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":185,"y":469,"rotation":0,"id":112,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":30,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[346,-109],[258.5,-109],[258.5,-109],[171,-109]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":338.5,"y":280,"rotation":0,"id":109,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":29,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

new

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":381,"y":302,"rotation":0,"id":108,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":28,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-21.004132160848144,0],[100.00413201974408,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":357.5,"y":238.5,"rotation":0,"id":106,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":27,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

addTest(Test)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":357.5,"y":234,"rotation":0,"id":104,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":26,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":147,"y":93,"rotation":0,"id":102,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":25,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[43,78],[83,-31.5]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":100,"px":0,"py":0.5}}},"linkMap":[]},{"x":230,"y":30,"rotation":0,"id":100,"uid":"com.gliffy.shape.uml.uml_v1.default.note","width":118,"height":63,"lockAspectRatio":false,"lockShape":false,"order":23,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.note.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":2.36,"y":0,"rotation":0,"id":103,"uid":null,"width":113.28,"height":14,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

把 class name 传入

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":113,"y":182,"rotation":0,"id":98,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":22,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

new

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":124,"y":196,"rotation":0,"id":97,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":21,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-5,0],[160.0121207669303,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":530,"y":593,"rotation":0,"id":58,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":307,"lockAspectRatio":false,"lockShape":false,"order":20,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":530,"y":330,"rotation":0,"id":45,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":30,"lockAspectRatio":false,"lockShape":false,"order":18,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":338.5,"y":234,"rotation":0,"id":40,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":126,"lockAspectRatio":false,"lockShape":false,"order":17,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":99.5,"y":164,"rotation":0,"id":39,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":736,"lockAspectRatio":false,"lockShape":false,"order":16,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":48,"y":126,"rotation":0,"id":18,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":878,"lockAspectRatio":false,"lockShape":false,"order":0,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":19,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":20,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":20,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":21,"uid":null,"width":120,"height":860,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":18,"magnitude":1},{"id":19,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":19,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":19,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":285.5,"y":189,"rotation":0,"id":22,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":810,"lockAspectRatio":false,"lockShape":false,"order":4,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":23,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":24,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestSuite\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":24,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":25,"uid":null,"width":120,"height":792,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":22,"magnitude":1},{"id":23,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":23,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":23,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":480,"y":290,"rotation":0,"id":26,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":724,"lockAspectRatio":false,"lockShape":false,"order":8,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":27,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":28,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestCase

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":28,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":29,"uid":null,"width":120,"height":706,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":26,"magnitude":1},{"id":27,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":27,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":27,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":730,"y":454,"rotation":0,"id":49,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":40,"lockAspectRatio":false,"lockShape":false,"order":19,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":680,"y":414,"rotation":0,"id":30,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":600,"lockAspectRatio":false,"lockShape":false,"order":12,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":31,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":32,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestResult\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":32,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":33,"uid":null,"width":120,"height":582,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":30,"magnitude":1},{"id":31,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":31,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":31,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":359.5,"y":570,"rotation":0,"id":122,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":38,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(TestResult)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":389,"y":600,"rotation":0,"id":123,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":39,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-26,-8],[139.0030302752043,-7.999999999999886]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":597,"y":648,"rotation":0,"id":124,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":40,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-47,-51],[130.10166571774528,-51]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":560,"y":570,"rotation":0,"id":126,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":42,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(TestCase)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":739.5,"y":600,"rotation":0,"id":129,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":44,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

startTest()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":562,"y":623,"rotation":0,"id":131,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":46,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

doRun()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":539.5,"y":691,"rotation":0,"id":134,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":48,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

setUp()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":539.5,"y":740,"rotation":0,"id":137,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":50,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

runTest()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":539.5,"y":791.5,"rotation":0,"id":140,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":52,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

tearDown()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":739.5,"y":860,"rotation":0,"id":144,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":55,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

endTest()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":558,"y":925,"rotation":0,"id":146,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":56,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[164,-28],[79,-28],[79,-28],[-6,-28]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":368,"y":927,"rotation":0,"id":147,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":57,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[164,-28],[79,-28],[79,-28],[-6,-28]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":163,"y":927,"rotation":0,"id":148,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":58,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[175,-28],[66.5,-28],[66.5,-28],[-42,-28]],"lockSegments":{}}},"children":null,"linkMap":[]}],"background":"#FFFFFF","width":888,"height":1014,"maxWidth":5000,"maxHeight":5000,"nodeIndex":149,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file From 9cc9e2bf8a51d750661084f0597df2c712ffe316 Mon Sep 17 00:00:00 2001 From: johnChnia Date: Sat, 9 Sep 2017 18:58:32 +0800 Subject: [PATCH 79/81] =?UTF-8?q?=E5=AE=8C=E6=88=90JUnitV4.0=E6=97=B6?= =?UTF-8?q?=E5=BA=8F=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uml/JUnit4\346\227\266\345\272\217\345\233\276.gliffy" | 1 + 1 file changed, 1 insertion(+) create mode 100644 "students/315863321/uml/JUnit4\346\227\266\345\272\217\345\233\276.gliffy" diff --git "a/students/315863321/uml/JUnit4\346\227\266\345\272\217\345\233\276.gliffy" "b/students/315863321/uml/JUnit4\346\227\266\345\272\217\345\233\276.gliffy" new file mode 100644 index 0000000000..210f03933c --- /dev/null +++ "b/students/315863321/uml/JUnit4\346\227\266\345\272\217\345\233\276.gliffy" @@ -0,0 +1 @@ +{"contentType":"application/gliffy+json","version":"1.1","metadata":{"title":"untitled","revision":0,"exportBorder":false},"embeddedResources":{"index":0,"resources":[]},"stage":{"objects":[{"x":213,"y":2513,"rotation":0,"id":268,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":131,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-13.017697729161,0],[100,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":409.99999999999994,"y":2420,"rotation":0,"id":261,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":40,"lockAspectRatio":false,"lockShape":false,"order":127,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":404,"y":2373.3333333333335,"rotation":0,"id":259,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":125,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[374.66666666666663,-8],[83.33333333333331,-8],[83.33333333333331,-8],[-208,-8]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":849.3333333333334,"y":2422.6666666666665,"rotation":0,"id":258,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":124,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[129.33333333333326,-53.33333333333303],[39.33333333333326,-53.33333333333303],[39.33333333333326,-53.33333333333303],[-50.66666666666674,-53.33333333333303]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":981.5,"y":2319,"rotation":0,"id":257,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":47.703125,"lockAspectRatio":false,"lockShape":false,"order":123,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":810.6666666666666,"y":2290.6666666666665,"rotation":0,"id":255,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":121,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-2.674508976812035,0],[110.6746985037181,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":216,"y":2262.6666666666665,"rotation":0,"id":249,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":116,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-10.698790518335016,0],[556.014116670961,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":468,"y":2252,"rotation":0,"id":248,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":115,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[308,-28],[24.666666666666686,-28],[24.666666666666686,-29.333333333333485],[-258.66666666666663,-29.333333333333485]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":781.5,"y":2180,"rotation":0,"id":247,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":186.875,"lockAspectRatio":false,"lockShape":false,"order":114,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":266.6666666666667,"y":2056,"rotation":0,"id":245,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":112,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[133.33333333333331,-24],[34.66666666666663,-24],[34.66666666666663,-24],[-64.00000000000003,-24]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":237.33333333333334,"y":2141.3333333333335,"rotation":0,"id":244,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":111,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-33.439957367432555,0],[488.001704678407,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":208,"y":2005.3333333333333,"rotation":0,"id":242,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":109,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-6.6749996745045905,0],[198.66666666666669,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":410,"y":2003,"rotation":0,"id":241,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":30,"lockAspectRatio":false,"lockShape":false,"order":108,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":445.3333333333333,"y":1994.6666666666667,"rotation":0,"id":237,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":107,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[138.66666666666669,-45.333333333333485],[-52.66666666666663,-45.333333333333485],[-52.66666666666663,-45.333333333333485],[-243.99999999999997,-45.333333333333485]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":591.5,"y":1900,"rotation":0,"id":236,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":50,"lockAspectRatio":false,"lockShape":false,"order":106,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":206.66666666666666,"y":1869.3333333333333,"rotation":0,"id":234,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":104,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[0,0],[334.6693226986238,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":297.3333333333333,"y":1800,"rotation":0,"id":233,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":103,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[105.33333333333337,-26.666666666666742],[7.333333333333371,-26.666666666666742],[7.333333333333371,-26.666666666666742],[-90.66666666666666,-26.666666666666742]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":410,"y":1725,"rotation":0,"id":232,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":50,"lockAspectRatio":false,"lockShape":false,"order":102,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":181.5,"y":1690,"rotation":0,"id":230,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":843.125,"lockAspectRatio":false,"lockShape":false,"order":100,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":225.33333333333334,"y":1698.6666666666667,"rotation":0,"id":229,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":99,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-18.734063258096995,0],[133.35671298164235,2.2737367544323206e-13]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":870,"y":1220,"rotation":0,"id":207,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":78,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":1193,"y":1125,"rotation":0,"id":205,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":76,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[193,55],[76.5,55],[76.5,55],[-40,55]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":1409,"y":1130,"rotation":0,"id":202,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":74,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":1409,"y":1080,"rotation":0,"id":199,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":72,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":1409,"y":1020,"rotation":0,"id":196,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":70,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":1409,"y":963.2660187604192,"rotation":0,"id":193,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":68,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":1237,"y":868,"rotation":0,"id":192,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":67,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[149,2],[31,2],[31,1],[-87,1]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":1621.5,"y":830,"rotation":0,"id":191,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":40,"lockAspectRatio":false,"lockShape":false,"order":66,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":1444,"y":946,"rotation":0,"id":190,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":65,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[177,-77],[75,-77],[75,-76],[-27,-76]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":1553,"y":742,"rotation":0,"id":189,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":64,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-47,37],[28,-37.45227278524749]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":175,"px":0,"py":0.7071067811865475}}},"linkMap":[]},{"x":1425,"y":801,"rotation":0,"id":186,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":62,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-13.0333282076042,1.1368683772161603e-13],[122.00409829181967,1.1368683772161603e-13]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":1581,"y":660,"rotation":0,"id":175,"uid":"com.gliffy.shape.uml.uml_v1.default.note","width":100,"height":63,"lockAspectRatio":false,"lockShape":false,"order":56,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.note.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":2,"y":0,"rotation":0,"id":188,"uid":null,"width":96,"height":42,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

传入了Before.class和After.class

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":1166,"y":962,"rotation":0,"id":166,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":54,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-11.004504413109316,0],[220.0021644498181,2.2737367544323206e-13]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":1390,"y":963.2660187604192,"rotation":0,"id":165,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":220.00000000000003,"lockAspectRatio":false,"lockShape":false,"order":53,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":1390,"y":790,"rotation":0,"id":163,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":80,"lockAspectRatio":false,"lockShape":false,"order":52,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":1190,"y":755,"rotation":0,"id":161,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":50,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-38.014491992689045,0],[147,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":1150.5,"y":687,"rotation":0,"id":156,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":48,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":876,"y":665,"rotation":0,"id":150,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":42,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-6,0],[251.00796800101784,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":873,"y":609,"rotation":0,"id":147,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":40,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":1131.5,"y":663.2660187604191,"rotation":0,"id":145,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":520,"lockAspectRatio":false,"lockShape":false,"order":39,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":869,"y":547,"rotation":0,"id":135,"uid":"com.gliffy.shape.uml.uml_v1.default.self_message","width":45,"height":23,"lockAspectRatio":false,"lockShape":false,"order":37,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.self_message.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#000000","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[],"linkMap":[]},{"x":643,"y":534,"rotation":0,"id":133,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":35,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-29.034879005639368,0],[204,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":850,"y":520,"rotation":0,"id":131,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":750,"lockAspectRatio":false,"lockShape":false,"order":34,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":680,"y":563,"rotation":0,"id":130,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":33,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[165,-87],[48.5,-87],[48.5,-87],[-68,-87]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":850,"y":460,"rotation":0,"id":129,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":20,"lockAspectRatio":false,"lockShape":false,"order":32,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":663,"y":359,"rotation":0,"id":126,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":31,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[22,19],[87,-54.45227278524749]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":124,"px":0,"py":0.7071067811865475}}},"linkMap":[]},{"x":750,"y":260,"rotation":0,"id":124,"uid":"com.gliffy.shape.uml.uml_v1.default.note","width":185.5,"height":63,"lockAspectRatio":false,"lockShape":false,"order":29,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.note.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":3.7100000000000004,"y":0,"rotation":0,"id":132,"uid":null,"width":178.08,"height":42,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

1、把BeforeClass.class 和AfterClass.class传入\n

2、重写了runUnprotected方法\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":616,"y":420,"rotation":0,"id":122,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":27,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[0,0],[162.00308639035245,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":388,"y":403,"rotation":0,"id":111,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":17,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-5,0],[204.03864282987297,-5.684341886080802e-14]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":170,"y":365,"rotation":0,"id":109,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":16,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(RunNotifier)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":188,"y":383,"rotation":0,"id":108,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":15,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-15.004347743900524,-5.684341886080802e-14],[168,-5.684341886080802e-14]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":591.5,"y":400,"rotation":0,"id":107,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":870,"lockAspectRatio":false,"lockShape":false,"order":14,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":361.5,"y":379,"rotation":0,"id":106,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":891,"lockAspectRatio":false,"lockShape":false,"order":13,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":151.5,"y":340,"rotation":0,"id":105,"uid":"com.gliffy.shape.uml.uml_v1.default.activation","width":19,"height":930,"lockAspectRatio":false,"lockShape":false,"order":12,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":null,"linkMap":[]},{"x":100,"y":130,"rotation":0,"id":93,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":1250,"lockAspectRatio":false,"lockShape":false,"order":0,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":94,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":95,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:JUnitCore

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":95,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":96,"uid":null,"width":120,"height":1232,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":93,"magnitude":1},{"id":94,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":94,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":94,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":310,"y":130,"rotation":0,"id":97,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":1250,"lockAspectRatio":false,"lockShape":false,"order":4,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":98,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":99,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:CompositeRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":99,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":100,"uid":null,"width":120,"height":1232,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":97,"magnitude":1},{"id":98,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":98,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":98,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":540,"y":130,"rotation":0,"id":101,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":1257,"lockAspectRatio":false,"lockShape":false,"order":8,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":102,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":103,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestClassRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":103,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":104,"uid":null,"width":120,"height":1239,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":101,"magnitude":1},{"id":102,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":102,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":102,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":390,"y":379,"rotation":0,"id":112,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":18,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(RunNotifier)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":783.5,"y":407,"rotation":0,"id":114,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":150,"height":959.9999999999999,"lockAspectRatio":false,"lockShape":false,"order":19,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":115,"uid":null,"width":150,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":116,"uid":null,"width":150,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:BeforeAndAfterRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":116,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":117,"uid":null,"width":150,"height":941.9999999999999,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":114,"magnitude":1},{"id":115,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":115,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":115,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":1060,"y":460,"rotation":0,"id":118,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":160,"height":894.2660187604192,"lockAspectRatio":false,"lockShape":false,"order":23,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":119,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":120,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestClassMethodsRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":120,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":121,"uid":null,"width":160,"height":876.2660187604192,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":118,"magnitude":1},{"id":119,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":119,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":119,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":610.5,"y":393,"rotation":0,"id":123,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":28,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

new

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":630,"y":506,"rotation":0,"id":134,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":36,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

runProtected()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":869,"y":540,"rotation":0,"id":137,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":38,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

runBefores()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":891.5,"y":609,"rotation":0,"id":149,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":41,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

runUnprotected()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":916,"y":643,"rotation":0,"id":151,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":43,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(RunNotifier)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":1340,"y":745.2660187604192,"rotation":0,"id":152,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":609,"lockAspectRatio":false,"lockShape":false,"order":44,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":153,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":154,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TestMethodRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":154,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":155,"uid":null,"width":120,"height":591,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":152,"magnitude":1},{"id":153,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":153,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":153,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":1173,"y":691.5,"rotation":0,"id":158,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":49,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

invokeTestMethod()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":1161,"y":733,"rotation":0,"id":162,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":51,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

new

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":1173,"y":949.2660187604192,"rotation":0,"id":170,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":55,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":1550,"y":791.6330093802096,"rotation":0,"id":182,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":160,"height":622,"lockAspectRatio":false,"lockShape":false,"order":58,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":183,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":184,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:BeforeAndAfterRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":184,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":185,"uid":null,"width":160,"height":604,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":182,"magnitude":1},{"id":183,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":183,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":183,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":1414,"y":783,"rotation":0,"id":187,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":63,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

super()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":1416,"y":960.7660187604192,"rotation":0,"id":195,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":69,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

runProtected()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":1418,"y":1020,"rotation":0,"id":198,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":71,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

runBefores

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":1420,"y":1080,"rotation":0,"id":201,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":73,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

runUnprotected()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":1414,"y":1129,"rotation":0,"id":204,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":75,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

runAfters

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":923,"y":1124,"rotation":0,"id":206,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":77,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[206,55],[79,55],[79,55],[-48,55]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":870,"y":1220,"rotation":0,"id":209,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":79,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

runAfters

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":668,"y":1155,"rotation":0,"id":210,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":80,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[179,114],[59.5,114],[59.5,114],[-60,114]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":440,"y":1153,"rotation":0,"id":211,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":81,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[151,114],[45.5,114],[45.5,114],[-60,114]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":189,"y":1224,"rotation":0,"id":212,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":82,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[165,46],[73.5,46],[73.5,46],[-18,46]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":130,"y":1620,"rotation":0,"id":213,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":971,"lockAspectRatio":false,"lockShape":false,"order":83,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":214,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":215,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:JUnitCore

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":215,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":216,"uid":null,"width":120,"height":953,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":213,"magnitude":1},{"id":214,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":214,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":214,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":360,"y":1690,"rotation":0,"id":217,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":840,"lockAspectRatio":false,"lockShape":false,"order":87,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":218,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":219,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:RunNotifier

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":219,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":220,"uid":null,"width":120,"height":822,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":217,"magnitude":1},{"id":218,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":218,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":218,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":730,"y":2130,"rotation":0,"id":221,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":409.99999999999994,"lockAspectRatio":false,"lockShape":false,"order":91,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":222,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":223,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:Result

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":223,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":224,"uid":null,"width":120,"height":391.99999999999994,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":221,"magnitude":1},{"id":222,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":222,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":222,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":540,"y":1870,"rotation":0,"id":225,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":589.9999999999999,"lockAspectRatio":false,"lockShape":false,"order":95,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":226,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":227,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

:TextListener

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":227,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":228,"uid":null,"width":120,"height":571.9999999999999,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":225,"magnitude":1},{"id":226,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":226,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":226,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":200.5,"y":1675,"rotation":0,"id":231,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":101,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

new

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":252,"y":1856.0000000000002,"rotation":0,"id":235,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":105,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

new

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":234.33333333333331,"y":1981,"rotation":0,"id":243,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":110,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

addListener

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":255.66666666666669,"y":2118.3333333333335,"rotation":0,"id":246,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":113,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

new

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":930,"y":2282.5,"rotation":0,"id":250,"uid":"com.gliffy.shape.uml.uml_v1.default.object_timeline","width":120,"height":273,"lockAspectRatio":false,"lockShape":false,"order":117,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":251,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":252,"uid":null,"width":120,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Listener

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":252,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":253,"uid":null,"width":120,"height":255,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.object_timeline.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":null,"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":250,"magnitude":1},{"id":251,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":251,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":251,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":791.0000000000001,"y":2262.5,"rotation":0,"id":256,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":20,"lockAspectRatio":false,"lockShape":false,"order":122,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

new

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":234.33333333333331,"y":2241,"rotation":0,"id":260,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":126,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

createListener

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":216.66666666666669,"y":2430,"rotation":0,"id":262,"uid":"com.gliffy.shape.uml.uml_v1.default.message","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":128,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":2,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":false,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-12.669117632335258,0],[191.33333333333331,0]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":245,"y":2407.6666666666665,"rotation":0,"id":263,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":129,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

addListener

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]},{"x":268.6666666666667,"y":2483.3333333333335,"rotation":0,"id":264,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":130,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[133.33333333333331,-24],[33.833333333333314,-24],[33.833333333333314,-24.333333333333485],[-65.66666666666669,-24.333333333333485]],"lockSegments":{}}},"children":null,"linkMap":[]},{"x":200,"y":2490,"rotation":0,"id":269,"uid":"com.gliffy.shape.basic.basic_v1.default.text","width":150,"height":14,"lockAspectRatio":false,"lockShape":false,"order":132,"graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

run(RunNotifier)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null,"linkMap":[]}],"background":"#FFFFFF","width":1712,"height":2591,"maxWidth":5000,"maxHeight":5000,"nodeIndex":270,"autoFit":true,"exportBorder":false,"gridOn":false,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file From 90242080f9d0b37b97448ccb219d8dedc2b3e6d8 Mon Sep 17 00:00:00 2001 From: johnChnia Date: Sat, 9 Sep 2017 19:06:06 +0800 Subject: [PATCH 80/81] =?UTF-8?q?=E5=88=A0=E9=99=A4Junit.gliffy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- students/315863321/uml/junit.gliffy | 1 - 1 file changed, 1 deletion(-) delete mode 100644 students/315863321/uml/junit.gliffy diff --git a/students/315863321/uml/junit.gliffy b/students/315863321/uml/junit.gliffy deleted file mode 100644 index 6497806282..0000000000 --- a/students/315863321/uml/junit.gliffy +++ /dev/null @@ -1 +0,0 @@ -{"contentType":"application/gliffy+json","version":"1.1","metadata":{"title":"untitled","revision":0,"exportBorder":false},"embeddedResources":{"index":0,"resources":[]},"stage":{"objects":[{"x":69.64285714285715,"y":79.39285714285714,"rotation":0,"id":175,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":175,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[3.357142857142847,207.60714285714286],[3.357142857142847,92.47362920476345],[70.35714285714288,92.47362920476345]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":168,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":60,"px":1.1102230246251563e-16,"py":0.2928932188134525}}},"linkMap":[]},{"x":1019.6923076923077,"y":745,"rotation":0,"id":165,"uid":"com.gliffy.shape.uml.uml_v1.default.note","width":250.30769230769238,"height":170,"lockAspectRatio":false,"lockShape":false,"order":90,"graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.note.uml_v1","strokeWidth":1,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":false,"state":0,"shadowX":0,"shadowY":0,"opacity":1}},"children":[{"x":5.006153846153847,"y":0,"rotation":0,"id":176,"uid":null,"width":240.29538461538462,"height":98,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"middle","overflow":"none","vposition":"none","hposition":"none","html":"

Command模式:表达一个测试用例\n

模板方法模式:实现数据的准备和清理\n

组合模式:屏蔽一个和多个的差别\n

收集参数模式:隔离测试用例和测试结果\n

观察者模式:隔离测试结果和UI层\n

装饰器模式:装饰测试用例使得它可以重复运行\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"linkMap":[]},{"x":1051.6071428571427,"y":459.64285714285717,"rotation":0,"id":162,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":89,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-96.60714285714266,-1.6428571428571672],[-96.60714285714266,-21.154885329441584],[-96.60714285714266,-40.66691351602594],[-96.60714285714266,-60.17894170261036]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":151,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":144,"px":0.5,"py":1}}},"linkMap":[]},{"x":1107.3214285714287,"y":310.60714285714283,"rotation":0,"id":161,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":88,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-515.3214285714287,-248.6401514461339],[-17.32142857142867,-248.6401514461339],[-17.32142857142867,32.6248148629806],[-57.32142857142867,32.6248148629806]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":36,"px":1,"py":0.29289321881345237}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":144,"px":1,"py":0.5}}},"linkMap":[]},{"x":940.3653846153845,"y":229.75549450549448,"rotation":0,"id":160,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":87,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[14.634615384615472,57.24450549450552],[14.634615384615472,-28.755494505494482],[-418.3653846153845,-28.755494505494482],[-418.3653846153845,-114.75549450549448]],"lockSegments":{"1":true}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":144,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":36,"px":0.5,"py":1}}},"linkMap":[]},{"x":121,"y":794,"rotation":0,"id":136,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":72,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[23,66],[23,52.66666666666663],[23,39.33333333333337],[23,26]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":129,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":113,"px":0.5,"py":1}}},"linkMap":[]},{"x":147,"y":632,"rotation":0,"id":128,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":64,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-3,38],[-3,10.666666666666629],[-3,-16.66666666666663],[-3,-44]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":113,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":94,"px":0.5,"py":1}}},"linkMap":[]},{"x":18,"y":478,"rotation":0,"id":94,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":252,"height":110,"lockAspectRatio":false,"lockShape":false,"order":47,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":95,"uid":null,"width":252,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":96,"uid":null,"width":252,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestListener

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":96,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":97,"uid":null,"width":252,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":98,"uid":null,"width":252,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":95,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":98,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":99,"uid":null,"width":252,"height":88,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":100,"uid":null,"width":252,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void addError(Test, Throwable)\n

+ void addFailure(Test, AssertionFailedError)\n

+ void endTest(Test)\n

+void startTest(Test)\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":94,"magnitude":1},{"id":95,"magnitude":-1},{"id":97,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":97,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":95,"magnitude":1},{"id":97,"magnitude":1},{"id":100,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":265,"y":526,"rotation":0,"id":111,"uid":"com.gliffy.shape.uml.uml_v1.default.association","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":56,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":0,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[4.844931234147168,1],[43.563287489431445,1],[82.28164374471572,1],[121,1]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":94,"px":1,"py":0.5}}},"linkMap":[]},{"x":720,"y":672,"rotation":0,"id":102,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":55,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[3,23],[-29,23],[-29,-85],[-61,-85]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":76,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":69,"px":1,"py":0.5}}},"linkMap":[]},{"x":796,"y":288,"rotation":0,"id":101,"uid":"com.gliffy.shape.uml.uml_v1.default.aggregation","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":54,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":1,"endArrow":5,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-204,-194.96699141100893],[-26,-194.96699141100893],[-26,54],[-66,54]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":36,"px":0.9999999999999998,"py":0.7071067811865475}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":52,"px":1,"py":0.5}}},"linkMap":[]},{"x":194,"y":530,"rotation":0,"id":93,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":46,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[466,-133],[466,-85.5],[328,-85.5],[328,-40]],"lockSegments":{"1":true}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":52,"px":0.5,"py":1}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":69,"px":0.5,"py":0}}},"linkMap":[]},{"x":223,"y":448,"rotation":0,"id":92,"uid":"com.gliffy.shape.uml.uml_v1.default.dependency","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":45,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":6,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[187,-37],[187,-3.5],[299,-3.5],[299,42]],"lockSegments":{"1":true}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":43,"px":0.5,"py":1}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":69,"px":0.5,"py":0}}},"linkMap":[]},{"x":723,"y":645,"rotation":0,"id":76,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":160,"height":100,"lockAspectRatio":false,"lockShape":false,"order":38,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":77,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":78,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestFailure

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":78,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":79,"uid":null,"width":160,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":80,"uid":null,"width":160,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- Test failedTest\n

- Throwable thrownException

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":77,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":80,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":81,"uid":null,"width":160,"height":50,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":82,"uid":null,"width":160,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":76,"magnitude":1},{"id":77,"magnitude":-1},{"id":79,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":79,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":77,"magnitude":1},{"id":79,"magnitude":1},{"id":82,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":385,"y":490,"rotation":0,"id":69,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":274,"height":194,"lockAspectRatio":false,"lockShape":false,"order":31,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":70,"uid":null,"width":274,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":71,"uid":null,"width":274,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestResult

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":71,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":72,"uid":null,"width":274,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":73,"uid":null,"width":274,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- List<TestFailure> failures\n

- List<TestFailure> errors\n

- List<TestListener> listeners

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":70,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":73,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":64,"rotation":0,"id":74,"uid":null,"width":274,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":75,"uid":null,"width":274,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void startTest(Test)\n

+ void endTest(Test)\n

+ void addError(Test, Throwable)\n

+ void addFailure(Test, AssertionFailedError)\n

+ void run(TestCase)\n

+ boolean wasSuccessful()\n

+ int errorCount()\n

+ int failureCount()\n

+ int runCount()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":69,"magnitude":1},{"id":70,"magnitude":-1},{"id":72,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":72,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":70,"magnitude":1},{"id":72,"magnitude":1},{"id":75,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":183,"y":338,"rotation":0,"id":68,"uid":"com.gliffy.shape.uml.uml_v1.default.generalization","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":30,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":null,"startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[157,11],[37,11],[37,-123]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":43,"px":0,"py":0.5}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":60,"px":0.5,"py":1}}},"linkMap":[]},{"x":140,"y":154,"rotation":0,"id":60,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":160,"height":61,"lockAspectRatio":false,"lockShape":false,"order":23,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":61,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":62,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

Assert

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":62,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":63,"uid":null,"width":160,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":64,"uid":null,"width":160,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":61,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":64,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":65,"uid":null,"width":160,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":66,"uid":null,"width":160,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

void assertEquals()\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":60,"magnitude":1},{"id":61,"magnitude":-1},{"id":63,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":63,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":61,"magnitude":1},{"id":63,"magnitude":1},{"id":66,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":649,"y":234,"rotation":0,"id":59,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":22,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[11,53],[11,-33],[-127,-33],[-127,-119]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":52,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":36,"px":0.5,"py":1}}},"linkMap":[]},{"x":590,"y":287,"rotation":0,"id":52,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":110,"lockAspectRatio":false,"lockShape":false,"order":15,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":53,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":54,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestSuite

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":54,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":55,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":56,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- String name\n

- List<Test> tests

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":53,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":56,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":50,"rotation":0,"id":57,"uid":null,"width":140,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":58,"uid":null,"width":140,"height":60,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void run(TestResult)\n

+ void addTest(Test)\n

+ void addTestSuite(Test)\n

+ int countTestCases()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":52,"magnitude":1},{"id":53,"magnitude":-1},{"id":55,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":55,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":53,"magnitude":1},{"id":55,"magnitude":1},{"id":58,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":455,"y":269,"rotation":0,"id":50,"uid":"com.gliffy.shape.uml.uml_v1.default.implements","width":100,"height":100,"lockAspectRatio":false,"lockShape":false,"order":14,"graphic":{"type":"Line","Line":{"strokeWidth":1,"strokeColor":"#000000","fillColor":"none","dashStyle":"8.0,2.0","startArrow":0,"endArrow":4,"startArrowRotation":"auto","endArrowRotation":"auto","ortho":true,"interpolationType":"linear","cornerRadius":null,"controlPath":[[-45,18],[-45,-68],[67,-68],[67,-154]],"lockSegments":{}}},"children":null,"constraints":{"constraints":[],"startConstraint":{"type":"StartPositionConstraint","StartPositionConstraint":{"nodeId":43,"px":0.5,"py":0}},"endConstraint":{"type":"EndPositionConstraint","EndPositionConstraint":{"nodeId":36,"px":0.5,"py":1}}},"linkMap":[]},{"x":340,"y":287,"rotation":0,"id":43,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":124,"lockAspectRatio":false,"lockShape":false,"order":7,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":44,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":45,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestCase

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":45,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":46,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":47,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

- String name

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":44,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":47,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":48,"uid":null,"width":140,"height":88,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":49,"uid":null,"width":140,"height":88,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ int countTestCases()\n

+ void run(TestResult)\n

# void doRun()\n

# void runTest()\n

# void setUp()\n

# void tearDown()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":43,"magnitude":1},{"id":44,"magnitude":-1},{"id":46,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":46,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":44,"magnitude":1},{"id":46,"magnitude":1},{"id":49,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":452,"y":40,"rotation":0,"id":36,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":75,"lockAspectRatio":false,"lockShape":false,"order":0,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":37,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":38,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

<<interface>>\n

Test

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":38,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":32,"rotation":0,"id":39,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":40,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":37,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":40,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":41,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":42,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ int countTestCases()\n

+ void run(TestResult)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":36,"magnitude":1},{"id":37,"magnitude":-1},{"id":39,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":39,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":37,"magnitude":1},{"id":39,"magnitude":1},{"id":42,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":32,"y":670,"rotation":0,"id":113,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":224.00000000000003,"height":150,"lockAspectRatio":false,"lockShape":false,"order":57,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":114,"uid":null,"width":224.00000000000003,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":115,"uid":null,"width":224.00000000000003,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

BaseTestRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":115,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":116,"uid":null,"width":224.00000000000003,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":117,"uid":null,"width":224.00000000000003,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":114,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":117,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":118,"uid":null,"width":224.00000000000003,"height":128,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":119,"uid":null,"width":224.00000000000003,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ Test getTest(String suiteClassName)\n

# Class loadSuiteClass(String suiteClassName)

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":113,"magnitude":1},{"id":114,"magnitude":-1},{"id":116,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":116,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":114,"magnitude":1},{"id":116,"magnitude":1},{"id":119,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":29,"y":860,"rotation":0,"id":129,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":229.99999999999997,"height":152,"lockAspectRatio":false,"lockShape":false,"order":65,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":130,"uid":null,"width":229.99999999999997,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":131,"uid":null,"width":229.99999999999997,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestRunner

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":131,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":132,"uid":null,"width":229.99999999999997,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":133,"uid":null,"width":229.99999999999997,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":130,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":133,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":134,"uid":null,"width":229.99999999999997,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":135,"uid":null,"width":229.99999999999997,"height":130,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void addError(Test, Throwable)\n

+ void addFailure(Test, AssertionFailedError)\n

+ void endTest(Test)\n

+ void startTest(Test)\n

+ void static main(String args[])\n

# TestResult start(String args[])\n

+ TestResult doRun(Test)\n

........

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":129,"magnitude":1},{"id":130,"magnitude":-1},{"id":132,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":132,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":130,"magnitude":1},{"id":132,"magnitude":1},{"id":135,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":860,"y":287,"rotation":0,"id":144,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":190,"height":112.46391544024681,"lockAspectRatio":false,"lockShape":false,"order":73,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":145,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":146,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

TestDecorator

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":146,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":147,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":148,"uid":null,"width":190,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

# Test

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":145,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":148,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":36,"rotation":0,"id":149,"uid":null,"width":190,"height":76.46391544024681,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":150,"uid":null,"width":190,"height":46,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void basicRun(TestResult)\n

+ void run(TestResult)\n

+ int countTestCases()

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":144,"magnitude":1},{"id":145,"magnitude":-1},{"id":147,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":147,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":145,"magnitude":1},{"id":147,"magnitude":1},{"id":150,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":885,"y":458,"rotation":0,"id":151,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":61,"lockAspectRatio":false,"lockShape":false,"order":80,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":152,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":153,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

RepeatedTest

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":153,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":154,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":155,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":152,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":155,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":156,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":157,"uid":null,"width":140,"height":32,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

+ void run(TestResult)\n

+ int countTestCases()\n

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":151,"magnitude":1},{"id":152,"magnitude":-1},{"id":154,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":154,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":152,"magnitude":1},{"id":154,"magnitude":1},{"id":157,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]},{"x":3,"y":287,"rotation":0,"id":168,"uid":"com.gliffy.shape.uml.uml_v1.default.class","width":140,"height":61,"lockAspectRatio":false,"lockShape":false,"order":97,"graphic":null,"children":[{"x":0,"y":0,"rotation":0,"id":169,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":170,"uid":null,"width":140,"height":18,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

AssertionFailedError

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":170,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":18,"rotation":0,"id":171,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":172,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"PositionConstraint","PositionConstraint":{"nodeId":169,"px":0,"py":1}},{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":172,"magnitude":1}],"growParent":true,"padding":0}}]}},{"x":0,"y":22,"rotation":0,"id":173,"uid":null,"width":140,"height":39,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Shape","Shape":{"tid":"com.gliffy.stencil.rectangle.basic_v1","strokeWidth":2,"strokeColor":"#000000","fillColor":"#FFFFFF","gradient":false,"dropShadow":true,"state":0,"shadowX":4,"shadowY":4,"opacity":1}},"children":[{"x":0,"y":0,"rotation":0,"id":174,"uid":null,"width":140,"height":4,"lockAspectRatio":false,"lockShape":false,"order":"auto","graphic":{"type":"Text","Text":{"tid":null,"valign":"top","overflow":"none","vposition":"none","hposition":"none","html":"

","paddingLeft":2,"paddingRight":2,"paddingBottom":2,"paddingTop":2}},"children":null}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":false,"heightInfo":[{"id":168,"magnitude":1},{"id":169,"magnitude":-1},{"id":171,"magnitude":-1}],"growParent":false,"padding":0}},{"type":"PositionConstraint","PositionConstraint":{"nodeId":171,"px":0,"py":1}}]}}],"constraints":{"constraints":[{"type":"HeightConstraint","HeightConstraint":{"isMin":true,"heightInfo":[{"id":169,"magnitude":1},{"id":171,"magnitude":1},{"id":174,"magnitude":1}],"growParent":false,"padding":0}}]},"linkMap":[]}],"background":"#FFFFFF","width":1270,"height":1014,"maxWidth":5000,"maxHeight":5000,"nodeIndex":177,"autoFit":true,"exportBorder":false,"gridOn":true,"snapToGrid":true,"drawingGuidesOn":true,"pageBreaksOn":false,"printGridOn":false,"printPaper":"LETTER","printShrinkToFit":false,"printPortrait":true,"shapeStyles":{},"lineStyles":{},"textStyles":{},"themeData":null}} \ No newline at end of file From eba9a5652cecc83d35410c632b0e0c9d9a91c2b5 Mon Sep 17 00:00:00 2001 From: johnChnia Date: Sat, 9 Sep 2017 19:11:46 +0800 Subject: [PATCH 81/81] =?UTF-8?q?v2=E7=89=88=E6=9C=AC=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8A=9F=E8=83=BDRepeatedTest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/litejunit/extension/RepeatedTest.java | 34 ++++++++++++++++ .../litejunit/extension/TestDecorator.java | 39 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/extension/RepeatedTest.java create mode 100644 students/315863321/ood/ood-assignment/src/main/java/org/litejunit/extension/TestDecorator.java diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/extension/RepeatedTest.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/extension/RepeatedTest.java new file mode 100644 index 0000000000..05cc2f3f61 --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/extension/RepeatedTest.java @@ -0,0 +1,34 @@ +package org.litejunit.extension; + +import org.litejunit.v2.Test; +import org.litejunit.v2.TestResult; + +/** + * Created by john on 2017/9/2. + */ +public class RepeatedTest extends TestDecorator { + private int fTimesRepeat; + + public RepeatedTest(Test test, int repeat) { + super(test); + if (repeat < 0) + throw new IllegalArgumentException("Repetition count must be > 0"); + fTimesRepeat = repeat; + } + + public int countTestCases() { + return super.countTestCases() * fTimesRepeat; + } + + public void run(TestResult result) { + for (int i = 0; i < fTimesRepeat; i++) { + if (result.shouldStop()) + break; + super.run(result); + } + } + + public String toString() { + return super.toString() + "(repeated)"; + } +} diff --git a/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/extension/TestDecorator.java b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/extension/TestDecorator.java new file mode 100644 index 0000000000..8feb61e3ab --- /dev/null +++ b/students/315863321/ood/ood-assignment/src/main/java/org/litejunit/extension/TestDecorator.java @@ -0,0 +1,39 @@ +package org.litejunit.extension; + +import org.litejunit.v2.Assert; +import org.litejunit.v2.Test; +import org.litejunit.v2.TestResult; + +/** + * Created by john on 2017/9/2. + */ +public class TestDecorator extends Assert implements Test { + protected Test test; + + public TestDecorator(Test test) { + this.test = test; + } + + /** + * The basic run behaviour. + */ + public void basicRun(TestResult result) { + test.run(result); + } + + public int countTestCases() { + return test.countTestCases(); + } + + public void run(TestResult result) { + basicRun(result); + } + + public String toString() { + return test.toString(); + } + + public Test getTest() { + return test; + } +} \ No newline at end of file