01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.rmi.server;
19:
20: import java.io.Serializable;
21: import java.rmi.RemoteException;
22: import java.rmi.server.SkeletonMismatchException;
23:
24: import org.apache.harmony.testframework.serialization.SerializationTest;
25: import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
26:
27: public class SkeletonMismatchExceptionTest extends
28: junit.framework.TestCase {
29:
30: private String errorMessage = "SkeletonMismatch Exception!";
31: private SkeletonMismatchException cause = new SkeletonMismatchException(
32: "cause");
33:
34: /**
35: * @tests java.rmi.server.SkeletonMismatchException#SkeletonMismatchException(String)
36: */
37: public void test_Constructor_String() {
38: SkeletonMismatchException e = new SkeletonMismatchException(
39: errorMessage);
40: assertTrue(e instanceof java.rmi.RemoteException);
41: assertTrue(e instanceof RemoteException);
42: assertEquals(errorMessage, e.getMessage());
43: assertNull(e.detail);
44: }
45:
46: // comparator for SkeletonMismatchException objects
47: private static final SerializableAssert comparator = new SerializableAssert() {
48: public void assertDeserialized(Serializable initial,
49: Serializable deserialized) {
50:
51: SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(
52: initial, deserialized);
53:
54: SkeletonMismatchException initEx = (SkeletonMismatchException) initial;
55: SkeletonMismatchException desrEx = (SkeletonMismatchException) deserialized;
56: assertEquals(initEx.getMessage(), desrEx.getMessage());
57: assertEquals(initEx.detail, desrEx.detail);
58: }
59: };
60:
61: /**
62: * @tests serialization/deserialization.
63: */
64: public void testSerializationSelf() throws Exception {
65:
66: SerializationTest.verifySelf(new SkeletonMismatchException(
67: errorMessage), comparator);
68: }
69:
70: /**
71: * @tests serialization/deserialization compatibility with RI.
72: */
73: public void testSerializationCompatibility() throws Exception {
74:
75: SerializationTest
76: .verifyGolden(this , new SkeletonMismatchException(
77: errorMessage), comparator);
78: }
79:
80: }
|