geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r689356 - in /geronimo/xbean/trunk/xbean-spring/src/test: java/org/apache/xbean/spring/context/ java/org/apache/xbean/spring/example/ resources/org/apache/xbean/spring/context/
Date Wed, 27 Aug 2008 04:44:29 GMT
Author: dain
Date: Tue Aug 26 21:44:27 2008
New Revision: 689356

URL: http://svn.apache.org/viewvc?rev=689356&view=rev
Log:
SocketAddress factory example for Alex

Added:
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SocketAddressSpringTest.java
      - copied, changed from r648017, geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SoupUsingSpringTest.java
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SocketAddressXBeanTest.java
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/SocketAddressFactory.java
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/SocketService.java
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/socket-address-normal.xml
      - copied, changed from r648017, geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/soup-normal.xml
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/socket-address.xml
      - copied, changed from r648017, geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/soup-xbean.xml

Copied: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SocketAddressSpringTest.java
(from r648017, geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SoupUsingSpringTest.java)
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SocketAddressSpringTest.java?p2=geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SocketAddressSpringTest.java&p1=geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SoupUsingSpringTest.java&r1=648017&r2=689356&rev=689356&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SoupUsingSpringTest.java
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SocketAddressSpringTest.java
Tue Aug 26 21:44:27 2008
@@ -16,39 +16,49 @@
  */
 package org.apache.xbean.spring.context;
 
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.xbean.spring.example.SocketService;
 import org.springframework.context.support.AbstractXmlApplicationContext;
-import org.apache.xbean.spring.example.SoupService;
 
 /**
  * @author Dain Sundstrom
  * @version $Id$
  * @since 1.0
  */
-public class SoupUsingSpringTest extends SpringTestSupport {
-    private static final long time = System.currentTimeMillis();
+public class SocketAddressSpringTest extends SpringTestSupport {
+
+    public void testSocketService() throws Exception {
+        SocketService socketService = (SocketService) getBean("socketService");
+
+//        System.out.println();
+//        System.out.println("===========================");
+//        System.out.println(socketService.getAddresses());
+//        System.out.println("===========================");
+//        System.out.println();
+
+        List<InetSocketAddress> expected = Arrays.asList(new InetSocketAddress("localhost",
42), new InetSocketAddress("localhost", 42));
+
+        assertEquals(expected, socketService.getAddresses());
 
-    public void testSoup() throws Exception {
-        SoupService soup = (SoupService) getBean("soupService");
-        SoupService nestedBean = (SoupService) getBean("nestedBean");
-        SoupService nestedValue = (SoupService) getBean("nestedValue");
-
-        asssertValidSoup(soup);
-        asssertValidSoup(nestedBean);
-        asssertValidSoup(nestedValue);
-
-        context.close();
-        assertFalse(soup.exists());
-        assertFalse(nestedBean.exists());
-        assertFalse(nestedValue.exists());
     }
 
-    private void asssertValidSoup(SoupService soup) {
-        assertEquals("type", "French Onion", soup.getSoupType());
-        assertTrue(soup.getCreateTime() >= time);
-        assertTrue(soup.exists());
+    public void testSocketAddress() throws Exception {
+        SocketAddress socketAddress = (SocketAddress) getBean("socketAddress");
+
+//        System.out.println();
+//        System.out.println("===========================");
+//        System.out.println(socketAddress);
+//        System.out.println("===========================");
+//        System.out.println();
+
+        assertEquals(new InetSocketAddress("localhost", 42), socketAddress);
     }
 
     protected AbstractXmlApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/xbean/spring/context/soup-normal.xml");
+        return new ClassPathXmlApplicationContext("org/apache/xbean/spring/context/socket-address-normal.xml");
     }
-}
+}
\ No newline at end of file

Added: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SocketAddressXBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SocketAddressXBeanTest.java?rev=689356&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SocketAddressXBeanTest.java
(added)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/SocketAddressXBeanTest.java
Tue Aug 26 21:44:27 2008
@@ -0,0 +1,38 @@
+/**
+ * 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.net.SocketAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Arrays;
+
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.apache.xbean.spring.example.SoupService;
+import org.apache.xbean.spring.example.SocketService;
+
+/**
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 1.0
+ */
+public class SocketAddressXBeanTest extends SocketAddressSpringTest {
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/xbean/spring/context/socket-address.xml");
+    }
+}
\ No newline at end of file

