-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transformed api error to exception and moved token to post body
Task: #38
- Loading branch information
Showing
7 changed files
with
103 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/test/java/net/sourceforge/jwbf/mediawiki/actions/editing/FileUploadTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package net.sourceforge.jwbf.mediawiki.actions.editing; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import net.sourceforge.jwbf.TestHelper; | ||
import net.sourceforge.jwbf.core.actions.util.HttpAction; | ||
import net.sourceforge.jwbf.mediawiki.actions.util.ApiException; | ||
import net.sourceforge.jwbf.mediawiki.bots.MediaWikiBot; | ||
import net.sourceforge.jwbf.mediawiki.contentRep.SimpleFile; | ||
import org.junit.Test; | ||
|
||
public class FileUploadTest { | ||
|
||
@Test | ||
public void testException() { | ||
// GIVEN | ||
MediaWikiBot bot = mock(MediaWikiBot.class); | ||
SimpleFile simpleFile = mock(SimpleFile.class); | ||
when(simpleFile.isFile()).thenReturn(true); | ||
when(simpleFile.exists()).thenReturn(true); | ||
when(simpleFile.canRead()).thenReturn(true); | ||
when(simpleFile.getPath()).thenReturn("any"); | ||
when(bot.isLoggedIn()).thenReturn(true); | ||
FileUpload testee = new FileUpload(simpleFile, bot); | ||
HttpAction action = mock(HttpAction.class); | ||
|
||
String xml = TestHelper.anyWikiResponse("uploadError.xml"); | ||
|
||
try { | ||
// WHEN | ||
testee.processReturningText(xml, action); | ||
fail(); | ||
} catch (ApiException e) { | ||
// THEN | ||
assertEquals("API ERROR CODE: mustposttoken VALUE: The 'token' parameter was found " // | ||
+ "in the query string, but must be in the POST body", e.getMessage()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" ?> | ||
<api servedby="mw1189"> | ||
<error code="mustposttoken" info="The 'token' parameter was found in the query string, but must be in the POST body" xml:space="preserve">See https://commons.wikimedia.org/w/api.php for API usage</error> | ||
</api> |