From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-24 13:05:57
|
Revision: 485 http://sword-app.svn.sourceforge.net/sword-app/?rev=485&view=rev Author: richard-jones Date: 2012-03-24 13:05:46 +0000 (Sat, 24 Mar 2012) Log Message: ----------- add complete deposit tests, and fix bug with client's complete method Modified Paths: -------------- JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java Modified: JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java =================================================================== --- JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java 2012-03-24 12:50:34 UTC (rev 484) +++ JavaClient2.0/src/main/java/org/swordapp/client/SWORDClient.java 2012-03-24 13:05:46 UTC (rev 485) @@ -949,10 +949,10 @@ throws SWORDClientException, ProtocolViolationException, SWORDError { String url = null; - SwordIdentifier eml = receipt.getEditMediaLink(); - if (eml != null) + SwordIdentifier el = receipt.getEditLink(); + if (el != null) { - url = eml.getHref(); + url = el.getHref(); return this.complete(url, auth); } return null; Modified: JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java =================================================================== --- JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java 2012-03-24 12:50:34 UTC (rev 484) +++ JavaClient2.0/src/test/java/org/swordapp/client/test/SpecTests.java 2012-03-24 13:05:46 UTC (rev 485) @@ -993,32 +993,32 @@ assertTrue(statement instanceof OreStatement); } - /* Python tests to mimic + @Test + public void completeDeposit() + throws Exception + { + SWORDClient client = new SWORDClient(new ClientConfiguration()); + ServiceDocument sd = client.getServiceDocument(this.sdIRI, new AuthCredentials(this.user, this.pass, this.obo)); + SWORDCollection col = sd.getWorkspaces().get(0).getCollections().get(0); - def test_34_complete_deposit(self): - conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO) - conn.get_service_document() - col = conn.sd.workspaces[0][1][0] - e = Entry(title="Foo", id="asidjasidj", dcterms_abstract="abstract", dcterms_title="my title") - with open(PACKAGE) as pkg: - receipt = conn.create(col_iri = col.href, - metadata_entry = e, - payload=pkg, - mimetype=PACKAGE_MIME, - filename="example.zip", - packaging = 'http://purl.org/net/sword/package/SimpleZip', - in_progress = True, - suggested_identifier = "zyxwvutsrq") + Deposit deposit = new Deposit(); + deposit.setFile(new FileInputStream(this.file)); + deposit.setMimeType("application/zip"); + deposit.setFilename("example.zip"); + deposit.setPackaging(UriRegistry.PACKAGE_SIMPLE_ZIP); + deposit.setMd5(this.fileMd5); + deposit.setInProgress(true); - # ensure that we have a receipt (the server may not give us one - # by default) - edit_iri = receipt.location - receipt = conn.get_deposit_receipt(edit_iri) + DepositReceipt receipt = client.deposit(col, deposit, new AuthCredentials(this.user, this.pass, this.obo)); + receipt = client.getDepositReceipt(receipt.getLocation(), new AuthCredentials(this.user, this.pass, this.obo)); - response = conn.complete_deposit(dr=receipt) + DepositReceipt newReceipt = client.complete(receipt, new AuthCredentials(this.user, this.pass, this.obo)); - assert response.code == 200 + assertEquals(newReceipt.getStatusCode(), 200); + } + /* Python tests to mimic + def test_35_error_checksum_mismatch(self): conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, error_response_raises_exceptions=False) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |