01: /*
02: * Copyright 2005 Sun Microsystems, Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.roller.util.rome;
18:
19: import java.io.File;
20: import java.net.URL;
21: import junit.framework.Test;
22: import junit.framework.TestCase;
23: import junit.framework.TestSuite;
24: import com.sun.syndication.fetcher.impl.SyndFeedInfo;
25:
26: /**
27: * @author David M Johnson
28: */
29: public class DiskFeedInfoCacheTest extends TestCase {
30:
31: public static void main(String[] args) {
32: junit.textui.TestRunner.run(DiskFeedInfoCacheTest.class);
33: }
34:
35: public void testCache() throws Exception {
36: URL url = new URL("http://cnn.com");
37: SyndFeedInfo info = new SyndFeedInfo();
38: info.setUrl(url);
39:
40: String buildDir = System.getProperty("ro.build");
41: assertNotNull("ro.build not null", buildDir);
42: assertTrue("ro.build not zero length",
43: buildDir.trim().length() > 0);
44: if (!buildDir.startsWith("/"))
45: buildDir = "..";
46: File file = new File(buildDir);
47:
48: assertTrue("buildDir exists", file.exists());
49: assertTrue("buildDir is directory", file.isDirectory());
50:
51: DiskFeedInfoCache cache = new DiskFeedInfoCache(buildDir
52: + "/tests/planet-cache");
53: cache.setFeedInfo(info.getUrl(), info);
54:
55: SyndFeedInfo info2 = cache.getFeedInfo(url);
56: assertNotNull(info2);
57: assertEquals(url, info2.getUrl());
58: }
59:
60: public static Test suite() {
61: return new TestSuite(DiskFeedInfoCacheTest.class);
62:
63: }
64:
65: }
|