Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libMetadata / src-test / simple / SimpleMetadataTest.java @ 21170

History | View | Annotate | Download (3.46 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 Geographic Information research group: http://www.geoinfo.uji.es
26
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
27
* Universitat Jaume I   
28
* {{Task}}
29
*/
30
 
31
package simple;
32

    
33
import java.util.Date;
34

    
35
import junit.framework.TestCase;
36

    
37
import org.gvsig.metadata.Metadata;
38
import org.gvsig.metadata.exceptions.NamedMetadataNotFoundException;
39
import org.gvsig.metadata.simple.SimpleMetadata;
40

    
41
public class SimpleMetadataTest extends TestCase{
42

    
43
        //@BeforeClass
44
        public static void setUpBeforeClass() throws Exception {
45
        }
46

    
47
        //@AfterClass
48
        public static void tearDownAfterClass() throws Exception {
49
        }
50

    
51
        //@Before
52
        public void setUp() throws Exception {
53
        }
54

    
55
        //@After
56
        public void tearDown() throws Exception {
57
        }
58

    
59

    
60
        //@Test
61
        public void testGet() throws NamedMetadataNotFoundException {
62
                Metadata md = new SimpleMetadata("prueba");
63
                md.set("Author", "Alejandro Llaves");
64
                assertEquals("Alejandro Llaves", md.get("Author"));
65
        }
66

    
67
        public void testGetBoolean() throws ClassCastException, NamedMetadataNotFoundException {
68
                Metadata md = new SimpleMetadata("prueba");
69
                md.setBoolean("Available", true);
70
                assertEquals(true, md.getBoolean("Available"));
71
        }
72
        
73
        public void testGetDouble() throws ClassCastException, NamedMetadataNotFoundException {
74
                Metadata md = new SimpleMetadata("prueba");
75
                md.setDouble("Area", (double) 500);
76
                assertEquals((double) 500, md.getDouble("Area"), 0);
77
        }
78
        
79
        public void testGetInt() throws ClassCastException, NamedMetadataNotFoundException {
80
                Metadata md = new SimpleMetadata("prueba");
81
                md.setInt("Number", 5);
82
                assertEquals(5, md.getInt("Number"));
83
        }
84
        
85
        public void testGetString() throws ClassCastException, NamedMetadataNotFoundException {
86
                Metadata md = new SimpleMetadata("prueba");
87
                md.setString("Author", "Alejandro Llaves");
88
                assertEquals("Alejandro Llaves", md.getString("Author"));
89
        }
90
        
91
        public void testGetDate() throws ClassCastException, NamedMetadataNotFoundException {
92
                Metadata md = new SimpleMetadata("prueba");
93
                md.setDate("Date", new Date(0L));
94
                assertEquals(new Date(0l), md.getDate("Date"));
95
        }
96

    
97
        //@Test
98
        public void testHasValue() {
99
                SimpleMetadata md = new SimpleMetadata("prueba");
100
                assertEquals(md.hasValue("Author"), false);
101
                md.set("Author", "Alejandro Llaves");
102
                assertEquals(md.hasValue("Author"), true);
103
        }
104

    
105
        //@Test
106
        public void testIsEmpty() {
107
                SimpleMetadata md = new SimpleMetadata("prueba");
108
                assertEquals(md.isEmpty(), true);
109
                md.set("Author", "Alejandro Llaves");
110
                assertEquals(md.isEmpty(), false);
111
        }
112

    
113
}