Package ch.inftec.ju.util

Examples of ch.inftec.ju.util.IOUtil


          if (JuUtils.getJuPropertyChain().get("ju-testing.export.compareToResource", Boolean.class, true)) {
            // Perform export in-memory and compare to resource
            String resourcePrefix = dataSetExport.resourcePrefix();
            String resourcePath = resourcePrefix + "/" + targetFileName;
            URL resourceUrl = JuUrl.singleResource(resourcePath);
            String resourceString = new IOUtil().loadTextFromUrl(resourceUrl);
           
            String xmlString = eb.writeToXmlString();
           
            logger.debug("Comparing DB export to resource {}", resourceUrl);
            Assert.assertEquals(resourceString, xmlString);
View Full Code Here


    JuSecurityUtils.performEncryption()
      .propertyFile(JuUrl.toUrl(testCopy))
      .encryptor(encryptor)
      .encryptToSourceFile();
   
    String res = new IOUtil().loadTextFromUrl(JuUrl.toUrl(testCopy));
    Assert.assertFalse(res.contains("doENC("));
   
    IOUtil.deleteFile(testCopy);
  }
View Full Code Here

  }
 
  @Test
  public void canEncrypt_toSourceFile_withBackup() throws Exception {
    Path srcFile = Paths.get("src/test/resources/ch/inftec/ju/util/security/JuSecurityUtilsTest_toBeEncrypted.properties");
    String original = new IOUtil().loadTextFromUrl(JuUrl.toUrl(srcFile));
    Path testCopy = Paths.get("target/tests").resolve(srcFile.getFileName());
   
    IOUtil.copyFile(srcFile, testCopy, true);
   
    JuTextEncryptor encryptor = JuSecurityUtils.buildEncryptor().password("secret").createTextEncryptor();
    Path backupFile = JuSecurityUtils.performEncryption()
      .propertyFile(JuUrl.toUrl(testCopy))
      .encryptor(encryptor)
      .encryptToSourceFileWithBackup();
   
    String res = new IOUtil().loadTextFromUrl(JuUrl.toUrl(testCopy));
    Assert.assertFalse(res.contains("doENC("));
   
    String backup = new IOUtil().loadTextFromUrl(JuUrl.toUrl(backupFile));
    Assert.assertEquals(original, backup);
   
    IOUtil.deleteFile(testCopy);
    IOUtil.deleteFile(backupFile);
  }
View Full Code Here

    TestUtils.assertEqualsResource("XmlUtilsTest_canCreateXml_fromJaxbObject_usingFormattedOutput.xml", xmlString);
  }
 
  @Test
  public void canCreate_object_fromXml() throws Exception {
    String xmlString = new IOUtil().loadTextFromUrl(JuUrl.resourceRelativeTo("XmlUtilsTest_canCreateXml_fromJaxbObject.xml", XmlUtilsJaxbTest.class));
    Object o = XmlUtils.marshaller().unmarshalRaw(xmlString, Player.class);
    this.assertMichael((Player) o);
  }
View Full Code Here

    this.assertMichael((Player) o);
  }
 
  @Test
  public void canCreate_typedOject_fromXml() throws Exception {
    String xmlString = new IOUtil().loadTextFromUrl(JuUrl.resourceRelativeTo("XmlUtilsTest_canCreateXml_fromJaxbObject.xml", XmlUtilsJaxbTest.class));
    Player p = XmlUtils.marshaller().unmarshal(xmlString, Player.class);
    this.assertMichael(p);
  }
View Full Code Here

  @Test
  public void canNot_createObject_fromXml_withoutNamespace() throws Exception {
    exception.expect(JuRuntimeException.class);
    exception.expectCause(Is.isA(UnmarshalException.class));
   
    String xmlString = new IOUtil().loadTextFromUrl(JuUrl.resourceRelativeTo("XmlUtilsTest_michael_noNamespace.xml", XmlUtilsJaxbTest.class));
    Object o = XmlUtils.marshaller().unmarshalRaw(xmlString, Player.class);
    this.assertMichael((Player) o);
  }
View Full Code Here

      .marshalToString(this.getMichael(100));
  }
 
  @Test
  public void canUnmarshal_invalidXml_whenNotUsingSchema() throws Exception {
    String xmlString = new IOUtil().loadTextFromUrl(JuUrl.resourceRelativeTo("XmlUtilsTest_michael_invalid.xml", this.getClass()));
    XmlUtils.marshaller().unmarshal(xmlString, Player.class);
  }
View Full Code Here

  @Test
  public void canNotUnmarshal_invalidXml_whenUsingSchema() throws Exception {
    exception.expect(JuRuntimeException.class);
    exception.expectCause(Is.isA(UnmarshalException.class));
   
    String xmlString = new IOUtil().loadTextFromUrl(JuUrl.resourceRelativeTo("XmlUtilsTest_michael_invalid.xml", this.getClass()));
   
    XmlUtils.marshaller()
      .schema(JuUrl.resourceRelativeTo("player.xsd", this.getClass()))
      .unmarshal(xmlString, Player.class);
  }
View Full Code Here

        if (JuUtils.getJuPropertyChain().get("ju-testing.export.compareToResource", Boolean.class, true)) {
          // Perform export in-memory and compare to resource
          String resourcePrefix = dataSetExport.resourcePrefix();
          String resourcePath = resourcePrefix + "/" + targetFileName;
          URL resourceUrl = JuUrl.singleResource(resourcePath);
          String resourceString = new IOUtil().loadTextFromUrl(resourceUrl);
         
          String xmlString = eb.writeToXmlString();
         
          logger.debug("Comparing DB export to resource {}", resourceUrl);
          Assert.assertEquals(resourceString, xmlString);
View Full Code Here

        if (JuUtils.getJuPropertyChain().get("ju-testing.export.compareToResource", Boolean.class, true)) {
          // Perform export in-memory and compare to resource
          String resourcePrefix = dataSetExport.resourcePrefix();
          String resourcePath = resourcePrefix + "/" + targetFileName;
          URL resourceUrl = JuUrl.singleResource(resourcePath);
          String resourceString = new IOUtil().loadTextFromUrl(resourceUrl);
         
          String xmlString = eb.writeToXmlString();
         
          logger.debug("Comparing DB export to resource {}", resourceUrl);
          Assert.assertEquals(resourceString, xmlString);
View Full Code Here

TOP

Related Classes of ch.inftec.ju.util.IOUtil

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.