A former student on trial for rape in a case that has cast a harsh light on the culture of an elite New Hampshire prep school testified on Wednesday that he had a consensual sexual encounter with his 15-year-old accuser that stopped short of intercourse.