标签:步骤 ado copyto 分享 size image syn err 背景
背景
我在开发haoop时,IDEA自带的junit3不知道为什么不能用,所以改用junit4
步骤
添加插件:File->Settings->Plugins
设置生成模式:File->Settings->Other Settings
修改模板:File->Settings->Other Settings->Junit Generator->Junit4注意:还是把package 整行删掉吧!!!!!!!!!!!!!!!!!!!!!!
右击类名-->goto-->test-->create test(还有一种方法:右击类名-->generate,直接就按照模板生成了)
这是被测试的类HdfsClientDemo
public class HdfsClientDemo {
FileSystem fs = null;
public void init() throws URISyntaxException, IOException, InterruptedException {
Configuration conf = new Configuration();
fs = FileSystem.get(new URI("hdfs://192.168.32.201:9000"),conf,"hadoop"); //最后一个参数为用户名
}
public void testUpLocalFile() throws IllegalArgumentException, IOException {
fs.copyFromLocalFile(new Path("e:/kk.xml"),new Path("/laji.bal.copy111"));
fs.close();
}
public void testDownLoad() throws IllegalArgumentException, IOException {
fs.copyToLocalFile(new Path("/kk.xml.copy"), new Path("e:/BaiduYunDownload"));
fs.close();
}
public static void main(String STR[]) throws URISyntaxException, IOException, InterruptedException {
FileSystem fs = null;
Configuration conf = new Configuration();
fs = FileSystem.get(new URI("hdfs://192.168.32.201:9000"),conf,"hadoop");
fs.copyFromLocalFile(new Path("e:/kk.xml"),new Path("/laji.bal.copy123"));
fs.close();
}
}
create new test后的样子
需要自己添加上代码
标签:步骤 ado copyto 分享 size image syn err 背景
原文地址:http://www.cnblogs.com/SuMeng/p/7862793.html