@Test public void LSComCDTest() { try { String cdcur = "C:\\Users\\Rahul\\Desktop"; jcon.setCurrentDir(cdcur); cdCom.setConsole(jcon); String[] args2 = {cdcur}; cdCom.execute(args2); File newFileDir = cdCom.getCurrentDir(); String newDir = newFileDir.toString(); // boolean cond=newDir.equals("C:\\Users\\Rahul\\Desktop"); String[] args1 = new String[0]; LSCom.execute(args1); String output = outContent.toString(); int count = output.length(); System.out.println("Count :" + count); boolean condition = output.contains("Maven"); Assert.assertTrue(condition); } catch (CommandFailedException e) { e.printStackTrace(); fail("Exception was thrown"); } outContent.reset(); }
@Before public void setUpStreams() { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); jcon = JConsole.instance(); jcon.setCurrentDir(curDir); LSCom.setConsole(jcon); }
@Test public void LSComFalseTest() { try { String[] args1 = new String[0]; LSCom.execute(args1); String output = outContent.toString(); int count = output.length(); System.out.println("Count :" + count); boolean condition = output.contains("Rahul.xml"); Assert.assertFalse(condition); } catch (CommandFailedException e) { e.printStackTrace(); fail("Exception was thrown"); } outContent.reset(); }
// Added by Rahul @Test public void LSComCountTest() { try { String[] args1 = new String[0]; LSCom.execute(args1); String output = outContent.toString(); int count = output.length(); System.out.println("Count :" + count); // boolean condition=(count==1704); Assert.assertEquals(count, 1704); } catch (CommandFailedException e) { e.printStackTrace(); fail("Exception was thrown"); } outContent.reset(); }
@Test public void LSComTest() { try { System.out.println("hwllo"); String[] args1 = new String[0]; String sampleFile = "Jconsole.xml"; LSCom.execute(args1); String output = outContent.toString(); System.out.println("the out put of ls command is:" + output); assertTrue(output.contains(sampleFile)); } catch (CommandFailedException e) { e.printStackTrace(); fail("Exception was thrown"); } outContent.reset(); }