@@ -0,0 +1,2630 @@
+package org.yamcs.xtce;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport java.lang.reflect.Field;%0A%0Aimport org.junit.Test;%0Aimport org.yamcs.xtceproc.XtceDbFactory;%0A%0A/**%0A * Test copy of parameter types%0A * @author nm%0A *%0A */%0Apublic class TestCloning %7B%0A    @Test%0A    public void test1() throws IllegalArgumentException, IllegalAccessException %7B%0A        XtceDb xtceDb  = XtceDbFactory.createInstanceByConfig(%22refmdb%22);%0A        for(Parameter p: xtceDb.getParameters()) %7B%0A            ParameterType t1 = p.getParameterType();%0A            if(t1==null) continue;%0A            ParameterType t2 = clone(t1);%0A            assertNotEquals(t1, t2);%0A            try %7B%0A                verifyEquals(t1, t2);%0A            %7D catch (AssertionError e) %7B%0A                throw new AssertionError(%22failed to verify %22+t1+%22: %22+e.getMessage());%0A            %7D%0A        %7D%0A    %7D%0A%0A%0A%0A    ParameterType clone(ParameterType ptype) %7B%0A        if(ptype instanceof BinaryParameterType) %7B%0A            BinaryParameterType t = (BinaryParameterType) ptype;%0A            return new BinaryParameterType(t);%0A%0A        %7D else if (ptype instanceof BooleanParameterType) %7B%0A            BooleanParameterType t = (BooleanParameterType) ptype;%0A            return new BooleanParameterType(t);%0A%0A        %7D else if (ptype instanceof EnumeratedParameterType) %7B%0A            EnumeratedParameterType t = (EnumeratedParameterType) ptype;%0A            return new EnumeratedParameterType(t);%0A%0A        %7D else if (ptype instanceof FloatParameterType) %7B%0A            FloatParameterType t = (FloatParameterType) ptype;%0A            return new FloatParameterType(t);%0A%0A        %7D else if (ptype instanceof IntegerParameterType) %7B%0A            IntegerParameterType t = (IntegerParameterType) ptype;%0A            return new IntegerParameterType(t);%0A%0A        %7D else if (ptype instanceof StringParameterType) %7B%0A            StringParameterType t = (StringParameterType) ptype;%0A            return new StringParameterType(t);%0A        %7D else %7B%0A            throw new IllegalArgumentException(%22Cannot clone type %22+ptype);%0A        %7D%0A    %7D%0A%0A%0A    private void verifyEquals(ParameterType p1, ParameterType p2) throws IllegalArgumentException, IllegalAccessException %7B%0A        Class c1 = p1.getClass();%0A        Class c2 = p2.getClass();%0A        while(true) %7B%0A            assertEquals(c1, c2);%0A            Field%5B%5D fa = c1.getDeclaredFields();%0A            for(Field f:fa) %7B%0A                f.setAccessible(true);%0A                assertEquals(f.get(p1), f.get(p2));%0A            %7D%0A            c1 = c1.getSuperclass();%0A            c2 = c2.getSuperclass();%0A            if(c1==null) %7B%0A                break;%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

test copy constructors