/**
 * The MIT License
 *
 * Copyright (C) 2015 Asterios Raptis
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package de.alpharogroup.crypto.key.reader;

import static org.testng.AssertJUnit.assertEquals;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

import org.bouncycastle.util.io.pem.PemObject;
import org.meanbean.test.BeanTestException;
import org.meanbean.test.BeanTester;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;

import de.alpharogroup.file.search.PathFinder;


/**
 * Test class for the class {@link PemObjectReader}.
 */
public class PemObjectReaderTest
{
	/** The LOGGER. */
	static final Logger logger = LoggerFactory.getLogger(PemObjectReaderTest.class.getName());

	/**
	 * Test method for {@link PemObjectReader#getPemObject(File)}.
	 *
	 * @throws IOException
	 *             Signals that an I/O exception has occurred.
	 */
	@Test
	public void testGetPemObject() throws IOException
	{
		final File privatekeyPemDir = new File(PathFinder.getSrcTestResourcesDir(), "pem");
		final File privatekeyPemFile = new File(privatekeyPemDir, "private.pem");

		final PemObject pemObject = PemObjectReader.getPemObject(privatekeyPemFile);
		final String actual = pemObject.getType();
		final String expected = "RSA PRIVATE KEY";
		assertEquals(expected, actual);

	}

	/**
	 * Test method for {@link PemObjectReader#toPemFormat(PemObject)}.
	 *
	 * @throws IOException
	 *             Signals that an I/O exception has occurred.
	 */
	@Test
	public void testToPemFormat() throws IOException
	{
		final File privatekeyPemDir = new File(PathFinder.getSrcTestResourcesDir(), "pem");
		final File privatekeyPemFile = new File(privatekeyPemDir, "private.pem");

		final PemObject pemObject = PemObjectReader.getPemObject(privatekeyPemFile);
		final String foo = PemObjectReader.toPemFormat(pemObject);
		logger.debug("\n" + foo);
	}

	/**
	 * Test method for {@link PemObjectReader} with {@link BeanTester}
	 */
	@Test(expectedExceptions = { BeanTestException.class, InvocationTargetException.class,
			UnsupportedOperationException.class })
	public void testWithBeanTester()
	{
		final BeanTester beanTester = new BeanTester();
		beanTester.testBean(PemObjectReader.class);
	}

}

@@ -3315,12 +3315,539 @@
 ass);%0A%09%7D
+%09%0A%0A%09/**%0A%09 * Test method for %7B@link PemObjectReader#readPemPrivateKey(File, String)%7D.%0A%09 *%0A%09 * @throws IOException%0A%09 *             Signals that an I/O exception has occurred.%0A%09 */%0A%09@Test%0A%09public void testReadPemPrivateKey() throws IOException%0A%09%7B%0A%09%09final File privatekeyPemDir = new File(PathFinder.getSrcTestResourcesDir(), %22pem%22);%0A%09%09final File privatekeyPemFile = new File(privatekeyPemDir, %22id_rsa%22);%0A%0A%09%09 PrivateKey privateKey = PemObjectReader.readPemPrivateKey(privatekeyPemFile, %22secret%22);%0A%09%09 assertNotNull(privateKey);%09%09%0A%09%7D
 %0A%0A%7D%0A

Update PemObjectReaderTest.java