Пример #1
0
  @Test
  public void shiftUpDecTest() throws IOException, InvalidEncryptionKeyException {
    // Decryption - ShiftUpEncryption
    doubleEncryption.decryptFile(TEST_INPUT2, TEST_OUT_PATH_2, TEST_KEY);
    String expected = fs.readFile(TEST_OUT_PATH_2);
    String actual = TI1;

    assertEquals(expected, actual);
  }
Пример #2
0
  @Test
  public void shiftMulEncTest() throws IOException, InvalidEncryptionKeyException {
    // Encryption - ShiftMultiplyEncryption
    doubleEncryption.setAlgorithem(alg2);

    doubleEncryption.encryptFile(TEST_INPUT3, TEST_OUT_PATH, TEST_KEY2);
    String expected = fs.readFile(TEST_OUT_PATH);
    String actual = TI4;

    assertEquals(expected, actual);
  }
Пример #3
0
  @Before
  public void executedBeforeEach() throws IOException, InvalidEncryptionKeyException {
    fs = mock(FileHandler.class);
    io_keys = mock(IOkeys.class);
    when(fs.readFile(TEST_INPUT)).thenReturn(TI1);
    when(fs.readFile(TEST_INPUT2)).thenReturn(TI2);
    when(fs.readFile(TEST_INPUT3)).thenReturn(TI3);
    when(fs.readFile(TEST_INPUT4)).thenReturn(TI4);
    when(io_keys.readKeys(TEST_KEY, 2)).thenReturn(new KeyM1(2, 4));
    when(io_keys.readKeys(TEST_KEY2, 2)).thenReturn(new KeyM1(2, 3));
    when(io_keys.readKeys(TEST_KEY3, 2)).thenReturn(new KeyM1(28, 32));
    when(io_keys.readKeys(TEST_KEY4, 2)).thenReturn(new Key1(5));
    // doCallRealMethod().when(fs).readKeys("testKey3", 2);
    // when(fs.readKeys("testKey2",2));
    doCallRealMethod().when(fs).writeToFile(anyString(), anyString());
    doCallRealMethod().when(fs).readFile(TEST_OUT_PATH);
    doCallRealMethod().when(fs).readFile(TEST_OUT_PATH_2);
    doCallRealMethod().when(io_keys).readKeys(TEST_OUT_PATH, 2);
    doCallRealMethod().when(io_keys).readKeys(KET_EXP0_PATH, 2);

    doubleEncryption = new DoubleEncryption(alg, fs, io_keys);

    // System.out.println("@Before: executedBeforeEach");
  }