@@ -0,0 +1,2788 @@
+/**%0A* OpenCPS PKI is the open source PKI Integration software%0A* Copyright (C) 2016-present OpenCPS community%0A%0A* This program is free software: you can redistribute it and/or modify%0A* it under the terms of the GNU Affero General Public License as published by%0A* the Free Software Foundation, either version 3 of the License, or%0A* any later version.%0A%0A* This program 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%0A* GNU Affero General Public License for more details.%0A* You should have received a copy of the GNU Affero General Public License%0A* along with this program. If not, see %3Chttp://www.gnu.org/licenses/%3E%0A*/%0Apackage org.opencps.pki;%0A%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileNotFoundException;%0Aimport java.net.URL;%0Aimport java.security.cert.Certificate;%0Aimport java.security.cert.CertificateException;%0Aimport java.security.cert.CertificateFactory;%0Aimport java.security.cert.X509Certificate;%0A%0Aimport junit.framework.Test;%0Aimport junit.framework.TestCase;%0Aimport junit.framework.TestSuite;%0A%0A/**%0A * @author Nguyen Van Nguyen %3Cnguyennv@iwayvietnam.com%3E%0A */%0Apublic class CertificateInfoTest extends TestCase%7B%0A%0A    private static final String certPath = %22./src/test/java/resources/cert.pem%22;%0A    private CertificateInfo certInfo;%0A    X509Certificate cert;%0A    %0A    /**%0A     * Create the test case%0A     */%0A    public CertificateInfoTest(String testName) %7B%0A        super(testName);%0A    %7D%0A%0A    protected void setUp() throws CertificateException, FileNotFoundException %7B%0A        CertificateFactory cf = CertificateFactory.getInstance(%22X.509%22);%0A        cert = (X509Certificate) cf.generateCertificate(new FileInputStream(new File(certPath)));%0A        certInfo = new CertificateInfo(cert);%0A    %7D%0A%0A    /**%0A     * @return the suite of tests being tested%0A     */%0A    public static Test suite()%0A    %7B%0A        return new TestSuite(CertificateInfoTest.class);%0A    %7D%0A    %0A    public void testGetCommonName() %7B%0A        assertEquals(%22OpenCPS PKI%22, certInfo.getCommonName());%0A    %7D%0A    %0A    public void testGetOrganizationUnit() %7B%0A        assertEquals(%22OpenCPS Technical Committee%22, certInfo.getOrganizationUnit());%0A    %7D%0A    %0A    public void testGetOrganization() %7B%0A        assertEquals(%22OpenCPS Community%22, certInfo.getOrganization());%0A    %7D%0A    %0A    public void testGetEmail() %7B%0A        assertEquals(%22demo@opencps.org.vn%22, certInfo.getEmail());%0A        System.out.println(certInfo.getSerialNumber());%0A    %7D%0A    %0A    public void testGetSerialNumber() %7B%0A        assertEquals(%2217284444107497658335%22, certInfo.getSerialNumber());%0A    %7D%0A    %0A    public void testGetCertificate() %7B%0A        assertEquals(cert, certInfo.getCertificate());%0A    %7D%0A%7D%0A

Add CertificateInfoTest