Package com.qspin.qtaste.testsuite

Examples of com.qspin.qtaste.testsuite.QTasteDataException


        getValue(key); // to check if data exists
        if (hashFiles.containsKey(key)) {
            byte[] array = (byte[]) hashFiles.get(key);
            return array;
        } else {
            throw new QTasteDataException("Test data " + key + " has no byte array value");
        }
    }
View Full Code Here


            bis.read(buffer);
            bis.close();
            logger.debug("Loaded file: " + f.getPath() + " size:" + buffer.length);
            hashFiles.put(key, buffer);
        } catch (IOException e) {
            throw new QTasteDataException(e.getMessage());
        }
    }
View Full Code Here

        final long beginTime_ms = System.currentTimeMillis(); // begin time
        long elapsedTime_ms = 0; // total elapsed time
        final long checkTimeInterval_ms = 100; // check every 100 ms

        if (!(value instanceof Comparable)) {
            throw new QTasteDataException("Value is not an instance of Comparable");
        }

        do {
            Object lastValue;
            try {
                Data lastData = getLast(name);
                lastValue = lastData.getValue();
                int comparisonResult = ((Comparable) value).compareTo(lastValue);
                boolean comparisonSuccessful = false;
                switch (comparator) {
                    case COMPARATOR_EQ:
                        comparisonSuccessful = comparisonResult == 0;
                        break;
                    case COMPARATOR_NEQ:
                        comparisonSuccessful = comparisonResult != 0;
                        break;
                    case COMPARATOR_LT:
                        comparisonSuccessful = comparisonResult > 0;
                        break;
                    case COMPARATOR_GT:
                        comparisonSuccessful = comparisonResult < 0;
                        break;
                    case COMPARATOR_LEQ:
                        comparisonSuccessful = comparisonResult >= 0;
                        break;
                    case COMPARATOR_GEQ:
                        comparisonSuccessful = comparisonResult <= 0;
                        break;
                }
                if (comparisonSuccessful) {
                    return lastData;
                }
            } catch (QTasteTestFailException e) {
                // variable not in cache
                lastValue = null;
            }
            if (elapsedTime_ms >= timeout) {
                String lastValueStr = (lastValue == null ? "null" : lastValue.toString());
                String comparatorStr = "";
                switch (comparator) {
                    case COMPARATOR_EQ:
                        comparatorStr = "==";
                        break;
                    case COMPARATOR_NEQ:
                        comparatorStr = "!=";
                        break;
                    case COMPARATOR_LT:
                        comparatorStr = "<";
                        break;
                    case COMPARATOR_GT:
                        comparatorStr = ">";
                        break;
                    case COMPARATOR_LEQ:
                        comparatorStr = "<=";
                        break;
                    case COMPARATOR_GEQ:
                        comparatorStr = ">=";
                        break;
                }
                throw new QTasteTestFailException("Variable " + name + " value (" + lastValueStr + ") didn't reach expected value (" + comparatorStr + " " + value + ")");
            }
            // wait
            try {
                Thread.sleep(checkTimeInterval_ms);
                elapsedTime_ms = System.currentTimeMillis() - beginTime_ms;
            } catch (InterruptedException e) {
                throw new QTasteDataException("Sleep interrupted");
            }
        } while (true);
    }
View Full Code Here

        } else if (comparatorString.equals("<=")) {
            return Comparator.COMPARATOR_LEQ;
        } else if (comparatorString.equals(">=")) {
            return Comparator.COMPARATOR_GEQ;
        } else {
            throw new QTasteDataException("Invalid comparator (" + comparatorString + ")");
        }
    }
View Full Code Here

TOP

Related Classes of com.qspin.qtaste.testsuite.QTasteDataException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.