Search in sources :

Example 1 with PolicyGrammarException

use of org.nhindirect.policy.PolicyGrammarException in project nhin-d by DirectProject.

the class SimpleTextV1LexiconPolicyParser_buildExpressionTest method testBuildExpression_binaryOperation_missingParameter_assertGrammarException.

public void testBuildExpression_binaryOperation_missingParameter_assertGrammarException() throws Exception {
    final SimpleTextV1LexiconPolicyParser parser = new SimpleTextV1LexiconPolicyParser();
    final InputStream stream = IOUtils.toInputStream("&& true");
    final Vector<SimpleTextV1LexiconPolicyParser.TokenTypeAssociation> tokens = parser.parseToTokens(stream);
    boolean exceptionOccured = false;
    try {
        parser.buildExpression(tokens.iterator());
    } catch (PolicyGrammarException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
    stream.close();
}
Also used : PolicyGrammarException(org.nhindirect.policy.PolicyGrammarException) InputStream(java.io.InputStream)

Example 2 with PolicyGrammarException

use of org.nhindirect.policy.PolicyGrammarException in project nhin-d by DirectProject.

the class SimpleTextV1LexiconPolicyParser_buildExpressionTest method testBuildExpression_operation_missingSingleParameter_assertGrammarException.

public void testBuildExpression_operation_missingSingleParameter_assertGrammarException() throws Exception {
    final SimpleTextV1LexiconPolicyParser parser = new SimpleTextV1LexiconPolicyParser();
    final InputStream stream = IOUtils.toInputStream("&&");
    final Vector<SimpleTextV1LexiconPolicyParser.TokenTypeAssociation> tokens = parser.parseToTokens(stream);
    boolean exceptionOccured = false;
    try {
        parser.buildExpression(tokens.iterator());
    } catch (PolicyGrammarException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
    stream.close();
}
Also used : PolicyGrammarException(org.nhindirect.policy.PolicyGrammarException) InputStream(java.io.InputStream)

Example 3 with PolicyGrammarException

use of org.nhindirect.policy.PolicyGrammarException in project nhin-d by DirectProject.

the class SimpleTextV1LexiconPolicyParser_parseTest method testParse_extraniousOperator_assertGrammarException.

public void testParse_extraniousOperator_assertGrammarException() throws Exception {
    final SimpleTextV1LexiconPolicyParser parser = new SimpleTextV1LexiconPolicyParser();
    final InputStream stream = IOUtils.toInputStream("1 = 1 =");
    boolean exceptionOccured = false;
    try {
        parser.parse(stream);
    } catch (PolicyGrammarException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : PolicyGrammarException(org.nhindirect.policy.PolicyGrammarException) InputStream(java.io.InputStream)

Example 4 with PolicyGrammarException

use of org.nhindirect.policy.PolicyGrammarException in project nhin-d by DirectProject.

the class SimpleTextV1LexiconPolicyParser_buildExpressionTest method testBuildExpression_emptyGroup_assertGrammarException.

public void testBuildExpression_emptyGroup_assertGrammarException() throws Exception {
    final SimpleTextV1LexiconPolicyParser parser = new SimpleTextV1LexiconPolicyParser();
    final InputStream stream = IOUtils.toInputStream("()");
    final Vector<SimpleTextV1LexiconPolicyParser.TokenTypeAssociation> tokens = parser.parseToTokens(stream);
    boolean exceptionOccured = false;
    try {
        parser.buildExpression(tokens.iterator());
    } catch (PolicyGrammarException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : PolicyGrammarException(org.nhindirect.policy.PolicyGrammarException) InputStream(java.io.InputStream)

Example 5 with PolicyGrammarException

use of org.nhindirect.policy.PolicyGrammarException in project nhin-d by DirectProject.

the class SimpleTextV1LexiconPolicyParser_buildExpressionTest method testBuildExpression_erroniousExpressionAtEnd_assertGrammarException.

public void testBuildExpression_erroniousExpressionAtEnd_assertGrammarException() throws Exception {
    final SimpleTextV1LexiconPolicyParser parser = new SimpleTextV1LexiconPolicyParser();
    final InputStream stream = IOUtils.toInputStream("((d = 1)) +");
    final Vector<SimpleTextV1LexiconPolicyParser.TokenTypeAssociation> tokens = parser.parseToTokens(stream);
    boolean exceptionOccured = false;
    try {
        parser.buildExpression(tokens.iterator());
    } catch (PolicyGrammarException e) {
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : PolicyGrammarException(org.nhindirect.policy.PolicyGrammarException) InputStream(java.io.InputStream)

Aggregations

PolicyGrammarException (org.nhindirect.policy.PolicyGrammarException)10 InputStream (java.io.InputStream)9 PolicyExpression (org.nhindirect.policy.PolicyExpression)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 PrintStream (java.io.PrintStream)1 X509Certificate (java.security.cert.X509Certificate)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 PolicyFilter (org.nhindirect.policy.PolicyFilter)1 PolicyLexiconParser (org.nhindirect.policy.PolicyLexiconParser)1 PolicyRequiredException (org.nhindirect.policy.PolicyRequiredException)1 StackMachineCompiler (org.nhindirect.policy.impl.machine.StackMachineCompiler)1