Project

General

Profile

1
/*  '$RCSfile$'
2
 *  Copyright: 2010 Regents of the University of California and the
3
 *              National Center for Ecological Analysis and Synthesis
4
 *  Purpose: To test the Access Controls in metacat by JUnit
5
 *
6
 *   '$Author: berkley $'
7
 *     '$Date: 2010-05-03 14:26:08 -0700 (Fri, 14 Aug 2009) $'
8
 * '$Revision: 5027 $'
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 */
24

    
25
package edu.ucsb.nceas.metacat.dataone;
26

    
27
import junit.framework.Test;
28
import junit.framework.TestSuite;
29

    
30
import org.dataone.client.ObjectFormatCache;
31
import org.dataone.service.exceptions.NotFound;
32
import org.dataone.service.types.v1.ObjectFormat;
33

    
34
import edu.ucsb.nceas.MCTestCase;
35

    
36
/**
37
 * A JUnit test for testing the dataone MetadataTypeRegister class
38
 */
39
public class MetadataTypeRegisterTest extends MCTestCase 
40
{   
41
    private int createCount = 0;
42
    
43
    /**
44
    * consstructor for the test
45
    */
46
    public MetadataTypeRegisterTest(String name)
47
    {
48
        super(name);
49
    }
50
  
51
    /**
52
     * Establish a testing framework by initializing appropriate objects
53
     */
54
    public void setUp() throws Exception 
55
    {
56
        super.setUp();
57
    }
58

    
59
    /**
60
     * Release any objects after tests are complete
61
     */
62
    public void tearDown() 
63
    {
64
        System.out.println(createCount + " docs created in this test session.");
65
    }
66

    
67
    /**
68
     * Create a suite of tests to be run together
69
     */
70
    public static Test suite() 
71
    {
72
        TestSuite suite = new TestSuite();
73
        suite.addTest(new MetadataTypeRegisterTest("testIsMetadataType"));
74
        return suite;
75
    }
76
    
77
    /**
78
     * MetadataTypeRegister.isMetadataType()
79
     */
80
    public void testIsMetadataType()
81
    {
82
      ObjectFormat of = null;
83
      try {
84
	        of = ObjectFormatCache.getInstance().getFormat("XXXX");
85
              
86
      } catch (NotFound e) {
87
        assertFalse(MetadataTypeRegister.isMetadataType(of));
88
      
89
      }
90
      
91
      try {
92
	      
93
      	of = ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.0.0");
94
	      assertTrue(MetadataTypeRegister.isMetadataType(of));
95
	      
96
	      of = ObjectFormatCache.getInstance().getFormat("http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2");
97
	      assertTrue(MetadataTypeRegister.isMetadataType(of));
98
	      
99
	      of = ObjectFormatCache.getInstance().getFormat("CF-1.3");
100
	      assertTrue(MetadataTypeRegister.isMetadataType(of));
101
	      
102
	      of = ObjectFormatCache.getInstance().getFormat("http://www.loc.gov/METS/");
103
	      assertTrue(MetadataTypeRegister.isMetadataType(of));
104
	      
105
	      of = ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-3.0.0");
106
	      assertFalse(MetadataTypeRegister.isMetadataType(of));
107
      
108
      } catch (NotFound e) {
109
      	e.printStackTrace();
110
      	
111
      }
112

    
113
    }
114
}
(4-4/6)