Project

General

Profile

« Previous | Next » 

Revision 4127

Added by daigle almost 16 years ago

Replace Options class with PropertyService and create PropertyService using log directory name instead of servlet context

View differences:

BuildIndexTest.java
24 24

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

  
27
import java.io.File;
28
import java.io.FileNotFoundException;
29 27
import java.io.FileReader;
30 28
import java.io.IOException;
31 29
import java.io.Reader;
......
45 43
import edu.ucsb.nceas.metacat.client.MetacatFactory;
46 44
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException;
47 45
import edu.ucsb.nceas.metacat.service.PropertyService;
46
import edu.ucsb.nceas.metacat.service.ServiceException;
48 47
import edu.ucsb.nceas.metacat.util.MetaCatUtil;
49
import edu.ucsb.nceas.metacat.util.SystemUtil;
50 48
import edu.ucsb.nceas.utilities.IOUtil;
51
import edu.ucsb.nceas.utilities.Options;
52 49
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
53 50
import junit.framework.Test;
54 51
import junit.framework.TestCase;
......
60 57
public class BuildIndexTest extends TestCase
61 58
{
62 59
    private static String metacatUrl;
63
    private static String propertyFileName;
64 60
    private static String username;
65 61
	private static String password;
66
	private static String anotheruser;
67
	private static String anotherpassword;
68 62
	static {
69 63
		try {
70
		    metacatUrl = SystemUtil.getServletURL();
71
		    propertyFileName = SystemUtil.getContextDir()
72
			+ "/WEB-INF/metacat.properties";
73
			username = PropertyService.getProperty("mcuser");
74
			password = PropertyService.getProperty("mcpassword");
64
			PropertyService.getInstance("build/tests");
65
		    metacatUrl = PropertyService.getProperty("test.metacat.url");
66
			username = PropertyService.getProperty("test.mcuser");
67
			password = PropertyService.getProperty("test.mcpassword");
75 68
		} catch (PropertyNotFoundException pnfe) {
76 69
			System.err.println("Could not get property in static block: " 
77 70
					+ pnfe.getMessage());
71
		} catch (ServiceException se) {
72
			System.err.println("Could not get PropertyService instance in static block: " 
73
					+ se.getMessage());
78 74
		}
79 75
	}
80 76

  
......
83 79
	private String testfile = "test/eml-sample.xml";
84 80
	private String testdocument = "";
85 81
	private Metacat m;
86
    /* Initialize Options */
82
    /* Initialize properties */
87 83
    static
88 84
    {
89 85
  	  try
90 86
  	  {
91
  		  Options.initialize(new File("build/tests/metacat.properties"));
87
  		  PropertyService.getInstance("build/tests");
92 88
  		  MetaCatUtil.pathsForIndexing 
93 89
  		         = MetaCatUtil.getOptionList(PropertyService.getProperty("indexPaths"));
94 90
  	  }
......
115 111
    public void setUp()
116 112
    {
117 113
        try {
118
            File propertyFile = new File(propertyFileName);
119
            Options options = Options.initialize(propertyFile);
120
            metacatUrl = SystemUtil.getServletURL();
121
        } catch (FileNotFoundException e) {
122
            fail(e.getMessage());
123
        } catch (IOException e) {
124
            fail(e.getMessage());
114
        	PropertyService.getInstance("build/tests");
115
            metacatUrl = PropertyService.getProperty("test.metacat.url");
116
        } catch (ServiceException se) {
117
            fail(se.getMessage());
125 118
        } catch (PropertyNotFoundException pnfe) {
126 119
        	fail (pnfe.getMessage());
127 120
        }

Also available in: Unified diff