Package com.getperka.flatpack.policy.pst

Examples of com.getperka.flatpack.policy.pst.PolicyFile


      return false;
    }

    @Override
    public boolean visit(PolicyFile x) {
      PolicyFile n = new PolicyFile();
      n.setAllows(clone(x.getAllows()));
      n.setPackagePolicies(clone(x.getPackagePolicies()));
      n.setTypePolicies(clone(x.getTypePolicies()));
      n.setVerbs(clone(x.getVerbs()));
      stack.push(n);
      return false;
    }
View Full Code Here


  /**
   * The top-level parse rule.
   */
  public Rule PolicyFile() {
    Var<PolicyFile> x = new Var<PolicyFile>(new PolicyFile());
    return Sequence(
        PolicyBlock(x),
        EOI);
  }
View Full Code Here

   * Parse the test file, and shuffle the elements to ensure that there aren't any test dependencies
   * on the particulars of how the contents of the file are ordered.
   */
  @Test
  public void testShuffle() {
    PolicyFile policyFile = loadTestPolicy();

    final Random r = new Random(0);
    for (int i = 0; i < 10; i++) {
      policyFile.accept(new PolicyVisitor() {

        /**
         * Shuffle nested lists.
         */
        @Override
        public void traverse(List<? extends PolicyNode> list) {
          if (list != null) {
            Collections.shuffle(list, r);
          }
          super.traverse(list);
        }

        /**
         * Don't re-order the internal state of an Ident.
         */
        @Override
        public boolean visit(Ident<?> x) {
          return false;
        }
      });

      try {
        doTest(policyFile.toSource());
      } catch (IllegalArgumentException e) {
        System.err.println(i + " Failing source:\n" + policyFile.toSource());
        throw e;
      }
    }
  }
View Full Code Here

  }

  @Test
  public void test() throws IOException {
    String contents = FileUtils.readAllText(getClass().getResourceAsStream("test.policy"));
    PolicyFile p = (PolicyFile) testRule(parser.PolicyFile(), contents);

    // Test print-parse-print to make sure nothing is getting lost
    String string = p.toSource();
    PolicyFile p2 = (PolicyFile) testRule(parser.PolicyFile(), string);
    assertEquals(string, p2.toSource());
  }
View Full Code Here

  }

  @Test
  public void testCloner() throws IOException {
    String contents = FileUtils.readAllText(getClass().getResourceAsStream("test.policy"));
    PolicyFile p = (PolicyFile) testRule(parser.PolicyFile(), contents);
    PolicyFile p2 = new PolicyCloner().clone(p);

    assertEquals(p.toSource(), p2.toSource());
  }
View Full Code Here

TOP

Related Classes of com.getperka.flatpack.policy.pst.PolicyFile

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.