Project

General

Profile

« Previous | Next » 

Revision 2917

Added by Matt Jones over 18 years ago

Some changes to the tests to use Logger rather than debugMessage().

View differences:

test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java
34 34
import junit.framework.TestCase;
35 35
import junit.framework.TestResult;
36 36
import junit.framework.TestSuite;
37
import org.apache.commons.logging.Log;
38
import org.apache.commons.logging.LogFactory;
37 39

  
38 40
import java.io.*;
39 41
import java.net.*;
......
47 49
{
48 50
  private String metacatURL=MetaCatUtil.getOption("junittesturl");
49 51
  private String serialNumber;
52
  private static final Log log = LogFactory.getLog("edu.ucsb.nceas.metacattest.MetaCatServletTest");
53
  
50 54
  /**
51 55
   * Constructor to build the test
52 56
   *
......
105 109
    //create random number for docid, so it can void repeat
106 110
    number = Math.random()*100000;
107 111
    serial = Integer.toString(((new Double(number)).intValue()));
108
    MetaCatUtil.debugMessage("serial: "+serial, 1);
112
    log.debug("serial: "+serial);
109 113
    suite.addTest(new MetaCatServletTest("testInsertXMLDocument", serial));
110 114
    suite.addTest(new MetaCatServletTest("testReadXMLDocumentXMLFormat", 
111 115
                                                        serial));
......
218 222
  {
219 223
    String name = "john"+MetaCatUtil.getOption("accNumSeparator")
220 224
                     +serialNumber+MetaCatUtil.getOption("accNumSeparator")+"1";
221
    MetaCatUtil.debugMessage("insert docid: "+name, 20);
225
    log.debug("insert docid: "+name);
222 226
    String content="<?xml version=\"1.0\"?>"
223 227
                   +"<!DOCTYPE acl PUBLIC \"-//ecoinformatics.org//"
224 228
                   +"eml-access-2.0.0beta6//EN\" \"http://pine.nceas.ucsb."
......
234 238
                   +"<permission>read</permission>"
235 239
                   +"</allow>"
236 240
                   +"</acl>";
237
     MetaCatUtil.debugMessage("xml document: "+content, 55);
241
    log.debug("xml document: "+content);
238 242
     assertTrue(handleXMLDocument(content, name, "insert"));
239 243
   
240 244
  }
......
247 251
  {
248 252
    String name = "john"+MetaCatUtil.getOption("accNumSeparator")
249 253
                     +serialNumber+MetaCatUtil.getOption("accNumSeparator")+"1";
250
    MetaCatUtil.debugMessage("insert docid: "+name, 20);
254
    log.debug("insert docid: "+name);
251 255
    String content="<?xml version=\"1.0\"?>"
252 256
                   +"<acl authSystem=\"knb\" order=\"allowFirst\">"
253 257
                   +"<identifier>"+name+"</identifier>"
......
260 264
                   +"<permission>read</permission>"
261 265
                   +"</allow>"
262 266
                   +"</acl>";
263
     MetaCatUtil.debugMessage("xml document: "+content, 55);
267
    log.debug("xml document: "+content);
264 268
     assertTrue(handleXMLDocument(content, name, "insert"));
265 269
  }
266 270
  
......
272 276
  {
273 277
    String name = "john"+MetaCatUtil.getOption("accNumSeparator")
274 278
                     +serialNumber+MetaCatUtil.getOption("accNumSeparator")+"1";
275
    MetaCatUtil.debugMessage("insert non well-formed docid: "+name, 20);
279
    log.debug("insert non well-formed docid: "+name);
276 280
    String content="<?xml version=\"1.0\"?>"
277 281
                   +"<acl authSystem=\"knb\" order=\"allowFirst\">"
278 282
                   +"<identifier>"+name+"</identifier>"
......
285 289
                   +"<permission>read</permission>"
286 290
                   +"</allow>";
287 291
  
288
     MetaCatUtil.debugMessage("xml document: "+content, 55);
292
    log.debug("xml document: "+content);
289 293
     assertTrue(!handleXMLDocument(content, name, "insert"));
290 294
  } 
291 295

  
......
330 334
  {
331 335
    String name = "john"+MetaCatUtil.getOption("accNumSeparator")
332 336
                     +serialNumber+MetaCatUtil.getOption("accNumSeparator")+"2";
333
    MetaCatUtil.debugMessage("update docid: "+name, 20);
337
    log.debug("update docid: "+name);
334 338
    String content="<?xml version=\"1.0\"?>"
335 339
                   +"<!DOCTYPE acl PUBLIC \"-//ecoinformatics.org//"
336 340
                   +"eml-access-2.0.0beta6//EN\" \"http://pine.nceas.ucsb."
......
346 350
                   +"<permission>read</permission>"
347 351
                   +"</allow>"
348 352
                   +"</acl>";
349
     MetaCatUtil.debugMessage("xml document: "+content, 55);
353
    log.debug("xml document: "+content);
350 354
     assertTrue(handleXMLDocument(content, name, "update"));
351 355
   
352 356
  }
......
358 362
  {
359 363
    String name = "john"+MetaCatUtil.getOption("accNumSeparator")
360 364
                     +serialNumber+MetaCatUtil.getOption("accNumSeparator")+"2";
361
    MetaCatUtil.debugMessage("delete docid: "+name, 20);
365
    log.debug("delete docid: "+name);
362 366
    assertTrue(handleDeleteFile(name));
363 367
   
364 368
  }
......
390 394

  
391 395
    // Now contact metacat
392 396
    String response = getMetacatString(prop);
393
    MetaCatUtil.debugMessage("Login Message: "+response, 55);
397
    log.debug("Login Message: "+response);
394 398
    boolean connected = false;
395 399
    if (response.indexOf("<login>") != -1) {
396 400
      connected = true;
......
417 421
    prop.put("qformat", "xml");
418 422
  
419 423
    String response = getMetacatString(prop);
420
     MetaCatUtil.debugMessage("Logout Message: "+response, 55);
424
    log.debug("Logout Message: "+response);
421 425
    HttpMessage.setCookie(null);
422 426
     
423 427
    if (response.indexOf("<logout>") != -1) 
......
448 452
    
449 453
    message = getMetacatString(prop);
450 454
    message = message.trim();
451
    //MetaCatUtil.debugMessage("Read Message: "+message, 30);
452 455
    if (message==null || message.equals("")||message.indexOf("<error>") != -1 )
453 456
    {//there was an error
454 457
      
......
484 487
    prop.put("docid", docid);
485 488
    
486 489
    String message = getMetacatString(prop);
487
    MetaCatUtil.debugMessage("Insert or Update Message: "+message, 55);
490
    log.debug("Insert or Update Message: "+message);
488 491
    if(message.indexOf("<error>") != -1)
489 492
    {//there was an error
490 493
      
......
512 515
    prop.put("docid", name);
513 516
 
514 517
    String message = getMetacatString(prop);
515
    MetaCatUtil.debugMessage("Delete Message: "+message, 55);
518
    log.debug("Delete Message: "+message);
516 519
    if(message.indexOf("<error>") != -1)
517 520
    {//there was an error
518 521
      
test/edu/ucsb/nceas/metacattest/SubTreeTest.java
33 33
import junit.framework.TestCase;
34 34
import junit.framework.TestResult;
35 35
import junit.framework.TestSuite;
36
import org.apache.commons.logging.Log;
37
import org.apache.commons.logging.LogFactory;
36 38

  
37 39
import java.io.*;
38 40
import java.net.*;
......
45 47
public class SubTreeTest extends TestCase
46 48
{
47 49
  private SubTree tree = null;
50
  private static final Log log = LogFactory.getLog("edu.ucsb.nceas.metacattest.ReplicationServerListTest");
48 51

  
49 52
  /**
50 53
   * Constructor to build the test
......
99 102
    }//try
100 103
    catch (Exception e)
101 104
    {
102
      MetaCatUtil.debugMessage("Error in ReplicationServerList() to get" +
103
                        " DBConnection pool"+e.getMessage(), 30);
105
        log.debug("Error in ReplicationServerList() to get" +
106
                        " DBConnection pool"+e.getMessage());
104 107
    }//catch
105 108

  
106 109
    TestSuite suite = new TestSuite();
......
121 124
    }//try
122 125
    catch (Exception e)
123 126
    {
124
      MetaCatUtil.debugMessage("Error in SubTreeTest.suite: "+
125
                                e.getMessage(), 10);
127
        log.debug("Error in SubTreeTest.suite: "+
128
                                e.getMessage());
126 129
    }//catch
127 130
    return suite;
128 131
 }
......
150 153
    }//try
151 154
    catch (Exception e)
152 155
    {
153
      MetaCatUtil.debugMessage("Error in SubTreeTest.suite: "+
154
                               e.getMessage(), 10);
156
        log.debug("Error in SubTreeTest.suite: "+ e.getMessage());
155 157
    }//catch
156 158

  
157 159
    while (!nodeStack.empty())
......
160 162
      String nodeType = node.getNodeType();
161 163
      if ( nodeType != null && nodeType.equals("ELEMENT"))
162 164
      {
163
        MetaCatUtil.debugMessage("Elment: "+ node.getNodeName(), 10);
165
          log.debug("Elment: "+ node.getNodeName());
164 166
      }
165 167
      else if (nodeType != null && nodeType.equals("ATTRIBUTE"))
166 168
      {
167
        MetaCatUtil.debugMessage("Attribute: "  +node.getNodeName() +
168
                                 " = " + node.getNodeData(), 10);
169
          log.debug("Attribute: "  +node.getNodeName() +
170
                                 " = " + node.getNodeData());
169 171
      }
170 172
      else
171 173
      {
172
        MetaCatUtil.debugMessage("text: " + node.getNodeData(), 10);
174
          log.debug("text: " + node.getNodeData());
173 175
      }
174 176
    }
175 177
    assertTrue(1 == 1);
176

  
177 178
  }
178

  
179

  
180
}//ReplicationServerListTest
179
}
test/edu/ucsb/nceas/metacattest/ReplicationServerListTest.java
33 33
import junit.framework.TestCase;
34 34
import junit.framework.TestResult;
35 35
import junit.framework.TestSuite;
36
import org.apache.commons.logging.Log;
37
import org.apache.commons.logging.LogFactory;
36 38

  
37 39
import java.io.*;
38 40
import java.net.*;
......
47 49
  private static String metacatReplicationURL=
48 50
                                   MetaCatUtil.getOption("junitreplicationurl");
49 51
  private ReplicationServerList serverList = null;
52
  private static final Log log = LogFactory.getLog("edu.ucsb.nceas.metacattest.ReplicationServerListTest");
53
  
50 54
  /**
51 55
   * Constructor to build the test
52 56
   *
......
100 104
    }//try
101 105
    catch (Exception e)
102 106
    {
103
      MetaCatUtil.debugMessage("Error in ReplicationServerList() to get" +
104
                        " DBConnection pool"+e.getMessage(), 30);
107
      log.debug("Error in ReplicationServerList() to get" +
108
                        " DBConnection pool"+e.getMessage());
105 109
    }//catch
106 110
    
107 111
    TestSuite suite = new TestSuite();
......
161 165
    }//try
162 166
    catch (Exception e)
163 167
    {
164
      MetaCatUtil.debugMessage("Error in ReplicationServerListTest.suite: "+
165
                                e.getMessage(), 10);
168
      log.debug("Error in ReplicationServerListTest.suite: "+
169
                                e.getMessage());
166 170
    }//catch
167 171
    
168 172
 

Also available in: Unified diff