From 4abe432ae7fd0b3943f440775d56c98701e98d34 Mon Sep 17 00:00:00 2001 From: Mars Liu Date: Mon, 29 Nov 2021 20:58:01 +0800 Subject: [PATCH] add junit --- .../ReflectTest.md" | 2 + .../DynamicProxyTest.md" | 9 ++- .../Collection.md" | 2 - .../List.md" | 2 - .../Set.md" | 2 - .../4.\351\230\237\345\210\227/Queue.md" | 1 + .../StaticMethod.md" | 1 - .../Annotation.md" | 1 - .../Apt.md" | 1 - .../junit.json" | 2 +- .../junit.md" | 78 +++++++++++++++++++ 11 files changed, 87 insertions(+), 14 deletions(-) diff --git "a/data/2.Java\344\270\255\351\230\266/5.\347\261\273\345\236\213\344\277\241\346\201\257/4.\345\217\215\345\260\204\357\274\232\350\277\220\350\241\214\346\227\266\347\261\273\344\277\241\346\201\257/ReflectTest.md" "b/data/2.Java\344\270\255\351\230\266/5.\347\261\273\345\236\213\344\277\241\346\201\257/4.\345\217\215\345\260\204\357\274\232\350\277\220\350\241\214\346\227\266\347\261\273\344\277\241\346\201\257/ReflectTest.md" index 74a8775..e731d3e 100644 --- "a/data/2.Java\344\270\255\351\230\266/5.\347\261\273\345\236\213\344\277\241\346\201\257/4.\345\217\215\345\260\204\357\274\232\350\277\220\350\241\214\346\227\266\347\261\273\344\277\241\346\201\257/ReflectTest.md" +++ "b/data/2.Java\344\270\255\351\230\266/5.\347\261\273\345\236\213\344\277\241\346\201\257/4.\345\217\215\345\260\204\357\274\232\350\277\220\350\241\214\346\227\266\347\261\273\344\277\241\346\201\257/ReflectTest.md" @@ -2,6 +2,7 @@ 以下程序是关于反射的一个例子,程序的控制台打印为: + ```java public class Reflect { public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { @@ -20,6 +21,7 @@ public class Reflect { ### before ```java + import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; diff --git "a/data/2.Java\344\270\255\351\230\266/5.\347\261\273\345\236\213\344\277\241\346\201\257/5.\345\212\250\346\200\201\344\273\243\347\220\206/DynamicProxyTest.md" "b/data/2.Java\344\270\255\351\230\266/5.\347\261\273\345\236\213\344\277\241\346\201\257/5.\345\212\250\346\200\201\344\273\243\347\220\206/DynamicProxyTest.md" index f6ff122..1213ab0 100644 --- "a/data/2.Java\344\270\255\351\230\266/5.\347\261\273\345\236\213\344\277\241\346\201\257/5.\345\212\250\346\200\201\344\273\243\347\220\206/DynamicProxyTest.md" +++ "b/data/2.Java\344\270\255\351\230\266/5.\347\261\273\345\236\213\344\277\241\346\201\257/5.\345\212\250\346\200\201\344\273\243\347\220\206/DynamicProxyTest.md" @@ -2,6 +2,7 @@ 以下程序是关于动态代理的一个例子,1和2处填入正确的是: + ```java interface Person { @@ -33,7 +34,7 @@ public class DynamicProxyTest { ## 答案 -``` +```java Person.class.getClassLoader() new Class[] { Person.class } ``` @@ -42,21 +43,21 @@ new Class[] { Person.class } ### A -``` +```java Person.getClassLoader() Person.class ``` ### B -``` +```java Person.class.getClassLoader() Person.getClass() ``` ### C -``` +```java Person.getClassLoader() new Class[] { Person.class } ``` diff --git "a/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/1.Collection\347\232\204\345\212\237\350\203\275\346\226\271\346\263\225/Collection.md" "b/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/1.Collection\347\232\204\345\212\237\350\203\275\346\226\271\346\263\225/Collection.md" index ed03141..9fa042a 100644 --- "a/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/1.Collection\347\232\204\345\212\237\350\203\275\346\226\271\346\263\225/Collection.md" +++ "b/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/1.Collection\347\232\204\345\212\237\350\203\275\346\226\271\346\263\225/Collection.md" @@ -3,8 +3,6 @@ 下列关于Collection功能方法的说法错误的是: - - ## 答案 ``` diff --git "a/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/2.List\347\232\204\345\212\237\350\203\275\346\226\271\346\263\225/List.md" "b/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/2.List\347\232\204\345\212\237\350\203\275\346\226\271\346\263\225/List.md" index d67a208..8c658f1 100644 --- "a/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/2.List\347\232\204\345\212\237\350\203\275\346\226\271\346\263\225/List.md" +++ "b/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/2.List\347\232\204\345\212\237\350\203\275\346\226\271\346\263\225/List.md" @@ -3,8 +3,6 @@ 下列关于 `List` 功能方法的说法正确的是: - - ## 答案 ``` diff --git "a/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/3.Set\345\222\214\345\255\230\345\202\250\351\241\272\345\272\217/Set.md" "b/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/3.Set\345\222\214\345\255\230\345\202\250\351\241\272\345\272\217/Set.md" index c4c1699..ceb199d 100644 --- "a/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/3.Set\345\222\214\345\255\230\345\202\250\351\241\272\345\272\217/Set.md" +++ "b/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/3.Set\345\222\214\345\255\230\345\202\250\351\241\272\345\272\217/Set.md" @@ -3,8 +3,6 @@ 下列关于 `Set` 说法正确的是: - - ## 答案 ``` diff --git "a/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/4.\351\230\237\345\210\227/Queue.md" "b/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/4.\351\230\237\345\210\227/Queue.md" index aa94f8e..31b853c 100644 --- "a/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/4.\351\230\237\345\210\227/Queue.md" +++ "b/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/4.\351\230\237\345\210\227/Queue.md" @@ -2,6 +2,7 @@ 下列代码用优先级队列实现了任务队列,运行程序控制台输出正确的是: + ```java class Task { private String name; diff --git "a/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/7.Collections\345\256\236\347\224\250\346\226\271\346\263\225/StaticMethod.md" "b/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/7.Collections\345\256\236\347\224\250\346\226\271\346\263\225/StaticMethod.md" index d7a50aa..78ad1ec 100644 --- "a/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/7.Collections\345\256\236\347\224\250\346\226\271\346\263\225/StaticMethod.md" +++ "b/data/2.Java\344\270\255\351\230\266/6.\346\267\261\345\205\245\347\240\224\347\251\266\345\256\271\345\231\250/7.Collections\345\256\236\347\224\250\346\226\271\346\263\225/StaticMethod.md" @@ -4,7 +4,6 @@ 下列关于Collections的实用方法,说法正确的是: - ## 答案 ``` diff --git "a/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/1.\345\237\272\346\234\254\350\257\255\346\263\225/Annotation.md" "b/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/1.\345\237\272\346\234\254\350\257\255\346\263\225/Annotation.md" index 43da993..6bc1e3c 100644 --- "a/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/1.\345\237\272\346\234\254\350\257\255\346\263\225/Annotation.md" +++ "b/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/1.\345\237\272\346\234\254\350\257\255\346\263\225/Annotation.md" @@ -4,7 +4,6 @@ 下列关于 `Annotation` 的说法错误的是: - ## 答案 ``` diff --git "a/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/2.\344\275\277\347\224\250apt\345\244\204\347\220\206\346\263\250\350\247\243/Apt.md" "b/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/2.\344\275\277\347\224\250apt\345\244\204\347\220\206\346\263\250\350\247\243/Apt.md" index f7deac9..91b30ee 100644 --- "a/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/2.\344\275\277\347\224\250apt\345\244\204\347\220\206\346\263\250\350\247\243/Apt.md" +++ "b/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/2.\344\275\277\347\224\250apt\345\244\204\347\220\206\346\263\250\350\247\243/Apt.md" @@ -3,7 +3,6 @@ 下列关于 `APT(Annotation Processing Tool)` 的说法正确的是: - ## 答案 ``` diff --git "a/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/3.\345\237\272\344\272\216\346\263\250\350\247\243\347\232\204\345\215\225\345\205\203\346\265\213\350\257\225/junit.json" "b/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/3.\345\237\272\344\272\216\346\263\250\350\247\243\347\232\204\345\215\225\345\205\203\346\265\213\350\257\225/junit.json" index 209105b..1cdeb54 100644 --- "a/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/3.\345\237\272\344\272\216\346\263\250\350\247\243\347\232\204\345\215\225\345\205\203\346\265\213\350\257\225/junit.json" +++ "b/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/3.\345\237\272\344\272\216\346\263\250\350\247\243\347\232\204\345\215\225\345\205\203\346\265\213\350\257\225/junit.json" @@ -2,5 +2,5 @@ "type": "code_options", "author": "ccat", "source": "junit.md", - "notebook_enable": true + "notebook_enable": false } \ No newline at end of file diff --git "a/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/3.\345\237\272\344\272\216\346\263\250\350\247\243\347\232\204\345\215\225\345\205\203\346\265\213\350\257\225/junit.md" "b/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/3.\345\237\272\344\272\216\346\263\250\350\247\243\347\232\204\345\215\225\345\205\203\346\265\213\350\257\225/junit.md" index e69de29..4858ac6 100644 --- "a/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/3.\345\237\272\344\272\216\346\263\250\350\247\243\347\232\204\345\215\225\345\205\203\346\265\213\350\257\225/junit.md" +++ "b/data/2.Java\344\270\255\351\230\266/7.\346\263\250\350\247\243/3.\345\237\272\344\272\216\346\263\250\350\247\243\347\232\204\345\215\225\345\205\203\346\265\213\350\257\225/junit.md" @@ -0,0 +1,78 @@ +# junit + +下列单元测试代码,会被忽略的是: + +## 答案 + +```java + +@Ignore +@Test +public void simpleCrlf() throws Throwable { + State state = newState("\r\n"); + Parsec crlf = new Crlf(); + + String re = crlf.parse(state); + Assert.assertEquals(re, "\r\n"); +} +``` + +## 选项 + +### A + +```java +@Test +public void simpleCrlf() throws Throwable { + State state = newState("\r\n"); + Parsec crlf = new Crlf(); + + String re = crlf.parse(state); + Assert.assertEquals(re, "\r\n"); +} +``` + +### B + +```java +@AfterClass +static public void close(){ + try { + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } +} +``` + +### C + +```java +@BeforeClass +static public void connect() { + try { + // create a connection to the database + conn = DriverManager.getConnection(url); + System.out.println("Connection to SQLite has been established."); + conn.prepareStatement("create table test(id integer primary key autoincrement, content text)") + .execute(); + } catch (SQLException e) { + System.out.println(e.getMessage()); + } +} +``` + +### D + +```java + @Test +public void zooCleanTest(){ + Statement statement = delete().from(table); + try{ + statement.execute(conn); + Assert.assertTrue(true); + } catch (SQLException|IllegalStateException e) { + Assert.fail(e.getMessage()); + } +} +``` \ No newline at end of file -- GitLab