// Path: test-webapp/src/main/java/org/gwtwidgets/server/spring/test/common/CustomException.java
// public class CustomException extends Exception implements IsSerializable{
// 
// }
// 
// Path: test-webapp/src/main/java/org/gwtwidgets/server/spring/test/common/TestService.java
// public interface TestService extends RemoteService{
// 	
// /**
//  * Adds two integers together and return result
//  * @param a
//  * @param b
//  * @return
//  */
// int add(int a, int b);
// 
// /**
//  * Set a session attribute and return old value
//  * @param name
//  * @param value
//  * @return
//  */
// String replaceAttribute(String name, String value);
// 
// /**
//  * Set a session attribute and return old value. Should use
//  * an alternative implementation to access the servlet session.
//  * @param name
//  * @param value
//  * @return
//  */
// String replaceAttributeAlt(String name, String value);
// 
// /**
//  * Throws an exceptions that has been declared in the interface}
//  * @throws CustomException
//  */
// void throwDeclaredException() throws CustomException;
// 
// /**
//  * Throws an exceptions that has not been declared in the interface}
//  * @throws RuntimeException
//  */
// void throwUndeclaredException();
// 
// /**
//  * @param o Object argument. Will turn string to lower case and increment number by 1
//  * @return Testing {@link GWTSerialisableObject}
//  */
// 
// GWTSerialisableObject getGWTSerialisableObject(GWTSerialisableObject o);
// 
// /**
//  * @param o Object argument. Will turn string to lower case and increment number by 1
//  * @return Testing {@link JavaSerialisableObject}
//  */
// 
// JavaSerialisableObject getJavaSerialisableObject(JavaSerialisableObject o);
// 
// /**
//  * Returns a random number. 
//  * @return
//  */
// Integer getRandomNumber();
// 
// }
// 
// Path: test-webapp/src/main/java/org/gwtwidgets/server/spring/test/common/TestServiceAsync.java
// public interface TestServiceAsync {
// 
// 	void add(int a, int b, AsyncCallback<Integer> callback);
// 
// 	void throwDeclaredException(AsyncCallback<Void> callback);
// 
// 	void throwUndeclaredException(AsyncCallback<Object> callback);
// 
// 	void replaceAttribute(String name, String value, AsyncCallback<String> callback);
// 
// 	void replaceAttributeAlt(String name, String value, AsyncCallback<String> callback);
// 
// 	void getGWTSerialisableObject(GWTSerialisableObject o, AsyncCallback<GWTSerialisableObject> callback);
// 
// 	void getJavaSerialisableObject(JavaSerialisableObject o, AsyncCallback<JavaSerialisableObject> callback);
// 	
// 	void getRandomNumber(AsyncCallback<Integer> callback);
// 
// }


import java.io.Serializable;
import java.util.Date;
import org.gwtwidgets.server.spring.test.common.CustomException;
import org.gwtwidgets.server.spring.test.common.TestService;
import org.gwtwidgets.server.spring.test.common.TestServiceAsync;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;

			public void onFailure(Throwable exception) {
				if (!(exception instanceof Serializable)) {
					fail("Test5 failed, expected a SerializableException.", exception);
					return;
				}
				log("Test5 success");
				Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
					public void execute() {
						testCustomException();
					}
				});
			}

			public void onSuccess(Object result) {
				fail("Test5 failed, expected a SerializableException.", null);
			}
		}));
	}

	// check
	void testCustomException() {

		log("Test5b: Testing for custom exception serialisability.");
		TestServiceAsync testRequest = getService();
		testRequest.throwDeclaredException((new AsyncCallback<Void>() {
			public void onFailure(Throwable exception) {
				if (!(exception instanceof CustomException)) {
					fail("Test5b failed, expected a CustomException.", exception);
					return;
				}

// Path: test-webapp/src/main/java/org/gwtwidgets/server/spring/test/common/CustomException.java
// public class CustomException extends Exception implements IsSerializable{
// 
// }
// 
// Path: test-webapp/src/main/java/org/gwtwidgets/server/spring/test/common/TestService.java
// public interface TestService extends RemoteService{
// 	
// /**
//  * Adds two integers together and return result
//  * @param a
//  * @param b
//  * @return
//  */
// int add(int a, int b);
// 
// /**
//  * Set a session attribute and return old value
//  * @param name
//  * @param value
//  * @return
//  */
// String replaceAttribute(String name, String value);
// 
// /**
//  * Set a session attribute and return old value. Should use
//  * an alternative implementation to access the servlet session.
//  * @param name
//  * @param value
//  * @return
//  */
// String replaceAttributeAlt(String name, String value);
// 
// /**
//  * Throws an exceptions that has been declared in the interface}
//  * @throws CustomException
//  */
// void throwDeclaredException() throws CustomException;
// 
// /**
//  * Throws an exceptions that has not been declared in the interface}
//  * @throws RuntimeException
//  */
// void throwUndeclaredException();
// 
// /**
//  * @param o Object argument. Will turn string to lower case and increment number by 1
//  * @return Testing {@link GWTSerialisableObject}
//  */
// 
// GWTSerialisableObject getGWTSerialisableObject(GWTSerialisableObject o);
// 
// /**
//  * @param o Object argument. Will turn string to lower case and increment number by 1
//  * @return Testing {@link JavaSerialisableObject}
//  */
// 
// JavaSerialisableObject getJavaSerialisableObject(JavaSerialisableObject o);
// 
// /**
//  * Returns a random number. 
//  * @return
//  */
// Integer getRandomNumber();
// 
// }
// 
// Path: test-webapp/src/main/java/org/gwtwidgets/server/spring/test/common/TestServiceAsync.java
// public interface TestServiceAsync {
// 
// 	void add(int a, int b, AsyncCallback<Integer> callback);
// 
// 	void throwDeclaredException(AsyncCallback<Void> callback);
// 
// 	void throwUndeclaredException(AsyncCallback<Object> callback);
// 
// 	void replaceAttribute(String name, String value, AsyncCallback<String> callback);
// 
// 	void replaceAttributeAlt(String name, String value, AsyncCallback<String> callback);
// 
// 	void getGWTSerialisableObject(GWTSerialisableObject o, AsyncCallback<GWTSerialisableObject> callback);
// 
// 	void getJavaSerialisableObject(JavaSerialisableObject o, AsyncCallback<JavaSerialisableObject> callback);
// 	
// 	void getRandomNumber(AsyncCallback<Integer> callback);
// 
// }


// Path: test-webapp/src/main/java/org/gwtwidgets/server/spring/test/client/ClientApplication.java
import java.io.Serializable;
import java.util.Date;
import org.gwtwidgets.server.spring.test.common.CustomException;
import org.gwtwidgets.server.spring.test.common.TestService;
import org.gwtwidgets.server.spring.test.common.TestServiceAsync;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;

			public void onFailure(Throwable exception) {
				if (!(exception instanceof Serializable)) {
					fail("Test5 failed, expected a SerializableException.", exception);
					return;
				}
				log("Test5 success");
				Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
					public void execute() {
						testCustomException();
					}
				});
			}

			public void onSuccess(Object result) {
				fail("Test5 failed, expected a SerializableException.", null);
			}
		}));
	}

	// check
	void testCustomException() {

		log("Test5b: Testing for custom exception serialisability.");
		TestServiceAsync testRequest = getService();
		testRequest.throwDeclaredException((new AsyncCallback<Void>() {
			public void onFailure(Throwable exception) {
				if (!(exception instanceof CustomException)) {
					fail("Test5b failed, expected a CustomException.", exception);
					return;
				}

				log("Test5b success");
