]> 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
Add 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) 2010 Mathieu Baudier <mbaudier@argeo.org>
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
17 package org.argeo.server.jxl.dao;
18
19 import java.util.List;
20
21 import junit.framework.TestCase;
22
23 import org.springframework.core.io.ClassPathResource;
24
25 @SuppressWarnings("restriction")
26 public class JxlDaoSupportTest extends TestCase {
27 public void testBasic() throws Exception {
28 JxlDaoSupport jsd = new JxlDaoSupport();
29 jsd.getExternalRefs().put("test", new OtherObject());
30
31 jsd.getResources().add(new ClassPathResource("/dao/simple.xls"));
32 jsd.init();
33
34 SimpleObject soAaa = jsd.getByKey(SimpleObject.class, "aaa");
35 assertNotNull(soAaa);
36 assertEquals("aaa", soAaa.getString());
37 assertEquals(1, soAaa.getInteger().intValue());
38 assertNotNull(soAaa.getOtherObject());
39 assertEquals("USD", soAaa.getOtherObject().getKey());
40 assertEquals("US Dollar", soAaa.getOtherObject().getValue());
41
42 SimpleObject soBbb = jsd.getByKey(SimpleObject.class, "bbb");
43 assertNotNull(soBbb.getOtherObject());
44 assertEquals("bbb", ((SimpleObject) soBbb.getOtherObject().getValue())
45 .getString());
46
47 List<SimpleObject> simpleObjects = jsd.list(SimpleObject.class, null);
48 assertEquals(4, simpleObjects.size());
49
50 List<CollectionsObject> collectionsObjects = jsd.list(
51 CollectionsObject.class, null);
52 assertEquals(4, collectionsObjects.size());
53 }
54 }