]>
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
2 * Copyright (C) 2007-2012 Mathieu Baudier
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.server
.jxl
.dao
;
18 import java
.util
.List
;
20 import junit
.framework
.TestCase
;
22 import org
.springframework
.core
.io
.ClassPathResource
;
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());
30 jsd
.getResources().add(new ClassPathResource("/dao/simple.xls"));
33 SimpleObject soAaa
= jsd
.getByKey(SimpleObject
.class, "aaa");
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());
41 SimpleObject soBbb
= jsd
.getByKey(SimpleObject
.class, "bbb");
42 assertNotNull(soBbb
.getOtherObject());
43 assertEquals("bbb", ((SimpleObject
) soBbb
.getOtherObject().getValue())
46 List
<SimpleObject
> simpleObjects
= jsd
.list(SimpleObject
.class, null);
47 assertEquals(4, simpleObjects
.size());
49 List
<CollectionsObject
> collectionsObjects
= jsd
.list(
50 CollectionsObject
.class, null);
51 assertEquals(4, collectionsObjects
.size());