@@ -0,0 +1,3569 @@
+/*%0A * This file is part of ClassGraph.%0A *%0A * Author: Luke Hutchison%0A *%0A * Hosted at: https://github.com/classgraph/classgraph%0A *%0A * --%0A *%0A * The MIT License (MIT)%0A *%0A * Copyright (c) 2019 Luke Hutchison%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated%0A * documentation files (the %22Software%22), to deal in the Software without restriction, including without%0A * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of%0A * the Software, and to permit persons to whom the Software is furnished to do so, subject to the following%0A * conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in all copies or substantial%0A * portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT%0A * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO%0A * EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN%0A * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE%0A * OR OTHER DEALINGS IN THE SOFTWARE.%0A */%0Apackage io.github.classgraph.issues.issue431;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0A%0Aimport java.util.Objects;%0A%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport io.github.classgraph.ClassGraph;%0Aimport io.github.classgraph.ClassInfo;%0Aimport io.github.classgraph.ScanResult;%0A%0A/**%0A * Issue431Test.%0A */%0Apublic class Issue431Test %7B%0A    /** Class X */%0A    public static class X %7B%0A        /** a */%0A        static final int a = 1;%0A        /** b */%0A        static final long b = 2L;%0A        /** c */%0A        static final short c = (short) 3;%0A        /** d */%0A        static final char d = 'd';%0A        /** e */%0A        static final boolean e = true;%0A        /** f */%0A        static final byte f = (byte) 10;%0A        /** g */%0A        static final float g = 1.0f;%0A        /** h */%0A        static final double h = 1.0d;%0A    %7D%0A%0A    /**%0A     * Test field equality.%0A     * %0A     * @param fieldName%0A     *            The field name%0A     * @param classInfo1%0A     *            The first ClassInfo%0A     * @param classInfo2%0A     *            The second ClassInfo%0A     */%0A    private void testFieldEquality(final String fieldName, final ClassInfo classInfo1, final ClassInfo classInfo2) %7B%0A        assertThat(Objects.equals(classInfo1.getFieldInfo(fieldName).getConstantInitializerValue(),%0A                classInfo2.getFieldInfo(fieldName).getConstantInitializerValue())).isTrue();%0A    %7D%0A%0A    /** Test serializing and deserializing primitive types. */%0A    @Test%0A    public void primitiveTypeSerialization() %7B%0A        final ClassGraph classGraph = new ClassGraph().whitelistPackages(Issue431Test.class.getPackage().getName())%0A                .enableAllInfo();%0A        try (ScanResult scanResult1 = classGraph.scan()) %7B%0A            final ClassInfo classInfo1 = scanResult1.getClassInfo(X.class.getName());%0A            assertThat(classInfo1).isNotNull();%0A            final String jsonResult = scanResult1.toJSON(2);%0A            final ScanResult scanResult2 = ScanResult.fromJSON(jsonResult);%0A            final ClassInfo classInfo2 = scanResult2.getClassInfo(X.class.getName());%0A            assertThat(classInfo2).isNotNull();%0A            for (char fieldName = 'a'; fieldName %3C= 'h'; fieldName++) %7B%0A                testFieldEquality(%22%22 + fieldName, classInfo1, classInfo2);%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add unit test (#431)