001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.harmony.rmi.server;
019:
020: import java.io.Serializable;
021: import java.rmi.server.SkeletonNotFoundException;
022:
023: import org.apache.harmony.testframework.serialization.SerializationTest;
024: import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
025:
026: public class SkeletonNotFoundExceptionTest extends
027: junit.framework.TestCase {
028:
029: private String errorMessage;
030:
031: private String causeMessage;
032:
033: private Exception cause;
034:
035: /**
036: * Sets up the fixture, for example, open a network connection. This method
037: * is called before a test is executed.
038: */
039: @Override
040: protected void setUp() {
041: errorMessage = "Skeleton Not Found";
042: causeMessage = "Caused Exception";
043: cause = new SkeletonNotFoundException(causeMessage);
044: }
045:
046: /**
047: * @tests java.rmi.server.SkeletonNotFoundException#SkeletonNotFoundException(String)
048: */
049: public void test_Constructor_String() {
050: SkeletonNotFoundException e = new SkeletonNotFoundException(
051: errorMessage);
052: assertTrue(e instanceof java.rmi.RemoteException);
053: assertEquals(errorMessage, e.getMessage());
054: }
055:
056: /**
057: * @tests java.rmi.server.SkeletonNotFoundException#SkeletonNotFoundException(String,Exception)
058: */
059: public void test_Constructor_String_Exception() {
060: SkeletonNotFoundException e = new SkeletonNotFoundException(
061: errorMessage, cause);
062: assertEquals(cause.getMessage(), e.getCause().getMessage());
063: }
064:
065: // comparator for SkeletonNotFoundException objects
066: private static final SerializableAssert comparator = new SerializableAssert() {
067: public void assertDeserialized(Serializable initial,
068: Serializable deserialized) {
069:
070: SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(
071: initial, deserialized);
072:
073: SkeletonNotFoundException initEx = (SkeletonNotFoundException) initial;
074: SkeletonNotFoundException desrEx = (SkeletonNotFoundException) deserialized;
075:
076: assertEquals(initEx.getMessage(), desrEx.getMessage());
077: assertEquals(initEx.getCause().getMessage(), desrEx
078: .getCause().getMessage());
079: }
080: };
081:
082: /**
083: * @tests serialization/deserialization.
084: */
085: public void testSerializationSelf() throws Exception {
086:
087: SerializationTest.verifySelf(new SkeletonNotFoundException(
088: errorMessage, cause), comparator);
089: }
090:
091: /**
092: * @tests serialization/deserialization compatibility with RI.
093: */
094: public void testSerializationCompatibility() throws Exception {
095:
096: SerializationTest.verifyGolden(this ,
097: new SkeletonNotFoundException(errorMessage, cause),
098: comparator);
099: }
100:
101: }
|