~janusz-martyniak/mcdb/mice.cdb.server

« back to all changes in this revision

Viewing changes to test/mice/cdb/service/beamline/BeamlineSMTest.java

  • Committer: Antony Wilson
  • Date: 2013-07-24 12:46:05 UTC
  • Revision ID: antony.wilson@stfc.ac.uk-20130724124605-od01pdjgw1euoaar
fix tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    @Test
48
48
    public final void testGetAllBeamlines() throws Exception {
49
49
        String result = m_beamline.getAllBeamlines();
50
 
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run><run runNumber='2' startTime='2010-10-26 16:29:22.791' endTime='2010-10-26 16:39:22.791' startNotes='junk' endNotes='endjunk2' optics='opts' protonAbsorberThickness='22' startPulse='666' endPulse='777' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-2' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='false' diffuserThickness='21' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='6'/></run></runs>";
 
50
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null' targetDelay='42.1' targetDepth='9.8' targetDriveVoltage='240.9'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run><run runNumber='2' startTime='2010-10-26 16:29:22.791' endTime='2010-10-26 16:39:22.791' startNotes='junk' endNotes='endjunk2' optics='opts' protonAbsorberThickness='22' startPulse='666' endPulse='777' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-2' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='false' diffuserThickness='21' gdcHostName='null' targetDelay='42.1' targetDepth='9.8' targetDriveVoltage='240.9'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='6'/></run><run runNumber='3' startTime='2010-10-28 16:29:22.791' endTime='2010-10-28 16:39:22.791' startNotes='junk' endNotes='endjunk3' optics='opts' protonAbsorberThickness='32' startPulse='666' endPulse='777' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='null' daqGateWidth='null' daqVersion='null' beamStop='true' diffuserThickness='31' gdcHostName='null' targetDelay='null' targetDepth='null' targetDriveVoltage='null'></run></runs>";
51
51
        assertEquals("runs", expectedResponse, result);
52
52
 
53
53
    }
56
56
    @Test
57
57
    public final void testGetBeamlineForRun() throws Exception {
58
58
        String result = m_beamline.getBeamlineForRun("1");
59
 
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run></runs>";
60
 
        assertEquals("run", expectedResponse, result);
 
59
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null' targetDelay='42.1' targetDepth='9.8' targetDriveVoltage='240.9'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run><run runNumber='2' startTime='2010-10-26 16:29:22.791' endTime='2010-10-26 16:39:22.791' startNotes='junk' endNotes='endjunk2' optics='opts' protonAbsorberThickness='22' startPulse='666' endPulse='777' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-2' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='false' diffuserThickness='21' gdcHostName='null' targetDelay='42.1' targetDepth='9.8' targetDriveVoltage='240.9'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='6'/></run><run runNumber='3' startTime='2010-10-28 16:29:22.791' endTime='2010-10-28 16:39:22.791' startNotes='junk' endNotes='endjunk3' optics='opts' protonAbsorberThickness='32' startPulse='666' endPulse='777' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='null' daqGateWidth='null' daqVersion='null' beamStop='true' diffuserThickness='31' gdcHostName='null' targetDelay='null' targetDepth='null' targetDriveVoltage='null'></run></runs>";
61
60
 
62
 
        result = m_beamline.getBeamlineForRun("3");
 
61
        result = m_beamline.getBeamlineForRun("99");
63
62
        expectedResponse = "<runs></runs>";
64
63
        assertEquals("run", expectedResponse, result);
65
64
    }
88
87
        getOneBeamlineForDates("2010-10-25 16:39:22.791", "2010-10-25 16:39:22.792");
89
88
        getNoBeamlineForDates("2010-10-25 16:39:22.792", "2010-10-25 16:39:22.792");
90
89
        String result = m_beamline.getBeamlinesForDates("2010-10-25 16:39:22.791", "2010-10-26 16:29:22.791");
91
 
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run><run runNumber='2' startTime='2010-10-26 16:29:22.791' endTime='2010-10-26 16:39:22.791' startNotes='junk' endNotes='endjunk2' optics='opts' protonAbsorberThickness='22' startPulse='666' endPulse='777' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-2' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='false' diffuserThickness='21' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='6'/></run></runs>";
 
