svn-gvsig-desktop / tags / PilotoRedes_Build_4 / extensions / extGraph_predes / src-test / com / iver / cit / gvsig / graphtests / TestNetworJdbcWriter.java @ 12191
History | View | Annotate | Download (2.05 KB)
1 | 8497 | fjp | package com.iver.cit.gvsig.graphtests; |
---|---|---|---|
2 | |||
3 | |||
4 | import java.io.File; |
||
5 | import java.sql.Connection; |
||
6 | import java.sql.DriverManager; |
||
7 | |||
8 | import junit.framework.TestCase; |
||
9 | |||
10 | import org.cresques.cts.IProjection; |
||
11 | |||
12 | import com.iver.cit.gvsig.fmap.DriverException; |
||
13 | import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
||
14 | import com.iver.cit.gvsig.fmap.edition.EditionException; |
||
15 | import com.iver.cit.gvsig.fmap.edition.writers.dbf.DbfWriter; |
||
16 | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
||
17 | import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
||
18 | import com.iver.cit.gvsig.graph.core.writers.NetworkJdbcWriter; |
||
19 | |||
20 | public class TestNetworJdbcWriter extends TestCase { |
||
21 | NetworkJdbcWriter netBuilder = new NetworkJdbcWriter();
|
||
22 | FLyrVect lyr; |
||
23 | /*
|
||
24 | * Test method for
|
||
25 | * 'com.iver.cit.gvsig.graph.core.NetworkWriter.writeNetwork()'
|
||
26 | */
|
||
27 | public void testWriteNetwork() { |
||
28 | try {
|
||
29 | long t1 = System.currentTimeMillis(); |
||
30 | netBuilder.writeNetwork(); |
||
31 | long t2 = System.currentTimeMillis(); |
||
32 | System.out.println("Building MYSQL time:" + (t2-t1) + " msecs."); |
||
33 | } catch (EditionException e) {
|
||
34 | // TODO Auto-generated catch block
|
||
35 | e.printStackTrace(); |
||
36 | } catch (DriverException e) {
|
||
37 | // TODO Auto-generated catch block
|
||
38 | e.printStackTrace(); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | |||
43 | protected void setUp() throws Exception { |
||
44 | LayerFactory |
||
45 | .setDriversPath("../_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
|
||
46 | IProjection prj = CRSFactory.getCRS("EPSG:23030");
|
||
47 | File shpFile = new File("c:/ejes.shp"); |
||
48 | lyr = (FLyrVect) LayerFactory.createLayer("Ejes",
|
||
49 | "gvSIG shp driver", shpFile, prj);
|
||
50 | |||
51 | String fieldType = "tipored"; |
||
52 | String fieldDist = "length"; |
||
53 | String fieldCost = "cost"; |
||
54 | String fieldSense = ""; |
||
55 | |||
56 | netBuilder.setLayer(lyr); |
||
57 | netBuilder.setFieldCost(fieldCost); |
||
58 | netBuilder.setFieldType(fieldType); |
||
59 | netBuilder.setFieldDist(fieldDist); |
||
60 | netBuilder.setFieldSense(fieldSense); |
||
61 | |||
62 | String dbURL = "jdbc:mysql://localhost:3306/test"; |
||
63 | String user = "root"; |
||
64 | String pwd = "aquilina"; |
||
65 | Connection conn;
|
||
66 | conn = DriverManager.getConnection(dbURL, user, pwd);
|
||
67 | |||
68 | netBuilder.setConnection(conn); |
||
69 | |||
70 | |||
71 | |||
72 | } |
||
73 | |||
74 | } |