/**
 * Copyright (c) 2012-2013, JCabi.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met: 1) Redistributions of source code must retain the above
 * copyright notice, this list of conditions and the following
 * disclaimer. 2) Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following
 * disclaimer in the documentation and/or other materials provided
 * with the distribution. 3) Neither the name of the jcabi.com nor
 * the names of its contributors may be used to endorse or promote
 * products derived from this software without specific prior written
 * permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.jcabi.ssl.maven.plugin;

import java.io.File;
import java.util.Properties;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

/**
 * Test case for {@link Cacerts}.
 * @author Yegor Bugayenko (yegor@tpc2.com)
 * @version $Id$
 */
public final class CacertsTest {

    /**
     * Temporary folder.
     * @checkstyle VisibilityModifier (3 lines)
     */
    @Rule
    public transient TemporaryFolder temp = new TemporaryFolder();

    /**
     * Cacerts can generate a keystore.
     * @throws Exception If something is wrong
     */
    @Test
    public void importsCertificatesFromKeystore() throws Exception {
        final File keystoreFile = this.temp.newFile("keystore.jks");
        keystoreFile.delete();
        final File truststoreFile = this.temp.newFile("cacerts.jks");
        truststoreFile.delete();
        final String pwd = "some-password";
        new Keystore(pwd).activate(keystoreFile);
        final Cacerts truststore = new Cacerts(truststoreFile);
        truststore.imprt();
        MatcherAssert.assertThat(
            new Keytool(truststoreFile, "changeit").list(),
            Matchers.containsString("localhost")
        );
        final Properties props = new Properties();
        truststore.populate(props);
        Assert.assertEquals(
            truststoreFile.getAbsolutePath(),
            props.getProperty(Cacerts.TRUST)
        );
        Assert.assertEquals(
            Cacerts.STD_PWD,
            props.getProperty(Cacerts.TRUST_PWD)
        );
    }
}

@@ -1711,33 +1711,8 @@
 rs;%0A
-import org.junit.Assert;%0A
 impo
@@ -2303,28 +2303,24 @@
 ile keystore
-File
  = this.temp
@@ -2357,28 +2357,24 @@
     keystore
-File
 .delete();%0A 
@@ -2401,20 +2401,16 @@
 uststore
-File
  = this.
@@ -2456,20 +2456,16 @@
 uststore
-File
 .delete(
@@ -2550,28 +2550,24 @@
 ate(keystore
-File
 );%0A        f
@@ -2579,26 +2579,23 @@
 Cacerts 
-truststore
+cacerts
  = new C
@@ -2611,20 +2611,16 @@
 uststore
-File
 );%0A     
@@ -2622,26 +2622,23 @@
         
-truststore
+cacerts
 .imprt()
@@ -2707,20 +2707,16 @@
 uststore
-File
 , %22chang
@@ -2848,26 +2848,23 @@
         
-truststore
+cacerts
 .populat
@@ -2873,32 +2873,39 @@
 props);%0A        
+Matcher
 Assert.assertEqu
@@ -2893,38 +2893,36 @@
 herAssert.assert
-Equals
+That
 (%0A            tr
@@ -2929,20 +2929,16 @@
 uststore
-File
 .getAbso
@@ -2953,32 +2953,49 @@
 (),%0A            
+Matchers.equalTo(
 props.getPropert
@@ -3010,16 +3010,17 @@
 s.TRUST)
+)
 %0A       
@@ -3031,16 +3031,23 @@
         
+Matcher
 Assert.a
@@ -3055,14 +3055,12 @@
 sert
-Equals
+That
 (%0A  
@@ -3098,16 +3098,33 @@
         
+Matchers.equalTo(
 props.ge
@@ -3151,16 +3151,17 @@
 UST_PWD)
+)
 %0A       

fix qulice, variable naming, replaced junit assetr for hamrest assert