src/test/java/org/jenkinsci/plugins/pretestedintegrationmercurial/MercurialIT.java
public void testProperWorkflow() throws Exception {
		//initialise remote
		setup();
		File remote = createTempDirectory();
		hg(remote,"init");
		File foo = new File(remote,"foo");
		FileUtils.touch(foo);
		hg(remote,"add","foo");

		File bar = new File(remote,"bar");
		FileUtils.touch(bar);
		hg(remote,"add","bar");
		hg(remote,"commit","-m","Initial import");
		
		//setup and configure 2 jobs for different branches with pretested integration
		FreeStyleProject alice = createJob(remote.getAbsolutePath(),"alice","alice","default");
		FreeStyleProject bob = createJob(remote.getAbsolutePath(),"bob","bob","default");
				
		//work on one branch
		hg(remote,"branch","alice");
		FileUtils.writeStringToFile(foo, "hello, world!");
		hg(remote,"commit","-m","Added foo");
		String aliceRevision = hg(remote,"tip","--template","{node}").toString();
		assertNotNull(aliceRevision);
		
		//work on the other
		hg(remote,"branch","bob");
		FileUtils.writeStringToFile(bar, "hello, world!");
		hg(remote,"commit","-m","Added bar");
		String bobRevision = hg(remote,"tip","--template","{node}").toString();
		assertNotNull(bobRevision);
		//trigger jenkins build
		
		Future<FreeStyleBuild> aliceBuild = alice.scheduleBuild2(0);
		aliceBuild.get();
		
		Future<FreeStyleBuild> bobBuild = bob.scheduleBuild2(0);
		bobBuild.get();
	
		//the jobs should now be present in the integration branch merged in the same order as comitted.
		ByteArrayOutputStream revisions = hg(remote,"log","--branch","default","--template","{desc}\n","-r",":");
		String[] revArr = revisions.toString().split("\n");
		//The first element is the initial commit
		assertTrue(revArr.length == 3);
		assertTrue(revArr[1].startsWith("Merge of revision " + aliceRevision));
		assertTrue(revArr[2].startsWith("Merge of revision " + bobRevision));
		
		//now alice can work on bobs changes
		hg(remote,"update","alice");
		hg(remote,"merge","default");
		hg(remote,"commit","-m","Synched with default");
		String aliceRevision2 = hg(remote,"tip","--template","{node}").toString();
		alice.scheduleBuild2(0).get();
		FileUtils.writeStringToFile(bar, "hello, world from bar");
		hg(remote,"commit","-m","Added sender in bar");
		String aliceRevision3 =  hg(remote,"tip","--template","{node}").toString();
		alice.scheduleBuild2(0).get();
		
		revisions = hg(remote,"log","--branch","default","--template","{desc}\n","-r",":");
		revArr = revisions.toString().split("\n");
		assertTrue(revArr[3].startsWith("Merge of revision " + aliceRevision2));
		assertTrue(revArr[4].startsWith("Merge of revision " + aliceRevision3));
		
		//bob can start on a new thing without checking out the integration branch
		hg(remote,"update","bob");
		File baz = new File(remote,"baz");
		FileUtils.writeStringToFile(baz, "This is a new feature in baz");
		hg(remote,"add","baz");
		hg(remote,"commit","-m","Started feature in baz");
		String bobRevision2 = hg(remote,"tip","--template","{node}").toString();
		bob.scheduleBuild2(0).get();

		revisions = hg(remote,"log","--branch","default","--template","{desc}\n","-r",":");
		revArr = revisions.toString().split("\n");
		assertTrue(revArr[5].startsWith("Merge of revision " + bobRevision2));
	}
/**
	 * Test that proper workflow with two development branches work
	 */
Test that proper workflow with two development branches work
Test that proper workflow with two development branches work
public void testProperWorkflow() throws Exception {
		setup();
		File remote = createTempDirectory();
		hg(remote,"init");
		File foo = new File(remote,"foo");
		FileUtils.touch(foo);
		hg(remote,"add","foo");
		File bar = new File(remote,"bar");
		FileUtils.touch(bar);
		hg(remote,"add","bar");
		hg(remote,"commit","-m","Initial import");
		FreeStyleProject alice = createJob(remote.getAbsolutePath(),"alice","alice","default");
		FreeStyleProject bob = createJob(remote.getAbsolutePath(),"bob","bob","default");
		hg(remote,"branch","alice");
		FileUtils.writeStringToFile(foo, "hello, world!");
		hg(remote,"commit","-m","Added foo");
		String aliceRevision = hg(remote,"tip","--template","{node}").toString();
		assertNotNull(aliceRevision);
		hg(remote,"branch","bob");
		FileUtils.writeStringToFile(bar, "hello, world!");
		hg(remote,"commit","-m","Added bar");
		String bobRevision = hg(remote,"tip","--template","{node}").toString();
		assertNotNull(bobRevision);
		Future<FreeStyleBuild> aliceBuild = alice.scheduleBuild2(0);
		aliceBuild.get();
		Future<FreeStyleBuild> bobBuild = bob.scheduleBuild2(0);
		bobBuild.get();
		ByteArrayOutputStream revisions = hg(remote,"log","--branch","default","--template","{desc}\n","-r",":");
		String[] revArr = revisions.toString().split("\n");
		assertTrue(revArr.length == 3);
		assertTrue(revArr[1].startsWith("Merge of revision " + aliceRevision));
		assertTrue(revArr[2].startsWith("Merge of revision " + bobRevision));
		hg(remote,"update","alice");
		hg(remote,"merge","default");
		hg(remote,"commit","-m","Synched with default");
		String aliceRevision2 = hg(remote,"tip","--template","{node}").toString();
		alice.scheduleBuild2(0).get();
		FileUtils.writeStringToFile(bar, "hello, world from bar");
		hg(remote,"commit","-m","Added sender in bar");
		String aliceRevision3 =  hg(remote,"tip","--template","{node}").toString();
		alice.scheduleBuild2(0).get();
		revisions = hg(remote,"log","--branch","default","--template","{desc}\n","-r",":");
		revArr = revisions.toString().split("\n");
		assertTrue(revArr[3].startsWith("Merge of revision " + aliceRevision2));
		assertTrue(revArr[4].startsWith("Merge of revision " + aliceRevision3));
		hg(remote,"update","bob");
		File baz = new File(remote,"baz");
		FileUtils.writeStringToFile(baz, "This is a new feature in baz");
		hg(remote,"add","baz");
		hg(remote,"commit","-m","Started feature in baz");
		String bobRevision2 = hg(remote,"tip","--template","{node}").toString();
		bob.scheduleBuild2(0).get();
		revisions = hg(remote,"log","--branch","default","--template","{desc}\n","-r",":");
		revArr = revisions.toString().split("\n");
		assertTrue(revArr[5].startsWith("Merge of revision " + bobRevision2));
	}
