Difference between revisions of "Developer Info"

From BITPlan mediawiki-japi Wiki
Jump to navigation Jump to search
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
== Development Environment ==
 +
=== Maven ===
 +
Maven 3 is is used in a pretty standard way - just look at [https://github.com/WolfgangFahl/Mediawiki-Japi/blob/master/pom.xml pom.xml] for details
 +
=== Eclipse ===
 +
==== initial import ====
 +
The project can be imported to eclipse - using the [http://eclipse.org/m2e/ m2eclipse plugin] is recommended
 +
[[File:EclipseImportProject.png]]
 +
==== Coding conventions ====
 +
spaces for indentation, not tabs!
 +
see
 +
* http://stackoverflow.com/questions/2636589/how-can-i-get-eclipse-to-insert-tabs-instead-of-spaces-for-java-content-assist
 +
and the answer
 +
* http://stackoverflow.com/a/7749086/1497139
 +
on how to do it
 +
 
== Testenvironment ==
 
== Testenvironment ==
There is a JUnit 4 Testsuite for the Mediawiki-Japi library that accesses some Example Wikis for the tests.
+
There is a JUnit 4 Testsuite for the Mediawiki-Japi library that accesses some [[ExampleWikis]] for the tests.
Please find below the list of example wikis being used
 
 
 
=== Read-only tests ===
 
* http://www.mediawiki.org
 
  
A login attempt is part of the tests - you'll need credentials at http://www.mediawiki.org  
+
A login attempt is part of most of the tests - you'll need credentials at http://www.mediawiki.org  
 
to run these tests successfully. You might want to create an account
 
to run these tests successfully. You might want to create an account
 
at https://www.mediawiki.org/w/index.php?title=Special:UserLogin&type=signup
 
at https://www.mediawiki.org/w/index.php?title=Special:UserLogin&type=signup
  
=== Read/Write tests ===
 
{| class="wikitable sortable"
 
|-
 
! wiki !! wikiid !! wikiname !! Version !! email
 
|-
 
| http://mediawiki-japi.bitplan.com/mw1_19/ || mw1_19test  ||  mediawiki-japi-test1_19 || 1.19.23 || mediawiki-japi@bitplan.com
 
|-
 
| http://mediawiki-japi.bitplan.com/mw1_23/ || mw1_23test  ||  mediawiki-japi-test1_23 || 1.23.8 || mediawiki-japi@bitplan.com
 
|-
 
| http://mediawiki-japi.bitplan.com/mw1_24/ || mw1_24test  ||  mediawiki-japi-test1_24 || 1.24.1 || mediawiki-japi@bitplan.com
 
|}
 
You need full api write access to these wikis to run these tests.
 
  
 
=== Credentials for the test example Mediawikis ===
 
=== Credentials for the test example Mediawikis ===
Line 28: Line 27:
 
the ini file at $HOME/.mediawiki-api/bob_mediawiki_org.ini.
 
the ini file at $HOME/.mediawiki-api/bob_mediawiki_org.ini.
  
If the credentials ini files do not exist yet they are created interactively during the test run.
+
If the credentials ini files do not exist yet you are warned during the test run e.g.
 +
<pre>
 +
Jan 04, 2015 6:27:51 PM com.bitplan.mediawiki.japi.user.WikiUser getUser
 +
Schwerwiegend: Need to be able to read Credentials for
 +
    http://www.mediawiki.org
 +
from /home/rene/.mediawiki-japi/rene_mediawiki_org.ini
 +
Please run
 +
    java -cp target/test-classes com.bitplan.mediawiki.japi.user.WikiUser mediawiki_org
 +
to create it. Then restart your tests.
 +
</pre>
 +
In this case you might want to run
 +
<source lang='bash'>
 +
    java -cp target/test-classes com.bitplan.mediawiki.japi.user.WikiUser mediawiki_org
 +
</source>
 +
The first parameter is the wikiid "mediawiki_org" which identifies the wiki the credentials are going to be used for.
 +
 
 +
When running WikiUser you'll be asked for:
 +
* username (please enter it with a capital first letter or fix the .ini file later)
 +
* password (will be encrypted)
 +
* e-mail
 +
like this:
 +
<pre>
 +
java -cp target/test-classes com.bitplan.mediawiki.japi.user.WikiUser mediawiki_org
 +
Please Enter username: Scott
 +
Please Enter password: tiger
 +
Please Enter email: scott@tiger.com
 +
Please Enter shall i store Scott's credentials encrypted in wf_mediawiki_org.ini y/n?: y
 +
</pre>
 +
 
 +
If you are using the Jar file you can of course also call
 +
<pre>
 +
java -cp mediawiki-japi-0.0.10.jar com.bitplan.mediawiki.japi.user.WikiUser ...
 +
</pre>
 +
if e.g. you just downloaded version 0.0.10 of the Jar file
  
 
=== Example for a credential ini file ===
 
=== Example for a credential ini file ===
 +
.mediawiki-japi/scott_mediawiki_org.ini
 
<source lang='ini'>
 
<source lang='ini'>
#Mediawiki-api
+
#Mediawiki JAPI credentials for mediawiki_org
#Fri Jan 02 19:58:49 CET 2015
+
#Mon Jan 05 05:51:15 CET 2015
secret=5hKnFOyU1uE\=
+
secret=/8UXoM9of6Q\=
 
user=Scott
 
user=Scott
email=scott@tiger.org
+
email=scott@tiger.com
salt=w75pcoUN
+
salt=FJgsesHK
cypher=YYmhAs86ygNnLbs@b9dNq36afytEzkCm
+
cypher=qh0CKZ2EQ4kO3nTtC90wM0AOl7RKrmwb
 
</source>
 
</source>

Revision as of 21:51, 9 November 2015

Development Environment

Maven

Maven 3 is is used in a pretty standard way - just look at pom.xml for details

Eclipse

initial import

The project can be imported to eclipse - using the m2eclipse plugin is recommended EclipseImportProject.png

Coding conventions

spaces for indentation, not tabs! see

and the answer

on how to do it

Testenvironment

There is a JUnit 4 Testsuite for the Mediawiki-Japi library that accesses some ExampleWikis for the tests.

A login attempt is part of most of the tests - you'll need credentials at http://www.mediawiki.org to run these tests successfully. You might want to create an account at https://www.mediawiki.org/w/index.php?title=Special:UserLogin&type=signup


Credentials for the test example Mediawikis

The credentials for the test example Mediawikis are fetched from ini files in the .mediawiki-api subdirectory of your home directory. E.g. if your username is bob and the id of the Mediawiki is "mediawiki_org" then you'll find the ini file at $HOME/.mediawiki-api/bob_mediawiki_org.ini.

If the credentials ini files do not exist yet you are warned during the test run e.g.

Jan 04, 2015 6:27:51 PM com.bitplan.mediawiki.japi.user.WikiUser getUser
Schwerwiegend: Need to be able to read Credentials for
    http://www.mediawiki.org
from /home/rene/.mediawiki-japi/rene_mediawiki_org.ini
Please run
    java -cp target/test-classes com.bitplan.mediawiki.japi.user.WikiUser mediawiki_org
to create it. Then restart your tests.

In this case you might want to run

    java -cp target/test-classes com.bitplan.mediawiki.japi.user.WikiUser mediawiki_org

The first parameter is the wikiid "mediawiki_org" which identifies the wiki the credentials are going to be used for.

When running WikiUser you'll be asked for:

  • username (please enter it with a capital first letter or fix the .ini file later)
  • password (will be encrypted)
  • e-mail

like this:

java -cp target/test-classes com.bitplan.mediawiki.japi.user.WikiUser mediawiki_org
Please Enter username: Scott
Please Enter password: tiger
Please Enter email: scott@tiger.com
Please Enter shall i store Scott's credentials encrypted in wf_mediawiki_org.ini y/n?: y

If you are using the Jar file you can of course also call

java -cp mediawiki-japi-0.0.10.jar com.bitplan.mediawiki.japi.user.WikiUser ...

if e.g. you just downloaded version 0.0.10 of the Jar file

Example for a credential ini file

.mediawiki-japi/scott_mediawiki_org.ini

#Mediawiki JAPI credentials for mediawiki_org
#Mon Jan 05 05:51:15 CET 2015
secret=/8UXoM9of6Q\=
user=Scott
email=scott@tiger.com
salt=FJgsesHK
cypher=qh0CKZ2EQ4kO3nTtC90wM0AOl7RKrmwb