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