package hudson.plugins.hadoop;

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

import java.io.File;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.hdfs.MiniDFSCluster;

public class HDFSDeployerTest {
	
	private String hdfsURI;
	
	@Before
	public void setUp() throws Exception {
		File baseDir = new File("./target/hdfs/testDeploy").getAbsoluteFile();
		FileUtil.fullyDelete(baseDir);
		Configuration conf = new Configuration();
		conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, baseDir.getAbsolutePath());
		MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf);
		MiniDFSCluster hdfsCluster = builder.build();
		hdfsURI = "hdfs://localhost:"+ hdfsCluster.getNameNodePort() + "/";
	}
	@Test
	public void testDeploy() throws Exception {
		File file = File.createTempFile("test", "jar");
		HDFSDeployer deployer = new HDFSDeployer();
		deployer.deploy(file.getAbsolutePath(), hdfsURI);
	}
}

@@ -25,16 +25,41 @@
 adoop;%0A%0A
+import org.junit.Assert;%0A
 import o
@@ -75,16 +75,16 @@
 Before;%0A
-
 import o
@@ -204,16 +204,50 @@
 leUtil;%0A
+import org.apache.hadoop.fs.Path;%0A
 import o
@@ -344,16 +344,53 @@
 dfsURI;%0A
+%09private MiniDFSCluster hdfsCluster;%0A
 %09%0A%09@Befo
@@ -476,19 +476,8 @@
 hdfs
-/testDeploy
 %22).g
@@ -718,31 +718,16 @@
 onf);%0A%09%09
-MiniDFSCluster 
 hdfsClus
@@ -970,16 +970,16 @@
 oyer();%0A
-
 %09%09deploy
@@ -1022,13 +1022,127 @@
 fsURI);%0A
+%09%09Assert.assertTrue(%22File is not deployed to HDFS%22,hdfsCluster.getFileSystem().exists(new Path(file.getName())));%0A
 %09%7D%0A%7D%0A

make unit test working