BasicApiConnection extends ApiConnection { public void logout() throws IOException, MediaWikiApiErrorException { if (this.loggedIn) { Map<String, String> params = new HashMap<>(); params.put("action", "logout"); params.put("token", getOrFetchToken("csrf")); params.put("format", "json"); try { sendJsonRequest("POST", params); } catch (MediaWikiApiErrorException e) { throw new IOException(e.getMessage(), e); } this.loggedIn = false; this.username = ""; this.password = ""; } } BasicApiConnection(String apiBaseUrl); @JsonCreator protected  BasicApiConnection(
			@JsonProperty("baseUrl") String apiBaseUrl,
			@JsonProperty("cookies") List<HttpCookieWrapper> cookies,
			@JsonProperty("username") String username,
			@JsonProperty("loggedIn") boolean loggedIn,
			@JsonProperty("tokens") Map<String, String> tokens,
			@JsonProperty("connectTimeout") int connectTimeout,
			@JsonProperty("readTimeout") int readTimeout); static BasicApiConnection getTestWikidataApiConnection(); static BasicApiConnection getWikidataApiConnection(); static BasicApiConnection getWikimediaCommonsApiConnection(); void login(String username, String password); @JsonProperty("cookies") List<HttpCookie> getCookies(); void clearCookies(); void logout();  }
@Test public void testLogout() throws IOException, LoginFailedException, MediaWikiApiErrorException { connection.login("username", "password"); connection.logout(); assertEquals("", connection.username); assertEquals("", connection.password); assertFalse(connection.loggedIn); }