/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/db/TestServlet.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/db/TestServlet.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

android/TrainInfoService/src/dk/thoerup/traininfoservice/TestServlet.java revision 851 by torben, Tue Jun 15 12:54:25 2010 UTC android/TrainInfoService/src/dk/thoerup/traininfoservice/db/TestServlet.java revision 1256 by torben, Mon Apr 4 11:58:30 2011 UTC
# Line 1  Line 1 
1  package dk.thoerup.traininfoservice;  package dk.thoerup.traininfoservice.db;
2    
3  import java.io.IOException;  import java.io.IOException;
4  import java.sql.SQLException;  import java.sql.SQLException;
5  import java.util.Random;  import java.util.Random;
6    
7  import javax.servlet.ServletException;  import javax.servlet.ServletException;
8    import javax.servlet.annotation.WebServlet;
9  import javax.servlet.http.HttpServlet;  import javax.servlet.http.HttpServlet;
10  import javax.servlet.http.HttpServletRequest;  import javax.servlet.http.HttpServletRequest;
11  import javax.servlet.http.HttpServletResponse;  import javax.servlet.http.HttpServletResponse;
12    
13    
14    @WebServlet(urlPatterns={"/TestServlet"})
15  public class TestServlet extends HttpServlet {  public class TestServlet extends HttpServlet {
16          private static final long serialVersionUID = 1L;          private static final long serialVersionUID = 1L;
17                    
18          Random r = new Random();          Random r = new Random();
19    
20          //South-West corner= 54.0, 7.0          //South-West corner= 54.5, 8.0
21          //North-East corner= 58.0, 13.0          //North-East corner= 57.8, 12.7
22          //Latitude span=4.0          //Latitude span=3.3
23          //Longitude span=6.0          //Longitude span=4.7
24          void testFindNearest(int count) throws SQLException {                    void testFindNearest(int count) throws SQLException {          
25    
26                  StationDAO db = new StationDAO();                  StationDAO db = new StationDAO();
27    
28    
29                  for (int i=0; i<count; i++) {                  for (int i=0; i<count; i++) {
30                          float lat = (r.nextFloat()*4.0F) + 54.0F;                          float lat = (r.nextFloat()*3.3F) + 54.5F;
31                          float lng = (r.nextFloat()*6.0F) + 7.0F;                          float lng = (r.nextFloat()*4.7F) + 8.0F;
32                          db.getByLocation(lat, lng);                          db.getByLocation(lat, lng);
33                  }                  }
   
   
   
34          }          }
35    
36          void testFindName(int count)  throws SQLException {          void testFindName(int count)  throws SQLException {
# Line 39  public class TestServlet extends HttpSer Line 38  public class TestServlet extends HttpSer
38                  StationDAO db = new StationDAO();                  StationDAO db = new StationDAO();
39                                    
40                  for (int i=0; i<count; i++) {                  for (int i=0; i<count; i++) {
41                          char c1 = ((char)r.nextInt(26));                          char c1 = getRandomCharacter();
42                          c1 += 'a';                          char c2 = getRandomCharacter();
                         char c2 = ((char)r.nextInt(26)) ;  
                         c2 += 'a';  
43    
44                          String search = "" + c1 + c2;                          String search = "" + c1 + c2;
45                          System.out.println(search);                          System.out.println(search);
# Line 50  public class TestServlet extends HttpSer Line 47  public class TestServlet extends HttpSer
47                          db.getByName(search);                          db.getByName(search);
48                  }                  }
49          }          }
50    
51            private char getRandomCharacter() {
52                    char c1 = ((char)r.nextInt(26));
53                    c1 += 'a';
54                    return c1;
55            }
56                    
57          void testFindFavorites(int count)  throws SQLException {          void testFindFavorites(int count)  throws SQLException {
58                                    

Legend:
Removed from v.851  
changed lines
  Added in v.1256

  ViewVC Help
Powered by ViewVC 1.1.20