Ailton Mizuki Sato 9 years ago
parent
commit
c970ea70ad

+ 7 - 4
config.properties

@@ -1,6 +1,9 @@
1
-jdbc= jdbc:mysql://localhost:3306/snail
2 1
 
3 2
 
4
-username= root
5
-		
6
-password= 99719797
3
+#domain = http://50.30.37.180:38080/snail/
4
+
5
+#domain= http://localhost:8080/snail/
6
+
7
+domain= http://localhost:7000/Servlet/
8
+
9
+

+ 7 - 3
src/test/Start.java

@@ -23,6 +23,7 @@ import test.servlet.user.post.TestUpdateUser;
23 23
 
24 24
 /**This is the started from tests*/
25 25
 public class Start {
26
+	
26 27
 	private static List<ServletTest> generateList()
27 28
 	{
28 29
 		List<ServletTest> tests = new ArrayList<ServletTest>();
@@ -41,10 +42,7 @@ public class Start {
41 42
 		tests.add(new TestUpdateCategory());
42 43
 		tests.add(new TestUpdateItem());
43 44
 
44
-
45 45
 		tests.add(new TestExistsUser());
46
-
47
-
48 46
 		tests.add(new TestCreateUser());
49 47
 		tests.add(new TestLogin());
50 48
 		tests.add(new TestUpdateUser());
@@ -70,6 +68,12 @@ public class Start {
70 68
 		{
71 69
 			System.out.println(test);
72 70
 		}
71
+		
72
+		
73
+		for(ServletTest test:tests)
74
+		{
75
+			System.out.println(test.getUrl());
76
+		}
73 77
 
74 78
 
75 79
 

+ 1 - 0
src/test/resource/ExecuteGet.java

@@ -11,6 +11,7 @@ public class ExecuteGet {
11 11
 	public String get(String urlToRead) throws IOException{
12 12
 		
13 13
 		URL url;
14
+		
14 15
 		HttpURLConnection conn;
15 16
 		BufferedReader rd;
16 17
 		String line;

+ 23 - 1
src/test/resource/ServletTest.java

@@ -1,5 +1,8 @@
1 1
 package test.resource;
2 2
 
3
+import java.io.FileReader;
4
+import java.util.Properties;
5
+
3 6
 import org.json.JSONArray;
4 7
 
5 8
 import javafx.util.Pair;
@@ -9,8 +12,22 @@ import javafx.util.Pair;
9 12
 
10 13
 public abstract class ServletTest {
11 14
 	
12
-	public String domain = "http://localhost:8080/SnailServlet/";
15
+	public ServletTest()
16
+	{
17
+		Properties props = new Properties();
18
+		try{
19
+			props.load(new FileReader("config.properties"));
20
+			domain = props.getProperty("domain");	
21
+		}catch(Exception e)
22
+		{
23
+			
24
+		}
25
+		
26
+	}
27
+	
28
+	public String domain ;
13 29
 	public String result="";
30
+	protected String url;
14 31
 	
15 32
 	
16 33
 	public void runTest()
@@ -69,5 +86,10 @@ public abstract class ServletTest {
69 86
 		return sb.toString();
70 87
 		
71 88
 	}
89
+
90
+	public String getUrl() {
91
+		// TODO Auto-generated method stub
92
+		return url;
93
+	}
72 94
 	
73 95
 }

+ 1 - 0
src/test/resource/ServletTestGet.java

@@ -11,6 +11,7 @@ public abstract class ServletTestGet extends ServletTest{
11 11
 	public boolean test() throws Exception {
12 12
 		
13 13
 		String url = domain +this.buildUrl();
14
+		this.url = url;
14 15
 		ExecuteGet executor = new ExecuteGet();
15 16
 		String result = executor.get(url);
16 17
 		boolean firstResult =  this.analyse(result);

+ 22 - 2
src/test/resource/ServletTestPost.java

@@ -10,15 +10,18 @@ import javafx.util.Pair;
10 10
 /**responsable to test the post methods*/
11 11
 public abstract class ServletTestPost extends ServletTest {
12 12
 
13
+	public String output;
14
+	
13 15
 	@Override
14 16
 	public boolean test() throws Exception {
15 17
 		ExecutePost post = new ExecutePost();
16 18
 
17 19
 
18 20
 		String url = domain +this.buildUrl();
21
+		this.url = url;
19 22
 		Map<String , String > parameters = this.buildParameters();
20
-		String result = post.execute(url, parameters);
21
-		return this.analyse(result);
23
+		output = post.execute(url, parameters);
24
+		return this.analyse(output);
22 25
 	}
23 26
 
24 27
 	public abstract Map<String , String> buildParameters();
@@ -43,4 +46,21 @@ public abstract class ServletTestPost extends ServletTest {
43 46
 
44 47
 	}
45 48
 
49
+	public Integer getId() {
50
+		
51
+		try{
52
+			JSONArray json = new JSONArray(output);
53
+			String value = json.getJSONObject(0).getString("id");
54
+			return new Integer(value);
55
+			
56
+		}catch(Exception e)
57
+		{
58
+			return 0;
59
+		}
60
+		
61
+		
62
+		
63
+	}
64
+	
65
+	
46 66
 }

+ 1 - 1
src/test/servlet/event/get/TestImportDataFacebook.java

@@ -11,7 +11,7 @@ public class TestImportDataFacebook extends ServletTestGet{
11 11
 	
12 12
 		
13 13
 		return "data?method=import_data&"
14
-				+ "token=CAACEdEose0cBADZBVpOMdjrAoMWYdXlgvVlBgYe33vJPZAAmnmwBB4IIIiszqSbbbY0tCGy0pp50nstfLMsyoZCxyG53yN3ZBpe0k4kuPsLNZBZB5IfKwD2wSW1d8OfmX2LTZCTsOaLufFRYJLaAfPvjxTS7OERdsfpPNAnrGDoPTwoaWpSip10aZB8cuuSTs5RZA3xZAimYcLUQdHvjYMlWkK"
14
+				+ "token=CAACEdEose0cBAIaFqPHYmsZAQHJnWwCZBJtXAODpUlRKJhvfM5nnRHnZCpdeYvKz2UIvGldXOZAXP3a70mImv69TmlGPOLuxQrUKNNUaf0G8pb2wiNfR6kYCh0SIPZBDV1UJFMIuejoZCvmNbB1LkmviEIArFALrDE9nER1MZAazKYSAgT2ExYmEZAesuTG2lZAagss1HmJiLht8U2Khnzg70"
15 15
 				+ "&type=Facebook&quantity=14&user_id=1";
16 16
 	}
17 17
 	

+ 4 - 0
src/test/servlet/event/post/TestCreateCategory.java

@@ -8,6 +8,8 @@ import test.resource.ServletTestPost;
8 8
 
9 9
 public class TestCreateCategory extends ServletTestPost {
10 10
 
11
+	
12
+	
11 13
 	@Override
12 14
 	public Map<String, String> buildParameters() {
13 15
 		// TODO Auto-generated method stub
@@ -32,5 +34,7 @@ public class TestCreateCategory extends ServletTestPost {
32 34
 		return new Pair<String, String>("name", "Radialize");
33 35
 	}
34 36
 
37
+
38
+
35 39
 	
36 40
 }

+ 3 - 2
src/test/servlet/event/post/TestCreateItem.java

@@ -11,12 +11,13 @@ public class TestCreateItem  extends ServletTestPost{
11 11
 	@Override
12 12
 	public Map<String, String> buildParameters() {
13 13
 		Map <String, String> map = new HashMap<String, String>();
14
-		map.put("user_id", "16");
14
+		map.put("user_id", "3");
15 15
 		map.put("category_id", "20");
16 16
 		map.put("content", "Zueira");
17 17
 		map.put("title", "Doido");
18 18
 		map.put("start_date", "2011-04-15");
19 19
 		map.put("end_date", "2014-12-10");
20
+		map.put("photo", "foto.jpg");
20 21
 		
21 22
 		
22 23
 		
@@ -26,7 +27,7 @@ public class TestCreateItem  extends ServletTestPost{
26 27
 	@Override
27 28
 	public Pair<String, String> buildCheckSum() {
28 29
 		// TODO Auto-generated method stub
29
-		return new Pair<String, String>("categoryId", "9");
30
+		return new Pair<String, String>("categoryId", "20");
30 31
 	}
31 32
 
32 33
 	@Override

+ 5 - 1
src/test/servlet/event/post/TestDeleteCategory.java

@@ -11,8 +11,12 @@ public class TestDeleteCategory extends ServletTestPost{
11 11
 	@Override
12 12
 	public Map<String, String> buildParameters() {
13 13
 		
14
+		TestCreateCategory createCategory = new  TestCreateCategory();
15
+		createCategory.runTest();
16
+		String id = new Integer(createCategory.getId()).toString();
17
+		
14 18
 		Map<String, String> map = new HashMap<String, String>();
15
-		map.put("category_id", "21");
19
+		map.put("category_id", id);
16 20
 		
17 21
 		return map;
18 22
 	}

+ 33 - 0
src/test/servlet/user/post/TestRecoverPassword.java

@@ -0,0 +1,33 @@
1
+package test.servlet.user.post;
2
+
3
+import java.util.Map;
4
+
5
+
6
+import javafx.util.Pair;
7
+import test.resource.ServletTestPost;
8
+
9
+public class TestRecoverPassword extends ServletTestPost{
10
+
11
+	@Override
12
+	public Map<String, String> buildParameters() {
13
+		// TODO Auto-generated method stub
14
+		
15
+		
16
+		return null;
17
+	}
18
+
19
+	@Override
20
+	public Pair<String, String> buildCheckSum() {
21
+		// TODO Auto-generated method stub
22
+		return null;
23
+	}
24
+
25
+	@Override
26
+	public String buildUrl() {
27
+		// TODO Auto-generated method stub
28
+		return null;
29
+	}
30
+
31
+	
32
+	
33
+}