public void testProperWorkflow ( ) throws Exception { setup ( ) ; File remote = createTempDirectory ( ) ; hg ( remote , "init" ) ; File foo = new File ( remote , "foo" ) ; FileUtils . touch ( foo ) ; hg ( remote , "add" , "foo" ) ; File bar = new File ( remote , "bar" ) ; FileUtils . touch ( bar ) ; hg ( remote , "add" , "bar" ) ; hg ( remote , "commit" , "-m" , "Initial import" ) ; FreeStyleProject alice = createJob ( remote . getAbsolutePath ( ) , "alice" , "alice" , "default" ) ; FreeStyleProject bob = createJob ( remote . getAbsolutePath ( ) , "bob" , "bob" , "default" ) ; hg ( remote , "branch" , "alice" ) ; FileUtils . writeStringToFile ( foo , "hello, world!" ) ; hg ( remote , "commit" , "-m" , "Added foo" ) ; String aliceRevision = hg ( remote , "tip" , "--template" , "{node}" ) . toString ( ) ; assertNotNull ( aliceRevision ) ; hg ( remote , "branch" , "bob" ) ; FileUtils . writeStringToFile ( bar , "hello, world!" ) ; hg ( remote , "commit" , "-m" , "Added bar" ) ; String bobRevision = hg ( remote , "tip" , "--template" , "{node}" ) . toString ( ) ; assertNotNull ( bobRevision ) ; Future < FreeStyleBuild > aliceBuild = alice . scheduleBuild2 ( 0 ) ; aliceBuild . get ( ) ; Future < FreeStyleBuild > bobBuild = bob . scheduleBuild2 ( 0 ) ; bobBuild . get ( ) ; ByteArrayOutputStream revisions = hg ( remote , "log" , "--branch" , "default" , "--template" , "{desc}\n" , "-r" , ":" ) ; String [ ] revArr = revisions . toString ( ) . split ( "\n" ) ; assertTrue ( revArr . length == 3 ) ; assertTrue ( revArr [ 1 ] . startsWith ( "Merge of revision " + aliceRevision ) ) ; assertTrue ( revArr [ 2 ] . startsWith ( "Merge of revision " + bobRevision ) ) ; hg ( remote , "update" , "alice" ) ; hg ( remote , "merge" , "default" ) ; hg ( remote , "commit" , "-m" , "Synched with default" ) ; String aliceRevision2 = hg ( remote , "tip" , "--template" , "{node}" ) . toString ( ) ; alice . scheduleBuild2 ( 0 ) . get ( ) ; FileUtils . writeStringToFile ( bar , "hello, world from bar" ) ; hg ( remote , "commit" , "-m" , "Added sender in bar" ) ; String aliceRevision3 = hg ( remote , "tip" , "--template" , "{node}" ) . toString ( ) ; alice . scheduleBuild2 ( 0 ) . get ( ) ; revisions = hg ( remote , "log" , "--branch" , "default" , "--template" , "{desc}\n" , "-r" , ":" ) ; revArr = revisions . toString ( ) . split ( "\n" ) ; assertTrue ( revArr [ 3 ] . startsWith ( "Merge of revision " + aliceRevision2 ) ) ; assertTrue ( revArr [ 4 ] . startsWith ( "Merge of revision " + aliceRevision3 ) ) ; hg ( remote , "update" , "bob" ) ; File baz = new File ( remote , "baz" ) ; FileUtils . writeStringToFile ( baz , "This is a new feature in baz" ) ; hg ( remote , "add" , "baz" ) ; hg ( remote , "commit" , "-m" , "Started feature in baz" ) ; String bobRevision2 = hg ( remote , "tip" , "--template" , "{node}" ) . toString ( ) ; bob . scheduleBuild2 ( 0 ) . get ( ) ; revisions = hg ( remote , "log" , "--branch" , "default" , "--template" , "{desc}\n" , "-r" , ":" ) ; revArr = revisions . toString ( ) . split ( "\n" ) ; assertTrue ( revArr [ 5 ] . startsWith ( "Merge of revision " + bobRevision2 ) ) ; }
Test that proper workflow with two development branches work
Test that proper workflow with two development branches work
//initialise remote //setup and configure 2 jobs for different branches with pretested integration //work on one branch //work on the other //trigger jenkins build //the jobs should now be present in the integration branch merged in the same order as comitted. //The first element is the initial commit //now alice can work on bobs changes //bob can start on a new thing without checking out the integration branch