Added: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/SocketAddressFactory.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/SocketAddressFactory.java?rev=689356&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/SocketAddressFactory.java
(added)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/SocketAddressFactory.java
Tue Aug 26 21:44:27 2008
@@ -0,0 +1,33 @@
+/**
+ *
+ * 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.net.SocketAddress;
+import java.net.InetSocketAddress;
+
+/**
+ * @org.apache.xbean.XBean element="socketAddress" contentProperty="value"
+ */
+public class SocketAddressFactory {
+    /**
+     * @org.apache.xbean.FactoryMethod
+     */
+    public static SocketAddress create(String value) {
+        return new InetSocketAddress(value, 42);
+    }
+}

Added: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/SocketService.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/SocketService.java?rev=689356&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/SocketService.java
(added)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/example/SocketService.java
Tue Aug 26 21:44:27 2008
@@ -0,0 +1,36 @@
+/**
+ *
+ * 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.net.SocketAddress;
+import java.util.List;
+
+/**
+ * @org.apache.xbean.XBean element="socketService"
+ */
+public class SocketService {
+    private List<SocketAddress> addresses;
+
+    public List<SocketAddress> getAddresses() {
+        return addresses;
+    }
+
+    public void setAddresses(List<SocketAddress> addresses) {
+        this.addresses = addresses;
+    }
+}

Copied: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/socket-address-normal.xml
(from r648017, geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/soup-normal.xml)
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/socket-address-normal.xml?p2=geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/socket-address-normal.xml&p1=geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/soup-normal.xml&r1=648017&r2=689356&rev=689356&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/soup-normal.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/socket-address-normal.xml
Tue Aug 26 21:44:27 2008
@@ -20,12 +20,22 @@
 <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
 <beans>
 
-  <bean id="soupService" name="nestedBean, nestedValue" class="org.apache.xbean.spring.example.SoupService"
-    init-method="make"
-    destroy-method="eat"
-    factory-method="newSoup"
-    >
-    <constructor-arg index="0" value="French Onion"/>
-  </bean>
+    <bean id="socketAddress" class="org.apache.xbean.spring.example.SocketAddressFactory"
factory-method="create">
+        <constructor-arg index="0" value="localhost"/>
+    </bean>
+
+    <bean id="socketService" class="org.apache.xbean.spring.example.SocketService">
+        <property name="addresses">
+            <list>
+                <bean class="org.apache.xbean.spring.example.SocketAddressFactory" factory-method="create">
+                    <constructor-arg index="0" value="localhost"/>
+                </bean>
+                <bean class="org.apache.xbean.spring.example.SocketAddressFactory" factory-method="create">
+                    <constructor-arg index="0" value="localhost"/>
+                </bean>
+            </list>
+        </property>
+    </bean>
+
 
 </beans>

Copied: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/socket-address.xml
(from r648017, geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/soup-xbean.xml)
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/socket-address.xml?p2=geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/socket-address.xml&p1=geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/soup-xbean.xml&r1=648017&r2=689356&rev=689356&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/soup-xbean.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/socket-address.xml
Tue Aug 26 21:44:27 2008
@@ -18,23 +18,15 @@
 
 -->
 <!-- START SNIPPET: xml -->
-<beans xmlns:s="http://xbean.apache.org/schemas/soup">
+<beans xmlns:b="http://xbean.apache.org/schemas/pizza">
+    <b:socketAddress id="socketAddress">localhost</b:socketAddress>
 
-  <s:soup id="soupService" type="French Onion"/>
-
-  <s:soup id="nestedBean">
-    <s:type>
-      <bean class="java.lang.String">
-        <constructor-arg index="0" value="French Onion"/>
-      </bean>
-    </s:type>
-  </s:soup>
-
-  <s:soup id="nestedValue">
-    <s:type>
-      <value>French Onion</value>
-    </s:type>
-  </s:soup>
+    <b:socketService id="socketService">
+        <addresses>
+            <b:socketAddress>localhost</b:socketAddress>
+            <b:socketAddress>localhost</b:socketAddress>
+        </addresses>
+    </b:socketService>
 </beans>
 <!-- END SNIPPET: xml -->
 



Mime
View raw message