Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2011 / libraries / libFMap_mapcontext / src-test / org / gvsig / fmap / mapcontext / tools / persistence / DimensionPersistenceFactoryTest.java @ 33562

History | View | Annotate | Download (3.14 KB)

1 33349 cordinyana
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (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
 * 2009 {}  {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext.tools.persistence;
28
29
import java.awt.Dimension;
30
31
import org.easymock.MockControl;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
34
import org.gvsig.tools.persistence.PersistenceManager;
35
import org.gvsig.tools.persistence.PersistentState;
36
37
/**
38
 * Unit tests for the class {@link DimensionPersistenceFactory}.
39
 *
40
 * @author gvSIG team
41
 */
42
public class DimensionPersistenceFactoryTest extends
43
                AbstractLibraryAutoInitTestCase {
44
45
        private DimensionPersistenceFactory factory;
46
        private MockControl stateControl;
47
        private PersistentState state;
48
        private Dimension dimension;
49
50
        protected void doSetUp() throws Exception {
51
                PersistenceManager persistenceManager = ToolsLocator
52
                                .getPersistenceManager();
53
                factory = (DimensionPersistenceFactory) persistenceManager
54
                                .getFactories().get(Dimension.class);
55
                stateControl = MockControl.createNiceControl(PersistentState.class);
56
                state = (PersistentState) stateControl.getMock();
57
                dimension = new Dimension(320, 200);
58
        }
59
60
        /**
61
         * Test method for
62
         * {@link org.gvsig.fmap.mapcontext.tools.persistence.DimensionPersistenceFactory#createFromState(org.gvsig.tools.persistence.PersistentState, java.lang.Class)}
63
         * .
64
         */
65
        public void testCreateFromState() throws Exception {
66
                stateControl.expectAndReturn(state
67
                                .getDouble(DimensionPersistenceFactory.FIELD_WIDTH), dimension
68
                                .getWidth());
69
                stateControl.expectAndReturn(state
70
                                .getDouble(DimensionPersistenceFactory.FIELD_HEIGHT), dimension
71
                                .getHeight());
72
                stateControl.replay();
73
74
                Dimension newDimension = (Dimension) factory.createFromState(state);
75
                assertTrue(newDimension.equals(dimension));
76
77
                stateControl.verify();
78
        }
79
80
        /**
81
         * Test method for
82
         * {@link org.gvsig.fmap.mapcontext.tools.persistence.DimensionPersistenceFactory#saveToState(org.gvsig.tools.persistence.PersistentState, java.lang.Object)}
83
         * .
84
         */
85
        public void testSaveToState() throws Exception {
86
                state
87
                                .set(DimensionPersistenceFactory.FIELD_WIDTH, dimension
88
                                                .getWidth());
89
                state.set(DimensionPersistenceFactory.FIELD_HEIGHT, dimension
90
                                .getHeight());
91
                stateControl.replay();
92
93
                factory.saveToState(state, dimension);
94
95
                stateControl.verify();
96
        }
97
98
}