KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > util > rome > DiskFeedInfoCacheTest


1 /*
2  * Copyright 2005 Sun Microsystems, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
20 import java.net.URL JavaDoc;
21
22 import junit.framework.Test;
23 import junit.framework.TestCase;
24 import junit.framework.TestSuite;
25
26 import org.apache.roller.business.FileManagerTest;
27 import com.sun.syndication.fetcher.impl.SyndFeedInfo;
28
29 /**
30  * @author David M Johnson
31  */

32 public class DiskFeedInfoCacheTest extends TestCase
33 {
34     public static void main(String JavaDoc[] args)
35     {
36         junit.textui.TestRunner.run(DiskFeedInfoCacheTest.class);
37     }
38
39     public void testCache() throws Exception JavaDoc
40     {
41         URL JavaDoc url = new URL JavaDoc("http://cnn.com");
42         SyndFeedInfo info = new SyndFeedInfo();
43         info.setUrl(url);
44         
45         String JavaDoc buildDir = System.getProperty("ro.build");
46         assertNotNull("ro.build not null", buildDir);
47         assertTrue("ro.build not zero length", buildDir.trim().length() > 0);
48         if (!buildDir.startsWith("/")) buildDir = "..";
49         File JavaDoc file = new File JavaDoc(buildDir);
50         
51         assertTrue("buildDir exists", file.exists());
52         assertTrue("buildDir is directory", file.isDirectory());
53         
54         DiskFeedInfoCache cache =
55             new DiskFeedInfoCache(buildDir + "/tests/planet-cache");
56         cache.setFeedInfo(info.getUrl(), info);
57         
58         SyndFeedInfo info2 = cache.getFeedInfo(url);
59         assertNotNull(info2);
60         assertEquals(url, info2.getUrl());
61     }
62
63     public static Test suite()
64     {
65         return new TestSuite(DiskFeedInfoCacheTest.class);
66
67     }
68 }
69
Popular Tags