root / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src-test / org / gvsig / fmap / mapcontext / tools / persistence / FontPersistenceFactoryTest.java @ 32880
History | View | Annotate | Download (3.06 KB)
1 |
/* 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.Font; |
30 |
|
31 |
import org.easymock.MockControl; |
32 |
import org.gvsig.fmap.mapcontext.tools.persistence.FontPersistenceFactory; |
33 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
34 |
import org.gvsig.tools.persistence.PersistentState; |
35 |
|
36 |
/**
|
37 |
* Unit tests for the class {@link FontPersistenceFactory}.
|
38 |
*
|
39 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
|
40 |
*/
|
41 |
public class FontPersistenceFactoryTest extends AbstractLibraryAutoInitTestCase { |
42 |
|
43 |
private FontPersistenceFactory factory;
|
44 |
private MockControl stateControl;
|
45 |
private PersistentState state;
|
46 |
private Font font; |
47 |
|
48 |
protected void doSetUp() throws Exception { |
49 |
factory = new FontPersistenceFactory();
|
50 |
stateControl = MockControl.createNiceControl(PersistentState.class); |
51 |
state = (PersistentState) stateControl.getMock(); |
52 |
font = new Font("Arial", Font.BOLD, 18); |
53 |
} |
54 |
|
55 |
/**
|
56 |
* Test method for
|
57 |
* {@link org.gvsig.fmap.mapcontext.tools.persistence.FontPersistenceFactory#createFromState(org.gvsig.tools.persistence.PersistentState, java.lang.Class)}
|
58 |
* .
|
59 |
*/
|
60 |
public void testCreateFromState() throws Exception { |
61 |
stateControl.expectAndReturn(state |
62 |
.getString(FontPersistenceFactory.FIELD_NAME), font.getName()); |
63 |
stateControl.expectAndReturn(state |
64 |
.getInt(FontPersistenceFactory.FIELD_STYLE), font.getStyle()); |
65 |
stateControl.expectAndReturn(state |
66 |
.getInt(FontPersistenceFactory.FIELD_SIZE), font.getSize()); |
67 |
stateControl.replay(); |
68 |
|
69 |
Font newFont = (Font) factory.createFromState(state); |
70 |
assertTrue(newFont.equals(font)); |
71 |
|
72 |
stateControl.verify(); |
73 |
} |
74 |
|
75 |
/**
|
76 |
* Test method for
|
77 |
* {@link org.gvsig.fmap.mapcontext.tools.persistence.FontPersistenceFactory#saveToState(org.gvsig.tools.persistence.PersistentState, java.lang.Object)}
|
78 |
* .
|
79 |
*/
|
80 |
public void testSaveToState() throws Exception { |
81 |
state.set(FontPersistenceFactory.FIELD_NAME, font.getName()); |
82 |
state.set(FontPersistenceFactory.FIELD_STYLE, font.getStyle()); |
83 |
state.set(FontPersistenceFactory.FIELD_SIZE, font.getSize()); |
84 |
stateControl.replay(); |
85 |
|
86 |
factory.saveToState(state, font); |
87 |
|
88 |
stateControl.verify(); |
89 |
} |
90 |
|
91 |
} |