use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class BlobberWorkerUnitTest method testStandardFloat.
public void testStandardFloat() throws Exception {
// was 0, which is now illegal
blobber.setCollectorIntervalSeconds(1);
getTestWorker().setCanHandle(true);
// Collector "TestCollector" is just a dummy to trick the worker to believe that
// there is a collector registered and start operating. "TestCollector" is not used at all.
// The TestBlobberWorker creates its own single collector from which the blobber worker will get data.
getTestWorker().addCollector("TestCollector");
String componentName = "CONTROL/DV01/PSA";
String serialNumber = "3456328928847";
String propertyName = "VOLTAGE_MID_1";
Any anyUp = create_any();
float[] dataArrayUp = { 1.0F, 2.0F, 3.0F, 4.0F, 5.0F, 6.0F, 7.0F, 8.0F, 9.0F, 10.0F };
floatBlobData[] dataUp = new floatBlobData[dataArrayUp.length];
int index = 0;
for (float value : dataArrayUp) {
dataUp[index] = new floatBlobData(BASE_TIME + index, value);
index++;
}
floatBlobDataSeqHelper.insert(anyUp, dataUp);
MonitorBlob blobUp = new MonitorBlob(false, (short) 0, null, "wrong:" + propertyName, anyUp);
MonitorBlob[] blobs = new MonitorBlob[1];
blobs[0] = blobUp;
long startTime = BASE_TIME + 100;
long stopTime = BASE_TIME + 101;
MonitorDataBlock block = new MonitorDataBlock(startTime, stopTime, componentName, serialNumber, blobs);
MonitorDataBlock[] blocks = new MonitorDataBlock[1];
blocks[0] = block;
getTestWorker().getCollector().setMonitorData(blocks);
ComponentData data = getTestWorker().fetchData();
String clob = BASE_TIME + "|1.0|" + (BASE_TIME + 1) + "|2.0|" + (BASE_TIME + 2) + "|3.0|" + (BASE_TIME + 3) + "|4.0|" + (BASE_TIME + 4) + "|5.0|" + (BASE_TIME + 5) + "|6.0|" + (BASE_TIME + 6) + "|7.0|" + (BASE_TIME + 7) + "|8.0|" + (BASE_TIME + 8) + "|9.0|" + (BASE_TIME + 9) + "|10.0\n";
checkData(data, clob, 10, componentName, propertyName, serialNumber, startTime, stopTime);
checkStatistics(data, 1.0, 10.0, 5.5, 3.0276503563);
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class CorbaAnyExtractionTest method testExtractData_floatBlobDataSeq.
/**
* Test of extractData method for 'floatBlobDataSeq' data.
*/
@Test
public void testExtractData_floatBlobDataSeq() throws Exception {
String propertyName = "MODULE_MODE_STATUS";
Any any = create_any();
float[] floatDataArray = { 1f, 2.1f, 3f, 4f, 5f, 6.666666f, 7f, 8f, 9f, 10f };
floatBlobData[] floatBlobDataArray = createFloatBlobData(floatDataArray);
floatBlobDataSeqHelper.insert(any, floatBlobDataArray);
List<MonitorPointTimeSeries> extractedData = anyExtractor.extractData(any, propertyName);
assertThat(extractedData, hasSize(1));
// Check the raw data
MonitorPointTimeSeries mpTs = extractedData.get(0);
assertThat(mpTs.getCorbaTypeId(), equalTo("IDL:alma/TMCDB/floatBlobDataSeq:1.0"));
assertThat(mpTs.getMonitorPointIndex(), equalTo(0));
List<MonitorPointValue> dataList = mpTs.getDataList();
assertThat(dataList, hasSize(floatDataArray.length));
for (int i = 0; i < floatBlobDataArray.length; i++) {
MonitorPointValue mpVal = dataList.get(i);
assertThat(mpVal.getTime(), equalTo(BASE_TIME + i));
assertThat(mpVal.getData(), contains((Object) new Float(floatDataArray[i])));
}
// Generate and check the CLOB data
String clobActual = clobber.generateClob(mpTs);
String clobExpected = BASE_TIME + "|1.0|" + (BASE_TIME + 1) + "|2.1|" + (BASE_TIME + 2) + "|3.0|" + (BASE_TIME + 3) + "|4.0|" + (BASE_TIME + 4) + "|5.0|" + (BASE_TIME + 5) + "|6.666666|" + (BASE_TIME + 6) + "|7.0|" + (BASE_TIME + 7) + "|8.0|" + (BASE_TIME + 8) + "|9.0|" + (BASE_TIME + 9) + "|10.0\n";
assertThat(clobActual, equalTo(clobExpected));
logger.info("Validated floatBlobDataSeq.");
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class CorbaAnyExtractionTest method create_any.
private Any create_any() {
Any ret = acsCorba.getORB().create_any();
assertThat(ret, notNullValue());
return ret;
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class CorbaAnyExtractionTest method testExtractData_doubleBlobDataSeq.
/**
* Test of extractData method for 'doubleBlobDataSeq' data.
*/
@Test
public void testExtractData_doubleBlobDataSeq() throws Exception {
String propertyName = "MODULE_MODE_STATUS";
Any any = create_any();
double[] doubleDataArray = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
doubleBlobData[] doubleBlobDataArray = createDoubleBlobData(doubleDataArray);
doubleBlobDataSeqHelper.insert(any, doubleBlobDataArray);
List<MonitorPointTimeSeries> extractedData = anyExtractor.extractData(any, propertyName);
assertThat(extractedData, hasSize(1));
// Check the raw data
MonitorPointTimeSeries mpTs = extractedData.get(0);
assertThat(mpTs.getCorbaTypeId(), equalTo("IDL:alma/TMCDB/doubleBlobDataSeq:1.0"));
assertThat(mpTs.getMonitorPointIndex(), equalTo(0));
List<MonitorPointValue> dataList = mpTs.getDataList();
assertThat(dataList, hasSize(doubleDataArray.length));
for (int i = 0; i < doubleBlobDataArray.length; i++) {
MonitorPointValue mpVal = dataList.get(i);
assertThat(mpVal.getTime(), equalTo(BASE_TIME + i));
assertThat(mpVal.getData(), contains((Object) new Double(doubleDataArray[i])));
}
// Generate and check the CLOB data
String clobActual = clobber.generateClob(mpTs);
String clobExpected = BASE_TIME + "|1.0|" + (BASE_TIME + 1) + "|2.0|" + (BASE_TIME + 2) + "|3.0|" + (BASE_TIME + 3) + "|4.0|" + (BASE_TIME + 4) + "|5.0|" + (BASE_TIME + 5) + "|6.0|" + (BASE_TIME + 6) + "|7.0|" + (BASE_TIME + 7) + "|8.0|" + (BASE_TIME + 8) + "|9.0|" + (BASE_TIME + 9) + "|10.0\n";
assertThat(clobActual, equalTo(clobExpected));
logger.info("Validated doubleBlobDataSeq.");
}
Aggregations