Statistics
| Revision:

gvsig-projects-pool / org.gvsig.vcsgis / trunk / org.gvsig.vcsgis / org.gvsig.vcsgis.lib / org.gvsig.vcsgis.lib.impl / src / test / java / org / gvsig / vcsgis / lib / impl / Test04AddEntity.java @ 2697

History | View | Annotate | Download (2.17 KB)

1
package org.gvsig.vcsgis.lib.impl;
2

    
3
import java.io.File;
4
import junit.framework.TestCase;
5
import static junit.framework.TestCase.assertEquals;
6
import org.apache.commons.io.FileUtils;
7
import org.gvsig.vcsgis.lib.vcsgis;
8
import org.gvsig.vcsgis.lib.vcsgisadmin;
9
import org.gvsig.fmap.dal.feature.FeatureStore;
10
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer;
11
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
12
import org.slf4j.Logger;
13
import org.slf4j.LoggerFactory;
14
import org.gvsig.vcsgis.lib.repository.VCSGisRepository;
15
import org.gvsig.vcsgis.lib.client.VCSGisWorkspace;
16

    
17
public class Test04AddEntity extends TestCase {
18

    
19
    private static final Logger LOGGER = LoggerFactory.getLogger(Test04AddEntity.class);
20

    
21
    public Test04AddEntity(String testName) {
22
        super(testName);
23
    }
24

    
25
    @Override
26
    protected void setUp() throws Exception {
27
        super.setUp();
28
        new DefaultLibrariesInitializer().fullInitialize();
29
    }
30

    
31
    @Override
32
    protected void tearDown() throws Exception {
33
        super.tearDown();
34
    }
35

    
36
    // TODO add test methods here. The name must begin with 'test'. For example:
37
    // public void testHello() {}
38
    
39
    public void testAdd_entity1() throws Exception {
40
        JDBCServerExplorer server = TestUtils.openServerExplorer("srv-adde");
41
        File wsfile = TestUtils.getFile(FileUtils.getFile("test-dbs","ws-adde")); 
42

    
43
        int r = vcsgisadmin.init_repository(server);
44
        assertEquals("srv-init status", 0, r);
45

    
46
        VCSGisRepository repo = vcsgisadmin.open_repository(server);
47
        TestUtils.h2sql_repository(repo);
48
        
49
        r = vcsgis.init_workspace(wsfile, repo, "Test add entity");
50
        assertEquals("ws-init status", 0, r);
51
        
52
        VCSGisWorkspace ws = vcsgis.open_workspace(wsfile);
53
        TestUtils.h2sql_workspace(ws);
54
        
55
        FeatureStore sourceStore = TestUtils.openSourceStore1();
56
        r = ws.addEntity(sourceStore.getDefaultFeatureType(), "sourceStore1", null, "ID");
57
        assertEquals("ws-add-entity status", 0, r);
58
        
59
        FeatureStore store = ws.getFeatureStore("sourceStore1");
60
        assertNotNull("added store is null",store);
61

    
62
        store.dispose();
63
        
64
    }
65
}