- Moved the AMFConnectionTest and AMFDataTypeTest to the Integration-Tests as 
they are per definition Integration-Tests
- Changed the tests to start a server only once and keep it open during the 
entire suite (Hereby causing far less open sockets and hopefully a lot less 
unstable builds)


Project: http://git-wip-us.apache.org/repos/asf/flex-blazeds/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-blazeds/commit/025e11cd
Tree: http://git-wip-us.apache.org/repos/asf/flex-blazeds/tree/025e11cd
Diff: http://git-wip-us.apache.org/repos/asf/flex-blazeds/diff/025e11cd

Branch: refs/heads/develop
Commit: 025e11cdbafbde57efb6d8ab5e822c2fd4c3e5d8
Parents: a57a08f
Author: Christofer Dutz <[email protected]>
Authored: Wed Jun 29 13:41:39 2016 +0200
Committer: Christofer Dutz <[email protected]>
Committed: Wed Jun 29 13:41:39 2016 +0200

----------------------------------------------------------------------
 pom.xml                                         |  29 +-
 testsuite/pom.xml                               | 116 +--
 .../test/java/amfclient/ClientCustomType.java   |   2 +-
 .../io/amf/client/AMFConnectionIT.java          | 781 ++++++++++++++++++
 .../io/amf/client/AMFConnectionTest.java        | 787 -------------------
 .../messaging/io/amf/client/AMFDataTypeIT.java  | 482 ++++++++++++
 .../io/amf/client/AMFDataTypeTest.java          | 486 ------------
 .../resources/WEB-INF/flex/remoting-config.xml  |   2 +-
 8 files changed, 1344 insertions(+), 1341 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/025e11cd/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5570784..d4c5528 100755
--- a/pom.xml
+++ b/pom.xml
@@ -89,14 +89,27 @@
                                </configuration>
                        </plugin>
 
-            <!-- Turned off till the JavaDoc tags are all correctly set -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-javadoc-plugin</artifactId>
-                <configuration>
-                    <skip>true</skip>
-                </configuration>
-            </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-failsafe-plugin</artifactId>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       
<goal>integration-test</goal>
+                                                       <goal>verify</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
+                       <!-- Turned off till the JavaDoc tags are all correctly 
set -->
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-javadoc-plugin</artifactId>
+                               <configuration>
+                                       <skip>true</skip>
+                               </configuration>
+                       </plugin>
 
                        <!-- Plugin to detect problems with JDK 
incompatabilities -->
                        <plugin>

http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/025e11cd/testsuite/pom.xml
----------------------------------------------------------------------
diff --git a/testsuite/pom.xml b/testsuite/pom.xml
index 5c1eb72..c45d786 100644
--- a/testsuite/pom.xml
+++ b/testsuite/pom.xml
@@ -17,68 +17,68 @@ limitations under the License.
 
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
-       <modelVersion>4.0.0</modelVersion>
+  <modelVersion>4.0.0</modelVersion>
 
-       <parent>
-        <groupId>org.apache.flex.blazeds</groupId>
-               <artifactId>blazeds</artifactId>
-               <version>4.7.3-SNAPSHOT</version>
-               <relativePath>../pom.xml</relativePath>
-       </parent>
+  <parent>
+    <groupId>org.apache.flex.blazeds</groupId>
+    <artifactId>blazeds</artifactId>
+    <version>4.7.3-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
 
-       <artifactId>flex-messaging-testsuite</artifactId>
+  <artifactId>flex-messaging-testsuite</artifactId>
 
-       <dependencies>
-               <dependency>
-            <groupId>org.apache.flex.blazeds</groupId>
-                       <artifactId>flex-messaging-core</artifactId>
-                       <version>${project.version}</version>
-            <scope>test</scope>
-               </dependency>
-        <dependency>
-            <groupId>org.apache.flex.blazeds</groupId>
-            <artifactId>flex-messaging-proxy</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.flex.blazeds</groupId>
-            <artifactId>flex-messaging-remoting</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.flex.blazeds</groupId>
+      <artifactId>flex-messaging-core</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.flex.blazeds</groupId>
+      <artifactId>flex-messaging-proxy</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.flex.blazeds</groupId>
+      <artifactId>flex-messaging-remoting</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
 
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-server</artifactId>
-            <version>9.1.0.v20131115</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-servlet</artifactId>
-            <version>9.1.0.v20131115</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-                       <groupId>junit</groupId>
-                       <artifactId>junit</artifactId>
-                       <version>3.8.2</version>
-                       <scope>test</scope>
-               </dependency>
-       </dependencies>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-server</artifactId>
+      <version>9.1.0.v20131115</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlet</artifactId>
+      <version>9.1.0.v20131115</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
 
-    <build>
-        <plugins>
-            <!-- Prevent this artifact from being deployed -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-deploy-plugin</artifactId>
-                <configuration>
-                    <skip>true</skip>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <!-- Prevent this artifact from being deployed -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 
 </project>

http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/025e11cd/testsuite/src/test/java/amfclient/ClientCustomType.java
----------------------------------------------------------------------
diff --git a/testsuite/src/test/java/amfclient/ClientCustomType.java 
b/testsuite/src/test/java/amfclient/ClientCustomType.java
index f7d8c3c..0e5bd46 100644
--- a/testsuite/src/test/java/amfclient/ClientCustomType.java
+++ b/testsuite/src/test/java/amfclient/ClientCustomType.java
@@ -17,7 +17,7 @@
 package amfclient;
 
 /**
- * The client side object used by the AMFConnectionTest. There is a 
corresponding
+ * The client side object used by the AMFConnectionIT. There is a corresponding
  * server side object.
  */
 public class ClientCustomType

