Пример #1
0
  /** A unit test for JUnit */
  public void testExecute() {
    try {
      builder.execute(msg);
    } catch (Exception e) {
      e.printStackTrace();
    }
    String query0 = "Insert into OtherTestTable ( NoField, sequence_field ) values ( 256.3652, 6 )";
    assertEquals("Query was not built and inserted into the MsgObject", query0, msg.getQuery()[0]);

    String query1 =
        "Insert into TestTable ( FirstField, SecondField ) values ( 1, 'testing string' )";
    assertEquals("Query was not built and inserted into the MsgObject", query1, msg.getQuery()[1]);
  }
Пример #2
0
  /** The JUnit setup method */
  protected void setUp() throws Exception {
    super.setUp();
    builder = new InsertBuilder();
    parserElements = new ArrayList<ParserElement>();
    insertElements = new ArrayList<InsertElement>();
    validElements = new ArrayList<InsertElement>();
    try {
      InsertElement ele = new InsertElement();
      String[] input = {"Table:TestTable~Field:FirstField~Value:1~Order:1"};
      ele.process(input);
      parserElements.add(ele);
      insertElements.add(ele);
      validElements.add(ele);

      /*
       *  - causing problems - how to remove value for duplicates in buildFieldList AND buildValueList
       *  /add duplicate to one above
       *  ele = new InsertElement();
       *  ele.process( input );
       *  parserElements.add( ele );
       *  insertElements.add( ele );
       */
      ele = new InsertElement();
      input[0] = "Table:TestTable~Field:SecondField~Value:testing string~Type:String~Order:2";
      ele.process(input);
      parserElements.add(ele);
      insertElements.add(ele);
      validElements.add(ele);

      ele = new InsertElement();
      input[0] = "Table:TestTable~Field:ThirdField~Order:3";
      ele.process(input);
      parserElements.add(ele);
      insertElements.add(ele);

      ele = new InsertElement();
      input[0] = "Table:OtherTestTable~Field:ThirdField~Order:5";
      ele.process(input);
      parserElements.add(ele);
      insertElements.add(ele);

      ele = new InsertElement();
      input[0] = "Table:OtherTestTable~Field:NoField~Value:256.3652~Order:1";
      ele.process(input);
      parserElements.add(ele);

      SelectElement sel = new SelectElement();
      input[0] = "Table:ASQPARRGMT~Field:OAGATGDATETOD~Order:28";
      sel.process(input);
      parserElements.add(sel);

      sel = new SelectElement();
      input[0] = "Table:ETMSTZ~Field:TRACKPOSCORD~Order:42";
      sel.process(input);
      parserElements.add(sel);

      FilterElement fil = new FilterElement();
      input[0] = "Table:FLIGHT~Field:CARRIER~Operator:=~Value:none";
      fil.process(input);
      parserElements.add(fil);

      /* add an InsertSequenceElement - this is a valid object */
      InsertSequenceElement sele = new InsertSequenceElement();
      input[0] = "Table:OtherTestTable~Field:sequence_field~Type:Numeric~Value:6~Order:6";
      sele.process(input);
      parserElements.add(sele);
      insertElements.add(sele);
      validElements.add(sele);

      msg = new MsgObject();
      msg.setWorkingObjects(parserElements);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }