📄 vericlient.java
字号:
printMethod("table.getString()"); checkFields(t); printStatus(null); printMethod("table.nextRow(), for(;;)"); t.firstRow(); for (int j = 0; j < t.getNumRows(); j++) { checkFields(t); t.nextRow(); }//for printStatus(null); printMethod("table.nextRow(), while(...)"); t.firstRow(); do { checkFields(t); } while(t.nextRow()); printStatus(null); printMethod("table.previousRow(), while(...)"); t.lastRow(); do { checkFields(t); } while(t.previousRow()); printStatus(null); printMethod("ostream.writeObject(table)"); FileOutputStream fos = new FileOutputStream("jcoveri.dat"); ObjectOutputStream os = new ObjectOutputStream(fos); os.writeObject(t); os.flush(); fos.close(); printStatus(null); printMethod("istream.readObject(table)"); FileInputStream fis = new FileInputStream("jcoveri.dat"); ObjectInputStream is = new ObjectInputStream(fis); tc = (JCO.Table)is.readObject(); is.close(); checkFields(tc); printStatus(null); } catch (Exception ex) { printStatus(ex); }//try } private void testSpecialValues() { if (smeta == null) testMetaData(); try { JCO.Structure s = new JCO.Structure(smeta); printMethod("record.setValue(\"0000-00-00\",\"DATE\")"); s.setValue("0000-00-00","FIELD_DATE"); if (s.getDate("FIELD_DATE") != null || !s.getString("FIELD_DATE").equals("0000-00-00")) { printStatus(new Exception("Setting a date of 0000-00-00 does not return the same value")); } else { printStatus(null); }//if printMethod("record.setValue(\"9999-99-99\",\"DATE\")"); s.setValue("9999-99-99","FIELD_DATE"); if (!s.getString("FIELD_DATE").equals("9999-99-99")) { printStatus(new Exception("Setting a date of 9999-99-99 does not return " + " the same value, got " + s.getString("FIELD_DATE") + " instead")); } else { printStatus(null); }//if printMethod("record.setValue(\"00:00:00\",\"TIME\")"); s.setValue("00:00:00","FIELD_TIME"); if (!s.getString("FIELD_TIME").equals("00:00:00")) { printStatus(new Exception("Setting a time of 00:00:00 does not return the same value "+ s.getString("FIELD_TIME"))); } else { printStatus(null); }//if printMethod("record.setValue(\"24:00:00\",\"TIME\")"); s.setValue("24:00:00","FIELD_TIME"); if (!s.getString("FIELD_TIME").equals("24:00:00")) { printStatus(new Exception("Setting a time of 24:00:00 does not return the same value")); } else { printStatus(null); }//if printMethod("record.setValue(0,\"FIELD_INT1\")"); s.setValue(0,"FIELD_INT1"); if (s.getInt("FIELD_INT1") != 0) { printStatus(new Exception("Setting a short to 0 does not return the same value")); } else { printStatus(null); }//if printMethod("record.setValue(255,\"FIELD_INT1\")"); s.setValue(255,"FIELD_INT1"); if (s.getInt("FIELD_INT1") != 255) { printStatus(new Exception("Setting a short to 255 does not return the same value")); } else { printStatus(null); }//if printMethod("record.setValue(Short.MIN_VALUE,\"FIELD_INT2\")"); s.setValue((int)Short.MIN_VALUE,"FIELD_INT2"); if (s.getInt("FIELD_INT2") != Short.MIN_VALUE) { printStatus(new Exception("Setting a short to " + Short.MIN_VALUE + " does return a wrong value of " + s.getInt("FIELD_INT2"))); } else { printStatus(null); }//if printMethod("record.setValue(Short.MAX_VALUE,\"FIELD_INT2\")"); s.setValue((int)Short.MAX_VALUE,"FIELD_INT2"); if (s.getInt("FIELD_INT2") != Short.MAX_VALUE) { printStatus(new Exception("Setting a short to " + Short.MAX_VALUE + " does not return the same value")); } else { printStatus(null); }//if printMethod("record.setValue(\"ABCDEF012345678\",\"FIELD_BYTE\")"); s.setValue("ABCDEF012345678","FIELD_BYTE"); if (s.getString("FIELD_BYTE").equals("ABCDEFG012345678")) { printStatus(new Exception("Setting a byte[] to does not return the same value")); } else { printStatus(null); }//if } catch (Exception ex) { printStatus(ex); }//try } public void run() { testMetaData(); testParameterList(); testStructure(); testTable(); testSpecialValues(); } } /** * Test the repository */ public static class TestRepository extends Test { IRepository repository; JCO.Client client = null; private void testRepository1() { if (repository != null) return; try { client = JCO.createClient(getLoginProperties()); client.connect(); printMethod("JCO.createRepository(REPOS,client)"); repository = JCO.createRepository("BFREPOSITORY1",client); printStatus(null); } catch (JCO.Exception ex) { printStatus(ex); }//try } private void testRepository2() { if (repository != null) return; try { JCO.addClientPool("BF",10,getLoginProperties()); printMethod("JCO.createRepository(REPOS,POOL)"); repository = JCO.createRepository("BFREPOSITORY2","BF"); printStatus(null); } catch (JCO.Exception ex) { printStatus(ex); }//try } private void testStructureDefinition() { if (repository == null) testRepository2(); try { printMethod("repository.getStructureDefinition(\"RFCSI\")"); IMetaData meta = repository.getStructureDefinition("RFCSI"); if (meta == null) printStatus(new Exception("Could not find structure definition for RFCSI")); printStatus(null); } catch (Exception ex) { printStatus(ex); }//try } private void testFunctionInterface() { if (repository == null) testRepository2(); try { printMethod("repository.getFunctionTemplate(\"RFC_SYSTEM_INFO\")"); IFunctionTemplate tmpl = repository.getFunctionTemplate("RFC_SYSTEM_INFO"); if (tmpl == null) printStatus(new Exception("Could not find function RFC_SYSTEM_INFO")); printStatus(null); } catch (Exception ex) { printStatus(ex); }//try } public void run() { testRepository1(); testStructureDefinition(); testFunctionInterface(); if (client != null) { client.disconnect(); repository = null; }//if testRepository2(); testStructureDefinition(); testFunctionInterface(); JCO.removeClientPool("BF"); repository = null; } } /** * Test function calls */ public static class TestFunctionCalls extends Test { IRepository repository; private void testRepository() { try { if (repository != null) return; JCO.addClientPool("BF",10,getLoginProperties()); repository = JCO.createRepository("BFREPOSITORY2","BF"); } catch (JCO.Exception ex) { printStatus(ex); }//try } private JCO.Function getFunction(String name) { if (repository == null) testRepository(); try { IFunctionTemplate tpl = repository.getFunctionTemplate(name); return (tpl == null ? null : new JCO.Function(tpl)); } catch (JCO.AbapException ex) { return null; } catch (JCO.Exception ex) { return null; } catch (Exception ex) { printStatus(ex); return null; }//try } private void testSTFC_CONNECTION() { JCO.Function function = getFunction("STFC_CONNECTION"); if (function == null) return; try { String intext = "JCo 2.0 Test Parameter", outtext; printMethod("client.execute(\"STFC_CONNECTION\")"); function.getImportParameterList().setValue(intext,"REQUTEXT"); JCO.Client client = JCO.getClient("BF"); client.execute(function); JCO.releaseClient(client); outtext = function.getExportParameterList().getString("ECHOTEXT"); if (!intext.equals(outtext)) { throw new Exception("Inconsistency between input and output parameter detected, "+ "expected ECHOTEXT='" + intext + "', got ECHOTEXT='" + outtext + "'"); }//if printStatus(null); } catch (Exception ex) { printStatus(ex); }//try } private void testSTFC_CHANGING() { JCO.Function function = getFunction("STFC_CHANGING"); if (function == null) return; try { printMethod("client.execute(\"STFC_CHANGING\")"); int start_value = 998, counter_in = 1; function.getImportParameterList().setValue(start_value,"START_VALUE");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -