Home | History | Annotate | Download | only in objenesis
      1 /**
      2  * Copyright 2006-2013 the original author or authors.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *     http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package org.objenesis;
     17 
     18 import java.io.NotSerializableException;
     19 
     20 import junit.framework.TestCase;
     21 
     22 /**
     23  * @author Henri Tremblay
     24  * @author Leonardo Mesquita
     25  */
     26 public class SerializingInstantiatorTest extends TestCase {
     27 
     28    protected void setUp() throws Exception {
     29       super.setUp();
     30    }
     31 
     32    protected void tearDown() throws Exception {
     33       super.tearDown();
     34    }
     35 
     36    public void testNotSerializable() {
     37       ObjenesisSerializer o = new ObjenesisSerializer();
     38       try {
     39     	  o.newInstance(Object.class);
     40     	  fail("Should have thrown an exception");
     41       } catch (ObjenesisException e) {
     42     	  assertTrue(e.getCause() instanceof NotSerializableException);
     43       }
     44    }
     45 }
     46