package org.lee.hackpad.jackpad;

import static org.junit.Assert.*;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import org.junit.Before;
import org.junit.Test;
import org.lee.hackpad.jackpad.content.Pad;

public class JackpadClientTest
{
	private static final String API_KEYS_FILE = "api_keys.txt";
	
	private String HACKPAD_CLIENT_ID;
	private String HACKPAD_SECRET;
	private JackpadClient jackpadClient;
	private Pad pad;
	
	@Before
	public void setUp()
	{
		setApiKey();
		jackpadClient = new JackpadClient(HACKPAD_CLIENT_ID, HACKPAD_SECRET);
		jackpadClient.build();
		pad = new Pad("text/plain", "ddd");
		pad.setTitle("hi");
	}
	
	public void setApiKey()
	{
		try
		{
			FileReader fr = new FileReader(API_KEYS_FILE);
			BufferedReader br = new BufferedReader(fr);
			String line;
			line = br.readLine();
			String[] para= line.split(" ");
			HACKPAD_CLIENT_ID = para[0];
			HACKPAD_SECRET = para[1];
			br.close();
			fr.close();
		}
		catch(IOException e)
		{
			System.out.println(e.toString());
		}
	}
	
	/*@Test
	public void TestCreatePad()
	{
		String test = jackpadClient.createPad(pad);
		System.out.println(test);
		assertEquals(false ,test.isEmpty());
	}*/
	
	@Test
	public void TestGetPadContent()
	{
		String padText = jackpadClient.getPadContent("ClziL81VPO9", "latest", "html");
		System.out.println(padText);
		assertEquals(false, padText.isEmpty());
	}
	
	@Test
	public void TestUpdatePadContent()
	{
		pad.setPadID("ClziL81VPO9");
		boolean test = jackpadClient.updatePadContent(pad);
		assertEquals(true, test);
	}
	
}

@@ -1006,16 +1006,67 @@
  e)%0A%09%09%7B%0A
+%09%09%09HACKPAD_CLIENT_ID = %22%22;%0A%09%09%09HACKPAD_SECRET = %22%22;%0A
 %09%09%09Syste
@@ -1261,24 +1261,26 @@
 ));%0A%09%7D*/%0A%09%0A%09
+/*
 @Test%0A%09publi
@@ -1629,13 +1629,15 @@
 est);%0A%09%7D
+*/
 %0A%09%0A%7D%0A

fix Test