geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r517176 - in /geronimo/xbean/trunk/xbean-spring/src/test: java/org/apache/xbean/spring/context/FlatMapTest.java java/org/apache/xbean/spring/example/FlatMapService.java resources/org/apache/xbean/spring/context/flatmap-xbean.xml
Date Mon, 12 Mar 2007 11:16:24 GMT
Author: gnodet
Date: Mon Mar 12 04:16:24 2007
New Revision: 517176

URL: http://svn.apache.org/viewvc?view=rev&rev=517176
Log:
XBEAN-82: Support flat maps, dups policies and default keys

Added:
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FlatMapTest.java
  (with props)
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/FlatMapService.java
  (with props)
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/flatmap-xbean.xml
  (with props)

Added: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FlatMapTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FlatMapTest.java?view=auto&rev=517176
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FlatMapTest.java
(added)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FlatMapTest.java
Mon Mar 12 04:16:24 2007
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xbean.spring.context;
+
+import java.util.List;
+
+import org.apache.xbean.spring.example.FlatMapService;
+import org.apache.xbean.spring.example.KegService;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+/**
+ * @author gnodet
+ */
+public class FlatMapTest extends SpringTestSupport {
+
+    public void testFlatMap() {
+        FlatMapService fm = (FlatMapService) getBean("flat-map");
+        assertEquals(3, fm.getServices().size());
+        Object obj = fm.getServices().get("key1");
+        assertTrue(obj instanceof List);
+        List l = (List) obj;
+        assertEquals(2, l.size());
+        System.out.println(l.get(0).getClass());
+        assertTrue(l.get(0) instanceof KegService);
+        System.out.println(l.get(1).getClass());
+        assertTrue(l.get(1) instanceof KegService);
+        obj = fm.getServices().get("key2");
+        assertTrue(obj instanceof List);
+        l = (List) obj;
+        assertEquals(1, l.size());
+        System.out.println(l.get(0).getClass());
+        assertTrue(l.get(0) instanceof KegService);
+        obj = fm.getServices().get("others");
+        assertTrue(obj instanceof List);
+        l = (List) obj;
+        assertEquals(1, l.size());
+        System.out.println(l.get(0).getClass());
+        assertTrue(l.get(0) instanceof KegService);
+    }
+    
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/xbean/spring/context/flatmap-xbean.xml");
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FlatMapTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FlatMapTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FlatMapTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/FlatMapService.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/FlatMapService.java?view=auto&rev=517176
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/FlatMapService.java
(added)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/FlatMapService.java
Mon Mar 12 04:16:24 2007
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xbean.spring.example;
+
+import java.util.Map;
+
+/**
+ * @org.apache.xbean.XBean element="flat-map"
+ * @author gnodet
+ */
+public class FlatMapService {
+
+    private Map services;
+
+    /**
+     * @org.apache.xbean.Map flat="true" dups="always" keyName="id" defaultKey="others"
+     */
+    public Map getServices() {
+        return services;
+    }
+
+    public void setServices(Map services) {
+        this.services = services;
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/FlatMapService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/FlatMapService.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/FlatMapService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/flatmap-xbean.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/flatmap-xbean.xml?view=auto&rev=517176
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/flatmap-xbean.xml
(added)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/flatmap-xbean.xml
Mon Mar 12 04:16:24 2007
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<!-- START SNIPPET: xml -->
+<beans xmlns:b="http://xbean.apache.org/schemas/pizza" xmlns:s="http://xbean.apache.org/schemas/spring/1.0">
+
+  <b:flat-map s:id="flat-map">
+    <b:services>
+      <b:keg id="key1" remaining="1000 ml"/>
+      <b:keg id="key1" remaining="5 pints"/>
+      <b:keg id="key2" remaining="20 liter"/>
+      <b:keg remaining="0"/>
+    </b:services>
+  </b:flat-map>
+
+</beans>
+<!-- END SNIPPET: xml -->
+

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/flatmap-xbean.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/flatmap-xbean.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message