import java.io.IOException;
import java.util.Properties;

import javax.xml.bind.JAXBException;

import org.junit.Before;
import org.junit.Test;

import uk.bl.odin.orcid.client.OrcidAccessToken;
import uk.bl.odin.orcid.client.OrcidOAuthClient;
import uk.bl.odin.orcid.client.constants.OrcidAuthScope;
import static org.junit.Assert.*;



/** Most tests migrated to orcid-update-app as it requires server interaction.
 * 
 * Developers should ensure that they copy testoauth.properties.example to testoauth.properties
 * and modify it to contain their credentials.
 *  
 * @author tom
 *
 */

public class OrcidOAuthClientTest {
	private Properties properties = new Properties();

	@Before
	public void before() throws IOException {
		properties.load(getClass().getResourceAsStream("testoauth.properties"));
	}
	
	@Test
	public final void testCreateProfile() throws IOException, JAXBException {
		OrcidOAuthClient client = new OrcidOAuthClient(properties.getProperty("orcidClientID"),
				properties.getProperty("orcidClientSecret"), properties.getProperty("orcidReturnUri"),
				Boolean.valueOf(properties.getProperty("orcidSandbox")));
		OrcidAccessToken tok = client.getCreateProfileAccessToken();
		assertNotNull(tok.getAccess_token());
	}
	
}

@@ -21,16 +21,44 @@
 eption;%0A
+import java.io.InputStream;%0A
 import j
@@ -758,78 +758,287 @@
 %7B%0A%09%09
-properties.load(getClass().getResourceAsStream(%22testoauth.properties%22)
+final String filename = %22testoauth.properties%22;%0A%09%09final InputStream inputStream = getClass().getResourceAsStream(filename);%0A%0A%09%09if (inputStream == null) %7B%0A%09%09%09throw new IOException(%22Unable to find properties file src/test/resources/%22 + filename);%0A%09%09%7D%0A%0A%09%09properties.load(inputStream
 );%0A%09

Throw meaningful exception if properties file could not be found