Return-Path: X-Original-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 753B19DEE for ; Tue, 11 Oct 2011 12:49:59 +0000 (UTC) Received: (qmail 11377 invoked by uid 500); 11 Oct 2011 12:49:59 -0000 Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org Received: (qmail 11318 invoked by uid 500); 11 Oct 2011 12:49:59 -0000 Mailing-List: contact connectors-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: connectors-dev@incubator.apache.org Delivered-To: mailing list connectors-commits@incubator.apache.org Received: (qmail 11311 invoked by uid 99); 11 Oct 2011 12:49:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2011 12:49:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2011 12:49:57 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1365923888FE; Tue, 11 Oct 2011 12:49:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1181757 - in /incubator/lcf/branches/CONNECTORS-256: connectors/wiki/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/wiki/tests/Base.java tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java Date: Tue, 11 Oct 2011 12:49:36 -0000 To: connectors-commits@incubator.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111011124937.1365923888FE@eris.apache.org> Author: kwright Date: Tue Oct 11 12:49:36 2011 New Revision: 1181757 URL: http://svn.apache.org/viewvc?rev=1181757&view=rev Log: Move the stub for the mock wiki service to the right place. Added: incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java (with props) Modified: incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/wiki/tests/Base.java Modified: incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/wiki/tests/Base.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/wiki/tests/Base.java?rev=1181757&r1=1181756&r2=1181757&view=diff ============================================================================== --- incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/wiki/tests/Base.java (original) +++ incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/wiki/tests/Base.java Tue Oct 11 12:49:36 2011 @@ -23,16 +23,6 @@ import org.apache.manifoldcf.agents.inte import org.apache.manifoldcf.crawler.interfaces.*; import org.apache.manifoldcf.crawler.system.ManifoldCF; -import org.mortbay.jetty.Server; -import org.mortbay.jetty.servlet.Context; -import org.mortbay.jetty.servlet.ServletHolder; - -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import java.io.*; -import java.util.*; import org.junit.*; /** This is a testing base class that is responsible for setting up/tearing down the agents framework. */ @@ -49,71 +39,5 @@ public class Base extends org.apache.man return new String[]{"org.apache.manifoldcf.crawler.connectors.wiki.WikiConnector"}; } - /** Mock wiki service */ - static class MockWikiService - { - Server server; - - public MockWikiService() - { - server = new Server(8089); - Context asContext = new Context(server,"/w",Context.SESSIONS); - asContext.addServlet(new ServletHolder(new WikiAPIServlet()), "/api.php"); - } - - public void start() throws Exception { - server.start(); - } - - public void stop() throws Exception { - server.stop(); - } - - public static class WikiAPIServlet extends HttpServlet - { - @Override - public void service(HttpServletRequest req, HttpServletResponse res) - throws IOException - { - String format = req.getParameter("format"); - if (!format.equals("xml")) - throw new IOException("Format parameter incorrect: "+format); - String list = req.getParameter("list"); - String action = req.getParameter("action"); - if (action == null && list == null) - throw new IOException("Must have either action or list"); - if (action != null && list != null) - throw new IOException("Cannot have both action and list"); - if (action != null) - { - if (!action.equals("query")) - throw new IOException("Action parameter incorrect: "+query); - String prop = req.getParameter("prop"); - String pageIds = req.getParameter("pageids"); - String rvprop = req.getParameter("rvprop"); - String inprop = req.getParameter("inprop"); - // MHL - } - else if (list != null) - { - if (!list.equals("allpages")) - throw new IOException("List parameter incorrect: "+list); - String apfrom = req.getParameter("apfrom"); - String aplimit = req.getParameter("aplimit"); - // MHL - } - - // MHL - String user = req.getParameter("username"); - res.setStatus(HttpServletResponse.SC_OK); - if(user.equals("user1") || user.equals("user2") || user.equals("user3")) - res.getWriter().printf("TOKEN:token1\n"); - if(user.equals("user2") || user.equals("user3")) - res.getWriter().printf("TOKEN:token2\n"); - if(user.equals("user3")) - res.getWriter().printf("TOKEN:token3\n"); - } - } - } } Added: incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java?rev=1181757&view=auto ============================================================================== --- incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java (added) +++ incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java Tue Oct 11 12:49:36 2011 @@ -0,0 +1,99 @@ +/* $Id$ */ + +/** +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.apache.manifoldcf.wiki_tests; + +import org.mortbay.jetty.Server; +import org.mortbay.jetty.servlet.Context; +import org.mortbay.jetty.servlet.ServletHolder; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import java.io.*; +import java.util.*; + +/** Mock wiki service */ +public class MockWikiService +{ + Server server; + + public MockWikiService() + { + server = new Server(8089); + Context asContext = new Context(server,"/w",Context.SESSIONS); + asContext.addServlet(new ServletHolder(new WikiAPIServlet()), "/api.php"); + } + + public void start() throws Exception + { + server.start(); + } + + public void stop() throws Exception + { + server.stop(); + } + + public static class WikiAPIServlet extends HttpServlet + { + @Override + public void service(HttpServletRequest req, HttpServletResponse res) + throws IOException + { + String format = req.getParameter("format"); + if (!format.equals("xml")) + throw new IOException("Format parameter incorrect: "+format); + String list = req.getParameter("list"); + String action = req.getParameter("action"); + if (action == null && list == null) + throw new IOException("Must have either action or list"); + if (action != null && list != null) + throw new IOException("Cannot have both action and list"); + if (action != null) + { + if (!action.equals("query")) + throw new IOException("Action parameter incorrect: "+query); + String prop = req.getParameter("prop"); + String pageIds = req.getParameter("pageids"); + String rvprop = req.getParameter("rvprop"); + String inprop = req.getParameter("inprop"); + // MHL + } + else if (list != null) + { + if (!list.equals("allpages")) + throw new IOException("List parameter incorrect: "+list); + String apfrom = req.getParameter("apfrom"); + String aplimit = req.getParameter("aplimit"); + // MHL + } + + // MHL + String user = req.getParameter("username"); + res.setStatus(HttpServletResponse.SC_OK); + if(user.equals("user1") || user.equals("user2") || user.equals("user3")) + res.getWriter().printf("TOKEN:token1\n"); + if(user.equals("user2") || user.equals("user3")) + res.getWriter().printf("TOKEN:token2\n"); + if(user.equals("user3")) + res.getWriter().printf("TOKEN:token3\n"); + } + } +} Propchange: incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/MockWikiService.java ------------------------------------------------------------------------------ svn:keywords = Id