001: /*
002: * Copyright 2007 Google Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package com.google.gwt.user.client.rpc;
017:
018: import com.google.gwt.core.client.GWT;
019: import com.google.gwt.junit.client.GWTTestCase;
020: import com.google.gwt.user.client.rpc.TestSetFactory.SerializableDoublyLinkedNode;
021:
022: /**
023: * TODO: document me.
024: */
025: public class ObjectGraphTest extends GWTTestCase {
026: private static final int TEST_DELAY = 5000;
027:
028: public String getModuleName() {
029: return "com.google.gwt.user.RPCSuite";
030: }
031:
032: public void testAcyclicGraph() {
033: delayTestFinish(TEST_DELAY);
034:
035: ObjectGraphTestServiceAsync service = getServiceAsync();
036: service.echo_AcyclicGraph(TestSetFactory.createAcyclicGraph(),
037: new AsyncCallback() {
038: public void onFailure(Throwable caught) {
039: TestSetValidator.rethrowException(caught);
040: }
041:
042: public void onSuccess(Object result) {
043: assertNotNull(result);
044: assertTrue(TestSetValidator
045: .isValidAcyclicGraph((SerializableDoublyLinkedNode) result));
046: finishTest();
047: }
048: });
049: }
050:
051: public void testComplexCyclicGraph() {
052: delayTestFinish(TEST_DELAY);
053:
054: ObjectGraphTestServiceAsync service = getServiceAsync();
055: service.echo_ComplexCyclicGraph(TestSetFactory
056: .createComplexCyclicGraph(), new AsyncCallback() {
057: public void onFailure(Throwable caught) {
058: TestSetValidator.rethrowException(caught);
059: }
060:
061: public void onSuccess(Object result) {
062: assertNotNull(result);
063: assertTrue(TestSetValidator
064: .isValidComplexCyclicGraph((SerializableDoublyLinkedNode) result));
065: finishTest();
066: }
067: });
068: }
069:
070: public void testComplexCyclicGraph2() {
071: delayTestFinish(TEST_DELAY);
072:
073: ObjectGraphTestServiceAsync service = getServiceAsync();
074: final SerializableDoublyLinkedNode node = TestSetFactory
075: .createComplexCyclicGraph();
076: service.echo_ComplexCyclicGraph(node, node,
077: new AsyncCallback() {
078: public void onFailure(Throwable caught) {
079: TestSetValidator.rethrowException(caught);
080: }
081:
082: public void onSuccess(Object result) {
083: assertNotNull(result);
084: assertTrue(TestSetValidator
085: .isValidComplexCyclicGraph((SerializableDoublyLinkedNode) result));
086: finishTest();
087: }
088: });
089: }
090:
091: public void testTrivialCyclicGraph() {
092: delayTestFinish(TEST_DELAY);
093:
094: ObjectGraphTestServiceAsync service = getServiceAsync();
095: service.echo_TrivialCyclicGraph(TestSetFactory
096: .createTrivialCyclicGraph(), new AsyncCallback() {
097: public void onFailure(Throwable caught) {
098: TestSetValidator.rethrowException(caught);
099: }
100:
101: public void onSuccess(Object result) {
102: assertNotNull(result);
103: assertTrue(TestSetValidator
104: .isValidTrivialCyclicGraph((SerializableDoublyLinkedNode) result));
105: finishTest();
106: }
107: });
108: }
109:
110: private ObjectGraphTestServiceAsync getServiceAsync() {
111: if (objectGraphTestService == null) {
112: objectGraphTestService = (ObjectGraphTestServiceAsync) GWT
113: .create(ObjectGraphTestService.class);
114: ((ServiceDefTarget) objectGraphTestService)
115: .setServiceEntryPoint(GWT.getModuleBaseURL()
116: + "objectgraphs");
117: }
118: return objectGraphTestService;
119: }
120:
121: private ObjectGraphTestServiceAsync objectGraphTestService;
122: }
|