@Test public void testValidate_Invalid_By_Not_Wellformed() throws UnsupportedEncodingException { final boolean valid = PolicyValidationUtils .validate(POLICY_STRING_NOT_WELLFORMED .getBytes(DOMUtils.DEFAULT_ENCODING)); assertFalse(valid); }
public static boolean validate(final byte[] policy) { boolean isValid = false; try { final String policyString = new String(policy, DOMUtils.DEFAULT_ENCODING); final Document policyDoc = DOMUtils.bytesToDocument(policy); final Evaluatable policyObj = PolicyMarshaller .unmarshal(new ByteArrayInputStream(policy)); Assert.notNull(policyString); Assert.notNull(policyObj); Assert.notNull(policyDoc); isValid = true; } catch (final Exception e) { LOGGER.debug(e.getMessage(), e); } return isValid; }
PolicyValidationUtils { public static boolean validate(final byte[] policy) { boolean isValid = false; try { final String policyString = new String(policy, DOMUtils.DEFAULT_ENCODING); final Document policyDoc = DOMUtils.bytesToDocument(policy); final Evaluatable policyObj = PolicyMarshaller .unmarshal(new ByteArrayInputStream(policy)); Assert.notNull(policyString); Assert.notNull(policyObj); Assert.notNull(policyDoc); isValid = true; } catch (final Exception e) { LOGGER.debug(e.getMessage(), e); } return isValid; } }
PolicyValidationUtils { public static boolean validate(final byte[] policy) { boolean isValid = false; try { final String policyString = new String(policy, DOMUtils.DEFAULT_ENCODING); final Document policyDoc = DOMUtils.bytesToDocument(policy); final Evaluatable policyObj = PolicyMarshaller .unmarshal(new ByteArrayInputStream(policy)); Assert.notNull(policyString); Assert.notNull(policyObj); Assert.notNull(policyDoc); isValid = true; } catch (final Exception e) { LOGGER.debug(e.getMessage(), e); } return isValid; }  }
PolicyValidationUtils { public static boolean validate(final byte[] policy) { boolean isValid = false; try { final String policyString = new String(policy, DOMUtils.DEFAULT_ENCODING); final Document policyDoc = DOMUtils.bytesToDocument(policy); final Evaluatable policyObj = PolicyMarshaller .unmarshal(new ByteArrayInputStream(policy)); Assert.notNull(policyString); Assert.notNull(policyObj); Assert.notNull(policyDoc); isValid = true; } catch (final Exception e) { LOGGER.debug(e.getMessage(), e); } return isValid; }  static boolean validate(final byte[] policy); static PolicyDto validateAndReturn(PolicyDto policyDto); }
PolicyValidationUtils { public static boolean validate(final byte[] policy) { boolean isValid = false; try { final String policyString = new String(policy, DOMUtils.DEFAULT_ENCODING); final Document policyDoc = DOMUtils.bytesToDocument(policy); final Evaluatable policyObj = PolicyMarshaller .unmarshal(new ByteArrayInputStream(policy)); Assert.notNull(policyString); Assert.notNull(policyObj); Assert.notNull(policyDoc); isValid = true; } catch (final Exception e) { LOGGER.debug(e.getMessage(), e); } return isValid; }  static boolean validate(final byte[] policy); static PolicyDto validateAndReturn(PolicyDto policyDto);  }