1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 * 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, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18package org.apache.harmony.luni.tests.java.net;
19
20import java.io.Serializable;
21import java.net.HttpRetryException;
22
23import junit.framework.TestCase;
24
25import org.apache.harmony.testframework.serialization.SerializationTest;
26import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
27
28public class HttpRetryExceptionTest extends TestCase {
29
30    private static final String LOCATION = "Http test"; //$NON-NLS-1$
31
32    private static final String DETAIL = "detail"; //$NON-NLS-1$
33
34    // comparator for HttpRetryException objects
35    private static final SerializableAssert comparator = new SerializableAssert() {
36        public void assertDeserialized(Serializable reference, Serializable test) {
37
38            HttpRetryException ref = (HttpRetryException) reference;
39            HttpRetryException tst = (HttpRetryException) test;
40
41            assertEquals("getLocation", ref.getLocation(), tst.getLocation());
42            assertEquals("responseCode", ref.responseCode(), tst.responseCode());
43            assertEquals("getReason", ref.getReason(), tst.getReason());
44            assertEquals("getMessage", ref.getMessage(), tst.getMessage());
45        }
46    };
47
48    /**
49     * @tests serialization/deserialization.
50     */
51    public void testSerializationSelf() throws Exception {
52        SerializationTest.verifySelf(new HttpRetryException(DETAIL, 100,
53                LOCATION), comparator);
54    }
55
56    /**
57     * @tests serialization/deserialization compatibility with RI.
58     */
59    public void testSerializationCompatibility() throws Exception {
60        SerializationTest.verifyGolden(this, new HttpRetryException(DETAIL,
61                100, LOCATION), comparator);
62    }
63}
64