Project

General

Profile

« Previous | Next » 

Revision 4735

Added by daigle almost 16 years ago

The test was failing because it was reading the sitemap file into a buffer and the limit was being reached. Used the FileUtil string reader to get the file.

View differences:

test/edu/ucsb/nceas/metacattest/SitemapTest.java
24 24

  
25 25
package edu.ucsb.nceas.metacattest;
26 26

  
27
import java.io.BufferedReader;
28 27
import java.io.File;
29 28
import java.io.FileNotFoundException;
30
import java.io.FileReader;
31 29
import java.io.IOException;
32 30
import java.util.Vector;
33 31

  
......
36 34
import edu.ucsb.nceas.metacat.Sitemap;
37 35
import edu.ucsb.nceas.metacat.client.MetacatAuthException;
38 36
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException;
37
import edu.ucsb.nceas.utilities.FileUtil;
39 38

  
40 39
/**
41 40
 * Test the Sitemap class by generating the sitemaps in a separate directory.
......
102 101
			debug("logging out");
103 102
			m.logout();
104 103

  
104
			// create the directory if it does not exist
105
			FileUtil.createDirectory(directoryName);
106

  
105 107
			File directory = new File(directoryName);
106
			directory.mkdirs();
107 108
			String urlRoot = "http://foo.example.com/ctx/metacat";
108 109
			String skin = "testskin";
109 110
			Sitemap smap = new Sitemap(directory, urlRoot, skin);
110 111
			smap.generateSitemaps();
112
			
111 113
			File sitemap1 = new File(directory, "metacat1.xml");
112 114
			assertTrue(sitemap1.exists() && sitemap1.isFile());
113

  
114
			FileReader r = new FileReader(sitemap1);
115
			BufferedReader br = new BufferedReader(r);
116
			char[] buf = new char[1024];
117
			br.read(buf, 0, 1024);
118
			br.close();
119
			String doc = new String(buf);
120
			//debug("**** sitemap doc *** \n");
121
			//debug(doc);
115
			
116
			String doc = FileUtil.readFileToString(directoryName + FileUtil.getFS() + "metacat1.xml");
117
			debug("**** sitemap doc *** \n");
118
			debug(doc);
122 119
			assertTrue(doc.indexOf("<?xml") >= 0);
123 120
			assertTrue(doc.indexOf("<urlset") >= 0);
124 121
			assertTrue(doc.indexOf("<url>") >= 0);

Also available in: Unified diff