⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testsearchimplementations.java

📁 ajax patterns 这是关于ajax设计模式方面的原代码
💻 JAVA
字号:
/*    Copyright 2006 Christian Gross http://www.devspace.com    From the book Ajax Patterns and Best Practices   Licensed 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 devspace.externalrequestor;import devspace.externalrequestor.search.*;import junit.framework.*;import java.util.*;// There is a missing class called devspace.APIIdentifiers, which is// not defined because each developer has to get their own keys.class LocalChain implements Parent {    public void clearAllCommands() {        throw new NoSuchMethodError();    }    public Iterator getCommands() {        throw new NoSuchMethodError();    }        public void processRequest(String type, Request request) {        throw new NoSuchMethodError();    }        public String getTransactionIdentifier() {        throw new NoSuchMethodError();    }        public void addCommand(Command cmd) {        throw new NoSuchMethodError();    }        public void processRequest(Request request) {        throw new NoSuchMethodError();    }        public void addResult(Result result) {        SearchResult searchResult = (SearchResult)result;        System.out.println( "URL (" + searchResult.getURL() +                           ") Title (" + searchResult.getTitle() +                           ") Snippet (" + searchResult.getSnippet() + ")");    }        public Request getRequest() {        return new SearchRequest( "applications");    }}public class TestSearchImplementations extends TestCase {    //private static String amazonEndPoint = "http://awis.amazonaws.com/onca/xml";    private static String amazonEndPoint = "http://192.168.1.104/onca/xml";    //private static String googleEndPoint = "http://api.google.com/search/beta2";    private static String googleEndPoint = "http://192.168.1.102:8100/search/beta2";        public void testSimpleAmazonSearch() {        AmazonSearchCommand cmd = new AmazonSearchCommand( amazonEndPoint,            devspace.APIIdentifiers.AmazonAccessKey,            devspace.APIIdentifiers.AmazonSecretAccessKey);        String accessKey = devspace.APIIdentifiers.AmazonAccessKey;        String secretKey = devspace.APIIdentifiers.AmazonSecretAccessKey;        String endpoint = amazonEndPoint;        cmd.assignParent( new LocalChain());        cmd.run();    }    public void testSimpleGoogleSearch() {        GoogleSearchCommand cmd = new GoogleSearchCommand(            googleEndPoint,            devspace.APIIdentifiers.GoogleSearchKey);        cmd.assignParent( new LocalChain());        cmd.run();    }    public void testSynchronizeChain() {        Parent chain = new SynchronousParent();        SearchBuilder.assignConfiguration( amazonEndPoint,                                          devspace.APIIdentifiers.AmazonAccessKey,                                          devspace.APIIdentifiers.AmazonSecretAccessKey,                                          googleEndPoint,                                        devspace.APIIdentifiers.GoogleSearchKey);        SearchBuilder.buildCommands( chain);                chain.processRequest( new SearchRequest( "applications"));                Iterator iter = ((SynchronousParent)chain).getResultsIterator();        while( iter.hasNext()) {            SearchResult result = (SearchResult)iter.next();            System.out.println( "URL (" + result.getURL() +                               ") Title (" + result.getTitle() +                               ") Snippet (" + result.getSnippet() + ")");        }            }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -