通过PC在Iseries上进行Java IFSFile测试 [英] Java IFSFile on Iseries testing over PC

查看:63
本文介绍了通过PC在Iseries上进行Java IFSFile测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个Java类,该类将在iSeries的RPG程序上使用.此类将使用IFSFile管理文件.问题是我不知道如何在PC上进行测试(如果可能).

I'm trying to develop a Java Class that will be used on a RPG program on iSeries. This Class will manage files with IFSFile. The problem is that I don't know how can I test this (if possible) on my PC.

我的代码如下:

import java.io.BufferedReader;
import java.io.IOException;

import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400SecurityException;
import com.ibm.as400.access.IFSFile;
import com.ibm.as400.access.IFSFileReader;
(...)

        AS400 system = new AS400("AS400SystemName");
        IFSFile file = new IFSFile(system, "/File1");
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new IFSFileReader(file));
        } catch (AS400SecurityException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        // Read one line of the file
        String line1 = null;
        try {
            line1 = reader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }

        // Print line
        System.out.println(line1);

        // Close reader
        try {
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }</pre>

我对iSeries不太了解,我对此有些疑问:

I don't know well iSeries and I have some doubts:

  1. 如果我尝试在PC上运行此代码,它将要求我输入用户名/密码,当该类将在iSeries上使用时,它也会询问,否则将带走正在运行该应用程序的用户?

  1. If I try to run this code on my PC it asks me to a user/password, when the class will be used on iSeries, it will ask also, or it will take the user that is running the application?

有什么方法可以在PC上测试该部件,以便知道它是否可以在生产环境中工作?我的想法是首先使用模拟进行单元测试,但后来我想进行一些不使用模拟的功能测试,也许是某种模拟器或类似的东西...

Is there any way in which I can test this part on my PC, in order to know if it will work on production? My idea is first use a mock for Unit testing, but later I would like to have some functional tests that don't use the mock, maybe some kind of emulator or similar...

谢谢.

推荐答案

  • 为回答问题1(用户标识和密码问题),请确保在iSeries端的类路径中使用JT400Native.jar而不是JT400.jar.使用JT400Native.jar时,使用com.ibm.as400.access类时,它应该使用当前正在运行的作业的用户ID和密码.

    • In answer to question 1, the user id and password issue, be sure to use the JT400Native.jar instead of JT400.jar in your classpath on the iSeries side. When using JT400Native.jar, it should take the user id and password of the currently running job when using the com.ibm.as400.access classes.

      为回答问题2,如果没有与iSeries进行对话,则无法测试程序. (可选)您可以从普通文件输入流读取或写入普通文件输出流,而不是IFSFile.至少,这将使您测试代码的业务逻辑.但是,当需要测试com.ibm.as400.access类时,如果没有访问真正的iSeries的权限就无法做到.一个仿真器会很好,但是架构却是如此不同,我不知道有谁制造过.

      In answer to question 2, you cannot test your program without an iSeries to talk to. Optionally, you can read from a normal file input stream or write to a normal file output stream instead of the IFSFile. This will, at least, let you test the business logic of your code. But when it's time to test the com.ibm.as400.access classes, you just can't do it without access to a real iSeries. An emulator would be nice, but the architecture is just so different, I don't know of anyone who made one.

      这篇关于通过PC在Iseries上进行Java IFSFile测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