Skip to content

Commit 37baab2

Browse files
添加测试用例
1 parent 64c348b commit 37baab2

File tree

6 files changed

+380
-0
lines changed

6 files changed

+380
-0
lines changed

src/main/java/com/bean/Person.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public Person(String name, String sex, int age) {
1414
this.age = age;
1515
}
1616

17+
public Person() {
18+
}
19+
1720
public String getName() {
1821
return name;
1922
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package test.com;
2+
3+
import com.FileUtilsDemo;
4+
import org.junit.Test;
5+
import org.junit.Before;
6+
import org.junit.After;
7+
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
11+
/**
12+
* FileUtilsDemo Tester.
13+
*
14+
* @author <Authors name>
15+
* @since <pre>02/06/2018</pre>
16+
* @version 1.0
17+
*/
18+
public class FileUtilsDemoTest {
19+
private String fileName;
20+
private String encoding;
21+
private List<String> lineList;
22+
23+
@Before
24+
public void before() throws Exception {
25+
fileName="E:\\java编程\\IO文件.txt";
26+
encoding="UTF-8";
27+
lineList =new ArrayList<String>();
28+
lineList.add("\n欢迎访问:");
29+
lineList.add("github.com");
30+
}
31+
32+
@After
33+
public void after() throws Exception {
34+
}
35+
36+
/**
37+
*
38+
* Method: readFile(String fileName)
39+
*
40+
*/
41+
@Test
42+
public void testReadFile() throws Exception {
43+
//TODO: Test goes here...
44+
FileUtilsDemo.readFile(fileName,encoding);
45+
46+
}
47+
@Test
48+
public void testReadFileByLine() throws Exception {
49+
//TODO: Test goes here...
50+
FileUtilsDemo.readFileByLine(fileName,encoding);
51+
}
52+
@Test
53+
public void testWriteFile() throws Exception {
54+
//TODO: Test goes here...
55+
FileUtilsDemo.writeFile(fileName,"test3",encoding);
56+
}
57+
@Test
58+
public void testWriteFileByLines() throws Exception {
59+
//TODO: Test goes here...
60+
FileUtilsDemo.writeFileByLines(fileName, lineList);
61+
}
62+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package test.com;
2+
3+
import com.IOUtilsDemo;
4+
import org.junit.Test;
5+
import org.junit.Before;
6+
import org.junit.After;
7+
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
11+
/**
12+
* IOUtilsDemo Tester.
13+
*
14+
* @author <Authors name>
15+
* @since <pre>02/11/2018</pre>
16+
* @version 1.0
17+
*/
18+
public class IOUtilsDemoTest {
19+
private int length;
20+
private String str;
21+
private String fileName;
22+
private String encoding;
23+
private List<String> lineList;
24+
25+
26+
@Before
27+
public void before() throws Exception {
28+
length=8;
29+
str="Hello World!";
30+
fileName="E:\\java编程\\IO文件.txt";
31+
encoding="UTF-8";
32+
lineList =new ArrayList<String>();
33+
lineList.add("\n欢迎访问:");
34+
lineList.add("github.com");
35+
}
36+
37+
@After
38+
public void after() throws Exception {
39+
}
40+
41+
/**
42+
*
43+
* Method: read()
44+
*
45+
*/
46+
@Test
47+
public void testReadTest() throws Exception {
48+
//TODO: Test goes here...
49+
IOUtilsDemo.read(str,length);
50+
51+
}
52+
53+
@Test
54+
public void testReadLines() throws Exception {
55+
//TODO: Test goes here...
56+
IOUtilsDemo.readLines(fileName);
57+
}
58+
59+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package test.com;
2+
3+
import com.JsonUtils;
4+
import com.bean.Person;
5+
import net.sf.json.JSONObject;
6+
import org.junit.Test;
7+
import org.junit.Before;
8+
import org.junit.After;
9+
10+
/**
11+
* JsonUtils Tester.
12+
*
13+
* @author <Authors name>
14+
* @since <pre>03/05/2018</pre>
15+
* @version 1.0
16+
*/
17+
public class JsonUtilsTest {
18+
19+
private Person person1=new Person("feng","male",26);
20+
@Before
21+
public void before() throws Exception {
22+
}
23+
24+
@After
25+
public void after() throws Exception {
26+
}
27+
28+
/**
29+
*
30+
* Method: objectToJson(Object object)
31+
*
32+
*/
33+
@Test
34+
public void testObjectToJson() throws Exception {
35+
//TODO: Test goes here...
36+
37+
System.out.println( JsonUtils.objectToJson(person1) );
38+
}
39+
40+
/**
41+
*
42+
* Method: listToJson(List<T> list)
43+
*
44+
*/
45+
@Test
46+
public void testListToJson() throws Exception {
47+
//TODO: Test goes here...
48+
}
49+
50+
/**
51+
*
52+
* Method: jsonToObject(JSONObject jsonObject, Class beanClass)
53+
*
54+
*/
55+
@Test
56+
public void testJsonToObject() throws Exception {
57+
//TODO: Test goes here...
58+
JSONObject jsonObject=JSONObject.fromObject(person1);
59+
Person person= (Person)JSONObject.toBean(jsonObject,Person.class) ;
60+
System.out.println(person.getAge());
61+
62+
}
63+
64+
65+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package test.com;
2+
3+
import com.StringUtilsDemo;
4+
import org.junit.Test;
5+
import org.junit.Before;
6+
import org.junit.After;
7+
8+
/**
9+
* StringUtilsDemo Tester.
10+
*
11+
* @author <Authors name>
12+
* @since <pre>02/13/2018</pre>
13+
* @version 1.0
14+
*/
15+
public class StringUtilsDemoTest {
16+
17+
@Before
18+
public void before() throws Exception {
19+
}
20+
21+
@After
22+
public void after() throws Exception {
23+
}
24+
25+
/**
26+
*
27+
* Method: remove()
28+
*
29+
*/
30+
@Test
31+
public void testRemove() throws Exception {
32+
//TODO: Test goes here...
33+
}
34+
35+
/**
36+
*
37+
* Method: stringCounts()
38+
*
39+
*/
40+
@Test
41+
public void testStringCounts() throws Exception {
42+
//TODO: Test goes here...
43+
}
44+
45+
/**
46+
*
47+
* Method: empty()
48+
*
49+
*/
50+
@Test
51+
public void testEmpty() throws Exception {
52+
//TODO: Test goes here...
53+
}
54+
55+
/**
56+
*
57+
* Method: equalsIgnoreCase()
58+
*
59+
*/
60+
@Test
61+
public void testEqualsIgnoreCase() throws Exception {
62+
//TODO: Test goes here...
63+
StringUtilsDemo.equalsIgnoreCase();
64+
}
65+
66+
@Test
67+
public void testSubString() throws Exception {
68+
//TODO: Test goes here...
69+
StringUtilsDemo.subString();
70+
}
71+
72+
73+
/**
74+
*
75+
* Method: main(String[] args)
76+
*
77+
*/
78+
@Test
79+
public void testMain() throws Exception {
80+
//TODO: Test goes here...
81+
}
82+
83+
84+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package test.com;
2+
3+
import com.XmlUtils;
4+
import org.junit.Test;
5+
import org.junit.Before;
6+
import org.junit.After;
7+
8+
/**
9+
* XmlUtils Tester.
10+
*
11+
* @author <Authors name>
12+
* @since <pre>02/28/2018</pre>
13+
* @version 1.0
14+
*/
15+
public class XmlUtilsTest {
16+
private XmlUtils xmlUtils=new XmlUtils();
17+
private String text="<csdn><java>Java班</java><net>Net班</net></csdn>";
18+
private String fileName1="E:\\test.xml";
19+
private String fileName2="E:\\test2.xml";
20+
private String[] names=new String[]{"西游记","作者"};
21+
22+
@Before
23+
public void before() throws Exception {
24+
}
25+
26+
@After
27+
public void after() throws Exception {
28+
}
29+
30+
/**
31+
*
32+
* Method: getXmlContent()
33+
*
34+
*/
35+
@Test
36+
public void testGetXmlContent() throws Exception {
37+
//TODO: Test goes here...
38+
xmlUtils.getXmlContent(fileName1,names);
39+
}
40+
41+
42+
/**
43+
*
44+
* Method: stringToDocument()
45+
*
46+
*/
47+
@Test
48+
public void testStringToDocument() throws Exception {
49+
//TODO: Test goes here...
50+
xmlUtils.stringToXml(text,fileName2);
51+
}
52+
/**
53+
*
54+
* Method: createDocumentToXml()
55+
*
56+
*/
57+
@Test
58+
public void testCreateDocumentToXml() throws Exception {
59+
//TODO: Test goes here...
60+
xmlUtils.createDocumentToXml(fileName2);
61+
}
62+
63+
64+
/**
65+
*
66+
* Method: listNodes(Element node)
67+
*
68+
*/
69+
@Test
70+
public void testListNodes() throws Exception {
71+
//TODO: Test goes here...
72+
73+
}
74+
75+
/**
76+
*
77+
* Method: getElementText(String fileName)
78+
*
79+
*/
80+
@Test
81+
public void testGetElementText() throws Exception {
82+
//TODO: Test goes here...
83+
xmlUtils.getElementText(fileName1);
84+
}
85+
86+
/**
87+
*
88+
* Method: writeToXml(Document document, String fileName)
89+
*
90+
*/
91+
@Test
92+
public void testWriteToXml() throws Exception {
93+
//TODO: Test goes here...
94+
95+
}
96+
97+
/**
98+
*
99+
* Method: addAttributeToXml(String fileName)
100+
*
101+
*/
102+
@Test
103+
public void testAddAttributeToXml() throws Exception {
104+
//TODO: Test goes here...
105+
xmlUtils.addAttributeToXml(fileName1);
106+
}
107+
}

0 commit comments

Comments
 (0)