Revision 932

View differences:

trunk/org.gvsig.postgresql/pom.xml
11 11
  <parent>
12 12
      <groupId>org.gvsig</groupId>
13 13
      <artifactId>org.gvsig.desktop</artifactId>
14
      <version>2.0.343</version>
14
      <version>2.0.344-SNAPSHOT</version>
15 15
  </parent>
16 16

  
17 17
  <url>https://devel.gvsig.org/redmine/projects/gvsig-postgresql</url>
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/pom.xml
42 42

  
43 43
    <dependency>
44 44
      <groupId>org.gvsig</groupId>
45
      <artifactId>org.gvsig.fmap.dal.db.jdbc</artifactId>
46
      <scope>test</scope>
47
      <type>test-jar</type>
48
    </dependency>
49

  
50
    <dependency>
51
      <groupId>org.gvsig</groupId>
45 52
      <artifactId>org.gvsig.fmap.dal.db.lib</artifactId>
46 53
      <scope>compile</scope>
47 54
    </dependency>
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/TestUtilsPostgreSQL.java
1
package org.gvsig.postgresql.dal;
2

  
3
import java.net.URL;
4
import java.util.Properties;
5
import org.gvsig.fmap.dal.DALLocator;
6
import org.gvsig.fmap.dal.DataManager;
7
import org.gvsig.fmap.dal.store.jdbc2.AbstractTestUtils;
8
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
9
import org.gvsig.fmap.dal.store.jdbc2.spi.FakeConnectionProvider;
10

  
11
/**
12
 *
13
 * @author jjdelcerro
14
 */
15
@SuppressWarnings("UseSpecificCatch")
16
public class TestUtilsPostgreSQL extends AbstractTestUtils {
17

  
18
    @Override
19
    public String getProviderName() {
20
        return PostgreSQLLibrary.NAME;
21
    }
22

  
23
    @Override
24
    public String getExpectedsPath() {
25
        return "/org/gvsig/postgresql/dal";
26
    }
27
    
28
    @Override
29
    protected Properties getProperties() {
30
        if (this.properties == null) {
31
            try {
32
                URL url = this.getClass().getResource("postgresql.properties");
33
                Properties props = new Properties();
34
                props.load(url.openStream());
35
                String[] keys = new String[]{
36
                    "PostgreSQLEnabled",
37
                    "PostgreSQLHost",
38
                    "PostgreSQLPort",
39
                    "PostgreSQLDbname",
40
                    "PostgreSQLSchema",
41
                    "PostgreSQLUser",
42
                    "PostgreSQLPassword"
43
                };
44
                for (String key : keys) {
45
                    if (System.getenv().containsKey(key)) {
46
                        props.setProperty(key, System.getenv(key));
47
                    }
48
                }
49
                this.properties = props;
50
            } catch (Exception ex) {
51
                throw new RuntimeException(ex);
52
            } 
53
        }
54
        return this.properties;
55
    }
56

  
57
    @Override
58
    public boolean isTheDatabaseAvailable() {
59
        return this.getPropertyBoolean("PostgreSQLEnabled");
60
    }
61

  
62
    @Override
63
    public JDBCHelper createJDBCHelper() throws Exception {
64
        PostgreSQLServerExplorerParameters params = this.getServerExplorerParameters("fake");
65
        PostgreSQLHelper helper = new PostgreSQLHelper(params, new FakeConnectionProvider());
66
      return helper;
67
    }
68

  
69
    @Override
70
    public PostgreSQLServerExplorerParameters getServerExplorerParameters(String dbname) throws Exception {
71
        DataManager dataManager = DALLocator.getDataManager();
72
        PostgreSQLServerExplorerParameters conn = (PostgreSQLServerExplorerParameters) dataManager.createServerExplorerParameters(this.getProviderName());
73
        conn.setHost(getProperty("PostgreSQLHost"));
74
        conn.setPort(getPropertyInt("PostgreSQLPort", 5432));
75
        conn.setDBName(getProperty("PostgreSQLDbname"));
76
        conn.setSchema(getProperty("PostgreSQLSchema"));
77
        conn.setUser(getProperty("PostgreSQLUser"));
78
        conn.setPassword(getProperty("PostgreSQLPassword"));
79
        conn.setShowInformationDBTables(false);
80
        return conn;
81
    }
82
    
83
}
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/test/java/org/gvsig/postgresql/dal/TestComputedAttributes.java
1
package org.gvsig.postgresql.dal;
2

  
3
import org.gvsig.fmap.dal.store.jdbc2.AbstractTestComputedAttributes;
4
import org.gvsig.fmap.dal.store.jdbc2.AbstractTestUtils;
5

  
6
public class TestComputedAttributes extends AbstractTestComputedAttributes {
7
    
8
    public TestComputedAttributes(String testName) {
9
        super(testName);
10
    }
11

  
12
    @Override
13
    protected AbstractTestUtils createUtils() {
14
        return new TestUtilsPostgreSQL();
15
    }
16

  
17
    @Override
18
    public void testComputed1() throws Exception {
19
        super.testComputed1(); 
20
    }
21

  
22
    @Override
23
    public void testComputed2() throws Exception {
24
        super.testComputed2(); 
25
    }
26
    
27
}
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/test/resources/org/gvsig/postgresql/dal/postgresql.properties
1
PostgreSQLEnabled=false
2
PostgreSQLHost=127.0.0.1
3
PostgreSQLPort=5532
4
PostgreSQLDbname=gvsigdb
5
PostgreSQLSchema=public
6
PostgreSQLUser=gvsig
7
PostgreSQLPassword=gvsig

Also available in: Unified diff