use of org.eclipse.titan.log.viewer.views.msc.model.EventType in project titan.EclipsePlug-ins by eclipse.
the class Parser method parseLogRecord.
/**
* Parse a single log record.
*
* @param logRecord the record to analyze.
* @param eventIndex the index of the event to be used in setverdict handling.
*/
private EventObject parseLogRecord(final LogRecord logRecord, final int eventIndex) {
final String message = logRecord.getMessage();
this.messageAnalyser.setMessage(message);
// TODO remove filtering from this function
boolean isLogRecordIgnored = false;
if (executionModel.getFilterPattern() != null) {
isLogRecordIgnored = !executionModel.getFilterPattern().match(logRecord);
}
// This branch handles send events.
if (this.messageAnalyser.isSend()) {
String sendType = messageAnalyser.getSendType();
if (!isSignalIgnored(sendType) && components != null) {
String sendTarget = messageAnalyser.getSendTarget();
TestComponent tc = components.get(sendTarget);
if (tc != null) {
String logComponentRef = logRecord.getComponentReference();
Set<String> sources = tc.getMappedFromReference(messageAnalyser.getSendSource());
String source = getSource(logComponentRef, sources);
if (source != null && !isComponentIgnored(source)) {
sends++;
EventObject event = createEventObject(logRecord, EventType.SEND);
String deciphered = decipherer.decipher(sendType.trim(), messageAnalyser.getSendValue());
if (deciphered != null) {
event.setName(deciphered);
} else {
event.setName(sendType);
}
event.setReference(source);
event.setTarget(sendTarget);
if (tc.getAlternative() != null) {
event.setTarget(tc.getAlternative());
}
return event;
}
}
}
} else if (messageAnalyser.isReceive()) {
// This branch handles receive events.
String recieveType = messageAnalyser.getReceiveType();
if (!isSignalIgnored(recieveType) && !isLogRecordIgnored && components != null) {
String sourceRef = messageAnalyser.getReceiveSource();
TestComponent tc = components.get(sourceRef);
if (tc != null) {
String recieveTargetPort = messageAnalyser.getReceiveTarget();
String logComponentRef = logRecord.getComponentReference();
Set<String> targetRefs = tc.getMappedFromReference(recieveTargetPort);
String targetRef = getTargetRef(logComponentRef, targetRefs);
if (targetRef != null && !isComponentIgnored(targetRef)) {
return handleReceive(logRecord, recieveType, sourceRef, tc, recieveTargetPort, targetRef);
}
}
}
} else if (messageAnalyser.isEnqueued()) {
// This branch handles enqueued events.
String recieveType = messageAnalyser.getReceiveType();
if (!isSignalIgnored(recieveType) && !isLogRecordIgnored && components != null) {
String sourceRef = messageAnalyser.getReceiveSource();
TestComponent tc = components.get(sourceRef);
if (tc != null) {
String enqueuedTargetPort = messageAnalyser.getEnqueuedTarget();
String logComponentRef = logRecord.getComponentReference();
Set<String> targetRefs = tc.getMappedFromReference(enqueuedTargetPort);
// In case of valid log files it cannot happen.
String targetRef = getTargetRef(logComponentRef, targetRefs);
if (targetRef != null && !isComponentIgnored(targetRef)) {
enqs++;
EventObject event = createEventObject(logRecord, EventType.ENQUEUED);
String msg = messageAnalyser.getReceiveValue();
String deciphered = decipherer.decipher(recieveType, msg);
if (deciphered != null) {
event.setName(deciphered);
} else {
event.setName(recieveType);
}
event.setReference(sourceRef);
event.setTarget(targetRef);
event.setPort(enqueuedTargetPort);
if (tc.getAlternative() != null) {
event.setReference(tc.getAlternative());
}
return event;
}
}
}
} else if (this.messageAnalyser.isReceiveOperation()) {
// This branch handles receive operation events. AFAIK,
// it is obsolete in new (>= 1.7.pl0) TITAN versions.
String recieveType = messageAnalyser.getReceiveOperationType();
if (!isSignalIgnored(recieveType) && components != null) {
String sourceRef = messageAnalyser.getReceiveSource();
TestComponent tc = components.get(sourceRef);
if (tc != null) {
String receiveTargetPort = messageAnalyser.getReceiveOperationTarget();
String logComponentRef = logRecord.getComponentReference();
Set<String> targetRefs = tc.getMappedFromReference(receiveTargetPort);
String targetRef = getTargetRef(logComponentRef, targetRefs);
if (targetRef != null && !isComponentIgnored(targetRef)) {
return handleReceive(logRecord, recieveType, sourceRef, tc, receiveTargetPort, targetRef);
}
}
}
} else if (this.messageAnalyser.isStartFunction()) {
// This branch handles function start events.
if (components != null) {
String targetRef = this.messageAnalyser.getStartFunctionReference();
if ((targetRef != null) && !isComponentIgnored(targetRef) && !isFunctionIgnored(this.messageAnalyser.getStartFunctionName())) {
EventObject event = createEventObject(logRecord, EventType.FUNCTION);
event.setName(this.messageAnalyser.getStartFunctionName());
event.setReference(Constants.MTC_REFERENCE);
event.setTarget(targetRef);
return event;
}
}
} else if (this.messageAnalyser.isComponentCreation()) {
// This branch handles component creation events.
if (components != null) {
EventObject event = createEventObject(logRecord, EventType.PTC_CREATE);
String reference = event.getReference();
TestComponent tc = components.get(reference);
if (tc == null || tc.getRecordNumber() == logRecord.getRecordNumber()) {
if ((reference != null) && !isComponentIgnored(reference)) {
return event;
}
} else {
if (!isComponentIgnored(reference)) {
logRecord.setComponentReference(reference);
event = eventObjectFactory.createEventObject(EventType.SILENT_EVENT, logRecord, this.messageAnalyser, this.logFileMetaData.getTimeStampConstant());
return event;
}
}
}
} else if (this.messageAnalyser.isComponentDone()) {
// This branch handles component done events.
EventObject event = createEventObject(logRecord, EventType.PTC_DONE);
String reference = event.getReference();
if ((reference != null) && !isComponentIgnored(reference)) {
return event;
}
} else if (this.messageAnalyser.isComponentTermination()) {
// This branch handles component termination events.
if (components != null) {
String ref = this.messageAnalyser.getComponentTerminationReference();
if ((ref != null) && !isComponentIgnored(ref)) {
String terminationVerdict = this.messageAnalyser.getComponentTerminationVerdict();
TestComponent component = components.get(ref);
if (component != null) {
component.setVerdict(terminationVerdict);
}
EventObject event = createEventObject(logRecord, EventType.PTC_TERMINATE);
event.setReference(ref);
event.setName(terminationVerdict);
return event;
}
}
} else if (this.messageAnalyser.isPortMapping()) {
// This branch handles port mapping events.
String mappingSource = this.messageAnalyser.getPortMappingSource();
final String compRef = this.messageAnalyser.getComponentRef(mappingSource);
String target = this.messageAnalyser.getPortMappingTarget();
String targetRef = this.messageAnalyser.getComponentRef(target);
String sourcePort = this.messageAnalyser.getPort(mappingSource);
String targetPort = this.messageAnalyser.getPort(target);
if (!filterMappingPorts && !(isComponentIgnored(compRef) || isComponentIgnored(targetRef))) {
logRecord.setComponentReference(compRef);
EventObject event = createEventObject(logRecord, EventType.MAPPING_PORT);
event.setPort(sourcePort);
event.setTargetPort(targetPort);
event.setTarget(targetRef);
event.setName(MAPPING);
return event;
}
// Used for mapping ports to reference
addPortMapping(compRef, sourcePort, targetRef, targetPort);
} else if (this.messageAnalyser.isPortUnmapping()) {
// This branch handles port unmapping events.
String unmappingSource = this.messageAnalyser.getPortUnMapping();
String compRef = this.messageAnalyser.getComponentRef(unmappingSource);
compRef = this.messageAnalyser.getComponentRef(compRef);
String target = this.messageAnalyser.getPortUnMappingTarget();
String targetRef = this.messageAnalyser.getComponentRef(target);
String sourcePort = this.messageAnalyser.getPort(unmappingSource);
String targetPort = this.messageAnalyser.getPort(target);
if (!filterMappingPorts && !(isComponentIgnored(compRef) || isComponentIgnored(targetRef))) {
logRecord.setComponentReference(compRef);
EventObject event = createEventObject(logRecord, EventType.UNMAPPING_PORT);
event.setPort(sourcePort);
event.setTargetPort(targetPort);
event.setTarget(targetRef);
event.setName(UNMAPPING);
return event;
}
// Used for mapping ports to reference
} else if (this.messageAnalyser.isPortConnection()) {
// This branch handles port connection events.
String connectionSource = this.messageAnalyser.getPortConnectionSource();
final String compRef = this.messageAnalyser.getComponentRef(connectionSource);
// Used for connect port and reference
String target = this.messageAnalyser.getPortConnectionTarget();
String targetRef = this.messageAnalyser.getComponentRef(target);
String sourcePort = this.messageAnalyser.getPort(connectionSource);
String targetPort = this.messageAnalyser.getPort(target);
if (!filterConnectingPorts && !(isComponentIgnored(compRef) || isComponentIgnored(targetRef))) {
logRecord.setComponentReference(compRef);
EventObject event = createEventObject(logRecord, EventType.CONNECTING_PORT);
event.setPort(sourcePort);
event.setTargetPort(targetPort);
event.setTarget(targetRef);
event.setName(CONNECTING);
return event;
}
addPortMapping(compRef, sourcePort, targetRef, targetPort);
} else if (this.messageAnalyser.isPortDisconnection()) {
// This branch handles port disconnection events.
String disconnectionSource = this.messageAnalyser.getPortDisconnectionSource();
final String compRef = this.messageAnalyser.getComponentRef(disconnectionSource);
// Used for disconnect port and reference
String target = this.messageAnalyser.getPortConnectionTarget();
String targetRef = this.messageAnalyser.getComponentRef(target);
String sourcePort = this.messageAnalyser.getPort(disconnectionSource);
String targetPort = this.messageAnalyser.getPort(target);
if (!filterConnectingPorts && !(isComponentIgnored(compRef) || isComponentIgnored(targetRef))) {
logRecord.setComponentReference(compRef);
EventObject event = createEventObject(logRecord, EventType.DISCONNECTING_PORT);
event.setPort(sourcePort);
event.setTargetPort(targetPort);
event.setTarget(targetRef);
event.setName(DISCONNECTING);
return event;
}
} else if (this.messageAnalyser.isTestcaseStart()) {
// This branch handles test case start events.
return eventObjectFactory.createEventObject(EventType.TC_START, logRecord, this.messageAnalyser, this.logFileMetaData.getTimeStampConstant());
} else if (this.messageAnalyser.isTestcaseEnd()) {
// This branch handles test case end events.
return eventObjectFactory.createEventObject(EventType.TC_END, logRecord, this.messageAnalyser, this.logFileMetaData.getTimeStampConstant());
} else if (this.messageAnalyser.isMTCCreation()) {
EventObject event = createEventObject(logRecord, EventType.MTC_CREATE);
addComponent(event);
return event;
} else if (this.messageAnalyser.isMTCTermination()) {
// This branch handles master test component termination events.
return eventObjectFactory.createEventObject(EventType.MTC_TERMINATE, logRecord, this.messageAnalyser, this.logFileMetaData.getTimeStampConstant());
} else if (this.messageAnalyser.isMTCDone()) {
// This branch handles master test component done and sets the verdict.
if (components != null) {
TestComponent component = components.get(Constants.MTC_REFERENCE);
if (component != null) {
String verdict = this.messageAnalyser.getMTCVerdict();
component.setVerdict(verdict);
}
}
EventObject event = createEventObject(logRecord, EventType.SILENT_EVENT);
event.setReference(Constants.MTC_REFERENCE);
return event;
} else if (this.messageAnalyser.isSetverdict()) {
if ((logRecord.getComponentReference() != null) && !isComponentIgnored(logRecord.getComponentReference())) {
// Get type - change type inconc
String setverdicttype = this.messageAnalyser.getSetverdictType();
if (Constants.TEST_CASE_VERDICT_INCONCLUSIVE.equals(setverdicttype) && displaySetverdictInconc) {
setverdictVector.add(eventIndex);
EventObject event = createEventObject(logRecord, EventType.SETVERDICT_INCONC);
event.setName(setverdicttype);
return event;
} else if (Constants.TEST_CASE_VERDICT_ERROR.equals(setverdicttype) && displaySetverdictError) {
setverdictVector.add(eventIndex);
EventObject event = createEventObject(logRecord, EventType.SETVERDICT);
event.setName(setverdicttype);
ConnectedRecord[] connectedRecords = errorVector.toArray(new ConnectedRecord[errorVector.size()]);
event.setConnectedRecords(connectedRecords);
return event;
} else if (Constants.TEST_CASE_VERDICT_FAIL.equals(setverdicttype) && displaySetverdictFail) {
setverdictVector.add(eventIndex);
EventObject event = createEventObject(logRecord, EventType.SETVERDICT);
event.setName(setverdicttype);
ConnectedRecord[] connectedRecords = failVector.toArray(new ConnectedRecord[failVector.size()]);
event.setConnectedRecords(connectedRecords);
return event;
} else if (Constants.TEST_CASE_VERDICT_NONE.equals(setverdicttype) && displaySetverdictNone) {
setverdictVector.add(eventIndex);
EventObject event = createEventObject(logRecord, EventType.SETVERDICT_NONE);
event.setName(setverdicttype);
return event;
} else if (Constants.TEST_CASE_VERDICT_PASS.equals(setverdicttype) && displaySetverdictPass) {
setverdictVector.add(eventIndex);
EventType setverdictPass = EventType.SETVERDICT_PASS;
EventObject event = createEventObject(logRecord, setverdictPass);
event.setName(setverdicttype);
return event;
}
errorVector.clear();
failVector.clear();
}
} else {
// Silent events
Boolean filtered = isEventIgnored(logRecord.getEventType());
if (!filtered) {
// component reference exists in the log record
if ((logRecord.getComponentReference() != null) && (logRecord.getComponentReference().trim().length() > 0)) {
return eventObjectFactory.createEventObject(EventType.SILENT_EVENT, logRecord, this.messageAnalyser, this.logFileMetaData.getTimeStampConstant());
} else {
final String compRef = this.messageAnalyser.isSilentEvent();
logRecord.setComponentReference(compRef != null ? compRef : Constants.MTC_REFERENCE);
return eventObjectFactory.createEventObject(EventType.SILENT_EVENT, logRecord, this.messageAnalyser, this.logFileMetaData.getTimeStampConstant());
}
}
}
// setverdict(error)
if (this.messageAnalyser.isDynamicTestCaseError()) {
ConnectedRecord connectedRecord = new ConnectedRecord(logRecord.getRecordOffset(), logRecord.getRecordLength(), logRecord.getRecordNumber());
errorVector.add(connectedRecord);
}
// check if fail messages, used for setverdict(fail)
if (this.messageAnalyser.isFailMessages()) {
ConnectedRecord connectedRecord = new ConnectedRecord(logRecord.getRecordOffset(), logRecord.getRecordLength(), logRecord.getRecordNumber());
failVector.add(connectedRecord);
}
return null;
}
use of org.eclipse.titan.log.viewer.views.msc.model.EventType in project titan.EclipsePlug-ins by eclipse.
the class ValueReader method readLogRecordFromLogFile.
public LogRecord readLogRecordFromLogFile(final URI logFilePath, final EventObject event) throws IOException, ParseException {
long offset = event.getRecordOffset();
int length = event.getRecordLength();
LogRecord logrecord = getLogRecord(logFilePath, offset, length);
String message = logrecord.getMessage();
EventType type = event.getType();
switch(type) {
case SEND:
message = readSendEvent(message);
break;
case RECEIVE:
message = readReceiveEvent(message);
break;
case SILENT_EVENT:
message = getValue(logFilePath, offset, length);
break;
case ENQUEUED:
message = readEnqueuedEvent(message);
break;
case SETVERDICT:
ConnectedRecord[] connectedRecords = event.getConnectedRecords();
if (connectedRecords != null) {
StringBuilder messageBuilder = new StringBuilder("{ message := " + message.trim());
if (connectedRecords.length > 0) {
messageBuilder.append(", causedBy := { ");
}
for (int i = 0; i < connectedRecords.length; i++) {
int eventNumber = i + 1;
ConnectedRecord connectedEvent = connectedRecords[i];
logrecord = getLogRecord(logFilePath, connectedEvent.getRecordOffset(), connectedEvent.getRecordLength());
messageBuilder.append("event" + eventNumber + " := { timestamp := " + logrecord.getTimestamp() + ", componentRef := " + logrecord.getComponentReference() + ", eventType := " + logrecord.getEventType() + ", sourceInfo := " + logrecord.getSourceInformation() + ", message := {" + logrecord.getMessage().trim() + "} }");
}
if (connectedRecords.length > 0) {
messageBuilder.append(" }");
}
message = messageBuilder.toString();
}
// $NON-NLS-1$
message = message + "}\n";
break;
case PTC_CREATE:
default:
break;
}
logrecord.setMessage(message);
return logrecord;
}
Aggregations