<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.synyx.urlaubsverwaltung.service;

import org.junit.After;
import org.junit.AfterClass;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import sun.security.rsa.RSAPrivateCrtKeyImpl;
import sun.security.rsa.RSAPublicKeyImpl;

import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;

import java.util.Arrays;


/**
 * tests functionality of cryptoService
 *
 * @author  <NAME>
 */
public class CryptoServiceTest {

    private CryptoService instance;

    public CryptoServiceTest() {
    }

    // vor Bauen der Klasse
    @BeforeClass
    public static void setUpClass() throws Exception {
    }


    // nach Klasse
    @AfterClass
    public static void tearDownClass() throws Exception {
    }


    // wird vor jedem Test neu gemacht
    @Before
    public void setUp() {

        instance = new CryptoService();
    }


    // nach jedem Test
    @After
    public void tearDown() {
    }


    /** Test of generateKeyPair method, of class CryptoService. */
    @Test
    public void testGenerateKeyPair() throws Exception {

        KeyPair returnValue = instance.generateKeyPair();

        assertNotNull(returnValue);

        assertEquals(RSAPrivateCrtKeyImpl.class, returnValue.getPrivate().getClass());
        assertEquals(RSAPublicKeyImpl.class, returnValue.getPublic().getClass());
    }


    /** Test of sign method, of class CryptoService. */
    @Test
    public void testSign() throws Exception {

        PrivateKey privKey = instance.generateKeyPair().getPrivate();

        byte[] data = "DiesIstEinBeispielFuerByteErzeugung".getBytes();

        byte[] returnValue = instance.sign(privKey, data);

        assertNotNull(returnValue);

        // byte[] wurde veraendert durch signieren
        assertFalse(Arrays.equals(data, returnValue));
    }

<commit_msg>Removed Sun proprietary API .<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.synyx.urlaubsverwaltung.service;

import org.junit.After;
import org.junit.AfterClass;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;

import java.util.Arrays;


/**
 * tests functionality of cryptoService
 *
 * @author  <NAME>
 */
public class CryptoServiceTest {

    private CryptoService instance;

    public CryptoServiceTest() {
    }

    // vor Bauen der Klasse
    @BeforeClass
    public static void setUpClass() throws Exception {
    }


    // nach Klasse
    @AfterClass
    public static void tearDownClass() throws Exception {
    }


    // wird vor jedem Test neu gemacht
    @Before
    public void setUp() {

        instance = new CryptoService();
    }


    // nach jedem Test
    @After
    public void tearDown() {
    }


    /** Test of generateKeyPair method, of class CryptoService. */
    @Test
    public void testGenerateKeyPair() throws Exception {

        KeyPair returnValue = instance.generateKeyPair();

        assertNotNull(returnValue);

        assertEquals(KeyPair.class, returnValue.getClass());
    }


    /** Test of sign method, of class CryptoService. */
    @Test
    public void testSign() throws Exception {

        PrivateKey privKey = instance.generateKeyPair().getPrivate();

        byte[] data = "DiesIstEinBeispielFuerByteErzeugung".getBytes();

        byte[] returnValue = instance.sign(privKey, data);

        assertNotNull(returnValue);

        // byte[] wurde veraendert durch signieren
        assertFalse(Arrays.equals(data, returnValue));
    }


{'fraction_non_alphanumeric': 0.09596325839980663, 'fraction_numerical': 0.0, 'mean_word_length': 3.201015228426396, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6818075', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1158, 'n_words': 312}