90
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null' targetDelay='42.1' targetDepth='9.8' targetDriveVoltage='240.9'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run><run runNumber='2' startTime='2010-10-26 16:29:22.791' endTime='2010-10-26 16:39:22.791' startNotes='junk' endNotes='endjunk2' optics='opts' protonAbsorberThickness='22' startPulse='666' endPulse='777' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-2' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='false' diffuserThickness='21' gdcHostName='null' targetDelay='42.1' targetDepth='9.8' targetDriveVoltage='240.9'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='6'/></run></runs>";
92
91
        assertEquals("runs", expectedResponse, result);
93
92
    }
94
93
 
117
116
        getOneBeamlineForPulses("555", "556");
118
117
        getNoBeamlineForPulses("556", "556");
119
118
        String result = m_beamline.getBeamlinesForPulses("555", "666");
120
 
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run><run runNumber='2' startTime='2010-10-26 16:29:22.791' endTime='2010-10-26 16:39:22.791' startNotes='junk' endNotes='endjunk2' optics='opts' protonAbsorberThickness='22' startPulse='666' endPulse='777' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-2' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='false' diffuserThickness='21' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='6'/></run></runs>";
 
119
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null' targetDelay='42.1' targetDepth='9.8' targetDriveVoltage='240.9'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run><run runNumber='2' startTime='2010-10-26 16:29:22.791' endTime='2010-10-26 16:39:22.791' startNotes='junk' endNotes='endjunk2' optics='opts' protonAbsorberThickness='22' startPulse='666' endPulse='777' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-2' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='false' diffuserThickness='21' gdcHostName='null' targetDelay='42.1' targetDepth='9.8' targetDriveVoltage='240.9'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='6'/></run><run runNumber='3' startTime='2010-10-28 16:29:22.791' endTime='2010-10-28 16:39:22.791' startNotes='junk' endNotes='endjunk3' optics='opts' protonAbsorberThickness='32' startPulse='666' endPulse='777' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='null' daqGateWidth='null' daqVersion='null' beamStop='true' diffuserThickness='31' gdcHostName='null' targetDelay='null' targetDepth='null' targetDriveVoltage='null'></run></runs>";
121
120
        assertEquals("runs", expectedResponse, result);
122
121
    }
123
122
 
134
133
    // setStartRun(xml)
135
134
    @Test
136
135
    public final void testAddRun() throws Exception {
137
 
        String xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
136
        String xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
138
137
        String result = m_beamline.setStartRun(xml);
139
 
        String expectedResponse = "<ok>Run data added</ok>";
 
138
        String expectedResponse = "<ok>Run data added for run 4</ok>";
140
139
        assertEquals("runs", expectedResponse, result);
141
140
    }
142
141
 
143
142
    @Test
