o2c.setProperty("name",o2c.clientId);
OAuth2Accessor o2a = new OAuth2Accessor(o2c);
o2a.setProperty("authorized",true);
SampleOAuth2Provider.generateCode(o2a);
ServletTester tester=new ServletTester();
tester.setContextPath("/test");
tester.addServlet(AccessTokenServlet2.class, "/token");
tester.start();
String postParameter = "grant_type=authorization_code&code="+o2a.code+
"&state=xyz&redirect_uri=http%3A%2F%2Flocalhost%2FCookieJar%2FCallback";
HttpTester request = new HttpTester();
HttpTester response = new HttpTester();
request.setMethod("POST");
request.setHeader("Host","server.example.com");
request.setURI("/test/token");
request.setVersion("HTTP/1.1");
request.setHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
String userPass = new String(Base64.encodeBase64("myKey:mySecret".getBytes()), "UTF-8");
request.setHeader("Authorization", "Basic "+userPass);
request.setContent(postParameter);
response.parse(tester.getResponses(request.generate()));
assertEquals(200,response.getStatus());
assertEquals("{\"access_token\":\"" + o2a.accessToken +
"\",\"token_type\":\"" + o2a.tokenType +
"\",\"expires_in\":\"3600\",\"refresh_token\":\"" + o2a.refreshToken +