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 / Test03GetWorkspaces.java @ 2823
History | View | Annotate | Download (3.89 KB)
1 |
package org.gvsig.vcsgis.lib.impl; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.util.Map; |
5 |
import junit.framework.TestCase; |
6 |
import static junit.framework.TestCase.assertEquals; |
7 |
import org.apache.commons.io.FileUtils; |
8 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
9 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
10 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
11 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
12 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository; |
13 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
14 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceDescriptor; |
15 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceDescriptorImpl; |
16 |
import org.slf4j.Logger; |
17 |
import org.slf4j.LoggerFactory; |
18 |
|
19 |
public class Test03GetWorkspaces extends TestCase { |
20 |
|
21 |
private static final Logger LOGGER = LoggerFactory.getLogger(Test07Checkout.class); |
22 |
|
23 |
public Test03GetWorkspaces(String testName) { |
24 |
super(testName);
|
25 |
} |
26 |
|
27 |
@Override
|
28 |
protected void setUp() throws Exception { |
29 |
super.setUp();
|
30 |
new DefaultLibrariesInitializer().fullInitialize();
|
31 |
} |
32 |
|
33 |
@Override
|
34 |
protected void tearDown() throws Exception { |
35 |
super.tearDown();
|
36 |
} |
37 |
|
38 |
// TODO add test methods here. The name must begin with 'test'. For example:
|
39 |
// public void testHello() {}
|
40 |
|
41 |
public void testGetWorkspaces() throws Exception { |
42 |
VCSGisManager manager = VCSGisLocator.getVCSGisManager(); |
43 |
|
44 |
Map<String, VCSGisWorkspaceDescriptor> workspaces = manager.getWorkspaces(); |
45 |
int number_of_workspaces_at_the_beginning_of_the_test = workspaces.size();
|
46 |
|
47 |
JDBCServerExplorer server = TestUtils.openServerExplorer("srv-getws");
|
48 |
File ws1file = TestUtils.getFile(FileUtils.getFile("test-dbs","ws-getws")); |
49 |
File ws2file = TestUtils.getFile(FileUtils.getFile("test-dbs","ws-getws")); |
50 |
|
51 |
manager.initRepository(server.getParameters(), null);
|
52 |
|
53 |
VCSGisRepository repo = manager.openRepository(server.getParameters()); |
54 |
TestUtils.h2sql_repository(repo); |
55 |
|
56 |
manager.initWorkspace(ws1file, repo, "Test getWorkspaces1",null); |
57 |
VCSGisWorkspace ws1 = manager.openWorkspace(ws1file); |
58 |
TestUtils.h2sql_workspace(ws1); |
59 |
|
60 |
manager.initWorkspace(ws2file, repo, "Test getWorkspaces2",null); |
61 |
VCSGisWorkspace ws2 = manager.openWorkspace(ws2file); |
62 |
TestUtils.h2sql_workspace(ws2); |
63 |
|
64 |
workspaces = manager.getWorkspaces(); |
65 |
|
66 |
assertEquals("num workspaces", number_of_workspaces_at_the_beginning_of_the_test+2, workspaces.size()); |
67 |
assertTrue("workspace1 is registered", workspaces.get(ws1.getCode())!=null); |
68 |
assertTrue("workspace2 is registered", workspaces.get(ws2.getCode())!=null); |
69 |
|
70 |
} |
71 |
|
72 |
public void testGetWorkspaces2() throws Exception { |
73 |
VCSGisManager manager = VCSGisLocator.getVCSGisManager(); |
74 |
|
75 |
Map<String, VCSGisWorkspaceDescriptor> workspaces = manager.getWorkspaces(); |
76 |
int number_of_workspaces_at_the_beginning_of_the_test = workspaces.size();
|
77 |
|
78 |
JDBCServerExplorer server = TestUtils.openServerExplorer("srv-getws");
|
79 |
File ws1file = TestUtils.getFile(FileUtils.getFile("test-dbs","ws-getws")); |
80 |
|
81 |
manager.initRepository(server.getParameters(), null);
|
82 |
|
83 |
VCSGisRepository repo = manager.openRepository(server.getParameters()); |
84 |
TestUtils.h2sql_repository(repo); |
85 |
|
86 |
manager.initWorkspace(ws1file, repo, "Test getWorkspaces1",null); |
87 |
VCSGisWorkspace ws1 = manager.openWorkspace(ws1file); |
88 |
TestUtils.h2sql_workspace(ws1); |
89 |
|
90 |
VCSGisWorkspaceDescriptor ws1Descriptor = manager.getWorkspaceDescriptor(ws1.getCode()); |
91 |
|
92 |
((VCSGisWorkspaceDescriptorImpl)ws1Descriptor).setWorkspace(null);
|
93 |
|
94 |
VCSGisWorkspace x = manager.openWorkspace(ws1.getExplorer()); |
95 |
assertTrue("workspace1 is initialized", x != null); |
96 |
|
97 |
} |
98 |
} |