Project

General

Profile

1 5394 berkley
/*  '$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 5568 berkley
package edu.ucsb.nceas.metacat.util;
26 5394 berkley
27
import java.util.*;
28
import java.io.*;
29
30
import java.security.MessageDigest;
31
32
import edu.ucsb.nceas.MCTestCase;
33
import edu.ucsb.nceas.metacat.IdentifierManager;
34
import edu.ucsb.nceas.metacat.client.MetacatAuthException;
35
import edu.ucsb.nceas.metacat.client.MetacatException;
36
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException;
37
import edu.ucsb.nceas.metacat.util.MetacatPopulator;
38
import edu.ucsb.nceas.metacat.dataone.CrudService;
39
import junit.framework.Test;
40
import junit.framework.TestSuite;
41
42
import org.apache.log.LogEvent;
43
import org.dataone.service.exceptions.InvalidRequest;
44
import org.dataone.service.exceptions.InvalidToken;
45
import org.dataone.service.exceptions.NotAuthorized;
46
import org.dataone.service.exceptions.NotImplemented;
47
import org.dataone.service.exceptions.ServiceFailure;
48
import org.dataone.service.types.*;
49
50
import edu.ucsb.nceas.metacat.properties.PropertyService;
51
import edu.ucsb.nceas.metacat.client.rest.MetacatRestClient;
52
53
import edu.ucsb.nceas.metacat.service.SessionService;
54
import edu.ucsb.nceas.metacat.util.SessionData;
55
56
/**
57
 * A JUnit test for testing the dataone MetacatPopulator class
58
 */
59
public class MetacatPopulatorTest extends MCTestCase
60
{
61
    /**
62
    * consstructor for the test
63
    */
64
    public MetacatPopulatorTest(String name)
65
    {
66
        super(name);
67
    }
68
69
    /**
70
     * Establish a testing framework by initializing appropriate objects
71
     */
72
    public void setUp() throws Exception
73
    {
74
        super.setUp();
75
    }
76
77
    /**
78
     * Release any objects after tests are complete
79
     */
80
    public void tearDown()
81
    {
82
    }
83
84
    /**
85
     * Create a suite of tests to be run together
86
     */
87
    public static Test suite()
88
    {
89
        TestSuite suite = new TestSuite();
90
        suite.addTest(new MetacatPopulatorTest("initialize"));
91
        suite.addTest(new MetacatPopulatorTest("testPopulate"));
92
93
        return suite;
94
    }
95
96
    public void testPopulate()
97
    {
98
        try
99
        {
100 5595 berkley
            //ids to upload to knb-mn:
101
            //connolly.301, kgordon.17.27
102 5394 berkley
            MetacatPopulator mp = new MetacatPopulator(
103
                    "http://knb.ecoinformatics.org/knb",
104 5595 berkley
                    /*"http://localhost:8080/knb"*/
105
                    "http://knb-mn.ecoinformatics.org/knb",
106
                    /*"msucci"*/"connolly.301", "uid=kepler,o=unaffiliated,dc=ecoinformatics,dc=org", "kepler");
107 5394 berkley
            mp.populate();
108
        }
109
        catch(Exception e)
110
        {
111
            e.printStackTrace();
112
            fail("Error: " + e.getMessage());
113
        }
114
    }
115
116
    /**
117
     * init
118
     */
119
    public void initialize()
120
    {
121
        assertTrue(1==1);
122
    }
123
}