144
143
    public final void testAddRunDuplicate() throws Exception {
145
 
        String xml = "<run runNumber='2' startTime='2010-10-25 16:29:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
144
        String xml = "<startRun runNumber='2' startTime='2010-10-25 16:29:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
146
145
        String result = m_beamline.setStartRun(xml);
147
146
        String expectedResponse = "<error>Problem inserting data into the database - duplicate record. No data has been inserted.</error>";
148
147
        assertEquals("runs", expectedResponse, result);
150
149
 
151
150
    @Test
152
151
    public final void testAddRunBadData() throws Exception {
153
 
        String xml = "<run runNumber='a' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
152
        String xml = "<startRun runNumber='a' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
154
153
        String result = m_beamline.setStartRun(xml);
155
154
        String expectedResponse = "<error>Could not parse Beamline XML. Please check input. Could not parse Int:a</error>";
156
155
        assertEquals("runs", expectedResponse, result);
157
156
 
158
 
        xml = "<run runNumber='4' startTime='201a-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
157
        xml = "<startRun runNumber='4' startTime='201a-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
159
158
        result = m_beamline.setStartRun(xml);
160
159
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]</error>";
161
160
        assertEquals("runs", expectedResponse, result);
162
161
 
163
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='j!unk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
162
        xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='j!unk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
164
163
        result = m_beamline.setStartRun(xml);
165
164
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. String contained non-aphanumeric/non-white space characters: j!unk</error>";
166
165
        assertEquals("runs", expectedResponse, result);
167
166
 
168
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='op\\\"ts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
167
        xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='op\\\"ts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
169
168
        result = m_beamline.setStartRun(xml);
170
169
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. String contained non-aphanumeric/non-white space characters: op\\\"ts</error>";
171
170
        assertEquals("runs", expectedResponse, result);
172
171
 
173
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='3.5' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
174
 
        result = m_beamline.setStartRun(xml);
175
 
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Could not parse Int:3.5</error>";
176
 
        assertEquals("runs", expectedResponse, result);
177
 
 
178
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='54.3' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
172
        xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='54.3' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
179
173
        result = m_beamline.setStartRun(xml);
180
174
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Could not parse Int:54.3</error>";
181
175
        assertEquals("runs", expectedResponse, result);
182
176
 
183
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
177
        xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
184
178
        result = m_beamline.setStartRun(xml);
185
179
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Could not parse Double:1.1.5</error>";
186
180
        assertEquals("runs", expectedResponse, result);
187
181
 
188
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='0\\\"01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
182
        xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='0\\\"01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
189
183
        result = m_beamline.setStartRun(xml);
190
184
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. String contained non-aphanumeric/non-white space characters: 0\\\"01011110101111000101111010111100</error>";
191
185
        assertEquals("runs", expectedResponse, result);
192
186
 
193
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF$1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
187
        xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF$1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
194
188
        result = m_beamline.setStartRun(xml);
195
189
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. String contained non-aphanumeric/non-white space characters: TOF$1</error>";
196
190
        assertEquals("runs", expectedResponse, result);
197
191
 
198
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4i' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
192
        xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4i' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
199
193
        result = m_beamline.setStartRun(xml);
200
194
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Could not parse Double:7.4i</error>";
201
195
        assertEquals("runs", expectedResponse, result);
202
196
 
203
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='tru' diffuserWidth='43' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
204
 
        result = m_beamline.setStartRun(xml);
205
 
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Could not parse boolean:tru</error>";
206
 
        assertEquals("runs", expectedResponse, result);
207
 
 
208
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='2' diffuserWidth='43' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
209
 
        result = m_beamline.setStartRun(xml);
210
 
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Could not parse boolean:2</error>";
211
 
        assertEquals("runs", expectedResponse, result);
212
 
 
213
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11.1' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
214
 
        result = m_beamline.setStartRun(xml);
215
 
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Could not parse Int:11.1</error>";
216
 
        assertEquals("runs", expectedResponse, result);
217
 
 
218
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1$' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
197
        xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1$' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
219
198
        result = m_beamline.setStartRun(xml);
220
199
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. String contained non-aphanumeric/non-white space characters: q1$</error>";
221
200
        assertEquals("runs", expectedResponse, result);
222
201
 
223
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9i' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
202
        xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9i' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
224
203
        result = m_beamline.setStartRun(xml);
225
204
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Could not parse Double:5.9i</error>";
226
205
        assertEquals("runs", expectedResponse, result);
227
206
 
228
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='=po.sitive'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
229
 
        result = m_beamline.setStartRun(xml);
230
 
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. String contained non-aphanumeric/non-white space characters: =po.sitive</error>";
231
 
        assertEquals("runs", expectedResponse, result);
232
 
 
233
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/>";
 
207
        xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/>";
234
208
        result = m_beamline.setStartRun(xml);
235
209
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. XML document structures must start and end within the same entity.</error>";
236
210
        assertEquals("runs", expectedResponse, result);
237
211
 
238
 
        xml = "<run startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
212
        xml = "<startRun startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
239
213
        result = m_beamline.setStartRun(xml);
240
214
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Could not parse Int:null</error>";
241
215
        assertEquals("runs", expectedResponse, result);
242
216
 
243
 
        xml = "<run runNumber='4' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
217
        xml = "<startRun runNumber='4' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
244
218
        result = m_beamline.setStartRun(xml);
245
219
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]</error>";
246
220
        assertEquals("runs", expectedResponse, result);