http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/025e11cd/testsuite/src/test/java/flex/messaging/io/amf/client/AMFConnectionIT.java
----------------------------------------------------------------------
diff --git 
a/testsuite/src/test/java/flex/messaging/io/amf/client/AMFConnectionIT.java 
b/testsuite/src/test/java/flex/messaging/io/amf/client/AMFConnectionIT.java
new file mode 100644
index 0000000..b1ef888
--- /dev/null
+++ b/testsuite/src/test/java/flex/messaging/io/amf/client/AMFConnectionIT.java
@@ -0,0 +1,781 @@
+/*
+ * 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 flex.messaging.io.amf.client;
+
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+
+import junit.extensions.TestSetup;
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import amfclient.ClientCustomType;
+
+import flex.messaging.util.TestServer;
+import flex.messaging.MessageException;
+import flex.messaging.messages.RemotingMessage;
+import flex.messaging.io.amf.ASObject;
+import flex.messaging.io.amf.AmfTrace;
+import flex.messaging.io.amf.client.AMFConnection.HttpResponseInfo;
+import flex.messaging.io.amf.client.exceptions.ClientStatusException;
+import flex.messaging.io.amf.client.exceptions.ServerStatusException;
+import flex.messaging.io.MessageIOConstants;
+
+
+/**
+ * JUnit tests for AMFConnection. Note that most of the tests require a running
+ * server with the specified destination.
+ */
+public class AMFConnectionIT extends TestCase
+{
+    private static final String DEFAULT_DESTINATION_ID = 
"amfConnectionTestService";
+    private static final String DEFAULT_METHOD_NAME = "echoString";
+    private static final String DEFAULT_METHOD_ARG = "echo me";
+    private static final String DEFAULT_URL = 
"http://localhost:%s/qa-regress/messagebroker/amf";;
+    private static final String DEFAULT_AMF_OPERATION = 
getOperationCall(DEFAULT_METHOD_NAME);
+    private static final String FOO_STRING = "foo";
+    private static final String BAR_STRING = "bar";
+    private static final String UNEXPECTED_EXCEPTION_STRING = "Unexpected 
exception: ";
+
+    private static TestServer server;
+    private static int serverPort;
+
+    /**
+     * Given a remote method name, returns the AMF connection call needed using
+     * the default destination id.
+     */
+    private static String getOperationCall(String method)
+    {
+        return DEFAULT_DESTINATION_ID + "." + method;
+    }
+
+    protected String getConnectionUrl() {
+        return String.format(DEFAULT_URL, serverPort);
+    }
+
+
+    public AMFConnectionIT(String name)
+    {
+        super(name);
+    }
+
+    public static Test suite()
+    {
+        //TestSuite suite = new TestSuite(AMFConnectionIT.class);
+        TestSuite suite = new TestSuite();
+        suite.addTest(new AMFConnectionIT("testConnect"));
+        suite.addTest(new AMFConnectionIT("testConnectAndClose"));
+        suite.addTest(new AMFConnectionIT("testConnectBadUrl"));
+        suite.addTest(new AMFConnectionIT("testCallMultipleTimes"));
+        suite.addTest(new AMFConnectionIT("testCallNoConnect"));
+        suite.addTest(new AMFConnectionIT("testCallNoConnectStringMsg"));
+        suite.addTest(new AMFConnectionIT("testCallUnreachableConnectUrl"));
+        suite.addTest(new AMFConnectionIT("testCallNonexistantMethod"));
+        suite.addTest(new 
AMFConnectionIT("testHttpResponseInfoWithNonexistantMethod"));
+        suite.addTest(new AMFConnectionIT("testCloseNoConnect"));
+        suite.addTest(new AMFConnectionIT("testSetGetObjectEncoding"));
+        suite.addTest(new AMFConnectionIT("testSetGetDefaultObjectEncoding"));
+        suite.addTest(new AMFConnectionIT("testSetGetAMFHeaderProcessor"));
+        suite.addTest(new AMFConnectionIT("testAddRemoveAMFHeaderTwoParam"));
+        suite.addTest(new AMFConnectionIT("testAddRemoveAMFHeader"));
+        suite.addTest(new AMFConnectionIT("testAddRemoveAllAMFHeaders"));
+        suite.addTest(new AMFConnectionIT("testAddRemoveHTTPRequestHeader"));
+        suite.addTest(new 
AMFConnectionIT("testAddRemoveAllHTTPRequestHeaders"));
+        suite.addTest(new AMFConnectionIT("testRemoveAMFHeader"));
+        suite.addTest(new AMFConnectionIT("testRemoveAllAMFHeaders"));
+        suite.addTest(new AMFConnectionIT("testRemoveHTTPRequestHeader"));
+        suite.addTest(new AMFConnectionIT("testRemoveAllHTTPRequestHeaders"));
+        suite.addTest(new AMFConnectionIT("testInstantiateTypes"));
+        suite.addTest(new AMFConnectionIT("testSetGetAMFTrace"));
+        suite.addTest(new AMFConnectionIT("testHTTPProxy"));
+
+        return new TestSetup(suite) {
+            protected void setUp() throws Exception {
+                server = new TestServer();
+                serverPort = 
server.startServer("classpath:/WEB-INF/flex/services-config.xml");
+                if(serverPort == -1) {
+                    Assert.fail("Couldn't start server process");
+                }
+                // Give the "server" some time to startup.
+                Thread.sleep(400L);
+
+                AMFConnection.registerAlias(
+                        "remoting.amfclient.ServerCustomType" /* server type 
*/,
+                        "amfclient.ClientCustomType" /* client type */);
+            }
+            protected void tearDown() throws Exception {
+                server.stopServer();
+                server = null;
+            }
+        };
+    }
+
+    // Not a test, just an example to show how to use AMFConnection.
+    public void example()
+    {
+        // Create the AMF connection.
+        AMFConnection amfConnection = new AMFConnection();
+
+        // Connect to the remote url.
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+        }
+        catch (ClientStatusException cse)
+        {
+            return;
+        }
+
+        // Make a remoting call and retrieve the result.
+        try
+        {
+            Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
DEFAULT_METHOD_ARG);
+            Assert.assertEquals(DEFAULT_METHOD_ARG, result);
+        }
+        catch (ClientStatusException cse)
+        {
+            // Ignore.
+        }
+        catch (ServerStatusException sse)
+        {
+            // Ignore.
+        }
+
+        // Close the connection.
+        amfConnection.close();
+    }
+
+    public void testConnect()
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testConnectAndClose()
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+            Assert.assertEquals(null, amfConnection.getUrl());
+        }
+    }
+
+    public void testConnectBadUrl()
+    {
+        String badUrl = "badUrl";
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(badUrl);
+            fail("ClientStatusException expected");
+        }
+        catch (ClientStatusException cse)
+        {
+            Assert.assertEquals(ClientStatusException.AMF_CONNECT_FAILED_CODE, 
cse.getCode());
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testCallMultipleTimes()
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        // Make a remoting call and retrieve the result.
+        try
+        {
+            for (int i = 1; i < 4; i++)
+            {
+                String stringToEcho = DEFAULT_METHOD_ARG + i;
+                Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
stringToEcho);
+                Assert.assertEquals(stringToEcho, result);
+            }
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testCallNoConnect()
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        // Make a remoting call without connect.
+        try
+        {
+            Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
DEFAULT_METHOD_ARG);
+            Assert.assertEquals(DEFAULT_METHOD_ARG, result);
+        }
+        catch (ClientStatusException cse)
+        {
+            Assert.assertEquals(ClientStatusException.AMF_CALL_FAILED_CODE, 
cse.getCode());
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testCallNoConnectStringMsg()
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        // Make a remoting call without connect.
+        try
+        {
+            Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
DEFAULT_METHOD_ARG);
+            Assert.assertEquals(DEFAULT_METHOD_ARG, result);
+        }
+        catch (ClientStatusException cse)
+        {
+            Assert.assertEquals(ClientStatusException.AMF_CALL_FAILED_CODE, 
cse.getCode());
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testCallUnreachableConnectUrl()
+    {
+        String unreachableUrl = 
"http://localhost:8400/team/messagebroker/unreachable";;
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            // Connect does not actually connect but simply sets the url.
+            amfConnection.connect(unreachableUrl);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        // Make a remoting call and retrieve the result.
+        try
+        {
+            Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
DEFAULT_METHOD_ARG);
+            Assert.assertEquals(DEFAULT_METHOD_ARG, result);
+        }
+        catch (ClientStatusException cse)
+        {
+            Assert.assertEquals(ClientStatusException.AMF_CALL_FAILED_CODE, 
cse.getCode());
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testCallNonexistantMethod()
+    {
+        String method = "nonExistantMethod";
+        final ClientCustomType methodArg = new ClientCustomType();
+        methodArg.setId(1);
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    fail("Unexcepted result: " + result);
+                }
+            });
+        }
+        catch (ServerStatusException sse)
+        {
+            ASObject status = (ASObject)sse.getData();
+            String code = (String)status.get("code");
+            
Assert.assertEquals(MessageException.CODE_SERVER_RESOURCE_UNAVAILABLE, code);
+            HttpResponseInfo info = sse.getHttpResponseInfo();
+            // AMF status messages are reported as HTTP_OK still.
+            Assert.assertEquals(HttpURLConnection.HTTP_OK, 
info.getResponseCode());
+            Assert.assertEquals("OK", info.getResponseMessage());
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testHttpResponseInfoWithNonexistantMethod()
+    {
+        String method = "nonExistantMethod";
+        final ClientCustomType methodArg = new ClientCustomType();
+        methodArg.setId(1);
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    fail("Unexcepted result: " + result);
+                }
+            });
+        }
+        catch (ServerStatusException sse)
+        {
+            HttpResponseInfo info = sse.getHttpResponseInfo();
+            // AMF status messages are reported as HTTP_OK still.
+            Assert.assertEquals(HttpURLConnection.HTTP_OK, 
info.getResponseCode());
+            Assert.assertEquals("OK", info.getResponseMessage());
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+    public void testCloseNoConnect()
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        // Closing with no connection or call.
+        try
+        {
+            amfConnection.close();
+            Assert.assertEquals(null, amfConnection.getUrl());
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testSetGetObjectEncoding()
+    {
+        int retAMF;
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            amfConnection.setObjectEncoding(MessageIOConstants.AMF0);
+            retAMF = amfConnection.getObjectEncoding();
+            Assert.assertEquals(MessageIOConstants.AMF0, retAMF);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testSetGetDefaultObjectEncoding()
+    {
+        int retAMF;
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            AMFConnection.setDefaultObjectEncoding(MessageIOConstants.AMF3);
+            retAMF = AMFConnection.getDefaultObjectEncoding();
+            Assert.assertEquals(MessageIOConstants.AMF3, retAMF);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    /**
+     * There doesn't seem to be a single implementation of AMFHeaderProcessor 
therefore this test
+     * is pretty useless.
+     */
+    public void testSetGetAMFHeaderProcessor()
+    {
+        AMFHeaderProcessor setAMF = null;
+        AMFHeaderProcessor retAMF;
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            amfConnection.setAMFHeaderProcessor(setAMF);
+            retAMF = amfConnection.getAMFHeaderProcessor();
+            Assert.assertEquals(setAMF, retAMF);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testAddRemoveAMFHeaderTwoParam()
+    {
+        boolean retAMF;
+        Object val = 1;
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            amfConnection.addAmfHeader(FOO_STRING,val);
+            retAMF = amfConnection.removeAmfHeader(FOO_STRING);
+            Assert.assertTrue(retAMF);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testAddRemoveAMFHeader()
+    {
+        boolean retAMF;
+        Object val = 1;
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            amfConnection.addAmfHeader(FOO_STRING,true,val);
+            retAMF = amfConnection.removeAmfHeader(FOO_STRING);
+            Assert.assertTrue(retAMF);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testAddRemoveAllAMFHeaders()
+    {
+        Object val1 = 1;
+        Object val2 = 2;
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            amfConnection.addAmfHeader(FOO_STRING,true,val1);
+            amfConnection.addAmfHeader(BAR_STRING,true,val2);
+            amfConnection.removeAllAmfHeaders();
+            Assert.assertTrue(true);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testAddRemoveHTTPRequestHeader()
+    {
+        boolean retHttp;
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            amfConnection.addHttpRequestHeader(FOO_STRING,BAR_STRING);
+            retHttp = amfConnection.removeHttpRequestHeader(FOO_STRING);
+            Assert.assertTrue(retHttp);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testAddRemoveAllHTTPRequestHeaders()
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            amfConnection.addHttpRequestHeader(FOO_STRING,BAR_STRING);
+            amfConnection.addHttpRequestHeader(BAR_STRING,FOO_STRING);
+            amfConnection.removeAllHttpRequestHeaders();
+            Assert.assertTrue(true);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testRemoveAMFHeader()
+    {
+        boolean retAMF;
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            retAMF = amfConnection.removeAmfHeader(FOO_STRING);
+            Assert.assertFalse(retAMF);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testRemoveAllAMFHeaders()
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            amfConnection.removeAllAmfHeaders();
+            Assert.assertTrue(true);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testRemoveHTTPRequestHeader()
+    {
+        boolean retHttp;
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            retHttp = amfConnection.removeHttpRequestHeader(FOO_STRING);
+            Assert.assertFalse(retHttp);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testRemoveAllHTTPRequestHeaders()
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            amfConnection.connect(getConnectionUrl());
+            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
+            amfConnection.removeAllHttpRequestHeaders();
+            Assert.assertTrue(true);
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+
+    public void testInstantiateTypes()
+    {
+        String method = "getObject2";
+        try
+        {
+            AMFConnection amfConnection = new AMFConnection();
+            amfConnection.connect(getConnectionUrl());
+
+            // First, make sure we get the strong type.
+            Object result = amfConnection.call(getOperationCall(method));
+            Assert.assertTrue(result instanceof ClientCustomType);
+
+            // Now, call again with instantiateTypes=false and expect an 
Object.
+            amfConnection.setInstantiateTypes(false);
+            result = amfConnection.call(getOperationCall(method));
+            Assert.assertTrue(!(result instanceof ClientCustomType));
+            amfConnection.close();
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testSetGetAMFTrace()
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        try
+        {
+            AmfTrace trace = new AmfTrace();
+            amfConnection.connect(getConnectionUrl());
+            amfConnection.setAmfTrace(trace);
+
+            String stringToEcho = DEFAULT_METHOD_ARG + 1;
+            Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
stringToEcho);
+            Assert.assertEquals(stringToEcho, result);
+
+            if (trace.toString().length() > 0) Assert.assertTrue(true);
+            else fail("AmfTrace did not get anything: " + trace.toString() + " 
" + trace.toString().length());
+
+            amfConnection.close();
+
+        }
+        catch (ClientStatusException cse)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + cse);
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+        finally
+        {
+            amfConnection.close();
+        }
+    }
+
+    public void testHTTPProxy()
+    {
+        AMFConnection amfconn = new AMFConnection();
+        try
+        {
+            amfconn.setProxy(new Proxy(Proxy.Type.HTTP, new 
InetSocketAddress("localhost", 8888)));
+            amfconn.connect("http://localhost:8400/team/messagebroker/amf";);
+            RemotingMessage call = new RemotingMessage();
+            call.setHeader("DSId", "" + System.identityHashCode(amfconn));
+            call.setClientId("ro");
+            call.setDestination("remoting_AMF");
+            call.setMessageId("12345");
+            call.setOperation("echo");
+            call.setBody("hello");
+            amfconn.call("foo", call);
+            fail("ClientStatusException expected");
+        }
+        catch (ClientStatusException cse)
+        {
+            Assert.assertEquals(ClientStatusException.AMF_CALL_FAILED_CODE, 
cse.getCode());
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+        finally
+        {
+            amfconn.close();
+        }
+    }
+
+    // A simple interface to handle AMF call results.
+    private interface CallResultHandler
+    {
+        void onResult(Object result);
+    }
+
+    // Helper method used by JUnit tests to pass in an operation and method 
argument
+    // When the AMF call returns, CallResultHandler.onResult is called to 
Assert things.
+    private void internalTestCall(String operation, Object methodArg, 
CallResultHandler resultHandler) throws ClientStatusException, 
ServerStatusException
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        // Connect.
+        amfConnection.connect(getConnectionUrl());
+        // Make a remoting call and retrieve the result.
+        Object result;
+        if (methodArg == null)
+            result = amfConnection.call(operation);
+        else
+            result = amfConnection.call(operation, methodArg);
+        resultHandler.onResult(result);
+        amfConnection.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/025e11cd/testsuite/src/test/java/flex/messaging/io/amf/client/AMFConnectionTest.java
----------------------------------------------------------------------
diff --git 
a/testsuite/src/test/java/flex/messaging/io/amf/client/AMFConnectionTest.java 
b/testsuite/src/test/java/flex/messaging/io/amf/client/AMFConnectionTest.java
deleted file mode 100644
index 0b66185..0000000
--- 
a/testsuite/src/test/java/flex/messaging/io/amf/client/AMFConnectionTest.java
+++ /dev/null
@@ -1,787 +0,0 @@
-/*
- * 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 flex.messaging.io.amf.client;
-
-import java.net.HttpURLConnection;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import amfclient.ClientCustomType;
-
-import flex.messaging.util.TestServer;
-import flex.messaging.MessageException;
-import flex.messaging.messages.RemotingMessage;
-import flex.messaging.io.amf.ASObject;
-import flex.messaging.io.amf.AmfTrace;
-import flex.messaging.io.amf.client.AMFConnection.HttpResponseInfo;
-import flex.messaging.io.amf.client.exceptions.ClientStatusException;
-import flex.messaging.io.amf.client.exceptions.ServerStatusException;
-import flex.messaging.io.MessageIOConstants;
-
-
-/**
- * JUnit tests for AMFConnection. Note that most of the tests require a running
- * server with the specified destination.
- */
-public class AMFConnectionTest extends TestCase
-{
-    private static final String DEFAULT_DESTINATION_ID = 
"amfConnectionTestService";
-    private static final String DEFAULT_METHOD_NAME = "echoString";
-    private static final String DEFAULT_METHOD_ARG = "echo me";
-    private static final String DEFAULT_URL = 
"http://localhost:%s/qa-regress/messagebroker/amf";;
-    private static final String DEFAULT_AMF_OPERATION = 
getOperationCall(DEFAULT_METHOD_NAME);
-    private static final String FOO_STRING = "foo";
-    private static final String BAR_STRING = "bar";
-    private static final String UNEXPECTED_EXCEPTION_STRING = "Unexpected 
exception: ";
-
-    private TestServer server;
-    private int serverPort;
-
-    /**
-     * Given a remote method name, returns the AMF connection call needed using
-     * the default destination id.
-     */
-    private static String getOperationCall(String method)
-    {
-        return DEFAULT_DESTINATION_ID + "." + method;
-    }
-
-    protected String getConnectionUrl() {
-        return String.format(DEFAULT_URL, serverPort);
-    }
-
-
-    public AMFConnectionTest(String name)
-    {
-        super(name);
-    }
-
-    public static Test suite()
-    {
-        //TestSuite suite = new TestSuite(AMFConnectionTest.class);
-        TestSuite suite = new TestSuite();
-        suite.addTest(new AMFConnectionTest("testConnect"));
-        suite.addTest(new AMFConnectionTest("testConnectAndClose"));
-        suite.addTest(new AMFConnectionTest("testConnectBadUrl"));
-        suite.addTest(new AMFConnectionTest("testCallMultipleTimes"));
-        suite.addTest(new AMFConnectionTest("testCallNoConnect"));
-        suite.addTest(new AMFConnectionTest("testCallNoConnectStringMsg"));
-        suite.addTest(new AMFConnectionTest("testCallUnreachableConnectUrl"));
-        suite.addTest(new AMFConnectionTest("testCallNonexistantMethod"));
-        suite.addTest(new 
AMFConnectionTest("testHttpResponseInfoWithNonexistantMethod"));
-        suite.addTest(new AMFConnectionTest("testCloseNoConnect"));
-        suite.addTest(new AMFConnectionTest("testSetGetObjectEncoding"));
-        suite.addTest(new 
AMFConnectionTest("testSetGetDefaultObjectEncoding"));
-        suite.addTest(new AMFConnectionTest("testSetGetAMFHeaderProcessor"));
-        suite.addTest(new AMFConnectionTest("testAddRemoveAMFHeaderTwoParam"));
-        suite.addTest(new AMFConnectionTest("testAddRemoveAMFHeader"));
-        suite.addTest(new AMFConnectionTest("testAddRemoveAllAMFHeaders"));
-        suite.addTest(new AMFConnectionTest("testAddRemoveHTTPRequestHeader"));
-        suite.addTest(new 
AMFConnectionTest("testAddRemoveAllHTTPRequestHeaders"));
-        suite.addTest(new AMFConnectionTest("testRemoveAMFHeader"));
-        suite.addTest(new AMFConnectionTest("testRemoveAllAMFHeaders"));
-        suite.addTest(new AMFConnectionTest("testRemoveHTTPRequestHeader"));
-        suite.addTest(new 
AMFConnectionTest("testRemoveAllHTTPRequestHeaders"));
-        suite.addTest(new AMFConnectionTest("testInstantiateTypes"));
-        suite.addTest(new AMFConnectionTest("testSetGetAMFTrace"));
-        suite.addTest(new AMFConnectionTest("testHTTPProxy"));
-        return suite;
-    }
-
-    @Override
-    protected void setUp() throws Exception
-    {
-        server = new TestServer();
-        serverPort = 
server.startServer("classpath:/WEB-INF/flex/services-config.xml");
-        if(serverPort == -1) {
-            Assert.fail("Couldn't start server process");
-        }
-        // Give the "server" some time to startup.
-        Thread.sleep(400L);
-
-        AMFConnection.registerAlias(
-                "remoting.amfclient.ServerCustomType" /* server type */,
-                "amfclient.ClientCustomType" /* client type */);
-
-        super.setUp();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        server.stopServer();
-        server = null;
-
-        super.tearDown();
-    }
-
-    // Not a test, just an example to show how to use AMFConnection.
-    public void example()
-    {
-        // Create the AMF connection.
-        AMFConnection amfConnection = new AMFConnection();
-
-        // Connect to the remote url.
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-        }
-        catch (ClientStatusException cse)
-        {
-            return;
-        }
-
-        // Make a remoting call and retrieve the result.
-        try
-        {
-            Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
DEFAULT_METHOD_ARG);
-            Assert.assertEquals(DEFAULT_METHOD_ARG, result);
-        }
-        catch (ClientStatusException cse)
-        {
-            // Ignore.
-        }
-        catch (ServerStatusException sse)
-        {
-            // Ignore.
-        }
-
-        // Close the connection.
-        amfConnection.close();
-    }
-
-    public void testConnect()
-    {
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testConnectAndClose()
-    {
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-            Assert.assertEquals(null, amfConnection.getUrl());
-        }
-    }
-
-    public void testConnectBadUrl()
-    {
-        String badUrl = "badUrl";
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(badUrl);
-            fail("ClientStatusException expected");
-        }
-        catch (ClientStatusException cse)
-        {
-            Assert.assertEquals(ClientStatusException.AMF_CONNECT_FAILED_CODE, 
cse.getCode());
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testCallMultipleTimes()
-    {
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        // Make a remoting call and retrieve the result.
-        try
-        {
-            for (int i = 1; i < 4; i++)
-            {
-                String stringToEcho = DEFAULT_METHOD_ARG + i;
-                Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
stringToEcho);
-                Assert.assertEquals(stringToEcho, result);
-            }
-        }
-        catch (Exception e)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + e);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testCallNoConnect()
-    {
-        AMFConnection amfConnection = new AMFConnection();
-        // Make a remoting call without connect.
-        try
-        {
-            Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
DEFAULT_METHOD_ARG);
-            Assert.assertEquals(DEFAULT_METHOD_ARG, result);
-        }
-        catch (ClientStatusException cse)
-        {
-            Assert.assertEquals(ClientStatusException.AMF_CALL_FAILED_CODE, 
cse.getCode());
-        }
-        catch (Exception e)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + e);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testCallNoConnectStringMsg()
-    {
-        AMFConnection amfConnection = new AMFConnection();
-        // Make a remoting call without connect.
-        try
-        {
-            Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
DEFAULT_METHOD_ARG);
-            Assert.assertEquals(DEFAULT_METHOD_ARG, result);
-        }
-        catch (ClientStatusException cse)
-        {
-            Assert.assertEquals(ClientStatusException.AMF_CALL_FAILED_CODE, 
cse.getCode());
-        }
-        catch (Exception e)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + e);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testCallUnreachableConnectUrl()
-    {
-        String unreachableUrl = 
"http://localhost:8400/team/messagebroker/unreachable";;
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            // Connect does not actually connect but simply sets the url.
-            amfConnection.connect(unreachableUrl);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        // Make a remoting call and retrieve the result.
-        try
-        {
-            Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
DEFAULT_METHOD_ARG);
-            Assert.assertEquals(DEFAULT_METHOD_ARG, result);
-        }
-        catch (ClientStatusException cse)
-        {
-            Assert.assertEquals(ClientStatusException.AMF_CALL_FAILED_CODE, 
cse.getCode());
-        }
-        catch (Exception e)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + e);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testCallNonexistantMethod()
-    {
-        String method = "nonExistantMethod";
-        final ClientCustomType methodArg = new ClientCustomType();
-        methodArg.setId(1);
-        try
-        {
-            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
-                public void onResult(Object result)
-                {
-                    fail("Unexcepted result: " + result);
-                }
-            });
-        }
-        catch (ServerStatusException sse)
-        {
-            ASObject status = (ASObject)sse.getData();
-            String code = (String)status.get("code");
-            
Assert.assertEquals(MessageException.CODE_SERVER_RESOURCE_UNAVAILABLE, code);
-            HttpResponseInfo info = sse.getHttpResponseInfo();
-            // AMF status messages are reported as HTTP_OK still.
-            Assert.assertEquals(HttpURLConnection.HTTP_OK, 
info.getResponseCode());
-            Assert.assertEquals("OK", info.getResponseMessage());
-        }
-        catch (Exception e)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + e);
-        }
-    }
-
-    public void testHttpResponseInfoWithNonexistantMethod()
-    {
-        String method = "nonExistantMethod";
-        final ClientCustomType methodArg = new ClientCustomType();
-        methodArg.setId(1);
-        try
-        {
-            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
-                public void onResult(Object result)
-                {
-                    fail("Unexcepted result: " + result);
-                }
-            });
-        }
-        catch (ServerStatusException sse)
-        {
-            HttpResponseInfo info = sse.getHttpResponseInfo();
-            // AMF status messages are reported as HTTP_OK still.
-            Assert.assertEquals(HttpURLConnection.HTTP_OK, 
info.getResponseCode());
-            Assert.assertEquals("OK", info.getResponseMessage());
-        }
-        catch (Exception e)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + e);
-        }
-    }
-    public void testCloseNoConnect()
-    {
-        AMFConnection amfConnection = new AMFConnection();
-        // Closing with no connection or call.
-        try
-        {
-            amfConnection.close();
-            Assert.assertEquals(null, amfConnection.getUrl());
-        }
-        catch (Exception e)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + e);
-        }
-    }
-
-    public void testSetGetObjectEncoding()
-    {
-        int retAMF;
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            amfConnection.setObjectEncoding(MessageIOConstants.AMF0);
-            retAMF = amfConnection.getObjectEncoding();
-            Assert.assertEquals(MessageIOConstants.AMF0, retAMF);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testSetGetDefaultObjectEncoding()
-    {
-        int retAMF;
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            AMFConnection.setDefaultObjectEncoding(MessageIOConstants.AMF3);
-            retAMF = AMFConnection.getDefaultObjectEncoding();
-            Assert.assertEquals(MessageIOConstants.AMF3, retAMF);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    /**
-     * There doesn't seem to be a single implementation of AMFHeaderProcessor 
therefore this test
-     * is pretty useless.
-     */
-    public void testSetGetAMFHeaderProcessor()
-    {
-        AMFHeaderProcessor setAMF = null;
-        AMFHeaderProcessor retAMF;
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            amfConnection.setAMFHeaderProcessor(setAMF);
-            retAMF = amfConnection.getAMFHeaderProcessor();
-            Assert.assertEquals(setAMF, retAMF);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testAddRemoveAMFHeaderTwoParam()
-    {
-        boolean retAMF;
-        Object val = 1;
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            amfConnection.addAmfHeader(FOO_STRING,val);
-            retAMF = amfConnection.removeAmfHeader(FOO_STRING);
-            Assert.assertTrue(retAMF);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testAddRemoveAMFHeader()
-    {
-        boolean retAMF;
-        Object val = 1;
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            amfConnection.addAmfHeader(FOO_STRING,true,val);
-            retAMF = amfConnection.removeAmfHeader(FOO_STRING);
-            Assert.assertTrue(retAMF);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testAddRemoveAllAMFHeaders()
-    {
-        Object val1 = 1;
-        Object val2 = 2;
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            amfConnection.addAmfHeader(FOO_STRING,true,val1);
-            amfConnection.addAmfHeader(BAR_STRING,true,val2);
-            amfConnection.removeAllAmfHeaders();
-            Assert.assertTrue(true);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testAddRemoveHTTPRequestHeader()
-    {
-        boolean retHttp;
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            amfConnection.addHttpRequestHeader(FOO_STRING,BAR_STRING);
-            retHttp = amfConnection.removeHttpRequestHeader(FOO_STRING);
-            Assert.assertTrue(retHttp);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testAddRemoveAllHTTPRequestHeaders()
-    {
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            amfConnection.addHttpRequestHeader(FOO_STRING,BAR_STRING);
-            amfConnection.addHttpRequestHeader(BAR_STRING,FOO_STRING);
-            amfConnection.removeAllHttpRequestHeaders();
-            Assert.assertTrue(true);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testRemoveAMFHeader()
-    {
-        boolean retAMF;
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            retAMF = amfConnection.removeAmfHeader(FOO_STRING);
-            Assert.assertFalse(retAMF);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testRemoveAllAMFHeaders()
-    {
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            amfConnection.removeAllAmfHeaders();
-            Assert.assertTrue(true);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testRemoveHTTPRequestHeader()
-    {
-        boolean retHttp;
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            retHttp = amfConnection.removeHttpRequestHeader(FOO_STRING);
-            Assert.assertFalse(retHttp);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testRemoveAllHTTPRequestHeaders()
-    {
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            amfConnection.connect(getConnectionUrl());
-            Assert.assertEquals(getConnectionUrl(), amfConnection.getUrl());
-            amfConnection.removeAllHttpRequestHeaders();
-            Assert.assertTrue(true);
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-
-    public void testInstantiateTypes()
-    {
-        String method = "getObject2";
-        try
-        {
-            AMFConnection amfConnection = new AMFConnection();
-            amfConnection.connect(getConnectionUrl());
-
-            // First, make sure we get the strong type.
-            Object result = amfConnection.call(getOperationCall(method));
-            Assert.assertTrue(result instanceof ClientCustomType);
-
-            // Now, call again with instantiateTypes=false and expect an 
Object.
-            amfConnection.setInstantiateTypes(false);
-            result = amfConnection.call(getOperationCall(method));
-            Assert.assertTrue(!(result instanceof ClientCustomType));
-            amfConnection.close();
-        }
-        catch (Exception e)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + e);
-        }
-    }
-
-    public void testSetGetAMFTrace()
-    {
-        AMFConnection amfConnection = new AMFConnection();
-        try
-        {
-            AmfTrace trace = new AmfTrace();
-            amfConnection.connect(getConnectionUrl());
-            amfConnection.setAmfTrace(trace);
-
-            String stringToEcho = DEFAULT_METHOD_ARG + 1;
-            Object result = amfConnection.call(DEFAULT_AMF_OPERATION, 
stringToEcho);
-            Assert.assertEquals(stringToEcho, result);
-
-            if (trace.toString().length() > 0) Assert.assertTrue(true);
-            else fail("AmfTrace did not get anything: " + trace.toString() + " 
" + trace.toString().length());
-
-            amfConnection.close();
-
-        }
-        catch (ClientStatusException cse)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + cse);
-        }
-        catch (Exception e)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + e);
-        }
-        finally
-        {
-            amfConnection.close();
-        }
-    }
-
-    public void testHTTPProxy()
-    {
-        AMFConnection amfconn = new AMFConnection();
-        try
-        {
-            amfconn.setProxy(new Proxy(Proxy.Type.HTTP, new 
InetSocketAddress("localhost", 8888)));
-            amfconn.connect("http://localhost:8400/team/messagebroker/amf";);
-            RemotingMessage call = new RemotingMessage();
-            call.setHeader("DSId", "" + System.identityHashCode(amfconn));
-            call.setClientId("ro");
-            call.setDestination("remoting_AMF");
-            call.setMessageId("12345");
-            call.setOperation("echo");
-            call.setBody("hello");
-            amfconn.call("foo", call);
-            fail("ClientStatusException expected");
-        }
-        catch (ClientStatusException cse)
-        {
-            Assert.assertEquals(ClientStatusException.AMF_CALL_FAILED_CODE, 
cse.getCode());
-        }
-        catch (Exception e)
-        {
-            fail(UNEXPECTED_EXCEPTION_STRING + e);
-        }
-        finally
-        {
-            amfconn.close();
-        }
-    }
-
-    // A simple interface to handle AMF call results.
-    private interface CallResultHandler
-    {
-        void onResult(Object result);
-    }
-
-    // Helper method used by JUnit tests to pass in an operation and method 
argument
-    // When the AMF call returns, CallResultHandler.onResult is called to 
Assert things.
-    private void internalTestCall(String operation, Object methodArg, 
CallResultHandler resultHandler) throws ClientStatusException, 
ServerStatusException
-    {
-        AMFConnection amfConnection = new AMFConnection();
-        // Connect.
-        amfConnection.connect(getConnectionUrl());
-        // Make a remoting call and retrieve the result.
-        Object result;
-        if (methodArg == null)
-            result = amfConnection.call(operation);
-        else
-            result = amfConnection.call(operation, methodArg);
-        resultHandler.onResult(result);
-        amfConnection.close();
-    }
-}

http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/025e11cd/testsuite/src/test/java/flex/messaging/io/amf/client/AMFDataTypeIT.java
----------------------------------------------------------------------
diff --git 
a/testsuite/src/test/java/flex/messaging/io/amf/client/AMFDataTypeIT.java 
b/testsuite/src/test/java/flex/messaging/io/amf/client/AMFDataTypeIT.java
new file mode 100644
index 0000000..c48a5d3
--- /dev/null
+++ b/testsuite/src/test/java/flex/messaging/io/amf/client/AMFDataTypeIT.java
@@ -0,0 +1,482 @@
+/*
+ * 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 flex.messaging.io.amf.client;
+
+import java.util.Date;
+import java.util.List;
+
+import junit.extensions.TestSetup;
+import org.w3c.dom.Document;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import amfclient.ClientCustomType;
+
+import flex.messaging.util.TestServer;
+import flex.messaging.io.amf.client.exceptions.ClientStatusException;
+import flex.messaging.io.amf.client.exceptions.ServerStatusException;
+import flex.messaging.util.XMLUtil;
+
+/**
+ * JUnit tests for AMFConnection. Note that most of the tests require a running
+ * server with the specified destination. 
+ */
+public class AMFDataTypeIT extends TestCase
+{
+    private static final String DEFAULT_DESTINATION_ID = 
"amfConnectionTestService";
+    private static final String DEFAULT_METHOD_NAME = "echoString";
+    private static final String DEFAULT_METHOD_ARG = "echo me";
+    private static final String DEFAULT_URL = 
"http://localhost:%s/qa-regress/messagebroker/amf";;
+    private static final String DEFAULT_AMF_OPERATION = 
getOperationCall(DEFAULT_METHOD_NAME);
+    private static final String UNEXPECTED_EXCEPTION_STRING = "Unexpected 
exception: ";
+
+    private static TestServer server;
+    private static int serverPort;
+
+    /**
+     * Given a remote method name, returns the AMF connection call needed using
+     * the default destination id.
+     */
+    private static String getOperationCall(String method)
+    {
+        return DEFAULT_DESTINATION_ID + "." + method;
+    }
+
+    protected String getConnectionUrl() {
+        return String.format(DEFAULT_URL, serverPort);
+    }
+
+
+    public AMFDataTypeIT(String name)
+    {
+        super(name);
+    }
+
+    public static Test suite()
+    {
+        //TestSuite suite = new TestSuite(AMFDataTypeIT.class);
+        TestSuite suite = new TestSuite();
+        suite.addTest(new AMFDataTypeIT("testCallStringArgStringReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallIntArgIntReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallBooleanArgBooleanReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallObjectArgObjectReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallObjectArgCustomReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallCustomArgObjectReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallCustomArgCustomReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallNoArgObjectReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallNoArgCustomReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallNoArgObjectArrayReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallDateArgDateReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallShortArgShortReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallDoubleArgDoubleReturn"));
+        suite.addTest(new AMFDataTypeIT("testCallIntArrayArgIntArrayReturn"));
+        suite.addTest(new 
AMFDataTypeIT("testCallObjectArrayArgObjectArrayReturn"));
+        suite.addTest(new AMFDataTypeIT("testXMLDocument"));
+
+        return new TestSetup(suite) {
+            protected void setUp() throws Exception {
+                server = new TestServer();
+                serverPort = 
server.startServer("classpath:/WEB-INF/flex/services-config.xml");
+                if(serverPort == -1) {
+                    Assert.fail("Couldn't start server process");
+                }
+                // Give the "server" some time to startup.
+                Thread.sleep(400L);
+
+                AMFConnection.registerAlias(
+                        "remoting.amfclient.ServerCustomType" /* server type 
*/,
+                        "amfclient.ClientCustomType" /* client type */);
+            }
+            protected void tearDown() throws Exception {
+                server.stopServer();
+                server = null;
+            }
+        };
+    }
+
+    public void testCallStringArgStringReturn()
+    {
+        try
+        {
+            internalTestCall(DEFAULT_AMF_OPERATION, DEFAULT_METHOD_ARG, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    Assert.assertEquals(DEFAULT_METHOD_ARG, result);
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallIntArgIntReturn()
+    {
+        String method = "echoInt";
+        final int methodArg = 1;
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    Assert.assertEquals(methodArg, 
((Double)result).intValue());
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallBooleanArgBooleanReturn()
+    {
+        try
+        {
+            String method = "echoBoolean";
+            final boolean methodArg = true;
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    Assert.assertEquals(methodArg, result);
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallDateArgDateReturn()
+    {
+        String method = "echoDate";
+        final Date methodArg = new Date(999991);
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    Assert.assertEquals(methodArg, result);
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallShortArgShortReturn()
+    {
+        String method = "echoShort";
+        final short methodArg = 32000;
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    Assert.assertEquals(methodArg, 
((Double)result).shortValue());
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallDoubleArgDoubleReturn()
+    {
+        String method = "echoDouble";
+        final double methodArg = -95.25;
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    Assert.assertEquals(methodArg, result);
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallObjectArgObjectReturn()
+    {
+        String method = "echoObject1";
+        ClientCustomType temp = new ClientCustomType();
+        temp.setId(1);
+        final Object methodArg = temp;
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    ClientCustomType temp2 = (ClientCustomType)result;
+                    Assert.assertEquals(1, temp2.getId());
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallObjectArgCustomReturn()
+    {
+        String method = "echoObject2";
+        ClientCustomType temp = new ClientCustomType();
+        temp.setId(1);
+        final Object methodArg = temp;
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    ClientCustomType temp2 = (ClientCustomType)result;
+                    Assert.assertEquals(1, temp2.getId());
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallCustomArgObjectReturn()
+    {
+        String method = "echoObject3";
+        final ClientCustomType methodArg = new ClientCustomType();
+        methodArg.setId(1);
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    ClientCustomType temp2 = (ClientCustomType)result;
+                    Assert.assertEquals(1, temp2.getId());
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallCustomArgCustomReturn()
+    {
+        String method = "echoObject4";
+        final ClientCustomType methodArg = new ClientCustomType();
+        methodArg.setId(1);
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    ClientCustomType temp2 = (ClientCustomType)result;
+                    Assert.assertEquals(1, temp2.getId());
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallNoArgObjectReturn()
+    {
+        String method = "getObject1";
+        try
+        {
+            internalTestCall(getOperationCall(method), null, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    ClientCustomType temp2 = (ClientCustomType)result;
+                    Assert.assertEquals(1, temp2.getId());
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallNoArgCustomReturn()
+    {
+        String method = "getObject2";
+        try
+        {
+            internalTestCall(getOperationCall(method), null, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    ClientCustomType temp2 = (ClientCustomType)result;
+                    Assert.assertEquals(1, temp2.getId());
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallNoArgObjectArrayReturn()
+    {
+        String method = "getObjectArray1";
+        try
+        {
+            internalTestCall(getOperationCall(method), null, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    List temp = (List)result;
+                    for (int i = 0; i < temp.size(); i++)
+                    {
+                        ClientCustomType temp2 = (ClientCustomType)temp.get(i);
+                        Assert.assertEquals(i, temp2.getId());
+                    }
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallIntArrayArgIntArrayReturn()
+    {
+        String method = "echoObject5";
+        final int[] methodArg = new int[] {0,1,2,3};
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    List temp = (List)result;
+                    for (int i = 0; i < temp.size(); i++)
+                    {
+                        Assert.assertEquals(i, 
((Integer)temp.get(i)).intValue());
+                    }
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    public void testCallObjectArrayArgObjectArrayReturn()
+    {
+        String method = "echoObject1";
+        Object[] temp = new Object[3];
+        for (int i = 0; i < temp.length; i++)
+        {
+            ClientCustomType cct = new ClientCustomType();
+            cct.setId(i);
+            temp[i] = cct;
+        }
+        final Object[] methodArg = temp;
+        try
+        {
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    List temp = (List)result;
+                    for (int i = 0; i < temp.size(); i++)
+                    {
+                        ClientCustomType temp2 = (ClientCustomType)temp.get(i);
+                        Assert.assertEquals(i, temp2.getId());
+                    }
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+  
+    public void testXMLDocument()
+    {
+        try
+        {
+            String method = "echoObject1";
+            final StringBuffer xml = new StringBuffer(512);
+            xml.append("<test>    <item id=\"1\">        <sweet/>    
</item></test>");
+
+            Document xmlDoc = XMLUtil.stringToDocument(xml.toString());
+            final Object methodArg = xmlDoc;
+            internalTestCall(getOperationCall(method), methodArg, new 
CallResultHandler(){
+                public void onResult(Object result)
+                {
+                    try
+                    {
+                        Document retXmlDoc = (Document)result;
+                        String retXML = XMLUtil.documentToString(retXmlDoc);
+                        Assert.assertEquals(xml.toString(), retXML);
+                    }
+                    catch (Exception e)
+                    {
+                        fail(UNEXPECTED_EXCEPTION_STRING + e);
+                    }
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            fail(UNEXPECTED_EXCEPTION_STRING + e);
+        }
+    }
+
+    // A simple interface to handle AMF call results.
+    private interface CallResultHandler
+    {
+        void onResult(Object result);
+    }
+
+    // Helper method used by JUnit tests to pass in an operation and method 
argument
+    // When the AMF call returns, CallResultHandler.onResult is called to 
Assert things.
+    private void internalTestCall(String operation, Object methodArg, 
CallResultHandler resultHandler) throws ClientStatusException, 
ServerStatusException
+    {
+        AMFConnection amfConnection = new AMFConnection();
+        // Connect.
+        amfConnection.connect(getConnectionUrl());
+        // Make a remoting call and retrieve the result.
+        Object result;
+        if (methodArg == null)
+            result = amfConnection.call(operation);
+        else
+            result = amfConnection.call(operation, methodArg);
+        resultHandler.onResult(result);
+        amfConnection.close();
+    }
+}

Reply via email to