]> git.argeo.org Git - lgpl/argeo-commons.git/blob - server/runtime/org.argeo.server.jxl/src/test/java/org/argeo/server/jxl/dao/JxlDaoSupportTest.java
Update license headers
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.jxl / src / test / java / org / argeo / server / jxl / dao / JxlDaoSupportTest.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.server.jxl.dao;
17
18 import java.util.List;
19
20 import junit.framework.TestCase;
21
22 import org.springframework.core.io.ClassPathResource;
23
24 @SuppressWarnings("restriction")
25 public class JxlDaoSupportTest extends TestCase {
26 public void testBasic() throws Exception {
27 JxlDaoSupport jsd = new JxlDaoSupport();
28 jsd.getExternalRefs().put("test", new OtherObject());
29
30 jsd.getResources().add(new ClassPathResource("/dao/simple.xls"));
31 jsd.init();
32
33 SimpleObject soAaa = jsd.getByKey(SimpleObject.class, "aaa");
34 assertNotNull(soAaa);
35 assertEquals("aaa", soAaa.getString());
36 assertEquals(1, soAaa.getInteger().intValue());
37 assertNotNull(soAaa.getOtherObject());
38 assertEquals("USD", soAaa.getOtherObject().getKey());
39 assertEquals("US Dollar", soAaa.getOtherObject().getValue());
40
41 SimpleObject soBbb = jsd.getByKey(SimpleObject.class, "bbb");
42 assertNotNull(soBbb.getOtherObject());
43 assertEquals("bbb", ((SimpleObject) soBbb.getOtherObject().getValue())
44 .getString());
45
46 List<SimpleObject> simpleObjects = jsd.list(SimpleObject.class, null);
47 assertEquals(4, simpleObjects.size());
48
49 List<CollectionsObject> collectionsObjects = jsd.list(
50 CollectionsObject.class, null);
51 assertEquals(4, collectionsObjects.size());
52 }
53 }