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
018package org.apache.commons.proxy2.provider;
019
020import org.apache.commons.proxy2.exception.ObjectProviderException;
021import org.apache.commons.proxy2.util.AbstractTestCase;
022import org.junit.Test;
023
024public class BeanProviderTest extends AbstractTestCase
025{
026    //**********************************************************************************************************************
027    // Other Methods
028    //**********************************************************************************************************************
029
030    @Test(expected = ObjectProviderException.class)
031    public void testAbstractBeanClass()
032    {
033        final BeanProvider<Number> p = new BeanProvider<Number>(Number.class);
034        p.getObject();
035    }
036
037    @Test(expected = ObjectProviderException.class)
038    public void testNonAccessibleConstructor()
039    {
040        new BeanProvider<MyBean>(MyBean.class).getObject();
041    }
042
043    @Test
044    public void testSerialization()
045    {
046        assertSerializable(new BeanProvider<MyBean>(MyBean.class));
047    }
048
049    @Test(expected = NullPointerException.class)
050    public void testWithNullBeanClass()
051    {
052        final BeanProvider<Object> p = new BeanProvider<Object>(null);
053        p.getObject();
054    }
055
056    //**********************************************************************************************************************
057    // Inner Classes
058    //**********************************************************************************************************************
059
060    public static class MyBean
061    {
062        private MyBean()
063        {
064
065        }
066    }
067}