From 4ad75d995cbf62b6e4f4e4b62e33c6d4954be0e0 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Fri, 5 Jan 2018 02:45:56 +0100 Subject: [PATCH] Cleaned tests. --- test/org/april/hebdobot/BotMock.java | 4 +- test/org/april/hebdobot/BotTest.java | 94 ------------------- .../org/april/hebdobot/OAuthRegistration.java | 56 ----------- test/org/april/hebdobot/conf.xml | 22 ----- test/org/april/hebdobot/users.xml | 3 - 5 files changed, 3 insertions(+), 176 deletions(-) delete mode 100644 test/org/april/hebdobot/BotTest.java delete mode 100644 test/org/april/hebdobot/OAuthRegistration.java delete mode 100644 test/org/april/hebdobot/conf.xml delete mode 100644 test/org/april/hebdobot/users.xml diff --git a/test/org/april/hebdobot/BotMock.java b/test/org/april/hebdobot/BotMock.java index f6ea321..1826476 100644 --- a/test/org/april/hebdobot/BotMock.java +++ b/test/org/april/hebdobot/BotMock.java @@ -19,6 +19,8 @@ */ package org.april.hebdobot; +import java.io.File; + import org.april.hebdobot.model.Hebdobot; /** @@ -34,7 +36,7 @@ public class BotMock extends Hebdobot */ public BotMock() throws Exception { - super("", 0, "bot", "channel", "revue.txt"); + super("myHost", 0, "Hebdobot", "#april-mock", new File("/tmp/"), "revue.txt"); } /* (non-Javadoc) diff --git a/test/org/april/hebdobot/BotTest.java b/test/org/april/hebdobot/BotTest.java deleted file mode 100644 index 4911276..0000000 --- a/test/org/april/hebdobot/BotTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (C) 2011-2013,2017 Nicolas Vinot - * Copyright (C) 2017 Christian Pierre MOMON - * - * This file is part of (April) Hebdobot. - * - * Hebdobot is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Hebdobot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Hebdobot. If not, see - */ -package org.april.hebdobot; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.april.hebdobot.model.Hebdobot; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * The Class BotTest. - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = "/org/april/hebdobot/conf.xml") -public class BotTest -{ - /** - * Redo. - * - * @throws Exception - * the exception - */ - @Test - public void redo() throws Exception - { - final Hebdobot bot = new BotMock(); - bot.run(); - - final InputStream is = BotTest.class.getResourceAsStream("/org/april/hebdobot/review.log"); - if (is == null) - { - return; - } - try - { - final Reader isr = new InputStreamReader(is); - try - { - final BufferedReader isbr = new BufferedReader(isr); - try - { - String line; - final Pattern pattern = Pattern.compile(".*\\s+<([^>]+)>\\s+(.*)"); - while ((line = isbr.readLine()) != null) - { - final Matcher matcher = pattern.matcher(line); - if (matcher.matches()) - { - bot.onMessage("channel", matcher.group(1), "", "", matcher.group(2)); - } - } - } - finally - { - isbr.close(); - } - - } - finally - { - isr.close(); - } - } - finally - { - is.close(); - } - } -} diff --git a/test/org/april/hebdobot/OAuthRegistration.java b/test/org/april/hebdobot/OAuthRegistration.java deleted file mode 100644 index 775f447..0000000 --- a/test/org/april/hebdobot/OAuthRegistration.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (C) 2011-2013,2017 Nicolas Vinot - * Copyright (C) 2017 Christian Pierre MOMON - * - * This file is part of (April) Hebdobot. - * - * Hebdobot is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Hebdobot is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Hebdobot. If not, see - */ -package org.april.hebdobot; - -import java.util.Scanner; - -import org.scribe.builder.ServiceBuilder; -import org.scribe.builder.api.TwitterApi; -import org.scribe.model.Token; -import org.scribe.model.Verifier; -import org.scribe.oauth.OAuthService; - -/** - * The Class OAuthRegistration. - */ -public class OAuthRegistration -{ - /** - * The main method. - * - * @param args - * the arguments - * @throws Exception - * the exception - */ - public static void main(final String args[]) throws Exception - { - final OAuthService service = new ServiceBuilder().provider(TwitterApi.class).apiKey("uCZMXbUWuda7a2RqqKd2yg") - .apiSecret("KUH2O77u5RJfqZ2rE8qV6Ak1HBKQRg70DUIVAXDr6oo").build(); - final Token requestToken = service.getRequestToken(); - final String authUrl = service.getAuthorizationUrl(requestToken); - System.out.println(authUrl); - - final String value = new Scanner(System.in).nextLine(); - final Verifier v = new Verifier(value); - final Token accessToken = service.getAccessToken(requestToken, v); - System.out.println(accessToken); - } -} diff --git a/test/org/april/hebdobot/conf.xml b/test/org/april/hebdobot/conf.xml deleted file mode 100644 index 5e297c0..0000000 --- a/test/org/april/hebdobot/conf.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - revue.txt - - - - - - - - - - diff --git a/test/org/april/hebdobot/users.xml b/test/org/april/hebdobot/users.xml deleted file mode 100644 index 8d602a4..0000000 --- a/test/org/april/hebdobot/users.xml +++ /dev/null @@ -1,3 +0,0 @@ - -