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: /**
19: * @author Vera Y. Petrashkova
20: * @version $Revision$
21: */package org.apache.harmony.auth.tests.javax.security.sasl.serialization;
22:
23: import java.io.Serializable;
24:
25: import javax.security.sasl.AuthorizeCallback;
26:
27: import org.apache.harmony.testframework.serialization.SerializationTest;
28:
29: /**
30: * Test for AuthorizeCallback serialization
31: *
32: */
33:
34: public class AuthorizeCallbackTest extends SerializationTest implements
35: SerializationTest.SerializableAssert {
36:
37: public static String[] msgs = {
38: "New String",
39: "Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID. Long stringID." };
40:
41: @Override
42: protected Object[] getData() {
43: String msg = null;
44: return new Object[] { new AuthorizeCallback(msg, msg),
45: new AuthorizeCallback("", null),
46: new AuthorizeCallback(null, msgs[0]),
47: new AuthorizeCallback(msgs[1], msgs[1]), };
48: }
49:
50: public void assertDeserialized(Serializable oref, Serializable otest) {
51: AuthorizeCallback ref = (AuthorizeCallback) oref;
52: AuthorizeCallback test = (AuthorizeCallback) otest;
53: String idC = ref.getAuthenticationID();
54: String idZ = ref.getAuthorizationID();
55: String id = ref.getAuthorizedID();
56: boolean is = ref.isAuthorized();
57: if (idC == null) {
58: assertNull(test.getAuthenticationID());
59: } else {
60: assertEquals(test.getAuthenticationID(), idC);
61: }
62: if (idZ == null) {
63: assertNull(test.getAuthorizationID());
64: } else {
65: assertEquals(test.getAuthorizationID(), idZ);
66: }
67: if (id == null) {
68: assertNull(test.getAuthorizedID());
69: } else {
70: assertEquals(test.getAuthorizedID(), id);
71: }
72: assertEquals(test.isAuthorized(), is);
73:
74: }
75: }
|