use of org.nhindirect.policy.impl.machine.StackMachineEntry in project nhin-d by DirectProject.
the class StackMachine_evaluateTest method testEvaluate_bitwiseAndBitSetOnOne_assertEquals.
public void testEvaluate_bitwiseAndBitSetOnOne_assertEquals() throws Exception {
Vector<Opcode> stuffToProcess = new Vector<Opcode>();
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(0)));
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(1)));
stuffToProcess.add(new StackMachineEntry(PolicyOperator.BITWISE_AND));
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(0)));
stuffToProcess.add(new StackMachineEntry(PolicyOperator.EQUALS));
StackMachine stMachine = new StackMachine();
assertTrue(stMachine.evaluate(stuffToProcess));
stuffToProcess = new Vector<Opcode>();
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(1)));
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(0)));
stuffToProcess.add(new StackMachineEntry(PolicyOperator.BITWISE_AND));
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(0)));
stuffToProcess.add(new StackMachineEntry(PolicyOperator.EQUALS));
stMachine = new StackMachine();
assertTrue(stMachine.evaluate(stuffToProcess));
}
use of org.nhindirect.policy.impl.machine.StackMachineEntry in project nhin-d by DirectProject.
the class StackMachine_evaluateTest method testEvaluate_notEnoughParamsForUnaryOperation_assertException.
public void testEvaluate_notEnoughParamsForUnaryOperation_assertException() throws Exception {
final Vector<Opcode> stuffToProcess = new Vector<Opcode>();
stuffToProcess.add(new StackMachineEntry(PolicyOperator.LOGICAL_NOT));
boolean exceptionOccured = false;
final StackMachine stMachine = new StackMachine();
try {
stMachine.evaluate(stuffToProcess);
} catch (IllegalStateException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.policy.impl.machine.StackMachineEntry in project nhin-d by DirectProject.
the class StackMachine_evaluateTest method testEvaluate_logicalOrNeitherTrue_assertFalse.
public void testEvaluate_logicalOrNeitherTrue_assertFalse() throws Exception {
final Vector<Opcode> stuffToProcess = new Vector<Opcode>();
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(false)));
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(false)));
stuffToProcess.add(new StackMachineEntry(PolicyOperator.LOGICAL_OR));
final StackMachine stMachine = new StackMachine();
assertFalse(stMachine.evaluate(stuffToProcess));
}
use of org.nhindirect.policy.impl.machine.StackMachineEntry in project nhin-d by DirectProject.
the class StackMachine_evaluateTest method testEvaluate_bitwiseOrBitSetOnBoth_assertEquals.
public void testEvaluate_bitwiseOrBitSetOnBoth_assertEquals() throws Exception {
final Vector<Opcode> stuffToProcess = new Vector<Opcode>();
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(1)));
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(1)));
stuffToProcess.add(new StackMachineEntry(PolicyOperator.BITWISE_OR));
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(1)));
stuffToProcess.add(new StackMachineEntry(PolicyOperator.EQUALS));
final StackMachine stMachine = new StackMachine();
assertTrue(stMachine.evaluate(stuffToProcess));
}
use of org.nhindirect.policy.impl.machine.StackMachineEntry in project nhin-d by DirectProject.
the class StackMachine_evaluateTest method testEvaluate_bitwiseAndBitSetOnBoth_assertEquals.
public void testEvaluate_bitwiseAndBitSetOnBoth_assertEquals() throws Exception {
final Vector<Opcode> stuffToProcess = new Vector<Opcode>();
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(1)));
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(1)));
stuffToProcess.add(new StackMachineEntry(PolicyOperator.BITWISE_AND));
stuffToProcess.add(new StackMachineEntry(PolicyValueFactory.getInstance(1)));
stuffToProcess.add(new StackMachineEntry(PolicyOperator.EQUALS));
final StackMachine stMachine = new StackMachine();
assertTrue(stMachine.evaluate(stuffToProcess));
}
Aggregations