52 |
52 |
// TODO add test methods here. The name must begin with 'test'. For example:
|
53 |
53 |
// public void testHello() {}
|
54 |
54 |
|
55 |
|
public void testCheckout() throws Exception {
|
56 |
|
// final String testid = "ServerCommit";
|
57 |
|
// final URL serverUrl = new URL("http://localhost:9810/");
|
58 |
|
//
|
59 |
|
// VCSGisManager manager = VCSGisLocator.getVCSGisManager();
|
60 |
|
// JDBCServerExplorer server = TestUtils.openServerExplorer("srv-"+testid);
|
61 |
|
// File ws1file = TestUtils.getFile(FileUtils.getFile("test-dbs","ws-"+testid));
|
62 |
|
//
|
63 |
|
// int r = manager.initRepository(server, null);
|
64 |
|
// assertEquals("initRepository status", ERR_NO_ERROR, r);
|
65 |
|
//
|
66 |
|
// VCSGisRepository repo = manager.openRepository(server);
|
67 |
|
// TestUtils.h2sql_repository(repo);
|
68 |
|
//
|
69 |
|
// // -------------------------
|
70 |
|
// // Prepare the data in workspace
|
71 |
|
// r = manager.initWorkspace(ws1file, repo, "Test "+testid, null);
|
72 |
|
// assertEquals("initWorkspace status", ERR_NO_ERROR, r);
|
73 |
|
//
|
74 |
|
// VCSGisWorkspace ws1 = manager.openWorkspace(ws1file);
|
75 |
|
// assertNotNull("openWorkspace status", ws1);
|
76 |
|
// TestUtils.h2sql_workspace(ws1);
|
77 |
|
//
|
78 |
|
// FeatureStore store2 = TestUtils.openSourceStore2();
|
79 |
|
// ws1.add("test", store2, "text");
|
80 |
|
// assertEquals("ws1.add status", ERR_NO_ERROR, r);
|
81 |
|
//
|
82 |
|
// DisposeUtils.disposeQuietly(store2);
|
83 |
|
//
|
84 |
|
// Map<String, String> expected = TestUtils.getExpecteds("S02Commit.txt");
|
85 |
|
//
|
86 |
|
// VCSGisRepository client = manager.openRepository(serverUrl);
|
87 |
|
// CommitRequestClient request = (CommitRequestClient) client.createCommitRequest();
|
88 |
|
// ((VCSGisWorkspaceImpl)ws1).prepareCommitRequest(request, null, null, null);
|
89 |
|
//
|
90 |
|
// ByteArrayOutputStream request_stream = new ByteArrayOutputStream(1024);
|
91 |
|
// LOGGER.debug("===: "+testid+"/produce request");
|
92 |
|
// request.requestDataProducer(request_stream);
|
93 |
|
// LOGGER.debug("===: "+testid+"/request built");
|
94 |
|
// String request_s = request_stream.toString().trim();
|
95 |
|
// assertTrue("request data", match(expected.get("request"), request_s));
|
96 |
|
//
|
97 |
|
// ByteArrayInputStream is = new ByteArrayInputStream(request_stream.toByteArray());
|
98 |
|
// LOGGER.debug("===: "+testid+"/handle request");
|
99 |
|
// CommitHandler handler = new CommitHandler(repo);
|
100 |
|
// InputStream response_stream = handler.handle(is);
|
101 |
|
//
|
102 |
|
// LOGGER.debug("===: "+testid+"/Transform response to string");
|
103 |
|
// String response_s = StringUtils.join(IOUtils.readLines(response_stream),'\n').trim();
|
104 |
|
// assertTrue("response data", match(expected.get("response"), response_s));
|
105 |
|
//
|
|
55 |
public void testCommit() throws Exception {
|
|
56 |
final String testid = "ServerCommit";
|
|
57 |
final URL serverUrl = new URL("http://localhost:9810/");
|
106 |
58 |
|
|
59 |
VCSGisManager manager = VCSGisLocator.getVCSGisManager();
|
|
60 |
JDBCServerExplorer server = TestUtils.openServerExplorer("srv-"+testid);
|
|
61 |
File ws1file = TestUtils.getFile(FileUtils.getFile("test-dbs","ws-"+testid));
|
|
62 |
|
|
63 |
int r = manager.initRepository(server, null);
|
|
64 |
assertEquals("initRepository status", ERR_NO_ERROR, r);
|
|
65 |
|
|
66 |
VCSGisRepository repo = manager.openRepository(server);
|
|
67 |
TestUtils.h2sql_repository(repo);
|
|
68 |
|
|
69 |
// -------------------------
|
|
70 |
// Prepare the data in workspace
|
|
71 |
r = manager.initWorkspace(ws1file, repo, "Test "+testid, null);
|
|
72 |
assertEquals("initWorkspace status", ERR_NO_ERROR, r);
|
|
73 |
|
|
74 |
VCSGisWorkspace ws1 = manager.openWorkspace(ws1file);
|
|
75 |
assertNotNull("openWorkspace status", ws1);
|
|
76 |
TestUtils.h2sql_workspace(ws1);
|
|
77 |
|
|
78 |
FeatureStore store2 = TestUtils.openSourceStore2();
|
|
79 |
ws1.add("test", store2, "text");
|
|
80 |
assertEquals("ws1.add status", ERR_NO_ERROR, r);
|
|
81 |
|
|
82 |
DisposeUtils.disposeQuietly(store2);
|
|
83 |
|
|
84 |
Map<String, String> expected = TestUtils.getExpecteds("S02Commit.txt");
|
|
85 |
|
|
86 |
VCSGisRepository client = manager.openRepository(serverUrl);
|
|
87 |
CommitRequestClient request = (CommitRequestClient) client.createCommitRequest();
|
|
88 |
((VCSGisWorkspaceImpl)ws1).prepareCommitRequest(request, null, null, null);
|
|
89 |
|
|
90 |
ByteArrayOutputStream request_stream = new ByteArrayOutputStream(1024);
|
|
91 |
LOGGER.debug("===: "+testid+"/produce request");
|
|
92 |
request.requestDataProducer(request_stream);
|
|
93 |
LOGGER.debug("===: "+testid+"/request built");
|
|
94 |
String request_s = request_stream.toString().trim();
|
|
95 |
assertTrue("request data", match(expected.get("request"), request_s));
|
|
96 |
|
|
97 |
ByteArrayInputStream is = new ByteArrayInputStream(request_stream.toByteArray());
|
|
98 |
LOGGER.debug("===: "+testid+"/handle request");
|
|
99 |
CommitHandler handler = new CommitHandler(repo);
|
|
100 |
InputStream response_stream = handler.handle(is);
|
|
101 |
|
|
102 |
LOGGER.debug("===: "+testid+"/Transform response to string");
|
|
103 |
String response_s = StringUtils.join(IOUtils.readLines(response_stream),'\n').trim();
|
|
104 |
assertTrue("response data", match(expected.get("response"), response_s));
|
|
105 |
|
|
106 |
|
107 |
107 |
}
|
108 |
108 |
}
|