예제 #1
0
  /** Test get siteinfo on Wikipedia DE. */
  @Test
  public final void siteInfoWikipediaDe() {
    // GIVEN
    String liveUrl = getWikipediaDeUrl();
    MediaWikiBot wikiBot = BotFactory.newWikimediaBot(liveUrl, getClass());

    // WHEN
    Siteinfo siteinfo = wikiBot.getSiteinfo();

    // THEN
    assertEquals(Version.DEVELOPMENT, siteinfo.getVersion());
  }
예제 #2
0
 public MediaWikiBot getBot() {
   if (bot == null) {
     bot = new MediaWikiBot("http://mediawiki/");
     //            bot = new MediaWikiBot("http://direct.ayfaar.org/mediawiki/");
     bot.login("admin", "ayfaar");
   }
   return bot;
 }
예제 #3
0
  private void prepare(MediaWikiBot bot) {
    SimpleArticle a = new SimpleArticle();

    for (int i = 0; i < COUNT; i++) {
      a.setTitle(DELETE_PREFIX + i);
      a.setText(getRandom(23));
      bot.writeContent(a);
    }
  }
예제 #4
0
  private void test(MediaWikiBot bot) throws ActionException, ProcessException {

    for (int i = 0; i < COUNT; i++) {
      ContentAccessable ca = bot.getArticle(DELETE_PREFIX + i);

      assertTrue(
          "textlength of Delete " + i + " is greater then 0 (" + ca.getText().length() + ")",
          ca.getText().length() == 0);
    }
  }
예제 #5
0
  public static Injector getBotInjector(Version v, boolean login) {
    final String wikiUrl = getWikiUrl(v, LiveTestFather.getValue("localwikihost"));
    TestHelper.assumeReachable(wikiUrl);
    Injector injector =
        masterInjector.createChildInjector(
            new AbstractModule() {

              @Override
              protected void configure() {
                bind(CacheActionClient.class) //
                    .toInstance(Mockito.spy(new CacheActionClient(wikiUrl, new WireRegister())));
                bind(HttpBot.class).to(CacheHttpBot.class);
                bind(MediaWikiBot.class).asEagerSingleton();
              }
            });
    MediaWikiBot bot = injector.getInstance(MediaWikiBot.class);
    if (login) {
      bot.login(getWikiUser(v), getWikiPass(v));
    }
    return injector;
  }
예제 #6
0
  private void delete(MediaWikiBot bot) throws ActionException, ProcessException {

    for (int i = 0; i < COUNT; i++) {
      bot.delete(DELETE_PREFIX + i);
    }
  }