Project

General

Profile

« Previous | Next » 

Revision 2306

Added by Matt Jones about 20 years ago

Updated the build index test.

View differences:

test/edu/ucsb/nceas/metacattest/BuildIndexTest.java
30 30
import java.io.IOException;
31 31
import java.io.Reader;
32 32
import java.io.StringReader;
33
import java.sql.SQLException;
34 33
import java.util.Calendar;
35 34
import java.util.Date;
36 35
import java.util.GregorianCalendar;
37 36
import java.util.SimpleTimeZone;
38 37
import java.util.TimeZone;
39 38

  
40
import edu.ucsb.nceas.metacat.DBConnection;
41
import edu.ucsb.nceas.metacat.DBConnectionPool;
42 39
import edu.ucsb.nceas.metacat.DocumentImpl;
43 40
import edu.ucsb.nceas.metacat.MetaCatUtil;
44 41
import edu.ucsb.nceas.metacat.McdbException;
......
98 95
                "/usr/local/devtools/jakarta-tomcat/webapps/knb/WEB-INF/metacat.properties");
99 96
            Options options = Options.initialize(propertyFile);
100 97
            util = new MetaCatUtil();
98
            metacatUrl = MetaCatUtil.getOption("junittesturl");
101 99
        } catch (FileNotFoundException e) {
102 100
            fail(e.getMessage());
103 101
        } catch (IOException e) {
......
126 124
    {
127 125
      TestSuite suite = new TestSuite();
128 126
        suite.addTest(new BuildIndexTest("initialize"));
129
        //suite.addTest(new BuildIndexTest("read"));
130
        suite.addTest(new BuildIndexTest("buildIndex"));
127
        suite.addTest(new BuildIndexTest("read"));
128
        //suite.addTest(new BuildIndexTest("buildIndex"));
131 129
        return suite;
132 130
    }
133 131

  
......
179 177
    public void buildIndex()
180 178
    {
181 179
        DocumentImpl d = null;
182
        DBConnection dbconn = null;
183
        int serialNumber = -1;
184 180
        try {
185
            mark(MetaCatUtil.getOption("dbAdapter"));
186
            dbconn = DBConnectionPool.getDBConnection(
187
                "BuildIndexTest.buildIndex");
188
            serialNumber = dbconn.getCheckOutSerialNumber();
189
        
190 181
            //d = new DocumentImpl(newdocid+".1", false);
191 182
            d = new DocumentImpl("test.2004236121212.1", false);
192 183
            d.buildIndex();
193
            dbconn.close();
194 184
        } catch (McdbException me) {
195 185
            System.err.println("Caught McdbException (1): " + me.getMessage());
196
        } catch (SQLException se) {
197
            System.err.println("Caught SQLException: " + se.getMessage());
198
        } finally {
199
            // Return db connection
200
            DBConnectionPool.returnDBConnection(dbconn, serialNumber);
201 186
        }
202 187
    }
203 188

  
204
    private void mark(String marker) {
205
        System.err.println("MARKER: " + marker);
206
    }
207

  
208 189
    /**
209 190
     * Create a hopefully unique docid for testing insert and update. Does
210 191
     * not include the 'revision' part of the id.

Also available in: Unified diff