@@ -0,0 +1,2182 @@
+//%0A// $Id$%0A//%0A// Depot library - a Java relational persistence library%0A// Copyright (C) 2006-2010 Michael Bayne and P%C3%A4r Winzell%0A//%0A// This library is free software; you can redistribute it and/or modify it%0A// under the terms of the GNU Lesser General Public License as published%0A// by the Free Software Foundation; either version 2.1 of the License, or%0A// (at your option) any later version.%0A//%0A// This library is distributed in the hope that it will be useful,%0A// but WITHOUT ANY WARRANTY; without even the implied warranty of%0A// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A// Lesser General Public License for more details.%0A//%0A// You should have received a copy of the GNU Lesser General Public%0A// License along with this library; if not, write to the Free Software%0A// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA%0A%0Apackage com.samskivert.depot.tests;%0A%0Aimport java.lang.reflect.Field;%0A%0Aimport org.junit.Test;%0Aimport static org.junit.Assert.*;%0A%0Aimport com.samskivert.util.ByteEnum;%0A%0Aimport com.samskivert.depot.PersistentRecord;%0Aimport com.samskivert.depot.impl.FieldMarshaller;%0A%0A/**%0A * Tests ByteEnum related bits.%0A */%0Apublic class ByteEnumTest%0A%7B%0A    public enum TestEnum implements ByteEnum %7B%0A        ONE(1), TWO(2), THREE(3);%0A%0A        // from interface ByteEnum%0A        public byte toByte () %7B%0A            return _code;%0A        %7D%0A%0A        TestEnum (int code) %7B%0A            _code = (byte)code;%0A        %7D%0A        protected byte _code;%0A    %7D%0A%0A    public class NotAnEnum implements ByteEnum %7B%0A        public byte toByte () %7B%0A            return 0;%0A        %7D%0A    %7D%0A%0A    public static class TestRecord extends PersistentRecord%0A    %7B%0A        public TestEnum good;%0A        public NotAnEnum bad;%0A    %7D%0A%0A    @Test public void testMarshaller ()%0A        throws NoSuchFieldException%0A    %7B%0A        Field good = TestRecord.class.getField(%22good%22);%0A        Field bad = TestRecord.class.getField(%22bad%22);%0A        assertTrue(FieldMarshaller.createMarshaller(good) != null);%0A%0A        try %7B%0A            FieldMarshaller.createMarshaller(bad);%0A            fail();%0A        %7D catch (IllegalArgumentException iae) %7B%0A            // expected%0A        %7D%0A    %7D%0A%7D%0A

Test good and bad byte enum marshaller creation.