Best Powermock code snippet using org.powermock.api.easymock.PowerMock.expectStrictNew
Source:ServerToClientTest.java
...467 // mock step 6468 EasyMock.expect(localFile.createNewFile()).andReturn(true).times(1);469 // mock step 7470 FileOutputStream fos = PowerMock.createStrictMock(FileOutputStream.class);471 PowerMock.expectStrictNew(FileOutputStream.class, localFile, true).andReturn(fos).times(1);472 EasyMock.expect(ftp.retrieveFile("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml", fos)).andReturn(false).times(1);473 // mock step 8474 fos.close();475 EasyMock.expectLastCall().times(1);476 PowerMock.replay(ftp, ftpFile, localFile, localFileParentPath, FileOutputStream.class, fos);477 // =================== Input ===================478 // =================== Process ===================479 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");480 boolean result = (Boolean) method.invoke(client);481 // =================== Output ===================482 Assert.assertEquals(false, result);483 // =================== After ===================484 PowerMock.verify(ftp, ftpFile, localFile, localFileParentPath, FileOutputStream.class, fos);485 }486 /**487 * Download process, when remote file exists, and local file not exists, and create local file success,488 * and retrieve remote file success, success is expected.489 *490 * @throws Exception491 */492 @Test493 @PrepareForTest({ ServerToClient.class })494 public void testDoTransferDownload006() throws Exception {495 // =================== Before ===================496 ServerToClient client = new ServerToClient();497 // ftpVO498 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");499 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");500 field1.setAccessible(true);501 field1.set(client, vo);502 // localFile503 File localFile = PowerMock.createStrictMock(File.class);504 Field field2 = ServerToClient.class.getDeclaredField("localFile");505 field2.setAccessible(true);506 field2.set(client, localFile);507 // ftp508 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);509 Field field3 = ServerToClient.class.getDeclaredField("ftp");510 field3.setAccessible(true);511 field3.set(client, ftp);512 // mock step 1513 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);514 // mock step 2515 ftp.enterLocalPassiveMode();516 EasyMock.expectLastCall().times(1);517 // mock step 3518 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);519 FTPFile[] ftpFiles = {ftpFile};520 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);521 // mock step 4522 EasyMock.expect(localFile.exists()).andReturn(false);523 // mock step 5524 File localFileParentPath = PowerMock.createStrictMock(File.class);525 EasyMock.expect(localFile.getParentFile()).andReturn(localFileParentPath).times(1);526 EasyMock.expect(localFileParentPath.exists()).andReturn(false).times(1);527 EasyMock.expect(localFile.getParentFile()).andReturn(localFileParentPath).times(1);528 EasyMock.expect(localFileParentPath.mkdirs()).andReturn(true).times(1);529 // mock step 6530 EasyMock.expect(localFile.createNewFile()).andReturn(true).times(1);531 // mock step 7532 FileOutputStream fos = PowerMock.createStrictMock(FileOutputStream.class);533 PowerMock.expectStrictNew(FileOutputStream.class, localFile, true).andReturn(fos).times(1);534 EasyMock.expect(ftp.retrieveFile("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml", fos)).andReturn(true).times(1);535 // mock step 8536 fos.close();537 EasyMock.expectLastCall().times(1);538 PowerMock.replay(ftp, ftpFile, localFile, localFileParentPath, FileOutputStream.class, fos);539 // =================== Input ===================540 // =================== Process ===================541 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");542 boolean result = (Boolean) method.invoke(client);543 // =================== Output ===================544 Assert.assertEquals(true, result);545 // =================== After ===================546 PowerMock.verify(ftp, ftpFile, localFile, localFileParentPath, FileOutputStream.class, fos);547 }548 /**549 * Download process, when remote file exists, and local file exists, and is not resume broken transfer mode,550 * but fail to delete local file, failure is expected.551 *552 * @throws Exception553 */554 @Test555 public void testDoTransferDownload007() throws Exception {556 // =================== Before ===================557 ServerToClient client = new ServerToClient();558 client.setResumeBroken(false);559 // ftpVO560 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");561 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");562 field1.setAccessible(true);563 field1.set(client, vo);564 // localFile565 File localFile = PowerMock.createStrictMock(File.class);566 Field field2 = ServerToClient.class.getDeclaredField("localFile");567 field2.setAccessible(true);568 field2.set(client, localFile);569 // ftp570 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);571 Field field3 = ServerToClient.class.getDeclaredField("ftp");572 field3.setAccessible(true);573 field3.set(client, ftp);574 // mock step 1575 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);576 // mock step 2577 ftp.enterLocalPassiveMode();578 EasyMock.expectLastCall().times(1);579 // mock step 3580 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);581 FTPFile[] ftpFiles = {ftpFile};582 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);583 // mock step 4584 EasyMock.expect(localFile.exists()).andReturn(true).times(1);585 // mock step 5586 EasyMock.expect(localFile.delete()).andReturn(false).times(1);587 EasyMock.replay(ftp, ftpFile, localFile);588 // =================== Input ===================589 // =================== Process ===================590 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");591 boolean result = (Boolean) method.invoke(client);592 // =================== Output ===================593 Assert.assertEquals(false, result);594 // =================== After ===================595 EasyMock.verify(ftp, ftpFile, localFile);596 }597 /**598 * Download process, when remote file exists, and local file exists, and is not resume broken transfer mode,599 * and delete local file success, but fail to recreate local file, failure is expected.600 *601 * @throws Exception602 */603 @Test604 public void testDoTransferDownload008() throws Exception {605 // =================== Before ===================606 ServerToClient client = new ServerToClient();607 client.setResumeBroken(false);608 // ftpVO609 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");610 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");611 field1.setAccessible(true);612 field1.set(client, vo);613 // localFile614 File localFile = PowerMock.createStrictMock(File.class);615 Field field2 = ServerToClient.class.getDeclaredField("localFile");616 field2.setAccessible(true);617 field2.set(client, localFile);618 // ftp619 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);620 Field field3 = ServerToClient.class.getDeclaredField("ftp");621 field3.setAccessible(true);622 field3.set(client, ftp);623 // mock step 1624 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);625 // mock step 2626 ftp.enterLocalPassiveMode();627 EasyMock.expectLastCall().times(1);628 // mock step 3629 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);630 FTPFile[] ftpFiles = {ftpFile};631 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);632 // mock step 4633 EasyMock.expect(localFile.exists()).andReturn(true).times(1);634 // mock step 5635 EasyMock.expect(localFile.delete()).andReturn(true).times(1);636 EasyMock.expect(localFile.createNewFile()).andReturn(false).times(1);637 EasyMock.replay(ftp, ftpFile, localFile);638 // =================== Input ===================639 // =================== Process ===================640 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");641 boolean result = (Boolean) method.invoke(client);642 // =================== Output ===================643 Assert.assertEquals(false, result);644 // =================== After ===================645 EasyMock.verify(ftp, ftpFile, localFile);646 }647 /**648 * Download process, when remote file exists, and local file exists, and is not resume broken transfer mode,649 * and delete local file success, and recreate local file success, and retrieve remote file success,650 * success is expected.651 *652 * @throws Exception653 */654 @Test655 @PrepareForTest({ ServerToClient.class })656 public void testDoTransferDownload009() throws Exception {657 // =================== Before ===================658 ServerToClient client = new ServerToClient();659 client.setResumeBroken(false);660 // ftpVO661 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");662 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");663 field1.setAccessible(true);664 field1.set(client, vo);665 // localFile666 File localFile = PowerMock.createStrictMock(File.class);667 Field field2 = ServerToClient.class.getDeclaredField("localFile");668 field2.setAccessible(true);669 field2.set(client, localFile);670 // ftp671 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);672 Field field3 = ServerToClient.class.getDeclaredField("ftp");673 field3.setAccessible(true);674 field3.set(client, ftp);675 // mock step 1676 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);677 // mock step 2678 ftp.enterLocalPassiveMode();679 EasyMock.expectLastCall().times(1);680 // mock step 3681 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);682 FTPFile[] ftpFiles = {ftpFile};683 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);684 // mock step 4685 EasyMock.expect(localFile.exists()).andReturn(true).times(1);686 // mock step 5687 EasyMock.expect(localFile.delete()).andReturn(true).times(1);688 EasyMock.expect(localFile.createNewFile()).andReturn(true).times(1);689 // mock step 6690 FileOutputStream fos = PowerMock.createStrictMock(FileOutputStream.class);691 PowerMock.expectStrictNew(FileOutputStream.class, localFile, true).andReturn(fos).times(1);692 EasyMock.expect(ftp.retrieveFile("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml", fos)).andReturn(true).times(1);693 // mock step 7694 fos.close();695 EasyMock.expectLastCall().times(1);696 PowerMock.replay(ftp, ftpFile, localFile, FileOutputStream.class, fos);697 // =================== Input ===================698 // =================== Process ===================699 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");700 boolean result = (Boolean) method.invoke(client);701 // =================== Output ===================702 Assert.assertEquals(true, result);703 // =================== After ===================704 PowerMock.verify(ftp, ftpFile, localFile, FileOutputStream.class, fos);705 }706 /**707 * Download process, when remote file exists, and local file exists, and is resume broken transfer mode,708 * but local file size is larger than remote file size, failure is expected.709 *710 * @throws Exception711 */712 @Test713 public void testDoTransferDownload010() throws Exception {714 // =================== Before ===================715 ServerToClient client = new ServerToClient();716 // ftpVO717 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");718 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");719 field1.setAccessible(true);720 field1.set(client, vo);721 // localFile722 File localFile = PowerMock.createStrictMock(File.class);723 Field field2 = ServerToClient.class.getDeclaredField("localFile");724 field2.setAccessible(true);725 field2.set(client, localFile);726 // ftp727 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);728 Field field3 = ServerToClient.class.getDeclaredField("ftp");729 field3.setAccessible(true);730 field3.set(client, ftp);731 // mock step 1732 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);733 // mock step 2734 ftp.enterLocalPassiveMode();735 EasyMock.expectLastCall().times(1);736 // mock step 3737 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);738 FTPFile[] ftpFiles = {ftpFile};739 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);740 // mock step 4741 EasyMock.expect(localFile.exists()).andReturn(true).times(1);742 // mock step 5743 EasyMock.expect(localFile.length()).andReturn(100L).times(1);744 EasyMock.expect(ftpFile.getSize()).andReturn(99L).times(1);745 EasyMock.replay(ftp, ftpFile, localFile);746 // =================== Input ===================747 // =================== Process ===================748 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");749 boolean result = (Boolean) method.invoke(client);750 // =================== Output ===================751 Assert.assertEquals(false, result);752 // =================== After ===================753 EasyMock.verify(ftp, ftpFile, localFile);754 }755 /**756 * Download process, when remote file exists, and local file exists, and is resume broken transfer mode,757 * but local file size is equal to remote file size, failure is expected.758 *759 * @throws Exception760 */761 @Test762 public void testDoTransferDownload011() throws Exception {763 // =================== Before ===================764 ServerToClient client = new ServerToClient();765 // ftpVO766 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");767 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");768 field1.setAccessible(true);769 field1.set(client, vo);770 // localFile771 File localFile = PowerMock.createStrictMock(File.class);772 Field field2 = ServerToClient.class.getDeclaredField("localFile");773 field2.setAccessible(true);774 field2.set(client, localFile);775 // ftp776 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);777 Field field3 = ServerToClient.class.getDeclaredField("ftp");778 field3.setAccessible(true);779 field3.set(client, ftp);780 // mock step 1781 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);782 // mock step 2783 ftp.enterLocalPassiveMode();784 EasyMock.expectLastCall().times(1);785 // mock step 3786 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);787 FTPFile[] ftpFiles = {ftpFile};788 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);789 // mock step 4790 EasyMock.expect(localFile.exists()).andReturn(true).times(1);791 // mock step 5792 EasyMock.expect(localFile.length()).andReturn(100L).times(1);793 EasyMock.expect(ftpFile.getSize()).andReturn(100L).times(1);794 EasyMock.replay(ftp, ftpFile, localFile);795 // =================== Input ===================796 // =================== Process ===================797 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");798 boolean result = (Boolean) method.invoke(client);799 // =================== Output ===================800 Assert.assertEquals(false, result);801 // =================== After ===================802 EasyMock.verify(ftp, ftpFile, localFile);803 }804 /**805 * Download process, when remote file exists, and local file exists, and is resume broken transfer mode,806 * and local file size is smaller than remote file size, and retrieve remote file success, success is expected.807 *808 * @throws Exception809 */810 @Test811 @PrepareForTest({ ServerToClient.class })812 public void testDoTransferDownload012() throws Exception {813 // =================== Before ===================814 ServerToClient client = new ServerToClient();815 // ftpVO816 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");817 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");818 field1.setAccessible(true);819 field1.set(client, vo);820 // localFile821 File localFile = PowerMock.createStrictMock(File.class);822 Field field2 = ServerToClient.class.getDeclaredField("localFile");823 field2.setAccessible(true);824 field2.set(client, localFile);825 // ftp826 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);827 Field field3 = ServerToClient.class.getDeclaredField("ftp");828 field3.setAccessible(true);829 field3.set(client, ftp);830 // mock step 1831 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);832 // mock step 2833 ftp.enterLocalPassiveMode();834 EasyMock.expectLastCall().times(1);835 // mock step 3836 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);837 FTPFile[] ftpFiles = {ftpFile};838 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);839 // mock step 4840 EasyMock.expect(localFile.exists()).andReturn(true).times(1);841 // mock step 5842 EasyMock.expect(localFile.length()).andReturn(99L).times(1);843 EasyMock.expect(ftpFile.getSize()).andReturn(100L).times(1);844 // mock step 6845 ftp.setRestartOffset(99L);846 EasyMock.expectLastCall().times(1);847 // mock step 7848 FileOutputStream fos = PowerMock.createStrictMock(FileOutputStream.class);849 PowerMock.expectStrictNew(FileOutputStream.class, localFile, true).andReturn(fos).times(1);850 EasyMock.expect(ftp.retrieveFile("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml", fos)).andReturn(true).times(1);851 // mock step 8852 fos.close();853 EasyMock.expectLastCall().times(1);854 PowerMock.replay(ftp, ftpFile, localFile, FileOutputStream.class, fos);855 // =================== Input ===================856 // =================== Process ===================857 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");858 boolean result = (Boolean) method.invoke(client);859 // =================== Output ===================860 Assert.assertEquals(true, result);861 // =================== After ===================862 PowerMock.verify(ftp, ftpFile, localFile, FileOutputStream.class, fos);863 }864 /**865 * Upload process, when local file not exists, failure is expected.866 *867 * @throws Exception868 */869 @Test870 public void testDoTransferUpload001() throws Exception {871 // =================== Before ===================872 ServerToClient client = new ServerToClient();873 client.setTransferMode(FTPTransferMode.UPLOAD);874 // ftpVO875 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");876 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");877 field1.setAccessible(true);878 field1.set(client, vo);879 // localFile880 File localFile = PowerMock.createStrictMock(File.class);881 Field field2 = ServerToClient.class.getDeclaredField("localFile");882 field2.setAccessible(true);883 field2.set(client, localFile);884 // ftp885 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);886 Field field3 = ServerToClient.class.getDeclaredField("ftp");887 field3.setAccessible(true);888 field3.set(client, ftp);889 // mock step 1890 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);891 // mock step 2892 ftp.enterLocalPassiveMode();893 EasyMock.expectLastCall().times(1);894 // mock step 3895 EasyMock.expect(localFile.exists()).andReturn(false).times(1);896 EasyMock.replay(ftp, localFile);897 // =================== Input ===================898 // =================== Process ===================899 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");900 boolean result = (Boolean) method.invoke(client);901 // =================== Output ===================902 Assert.assertEquals(false, result);903 // =================== After ===================904 EasyMock.verify(ftp, localFile);905 }906 /**907 * Upload process, when local file exists, and remote file not exists, but fail to create remote file parent directory,908 * failure is expected.909 *910 * @throws Exception911 */912 @Test913 public void testDoTransferUpload002() throws Exception {914 // =================== Before ===================915 ServerToClient client = PowerMock.createPartialMock(ServerToClient.class, "changeDir");916 client.setTransferMode(FTPTransferMode.UPLOAD);917 // ftpVO918 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");919 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");920 field1.setAccessible(true);921 field1.set(client, vo);922 // localFile923 File localFile = PowerMock.createStrictMock(File.class);924 Field field2 = ServerToClient.class.getDeclaredField("localFile");925 field2.setAccessible(true);926 field2.set(client, localFile);927 // ftp928 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);929 Field field3 = ServerToClient.class.getDeclaredField("ftp");930 field3.setAccessible(true);931 field3.set(client, ftp);932 // mock step 1933 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);934 // mock step 2935 ftp.enterLocalPassiveMode();936 EasyMock.expectLastCall().times(1);937 // mock step 3938 EasyMock.expect(localFile.exists()).andReturn(true).times(1);939 // mock step 4940 FTPFile[] ftpFiles = {};941 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);942 // mock step 5943 PowerMock.expectPrivate(client, "changeDir", ftp, "/ftp/cmdfile").andReturn(false).times(1);944 PowerMock.replay(ServerToClient.class, client, ftp, localFile);945 // =================== Input ===================946 // =================== Process ===================947 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");948 boolean result = (Boolean) method.invoke(client);949 // =================== Output ===================950 Assert.assertEquals(false, result);951 // =================== After ===================952 PowerMock.verify(ServerToClient.class, client, ftp, localFile);953 }954 /**955 * Upload process, when local file exists, and remote file not exists, and create remote file parent directory success,956 * but fail to store remote file, failure is expected.957 *958 * @throws Exception959 */960 @Test961 @PrepareForTest({ ServerToClient.class })962 public void testDoTransferUpload003() throws Exception {963 // =================== Before ===================964 ServerToClient client = PowerMock.createPartialMock(ServerToClient.class, "changeDir");965 client.setTransferMode(FTPTransferMode.UPLOAD);966 // ftpVO967 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");968 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");969 field1.setAccessible(true);970 field1.set(client, vo);971 // localFile972 File localFile = PowerMock.createStrictMock(File.class);973 Field field2 = ServerToClient.class.getDeclaredField("localFile");974 field2.setAccessible(true);975 field2.set(client, localFile);976 // ftp977 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);978 Field field3 = ServerToClient.class.getDeclaredField("ftp");979 field3.setAccessible(true);980 field3.set(client, ftp);981 // mock step 1982 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);983 // mock step 2984 ftp.enterLocalPassiveMode();985 EasyMock.expectLastCall().times(1);986 // mock step 3987 EasyMock.expect(localFile.exists()).andReturn(true).times(1);988 // mock step 4989 FTPFile[] ftpFiles = {};990 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);991 // mock step 5992 PowerMock.expectPrivate(client, "changeDir", ftp, "/ftp/cmdfile").andReturn(true).times(1);993 // mock step 6994 FileInputStream fis = PowerMock.createStrictMock(FileInputStream.class);995 PowerMock.expectStrictNew(FileInputStream.class, localFile).andReturn(fis).times(1);996 EasyMock.expect(fis.skip(0L)).andReturn(0L).times(1);997 // mock step 7998 EasyMock.expect(ftp.storeFile("04_VOD_20110411093958_001047556.xml", fis)).andReturn(false).times(1);999 // mock step 81000 fis.close();1001 EasyMock.expectLastCall().times(1);1002 PowerMock.replay(ServerToClient.class, client, ftp, localFile, FileInputStream.class, fis);1003 // =================== Input ===================1004 // =================== Process ===================1005 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");1006 boolean result = (Boolean) method.invoke(client);1007 // =================== Output ===================1008 Assert.assertEquals(false, result);1009 // =================== After ===================1010 PowerMock.verify(ServerToClient.class, client, ftp, localFile, FileInputStream.class, fis);1011 }1012 /**1013 * Upload process, when local file exists, and remote file not exists, and create remote file parent directory success,1014 * and store remote file success, success is expected.1015 *1016 * @throws Exception1017 */1018 @Test1019 @PrepareForTest({ ServerToClient.class })1020 public void testDoTransferUpload004() throws Exception {1021 // =================== Before ===================1022 ServerToClient client = PowerMock.createPartialMock(ServerToClient.class, "changeDir");1023 client.setTransferMode(FTPTransferMode.UPLOAD);1024 // ftpVO1025 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");1026 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");1027 field1.setAccessible(true);1028 field1.set(client, vo);1029 // localFile1030 File localFile = PowerMock.createStrictMock(File.class);1031 Field field2 = ServerToClient.class.getDeclaredField("localFile");1032 field2.setAccessible(true);1033 field2.set(client, localFile);1034 // ftp1035 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);1036 Field field3 = ServerToClient.class.getDeclaredField("ftp");1037 field3.setAccessible(true);1038 field3.set(client, ftp);1039 // mock step 11040 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);1041 // mock step 21042 ftp.enterLocalPassiveMode();1043 EasyMock.expectLastCall().times(1);1044 // mock step 31045 EasyMock.expect(localFile.exists()).andReturn(true).times(1);1046 // mock step 41047 FTPFile[] ftpFiles = {};1048 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);1049 // mock step 51050 PowerMock.expectPrivate(client, "changeDir", ftp, "/ftp/cmdfile").andReturn(true).times(1);1051 // mock step 61052 FileInputStream fis = PowerMock.createStrictMock(FileInputStream.class);1053 PowerMock.expectStrictNew(FileInputStream.class, localFile).andReturn(fis).times(1);1054 EasyMock.expect(fis.skip(0L)).andReturn(0L).times(1);1055 // mock step 71056 EasyMock.expect(ftp.storeFile("04_VOD_20110411093958_001047556.xml", fis)).andReturn(true).times(1);1057 // mock step 81058 fis.close();1059 EasyMock.expectLastCall().times(1);1060 PowerMock.replay(ServerToClient.class, client, ftp, localFile, FileInputStream.class, fis);1061 // =================== Input ===================1062 // =================== Process ===================1063 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");1064 boolean result = (Boolean) method.invoke(client);1065 // =================== Output ===================1066 Assert.assertEquals(true, result);1067 // =================== After ===================1068 PowerMock.verify(ServerToClient.class, client, ftp, localFile, FileInputStream.class, fis);1069 }1070 /**1071 * Upload process, when local file exists, and remote file exists, and is not resume broken transfer mode,1072 * but fail to delete remote file, failure is expected.1073 *1074 * @throws Exception1075 */1076 @Test1077 public void testDoTransferUpload005() throws Exception {1078 // =================== Before ===================1079 ServerToClient client = new ServerToClient();1080 client.setTransferMode(FTPTransferMode.UPLOAD);1081 client.setResumeBroken(false);1082 // ftpVO1083 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");1084 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");1085 field1.setAccessible(true);1086 field1.set(client, vo);1087 // localFile1088 File localFile = PowerMock.createStrictMock(File.class);1089 Field field2 = ServerToClient.class.getDeclaredField("localFile");1090 field2.setAccessible(true);1091 field2.set(client, localFile);1092 // ftp1093 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);1094 Field field3 = ServerToClient.class.getDeclaredField("ftp");1095 field3.setAccessible(true);1096 field3.set(client, ftp);1097 // mock step 11098 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);1099 // mock step 21100 ftp.enterLocalPassiveMode();1101 EasyMock.expectLastCall().times(1);1102 // mock step 31103 EasyMock.expect(localFile.exists()).andReturn(true).times(1);1104 // mock step 41105 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);1106 FTPFile[] ftpFiles = {ftpFile};1107 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);1108 // mock step 51109 EasyMock.expect(ftp.deleteFile("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(false).times(1);1110 EasyMock.replay(ftp, localFile);1111 // =================== Input ===================1112 // =================== Process ===================1113 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");1114 boolean result = (Boolean) method.invoke(client);1115 // =================== Output ===================1116 Assert.assertEquals(false, result);1117 // =================== After ===================1118 EasyMock.verify(ftp, localFile);1119 }1120 /**1121 * Upload process, when local file exists, and remote file exists, and is not resume broken transfer mode,1122 * and delete remote file success, and store remote file success, success is expected.1123 *1124 * @throws Exception1125 */1126 @Test1127 @PrepareForTest({ ServerToClient.class })1128 public void testDoTransferUpload006() throws Exception {1129 // =================== Before ===================1130 ServerToClient client = PowerMock.createPartialMock(ServerToClient.class, "changeDir");1131 client.setTransferMode(FTPTransferMode.UPLOAD);1132 client.setResumeBroken(false);1133 // ftpVO1134 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");1135 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");1136 field1.setAccessible(true);1137 field1.set(client, vo);1138 // localFile1139 File localFile = PowerMock.createStrictMock(File.class);1140 Field field2 = ServerToClient.class.getDeclaredField("localFile");1141 field2.setAccessible(true);1142 field2.set(client, localFile);1143 // ftp1144 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);1145 Field field3 = ServerToClient.class.getDeclaredField("ftp");1146 field3.setAccessible(true);1147 field3.set(client, ftp);1148 // mock step 11149 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);1150 // mock step 21151 ftp.enterLocalPassiveMode();1152 EasyMock.expectLastCall().times(1);1153 // mock step 31154 EasyMock.expect(localFile.exists()).andReturn(true).times(1);1155 // mock step 41156 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);1157 FTPFile[] ftpFiles = {ftpFile};1158 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);1159 // mock step 51160 EasyMock.expect(ftp.deleteFile("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(true).times(1);1161 // mock step 61162 PowerMock.expectPrivate(client, "changeDir", ftp, "/ftp/cmdfile").andReturn(true).times(1);1163 // mock step 71164 FileInputStream fis = PowerMock.createStrictMock(FileInputStream.class);1165 PowerMock.expectStrictNew(FileInputStream.class, localFile).andReturn(fis).times(1);1166 EasyMock.expect(fis.skip(0L)).andReturn(0L).times(1);1167 // mock step 81168 EasyMock.expect(ftp.storeFile("04_VOD_20110411093958_001047556.xml", fis)).andReturn(true).times(1);1169 // mock step 81170 fis.close();1171 EasyMock.expectLastCall().times(1);1172 PowerMock.replay(ServerToClient.class, client, ftp, localFile, FileInputStream.class, fis);1173 // =================== Input ===================1174 // =================== Process ===================1175 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");1176 boolean result = (Boolean) method.invoke(client);1177 // =================== Output ===================1178 Assert.assertEquals(true, result);1179 // =================== After ===================1180 PowerMock.verify(ServerToClient.class, client, ftp, localFile, FileInputStream.class, fis);1181 }1182 /**1183 * Upload process, when local file exists, and remote file exists, and is resume broken transfer mode,1184 * local file size is smaller than remote file size, failure is expected.1185 *1186 * @throws Exception1187 */1188 @Test1189 public void testDoTransferUpload007() throws Exception {1190 // =================== Before ===================1191 ServerToClient client = new ServerToClient();1192 client.setTransferMode(FTPTransferMode.UPLOAD);1193 // ftpVO1194 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");1195 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");1196 field1.setAccessible(true);1197 field1.set(client, vo);1198 // localFile1199 File localFile = PowerMock.createStrictMock(File.class);1200 Field field2 = ServerToClient.class.getDeclaredField("localFile");1201 field2.setAccessible(true);1202 field2.set(client, localFile);1203 // ftp1204 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);1205 Field field3 = ServerToClient.class.getDeclaredField("ftp");1206 field3.setAccessible(true);1207 field3.set(client, ftp);1208 // mock step 11209 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);1210 // mock step 21211 ftp.enterLocalPassiveMode();1212 EasyMock.expectLastCall().times(1);1213 // mock step 31214 EasyMock.expect(localFile.exists()).andReturn(true).times(1);1215 // mock step 41216 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);1217 FTPFile[] ftpFiles = {ftpFile};1218 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);1219 // mock step 51220 EasyMock.expect(localFile.length()).andReturn(99L).times(1);1221 EasyMock.expect(ftpFile.getSize()).andReturn(100L).times(1);1222 EasyMock.replay(ftp, localFile, ftpFile);1223 // =================== Input ===================1224 // =================== Process ===================1225 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");1226 boolean result = (Boolean) method.invoke(client);1227 // =================== Output ===================1228 Assert.assertEquals(false, result);1229 // =================== After ===================1230 EasyMock.verify(ftp, localFile, ftpFile);1231 }1232 /**1233 * Upload process, when local file exists, and remote file exists, and is resume broken transfer mode,1234 * local file size is equal to remote file size, failure is expected.1235 *1236 * @throws Exception1237 */1238 @Test1239 public void testDoTransferUpload008() throws Exception {1240 // =================== Before ===================1241 ServerToClient client = new ServerToClient();1242 client.setTransferMode(FTPTransferMode.UPLOAD);1243 // ftpVO1244 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");1245 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");1246 field1.setAccessible(true);1247 field1.set(client, vo);1248 // localFile1249 File localFile = PowerMock.createStrictMock(File.class);1250 Field field2 = ServerToClient.class.getDeclaredField("localFile");1251 field2.setAccessible(true);1252 field2.set(client, localFile);1253 // ftp1254 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);1255 Field field3 = ServerToClient.class.getDeclaredField("ftp");1256 field3.setAccessible(true);1257 field3.set(client, ftp);1258 // mock step 11259 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);1260 // mock step 21261 ftp.enterLocalPassiveMode();1262 EasyMock.expectLastCall().times(1);1263 // mock step 31264 EasyMock.expect(localFile.exists()).andReturn(true).times(1);1265 // mock step 41266 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);1267 FTPFile[] ftpFiles = {ftpFile};1268 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);1269 // mock step 51270 EasyMock.expect(localFile.length()).andReturn(100L).times(1);1271 EasyMock.expect(ftpFile.getSize()).andReturn(100L).times(1);1272 EasyMock.replay(ftp, localFile, ftpFile);1273 // =================== Input ===================1274 // =================== Process ===================1275 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");1276 boolean result = (Boolean) method.invoke(client);1277 // =================== Output ===================1278 Assert.assertEquals(false, result);1279 // =================== After ===================1280 EasyMock.verify(ftp, localFile, ftpFile);1281 }1282 /**1283 * Upload process, when local file exists, and remote file exists, and is resume broken transfer mode,1284 * local file size is larger than remote file size, but fail to set local file skip size, failure is expected.1285 *1286 * @throws Exception1287 */1288 @Test1289 @PrepareForTest({ ServerToClient.class })1290 public void testDoTransferUpload009() throws Exception {1291 // =================== Before ===================1292 ServerToClient client = PowerMock.createPartialMock(ServerToClient.class, "changeDir");1293 client.setTransferMode(FTPTransferMode.UPLOAD);1294 client.setResumeBroken(true);1295 // ftpVO1296 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");1297 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");1298 field1.setAccessible(true);1299 field1.set(client, vo);1300 // localFile1301 File localFile = PowerMock.createStrictMock(File.class);1302 Field field2 = ServerToClient.class.getDeclaredField("localFile");1303 field2.setAccessible(true);1304 field2.set(client, localFile);1305 // ftp1306 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);1307 Field field3 = ServerToClient.class.getDeclaredField("ftp");1308 field3.setAccessible(true);1309 field3.set(client, ftp);1310 // mock step 11311 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);1312 // mock step 21313 ftp.enterLocalPassiveMode();1314 EasyMock.expectLastCall().times(1);1315 // mock step 31316 EasyMock.expect(localFile.exists()).andReturn(true).times(1);1317 // mock step 41318 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);1319 FTPFile[] ftpFiles = {ftpFile};1320 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);1321 // mock step 51322 EasyMock.expect(localFile.length()).andReturn(100L).times(1);1323 EasyMock.expect(ftpFile.getSize()).andReturn(99L).times(1);1324 // mock step 61325 ftp.setRestartOffset(99L);1326 EasyMock.expectLastCall().times(1);1327 // mock step 71328 PowerMock.expectPrivate(client, "changeDir", ftp, "/ftp/cmdfile").andReturn(true).times(1);1329 // mock step 81330 FileInputStream fis = PowerMock.createStrictMock(FileInputStream.class);1331 PowerMock.expectStrictNew(FileInputStream.class, localFile).andReturn(fis).times(1);1332 EasyMock.expect(fis.skip(99L)).andReturn(0L).times(1);1333 // mock step 91334 fis.close();1335 EasyMock.expectLastCall();1336 PowerMock.replay(ServerToClient.class, client, ftp, localFile, ftpFile, FileInputStream.class, fis);1337 // =================== Input ===================1338 // =================== Process ===================1339 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");1340 boolean result = (Boolean) method.invoke(client);1341 // =================== Output ===================1342 Assert.assertEquals(false, result);1343 // =================== After ===================1344 PowerMock.verify(ServerToClient.class, client, ftp, localFile, ftpFile, FileInputStream.class, fis);1345 }1346 /**1347 * Upload process, when local file exists, and remote file exists, and is resume broken transfer mode,1348 * local file size is larger than remote file size, and set local file skip size success, and store remote file success,1349 * success is expected.1350 *1351 * @throws Exception1352 */1353 @Test1354 @PrepareForTest({ ServerToClient.class })1355 public void testDoTransferUpload010() throws Exception {1356 // =================== Before ===================1357 ServerToClient client = PowerMock.createPartialMock(ServerToClient.class, "changeDir");1358 client.setTransferMode(FTPTransferMode.UPLOAD);1359 client.setResumeBroken(true);1360 // ftpVO1361 FTPFileInfoVO vo = AbstractFTPClient.convertFTPUrlToVO("ftp://username:password@192.168.19.251/ftp/cmdfile/04_VOD_20110411093958_001047556.xml");1362 Field field1 = ServerToClient.class.getDeclaredField("ftpVO");1363 field1.setAccessible(true);1364 field1.set(client, vo);1365 // localFile1366 File localFile = PowerMock.createStrictMock(File.class);1367 Field field2 = ServerToClient.class.getDeclaredField("localFile");1368 field2.setAccessible(true);1369 field2.set(client, localFile);1370 // ftp1371 FTPClient ftp = PowerMock.createStrictMock(FTPClient.class);1372 Field field3 = ServerToClient.class.getDeclaredField("ftp");1373 field3.setAccessible(true);1374 field3.set(client, ftp);1375 // mock step 11376 EasyMock.expect(ftp.setFileType(FTP.BINARY_FILE_TYPE)).andReturn(true).times(1);1377 // mock step 21378 ftp.enterLocalPassiveMode();1379 EasyMock.expectLastCall().times(1);1380 // mock step 31381 EasyMock.expect(localFile.exists()).andReturn(true).times(1);1382 // mock step 41383 FTPFile ftpFile = PowerMock.createStrictMock(FTPFile.class);1384 FTPFile[] ftpFiles = {ftpFile};1385 EasyMock.expect(ftp.listFiles("/ftp/cmdfile/04_VOD_20110411093958_001047556.xml")).andReturn(ftpFiles).times(1);1386 // mock step 51387 EasyMock.expect(localFile.length()).andReturn(100L).times(1);1388 EasyMock.expect(ftpFile.getSize()).andReturn(99L).times(1);1389 // mock step 61390 ftp.setRestartOffset(99L);1391 EasyMock.expectLastCall().times(1);1392 // mock step 71393 PowerMock.expectPrivate(client, "changeDir", ftp, "/ftp/cmdfile").andReturn(true).times(1);1394 // mock step 81395 FileInputStream fis = PowerMock.createStrictMock(FileInputStream.class);1396 PowerMock.expectStrictNew(FileInputStream.class, localFile).andReturn(fis).times(1);1397 EasyMock.expect(fis.skip(99L)).andReturn(99L).times(1);1398 // mock step 91399 EasyMock.expect(ftp.storeFile("04_VOD_20110411093958_001047556.xml", fis)).andReturn(true).times(1);1400 // mock step 101401 fis.close();1402 EasyMock.expectLastCall();1403 PowerMock.replay(ServerToClient.class, client, ftp, localFile, ftpFile, FileInputStream.class, fis);1404 // =================== Input ===================1405 // =================== Process ===================1406 Method method = ServerToClient.class.getDeclaredMethod("doTransfer");1407 boolean result = (Boolean) method.invoke(client);1408 // =================== Output ===================1409 Assert.assertEquals(true, result);1410 // =================== After ===================...
Source:TranslateTaskTest.java
...76 // the next thing is calling the task and that should actually do things.77 Future<String> firstFuture = createMock(Future.class);78 expect(firstFuture.get()).andReturn("Hallo.").anyTimes();79 TranslateSentenceTask task1Mock = PowerMock.createMock(TranslateSentenceTask.class);80 PowerMock.expectStrictNew(TranslateSentenceTask.class,81 new Class<?>[]{TranslationProvider.class, TranslationDirection.class, String.class},82 provider, TranslationDirection.EnglishToGerman, "Hello.")83 .andReturn(task1Mock);84 expect(service.submit(task1Mock)).andReturn(firstFuture);85 Future<String> secondFuture = createMock(Future.class);86 expect(secondFuture.get()).andReturn("Das ist eine Zeile mit mehreren Sätzen.").anyTimes();87 TranslateSentenceTask task2Mock = PowerMock.createMock(TranslateSentenceTask.class);88 PowerMock.expectStrictNew(TranslateSentenceTask.class,89 new Class<?>[]{TranslationProvider.class, TranslationDirection.class, String.class},90 provider, TranslationDirection.EnglishToGerman,91 "This is a multi sentence line!").andReturn(task2Mock);92 expect(service.submit(task2Mock)).andReturn(secondFuture);93 Future<String> thirdFuture = createMock(Future.class);94 expect(thirdFuture.get()).andReturn("Sie sollte geteilt werden.").anyTimes();95 TranslateSentenceTask task3Mock = PowerMock.createMock(TranslateSentenceTask.class);96 PowerMock.expectStrictNew(TranslateSentenceTask.class,97 new Class<?>[]{TranslationProvider.class, TranslationDirection.class, String.class},98 provider, TranslationDirection.EnglishToGerman,99 "It should be split.").andReturn(task3Mock);100 expect(service.submit(task3Mock)).andReturn(thirdFuture);101 Future<String> fourthFuture = createMock(Future.class);102 expect(fourthFuture.get()).andReturn("Auch wenn der letzte Teil nicht abgeschlossen ist").anyTimes();103 TranslateSentenceTask task4Mock = PowerMock.createMock(TranslateSentenceTask.class);104 PowerMock.expectStrictNew(TranslateSentenceTask.class,105 new Class<?>[]{TranslationProvider.class, TranslationDirection.class, String.class},106 provider, TranslationDirection.EnglishToGerman,107 "Even if the last part is not terminated").andReturn(task4Mock);108 expect(service.submit(task4Mock)).andReturn(fourthFuture);109 callback.sendTranslation("Hallo. Das ist eine Zeile mit mehreren Sätzen. Sie sollte geteilt werden. Auch wenn" +110 " der letzte Teil nicht abgeschlossen ist");111 PowerMock.replay(task1Mock, task2Mock, task3Mock, task4Mock);112 PowerMock.replay(TranslateSentenceTask.class);113 replayAll();114 // Everything we expect is recorded. Let's do this.115 task.call();116 PowerMock.verify(task1Mock, task2Mock, task3Mock, task4Mock);117 PowerMock.verify(TranslateSentenceTask.class);118 verifyAll();119 }120 /**121 * Test if the translation task correctly excludes the default headers from the text.122 *123 * @throws Exception124 */125 @SuppressWarnings({"ConstantConditions", "unchecked"})126 @Test127 public void testHeaderExclusion1() throws Exception {128 service = createMock(ExecutorService.class);129 provider = createMock(TranslationProvider.class);130 callback = createMock(TranslatorCallback.class);131 replayAll();132 Callable task = new TranslateTask(service, provider, TranslationDirection.EnglishToGerman,133 "You hear: ALL YOUR BASE ARE BELONG TO US.",134 callback);135 verifyAll();136 resetAll();137 // until now nothing should happen to ensure that the creation of the task is very cheap138 // the next thing is calling the task and that should actually do things.139 Future<String> translationFuture = createMock(Future.class);140 expect(translationFuture.get()).andReturn("ALL DEINE STÃTZPUNKT SIND GEHÃREN UNS.").anyTimes();141 TranslateSentenceTask sentenceTask = PowerMock.createMock(TranslateSentenceTask.class);142 PowerMock.expectStrictNew(TranslateSentenceTask.class,143 new Class<?>[]{TranslationProvider.class, TranslationDirection.class, String.class},144 provider, TranslationDirection.EnglishToGerman, "ALL YOUR BASE ARE BELONG TO US.")145 .andReturn(sentenceTask);146 expect(service.submit(sentenceTask)).andReturn(translationFuture);147 callback.sendTranslation("You hear: ALL DEINE STÃTZPUNKT SIND GEHÃREN UNS.");148 PowerMock.replay(sentenceTask);149 PowerMock.replay(TranslateSentenceTask.class);150 replayAll();151 // Everything we expect is recorded. Let's do this.152 task.call();153 PowerMock.verify(sentenceTask);154 PowerMock.verify(TranslateSentenceTask.class);155 verifyAll();156 }157 /**158 * Test if the translation task correctly excludes headers that contain generic parts (names) from the text.159 *160 * @throws Exception161 */162 @SuppressWarnings({"ConstantConditions", "unchecked"})163 @Test164 public void testHeaderExclusion2() throws Exception {165 service = createMock(ExecutorService.class);166 provider = createMock(TranslationProvider.class);167 callback = createMock(TranslatorCallback.class);168 replayAll();169 Callable task = new TranslateTask(service, provider, TranslationDirection.EnglishToGerman,170 "Somebody says: ALL YOUR BASE ARE BELONG TO US.",171 callback);172 verifyAll();173 resetAll();174 // until now nothing should happen to ensure that the creation of the task is very cheap175 // the next thing is calling the task and that should actually do things.176 Future<String> translationFuture = createMock(Future.class);177 expect(translationFuture.get()).andReturn("ALL DEINE STÃTZPUNKT SIND GEHÃREN UNS.").anyTimes();178 TranslateSentenceTask sentenceTask = PowerMock.createMock(TranslateSentenceTask.class);179 PowerMock.expectStrictNew(TranslateSentenceTask.class,180 new Class<?>[]{TranslationProvider.class, TranslationDirection.class, String.class},181 provider, TranslationDirection.EnglishToGerman, "ALL YOUR BASE ARE BELONG TO US.")182 .andReturn(sentenceTask);183 expect(service.submit(sentenceTask)).andReturn(translationFuture);184 callback.sendTranslation("Somebody says: ALL DEINE STÃTZPUNKT SIND GEHÃREN UNS.");185 PowerMock.replay(sentenceTask);186 PowerMock.replay(TranslateSentenceTask.class);187 replayAll();188 // Everything we expect is recorded. Let's do this.189 task.call();190 PowerMock.verify(sentenceTask);191 PowerMock.verify(TranslateSentenceTask.class);192 verifyAll();193 }194 /**195 * Test if the translation task correctly identifies and excludes OOC marks from the translation.196 *197 * @throws Exception198 */199 @SuppressWarnings({"ConstantConditions", "unchecked"})200 @Test201 public void testHeaderExclusionOoc() throws Exception {202 service = createMock(ExecutorService.class);203 provider = createMock(TranslationProvider.class);204 callback = createMock(TranslatorCallback.class);205 replayAll();206 Callable task = new TranslateTask(service, provider, TranslationDirection.EnglishToGerman,207 "Somebody says: ((ALL YOUR BASE ARE BELONG TO US.))",208 callback);209 verifyAll();210 resetAll();211 // until now nothing should happen to ensure that the creation of the task is very cheap212 // the next thing is calling the task and that should actually do things.213 Future<String> translationFuture = createMock(Future.class);214 expect(translationFuture.get()).andReturn("ALL DEINE STÃTZPUNKT SIND GEHÃREN UNS.").anyTimes();215 TranslateSentenceTask sentenceTask = PowerMock.createMock(TranslateSentenceTask.class);216 PowerMock.expectStrictNew(TranslateSentenceTask.class,217 new Class<?>[]{TranslationProvider.class, TranslationDirection.class, String.class},218 provider, TranslationDirection.EnglishToGerman, "ALL YOUR BASE ARE BELONG TO US.")219 .andReturn(sentenceTask);220 expect(service.submit(sentenceTask)).andReturn(translationFuture);221 callback.sendTranslation("Somebody says: ((ALL DEINE STÃTZPUNKT SIND GEHÃREN UNS.))");222 PowerMock.replay(sentenceTask);223 PowerMock.replay(TranslateSentenceTask.class);224 replayAll();225 // Everything we expect is recorded. Let's do this.226 task.call();227 PowerMock.verify(sentenceTask);228 PowerMock.verify(TranslateSentenceTask.class);229 verifyAll();230 }...
Source:UrlValidatorTest.java
...3import static junit.framework.Assert.assertEquals;4import static org.powermock.api.easymock.PowerMock.createNiceMock;5import static org.powermock.api.easymock.PowerMock.createStrictMock;6import static org.powermock.api.easymock.PowerMock.expectLastCall;7import static org.powermock.api.easymock.PowerMock.expectStrictNew;8import static org.powermock.api.easymock.PowerMock.expectNew;9import static org.powermock.api.easymock.PowerMock.replayAll;10import static org.powermock.api.easymock.PowerMock.verifyAll;1112import java.net.HttpURLConnection;13import java.net.MalformedURLException;14import java.net.URL;15import java.util.ResourceBundle;1617import org.junit.Before;18import org.junit.Test;19import org.junit.runner.RunWith;20import org.powermock.core.classloader.annotations.PrepareForTest;21import org.powermock.modules.junit4.PowerMockRunner;2223import de.juwimm.cms.common.Constants;24import de.juwimm.cms.util.UrlValidator;2526@RunWith(PowerMockRunner.class)27@PrepareForTest( {URL.class, UrlValidator.class})28public class UrlValidatorTest {2930 @Before31 public void setUp() {32 Constants.rb = ResourceBundle.getBundle("CMS", Constants.CMS_LOCALE);33 }3435 @Test36 public void testValidateHappyFlow() throws Exception {37 String testLink = "igoogle.com";3839 URL url = createStrictMock(URL.class);40 HttpURLConnection conn = createNiceMock(HttpURLConnection.class);4142 expectStrictNew(URL.class, "http://" + testLink).andReturn(url);43 url.openConnection();44 expectLastCall().andReturn(conn);45 conn.setConnectTimeout(2000);46 expectLastCall();47 conn.setReadTimeout(5000);48 expectLastCall();49 conn.setInstanceFollowRedirects(true);50 expectLastCall();51 conn.setRequestProperty("User-agent", "crawler");52 expectLastCall();53 conn.connect();54 expectLastCall();55 conn.getResponseCode();56 expectLastCall().andReturn(200);57 conn.getURL();58 expectLastCall().andReturn(url);59 url.toExternalForm();60 expectLastCall().andReturn(testLink);6162 replayAll();63 String actual = UrlValidator.validate(testLink);64 assertEquals(testLink, actual);65 verifyAll();66 }6768 @Test69 public void testValidateInvalidUrl() throws Exception {70 String testLink = "cd+45";7172 URL url = createStrictMock(URL.class);73 HttpURLConnection conn = createNiceMock(HttpURLConnection.class);7475 expectStrictNew(URL.class, "http://" + testLink).andReturn(url);76 url.openConnection();77 expectLastCall().andThrow(new MalformedURLException());7879 replayAll();80 String actual = UrlValidator.validate(testLink);81 assertEquals("Invalid URL", actual);82 verifyAll();83 }84}
...
expectStrictNew
Using AI Code Generation
1import org.powermock.api.easymock.PowerMock;2import org.junit.Test;3import static org.easymock.EasyMock.*;4public class 4 {5 public void test() {6 PowerMock.expectStrictNew(4.class, "1", "2", "3").andReturn("4");7 PowerMock.replayAll();8 PowerMock.verifyAll();9 }10}11import org.powermock.api.easymock.PowerMock;12import org.junit.Test;13import static org.easymock.EasyMock.*;14public class 5 {15 public void test() {16 PowerMock.expectNew(5.class, "1", "2", "3").andReturn("4");17 PowerMock.replayAll();18 PowerMock.verifyAll();19 }20}21import org.powermock.api.easymock.PowerMock;22import org.junit.Test;23import static org.easymock.EasyMock.*;24public class 6 {25 public void test() {26 PowerMock.expectNew(6.class, "1", "2", "3").andReturn("4");27 PowerMock.replayAll();28 PowerMock.verifyAll();29 }30}31import org.powermock.api.easymock.PowerMock;32import org.junit.Test;33import static org.easymock.EasyMock.*;34public class 7 {35 public void test() {36 PowerMock.expectNew(7.class, "1", "2", "3").andReturn("4");37 PowerMock.replayAll();38 PowerMock.verifyAll();39 }40}41import org.powermock.api.easymock.PowerMock;42import org.junit.Test;43import static org.easymock.EasyMock.*;44public class 8 {45 public void test() {46 PowerMock.expectNew(8.class, "1", "2", "3").andReturn("4");
expectStrictNew
Using AI Code Generation
1package org.powermock.examples.tutorial.strictnew;2import static org.easymock.EasyMock.expect;3import static org.powermock.api.easymock.PowerMock.expectNew;4import java.util.ArrayList;5import java.util.List;6import org.junit.Test;7import org.junit.runner.RunWith;8import org.powermock.core.classloader.annotations.PrepareForTest;9import org.powermock.modules.junit4.PowerMockRunner;10@RunWith(PowerMockRunner.class)11@PrepareForTest({ ClassWithStaticInitialization.class, ClassWithStaticInitializationWithArguments.class })12public class StrictNewTest {13 public void test() throws Exception {14 expectNew(ArrayList.class).andStubReturn(new ArrayList());15 expectNew(ArrayList.class, 10).andStubReturn(new ArrayList());16 expectNew(ClassWithStaticInitialization.class).andStubReturn(new ClassWithStaticInitialization());17 expectNew(ClassWithStaticInitializationWithArguments.class, "test").andStubReturn(new ClassWithStaticInitializationWithArguments("test"));18 }19}20package org.powermock.examples.tutorial.strictnew;21import static org.easymock.EasyMock.expect;22import static org.powermock.api.easymock.PowerMock.expectNew;23import java.util.ArrayList;24import java.util.List;25import org.junit.Test;26import org.junit.runner.RunWith;27import org.powermock.core.classloader.annotations.PrepareForTest;28import org.powermock.modules.junit4.PowerMockRunner;29@RunWith(PowerMockRunner.class)30@PrepareForTest({ ClassWithStaticInitialization.class, ClassWithStaticInitializationWithArguments.class })31public class StrictNewTest {32 public void test() throws Exception {33 expectNew(ArrayList.class).andStubReturn(new ArrayList());34 expectNew(ArrayList.class, 10).andStubReturn(new ArrayList());35 expectNew(ClassWithStaticInitialization.class).andStubReturn(new ClassWithStaticInitialization());36 expectNew(ClassWithStaticInitializationWithArguments.class, "test").andStubReturn(new ClassWithStaticInitializationWithArguments("test"));37 }38}39package org.powermock.examples.tutorial.strictnew;40import static org.easymock.EasyMock.expect;41import static org.powermock.api.easymock.PowerMock.expectNew;42import java.util.ArrayList;43import java.util.List
expectStrictNew
Using AI Code Generation
1import org.powermock.api.easymock.PowerMock;2import org.powermock.core.classloader.annotations.PrepareForTest;3import static org.easymock.EasyMock.expect;4import static org.easymock.EasyMock.expectNew;5import static org.easymock.EasyMock.replay;6import static org.easymock.EasyMock.verify;7import static org.junit.Assert.assertEquals;8import org.junit.Before;9import org.junit.Test;10@PrepareForTest({ClassToMock.class})11public class ClassToMockTest {12 private ClassToMock classToMock;13 private ClassToMock mockClassToMock;14 public void setUp() throws Exception {15 classToMock = new ClassToMock();16 mockClassToMock = PowerMock.expectStrictNew(ClassToMock.class);17 }18 public void test() {19 expect(mockClassToMock.doSomething()).andReturn("Mocked");20 replay(mockClassToMock);21 assertEquals("Mocked", classToMock.doSomething());22 verify(mockClassToMock);23 }24}25import org.powermock.api.easymock.PowerMock;26import org.powermock.core.classloader.annotations.PrepareForTest;27import static org.easymock.EasyMock.expect;28import static org.easymock.EasyMock.expectNew;29import static org.easymock.EasyMock.replay;30import static org.easymock.EasyMock.verify;31import static org.junit.Assert.assertEquals;32import org.junit.Before;33import org.junit.Test;34@PrepareForTest({ClassToMock.class})35public class ClassToMockTest {36 private ClassToMock classToMock;37 private ClassToMock mockClassToMock;38 public void setUp() throws Exception {39 classToMock = new ClassToMock();40 mockClassToMock = PowerMock.expectNew(ClassToMock.class);41 }42 public void test() {43 expect(mockClassToMock.doSomething()).andReturn("Mocked");44 replay(mockClassToMock);45 assertEquals("Mocked", classToMock.doSomething());46 verify(mockClassToMock);47 }48}
expectStrictNew
Using AI Code Generation
1package com.powermock.demo;2import org.powermock.api.easymock.PowerMock;3import org.powermock.core.classloader.annotations.PrepareForTest;4@PrepareForTest( { 4.class })5public class 4 {6 public void testStrictNew() {7 PowerMock.expectStrictNew(4.class, "test").andReturn(4);8 }9}10package com.powermock.demo;11import org.powermock.api.easymock.PowerMock;12import org.powermock.core.classloader.annotations.PrepareForTest;13@PrepareForTest( { 4.class })14public class 4 {15 public void testNew() {16 PowerMock.expectNew(4.class, "test").andReturn(4);17 }18}19package com.powermock.demo;20import org.powermock.api.easymock.PowerMock;21import org.powermock.core.classloader.annotations.PrepareForTest;22@PrepareForTest( { 4.class })23public class 4 {24 public void testNew() {25 PowerMock.expectNew(4.class, "test").andReturn(4);26 }27}28package com.powermock.demo;29import org.powermock.api.easymock.PowerMock;30import org.powermock.core.classloader.annotations.PrepareForTest;31@PrepareForTest( { 4.class })32public class 4 {33 public void testNew() {34 PowerMock.expectNew(4.class, "test").andReturn(4);35 }36}37package com.powermock.demo;38import org.powermock.api.easymock.PowerMock;39import org.powermock.core.classloader.annotations.PrepareForTest;40@PrepareForTest( { 4.class })41public class 4 {42 public void testNew() {43 PowerMock.expectNew(4.class, "test").andReturn(4);44 }45}
expectStrictNew
Using AI Code Generation
1package com.ack.j2se.mock;2import org.easymock.EasyMock;3import org.junit.Test;4import org.powermock.api.easymock.PowerMock;5import java.util.ArrayList;6public class Test4 {7 public void test() {8 ArrayList mock = PowerMock.expectStrictNew( ArrayList.class );9 EasyMock.expect( mock.size() ).andReturn( 5 );10 PowerMock.replayAll();11 System.out.println( mock.size() );12 PowerMock.verifyAll();13 }14}15package com.ack.j2se.mock;16import org.easymock.EasyMock;17import org.junit.Test;18import org.powermock.api.easymock.PowerMock;19import java.util.ArrayList;20public class Test5 {21 public void test() {22 ArrayList mock = PowerMock.expectNew( ArrayList.class );23 EasyMock.expect( mock.size() ).andReturn( 5 );24 PowerMock.replayAll();25 System.out.println( mock.size() );26 PowerMock.verifyAll();27 }28}29package com.ack.j2se.mock;30import org.easymock.EasyMock;31import org.junit.Test;32import org.powermock.api.easymock.PowerMock;33import java.util.ArrayList;34public class Test6 {35 public void test() {36 ArrayList mock = PowerMock.expectNew( ArrayList.class );37 EasyMock.expect( mock.size() ).andReturn( 5 );38 PowerMock.replayAll();39 System.out.println( mock.size() );40 PowerMock.verifyAll();41 }42}43package com.ack.j2se.mock;44import org.easymock.EasyMock;45import org.junit.Test;46import org.powermock.api.easymock.PowerMock;47import java.util.ArrayList;48public class Test7 {49 public void test() {50 ArrayList mock = PowerMock.expectNew( ArrayList.class );51 EasyMock.expect( mock.size() ).andReturn( 5 );52 PowerMock.replayAll();53 System.out.println( mock
expectStrictNew
Using AI Code Generation
1public class Test {2 public void test() {3 PowerMock.expectNew(4.class).andReturn(new 4());4 PowerMock.replayAll();5 4 t = new 4();6 PowerMock.verifyAll();7 }8}9public class Test {10 public void test() {11 PowerMock.expectNew(5.class).andReturn(new 5());12 PowerMock.replayAll();13 5 t = new 5();14 PowerMock.verifyAll();15 }16}17public class Test {18 public void test() {19 PowerMock.expectNew(6.class).andReturn(new 6());20 PowerMock.replayAll();21 6 t = new 6();22 PowerMock.verifyAll();23 }24}25public class Test {26 public void test() {27 PowerMock.expectNew(7.class).andReturn(new 7());28 PowerMock.replayAll();29 7 t = new 7();30 PowerMock.verifyAll();31 }32}33public class Test {34 public void test() {35 PowerMock.expectNew(8.class).andReturn(new 8());36 PowerMock.replayAll();37 8 t = new 8();38 PowerMock.verifyAll();39 }40}41public class Test {42 public void test() {43 PowerMock.expectNew(9.class).andReturn(new 9());44 PowerMock.replayAll();45 9 t = new 9();46 PowerMock.verifyAll();47 }48}49public class Test {50 public void test() {
expectStrictNew
Using AI Code Generation
1import org.powermock.api.easymock.PowerMock;2import org.powermock.core.classloader.annotations.PrepareForTest;3import org.powermock.modules.junit4.PowerMockRunner;4import org.junit.Test;5import org.junit.runner.RunWith;6import static org.easymock.EasyMock.expectNew;7import static org.powermock.api.easymock.PowerMock.replay;8import static org.powermock.api.easymock.PowerMock.verify;9import static org.junit.Assert.assertEquals;10@RunWith(PowerMockRunner.class)11@PrepareForTest({4.class})12public class 4 {13 public void test() throws Exception {14 3 mock = PowerMock.createMock(3.class);15 expectNew(3.class, "test").andReturn(mock);16 replay(3.class);17 4 test = new 4();18 3 result = test.test();19 verify(3.class);20 assertEquals(mock, result);21 }22}
expectStrictNew
Using AI Code Generation
1 }2}3package com.ack.j2se.mock;4import org.easymock.EasyMock;5import org.junit.Test;6import org.powermock.api.easymock.PowerMock;7import java.util.ArrayList;8public class Test7 {9 public void test() {10 ArrayList mock = PowerMock.expectNew( ArrayList.class );11 EasyMock.expect( mock.size() ).andReturn( 5 );12 PowerMock.replayAll();13 System.out.println( mock
expectStrictNew
Using AI Code Generation
1public class Test {2 public void test() {3 PowerMock.expectNew(4.class).andReturn(new 4());4 PowerMock.replayAll();5 4 t = new 4();6 PowerMock.verifyAll();7 }8}9public class Test {10 public void test() {11 PowerMock.expectNew(5.class).andReturn(new 5());12 PowerMock.replayAll();13 5 t = new 5();14 PowerMock.verifyAll();15 }16}17public class Test {18 public void test() {19 PowerMock.expectNew(6.class).andReturn(new 6());20 PowerMock.replayAll();21 6 t = new 6();22 PowerMock.verifyAll();23 }24}25public class Test {26 public void test() {27 PowerMock.expectNew(7.class).andReturn(new 7());28 PowerMock.replayAll();29 7 t = new 7();30 PowerMock.verifyAll();31 }32}33public class Test {34 public void test() {35 PowerMock.expectNew(8.class).andReturn(new 8());36 PowerMock.replayAll();37 8 t = new 8();38 PowerMock.verifyAll();39 }40}41public class Test {42 public void test() {43 PowerMock.expectNew(9.class).andReturn(new 9());44 PowerMock.replayAll();45 9 t = new 9();46 PowerMock.verifyAll();47 }48}49public class Test {50 public void test() {
expectStrictNew
Using AI Code Generation
1import org.powermock.api.easymock.PowerMock;2import org.powermock.core.classloader.annotations.PrepareForTest;3import org.powermock.modules.junit4.PowerMockRunner;4import org.junit.Test;5import org.junit.runner.RunWith;6import static org.easymock.EasyMock.expectNew;7import static org.powermock.api.easymock.PowerMock.replay;8import static org.powermock.api.easymock.PowerMock.verify;9import static org.junit.Assert.assertEquals;10@RunWith(PowerMockRunner.class)11@PrepareForTest({4.class})12public class 4 {13 public void test() throws Exception {14 3 mock = PowerMock.createMock(3.class);15 expectNew(3.class, "test").andReturn(mock);16 replay(3.class);17 4 test = new 4();18 3 result = test.test();19 verify(3.class);20 assertEquals(mock, result);21 }22}
expectStrictNew
Using AI Code Generation
1import java.util.ArrayList;2public class Test7 {3 public void test() {4 ArrayList mock = PowerMock.expectNew( ArrayList.class );5 EasyMock.expect( mock.size() ).andReturn( 5 );6 PowerMock.replayAll();7 System.out.println( mock
expectStrictNew
Using AI Code Generation
1public class Test {2 public void test() {3 PowerMock.expectNew(4.class).andReturn(new 4());4 PowerMock.replayAll();5 4 t = new 4();6 PowerMock.verifyAll();7 }8}9public class Test {10 public void test() {11 PowerMock.expectNew(5.class).andReturn(new 5());12 PowerMock.replayAll();13 5 t = new 5();14 PowerMock.verifyAll();15 }16}17public class Test {18 public void test() {19 PowerMock.expectNew(6.class).andReturn(new 6());20 PowerMock.replayAll();21 6 t = new 6();22 PowerMock.verifyAll();23 }24}25public class Test {26 public void test() {27 PowerMock.expectNew(7.class).andReturn(new 7());28 PowerMock.replayAll();29 7 t = new 7();30 PowerMock.verifyAll();31 }32}33public class Test {34 public void test() {35 PowerMock.expectNew(8.class).andReturn(new 8());36 PowerMock.replayAll();37 8 t = new 8();38 PowerMock.verifyAll();39 }40}41public class Test {42 public void test() {43 PowerMock.expectNew(9.class).andReturn(new 9());44 PowerMock.replayAll();45 9 t = new 9();46 PowerMock.verifyAll();47 }48}49public class Test {50 public void test() {
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!