更新报错为英文描述,更新开发者文档建议编写测试用例

更新报错为英文描述,更新开发者文档建议编写测试用例
This commit is contained in:
FuYouJ 2023-08-14 20:20:32 +08:00
parent a3430ee00b
commit db93a0eb0d
6 changed files with 30 additions and 21 deletions

View File

@ -55,16 +55,17 @@ public class ExampleConfigParser {
} }
if (!pluginTypeMap.isEmpty()) { if (!pluginTypeMap.isEmpty()) {
String failedPlugin = pluginTypeMap.keySet().toString(); String failedPlugin = pluginTypeMap.keySet().toString();
String message = "\n插件%s加载失败尝试从以下方面分析原因\n" + String message = "\nplugin %s load failed ry to analyze the reasons from the following aspects.\n" +
"1: 检查插件的名字是否书写正确\n" + "1: Check if the name of the plugin is spelled correctly, and verify whether DataX supports this plugin\n" +
"2相关插件的pom文件的<build></build>下是否已经添加了 <resource>\n" + "2Verify if the <resource></resource> tag has been added under <build></build> section in the pom file of the relevant plugin.\n<resource>" +
" <directory>src/main/resources</directory>\n" + " <directory>src/main/resources</directory>\n" +
" <includes>\n" + " <includes>\n" +
" <include>**/*.*</include>\n" + " <include>**/*.*</include>\n" +
" </includes>\n" + " </includes>\n" +
" <filtering>true</filtering>\n" + " <filtering>true</filtering>\n" +
" </resource>\n [可参阅streamreader pom文件] \n" + " </resource>\n [可参阅streamreader pom文件] \n" +
"3如果你是以datax-example为启动模块example模块是否导入了插件的依赖。参开example的pom文件"; "3If you are using 'datax-example' as the startup module, " +
"check whether the 'example' module has imported the dependencies of the plugin. Refer to the 'pom' file of the 'example' module";
message = String.format(message, failedPlugin); message = String.format(message, failedPlugin);
throw DataXException.asDataXException(FrameworkErrorCode.PLUGIN_INIT_ERROR, message); throw DataXException.asDataXException(FrameworkErrorCode.PLUGIN_INIT_ERROR, message);
} }

View File

@ -15,10 +15,11 @@ public class PathUtil {
public static String getAbsolutePathFromClassPath(String path) { public static String getAbsolutePathFromClassPath(String path) {
URL resource = PathUtil.class.getResource(path); URL resource = PathUtil.class.getResource(path);
try { try {
assert resource != null;
URI uri = resource.toURI(); URI uri = resource.toURI();
return Paths.get(uri).toString(); return Paths.get(uri).toString();
} catch (NullPointerException | URISyntaxException e) { } catch (NullPointerException | URISyntaxException e) {
throw DataXException.asDataXException("path 路径错误"); throw DataXException.asDataXException("path error,please check whether the path is correct");
} }
} }

View File

@ -1,16 +0,0 @@
package com.alibaba.datax.example;
import com.alibaba.datax.example.util.PathUtil;
import org.junit.Test;
public class DataXExampleTest {
@Test
public void testStreamReader2StreamWriter() {
String path = "/job/stream2stream.json";
String jobPath = PathUtil.getAbsolutePathFromClassPath(path);
ExampleContainer.start(jobPath);
}
}

View File

@ -0,0 +1,19 @@
package com.alibaba.datax.example.streamreader;
import com.alibaba.datax.example.ExampleContainer;
import com.alibaba.datax.example.util.PathUtil;
import org.junit.Test;
/**
* {@code Author} FuYouJ
* {@code Date} 2023/8/14 20:16
*/
public class StreamReader2StreamWriterTest {
@Test
public void testStreamReader2StreamWriter() {
String path = "/job/stream/stream2stream.json";
String jobPath = PathUtil.getAbsolutePathFromClassPath(path);
ExampleContainer.start(jobPath);
}
}

View File

@ -447,6 +447,10 @@ DataX的内部类型在实现上会选用不同的java类型
3. 用户在插件中在`reader`/`writer`配置的`name`字段指定插件名字。框架根据插件的类型(`reader`/`writer`和插件名称去插件的路径下扫描所有的jar加入`classpath`。 3. 用户在插件中在`reader`/`writer`配置的`name`字段指定插件名字。框架根据插件的类型(`reader`/`writer`和插件名称去插件的路径下扫描所有的jar加入`classpath`。
4. 根据插件配置中定义的入口类,框架通过反射实例化对应的`Job`和`Task`对象。 4. 根据插件配置中定义的入口类,框架通过反射实例化对应的`Job`和`Task`对象。
### 编写测试用例
1. 你可以在你的插件模块引入datax-example模块,调用`ExampleContainer.start(jobPath)`方法来检测你的代码逻辑是否正确。[datax-example使用](https://github.com/alibaba/DataX/datax-example/doc/README.md)
2. 你可以在datax-example模块引入你的插件模块编写测试方法调用`ExampleContainer.start(jobPath)`方法来检测你的代码逻辑是否正确。[datax-example使用](https://github.com/alibaba/DataX/datax-example/doc/README.md)
## 三、Last but not Least ## 三、Last but not Least