@@ -0,0 +1,2017 @@
+package org.bouncycastle.asn1.test;%0A%0A%0Aimport java.util.Random;%0A%0Aimport org.bouncycastle.asn1.DERSequence;%0Aimport org.bouncycastle.asn1.cmc.BodyPartID;%0A%0Aimport org.bouncycastle.asn1.cmc.BodyPartPath;%0Aimport org.bouncycastle.util.test.SimpleTest;%0A%0Apublic class BodyPartPathTest extends SimpleTest%0A%7B%0A%0A    public void performTest()%0A        throws Exception%0A    %7B%0A        Random rand = new Random();%0A        %7B%0A            BodyPartID%5B%5D bpid = new BodyPartID%5BMath.abs(rand.nextInt()) %25 20%5D;%0A            for (int t = 0; t %3C bpid.length; t++)%0A            %7B%0A                bpid%5Bt%5D = new BodyPartID(Math.abs(rand.nextLong() %25 4294967295L));%0A            %7D%0A            BodyPartPath bpp = new BodyPartPath(bpid);%0A            DERSequence _bpp = (DERSequence)bpp.toASN1Primitive();%0A            byte%5B%5D b = bpp.getEncoded();%0A%0A            //%0A            // Decode and compare results.%0A            //%0A%0A            BodyPartPath resList = BodyPartPath.getInstance(b);%0A            DERSequence _resList = (DERSequence)resList.toASN1Primitive();%0A%0A            isEquals(_bpp.size(), _resList.size());%0A%0A            for (int j = 0; j %3C _bpp.size(); j++)%0A            %7B%0A                isEquals(_resList.getObjectAt(j), _bpp.getObjectAt(j));%0A            %7D%0A        %7D%0A        %7B%0A            //%0A            // Compare when same thing instantiated via different constructors.%0A            //%0A%0A            BodyPartID bpid = new BodyPartID(Math.abs(rand.nextLong() %25 4294967295L));%0A            BodyPartPath bpidList = new BodyPartPath(bpid); // Single entry constructor.%0A            BodyPartPath resList = new BodyPartPath(new BodyPartID%5B%5D%7Bbpid%7D); // Array constructor.%0A%0A            DERSequence _bpidList = (DERSequence)bpidList.toASN1Primitive();%0A            DERSequence _resList = (DERSequence)resList.toASN1Primitive();%0A%0A            isEquals(_bpidList, _resList);%0A        %7D%0A    %7D%0A%0A    public String getName()%0A    %7B%0A        return %22BodyPartPathTest%22;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        runTest(new BodyPartPathTest());%0A    %7D%0A%0A%7D%0A

Test for BodyPartPath.