01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.geronimo.connector.outbound;
21:
22: import java.net.URI;
23: import java.io.ByteArrayOutputStream;
24: import java.io.ObjectOutputStream;
25: import java.io.ByteArrayInputStream;
26: import java.io.ObjectInputStream;
27:
28: import junit.framework.TestCase;
29: import org.apache.geronimo.kernel.Kernel;
30: import org.apache.geronimo.kernel.basic.BasicKernel;
31: import org.apache.geronimo.gbean.GBeanData;
32: import org.apache.geronimo.gbean.AbstractName;
33: import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoTransactions;
34: import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool;
35:
36: /**
37: * @version $Rev: 541105 $ $Date: 2007-05-23 15:27:56 -0700 (Wed, 23 May 2007) $
38: */
39: public class GenericConnectionManagerGBeanSerializationTest extends
40: TestCase {
41:
42: public void testSerialization() throws Exception {
43: Kernel kernel = new BasicKernel("test");
44: kernel.boot();
45: AbstractName abstractName = new AbstractName(URI
46: .create("foo/bar/1/car?name=ConnectionManager"));
47: GBeanData data = new GBeanData(abstractName,
48: GenericConnectionManagerGBean.GBEAN_INFO);
49: data
50: .setAttribute("transactionSupport",
51: NoTransactions.INSTANCE);
52: data.setAttribute("pooling", new SinglePool(10, 0, 5000, 5,
53: false, false, true));
54: kernel.loadGBean(data, this .getClass().getClassLoader());
55: kernel.startGBean(abstractName);
56: Object cm = kernel.getGBean(abstractName);
57: assertTrue(cm instanceof GenericConnectionManagerGBean);
58: ByteArrayOutputStream baos = new ByteArrayOutputStream();
59: ObjectOutputStream out = new ObjectOutputStream(baos);
60: out.writeObject(cm);
61: out.flush();
62: byte[] bytes = baos.toByteArray();
63: ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
64: ObjectInputStream in = new ObjectInputStream(bais);
65: Object cm2 = in.readObject();
66: assertSame(cm, cm2);
67: }
68: }
|