247
221
 
248
 
        xml = "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
222
        xml = "<startRun runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
249
223
        result = m_beamline.setStartRun(xml);
250
224
        expectedResponse = "<error>Could not parse Beamline XML. Please check input. Could not parse Double:null</error>";
251
225
        assertEquals("runs", expectedResponse, result);
252
 
 
253
 
        // xml =
254
 
        // "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
255
 
        // result = m_beamline.setStartRun(xml);
256
 
        // expectedResponse =
257
 
        // "<error>Could not parse Beamline XML. Please check input. Could not parse bits:null</error>";
258
 
        // assertEquals("runs", expectedResponse, result);
259
 
 
260
 
        // xml =
261
 
        // "<run runNumber='4' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
262
 
        // result = m_beamline.setStartRun(xml);
263
 
        // expectedResponse =
264
 
        // "<error>Could not parse Beamline XML. Please check input. String cannot be null or empty</error>";
265
 
        // assertEquals("runs", expectedResponse, result);
266
226
    }
267
227
 
268
228
    // setEndRun(xml)
269
229
    @Test
270
230
    public final void testUpdateRun() throws Exception {
271
 
        String xml = "<run runNumber='5' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
231
        String xml = "<startRun runNumber='5' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
272
232
        m_beamline.setStartRun(xml);
273
233
        xml = "<endRun runNumber='5' endTime='2010-10-25 16:29:22.791' endPulse='543' status='true'/>";
274
234
        String result = m_beamline.setEndRun(xml);
275
 
        String expectedResponse = "<ok>Run data updated</ok>";
 
235
        String expectedResponse = "<ok>Run data updated for run 5</ok>";
276
236
        assertEquals("runs", expectedResponse, result);
277
237
    }
278
238
 
279
239
    @Test
280
240
    public final void testUpdateRunDuplicate() throws Exception {
281
 
        String xml = "<run runNumber='6' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></run>";
 
241
        String xml = "<startRun runNumber='6' startTime='2010-10-25 16:29:22.791' startNotes='junk' optics='opts' protonAbsorberThickness='12' startPulse='543' step='1.5' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/></startRun>";
282
242
        m_beamline.setStartRun(xml);
283
243
        xml = "<endRun runNumber='6' endTime='2010-10-25 16:29:22.791' endPulse='543' status='true'/>";
284
244
        m_beamline.setEndRun(xml);
333
293
 
334
294
    private void getOneBeamlineForDates(String start, String end) throws Exception {
335
295
        String result = m_beamline.getBeamlinesForDates(start, end);
336
 
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run></runs>";
 
296
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null' targetDelay='42.1' targetDepth='9.8' targetDriveVoltage='240.9'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run></runs>";
337
297
        assertEquals("runs", expectedResponse, result);
338
298
    }
339
299
 
351
311
 
352
312
    private void getOneBeamlineForPulses(String start, String end) throws Exception {
353
313
        String result = m_beamline.getBeamlinesForPulses(start, end);
354
 
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run></runs>";
 
314
        String expectedResponse = "<runs><run runNumber='1' startTime='2010-10-25 16:29:22.791' endTime='2010-10-25 16:39:22.791' startNotes='junk' endNotes='endjunk1' optics='opts' protonAbsorberThickness='12' startPulse='543' endPulse='555' step='1.5' status='true' runType='01011110101111000101111010111100' daqTrigger='TOF-1' daqGateWidth='7.4' daqVersion='3.2.1-42' beamStop='true' diffuserThickness='11' gdcHostName='null' targetDelay='42.1' targetDepth='9.8' targetDriveVoltage='240.9'><magnet name='q1' setCurrent='5.9' polarity='1'/><magnet name='q2' setCurrent='7.54' polarity='-1'/><scalar name='SumPartTrig' value='1'/><scalar name='SumReqTrig' value='2'/></run></runs>";
355
315
        assertEquals("runs", expectedResponse, result);
356
316
    }
357
317