ALEXANDRIA, Va. — A New York Times reporter is providing little assistance to prosecutors as they put a former CIA officer on trial for allegedly leaking classified information about a botched operation in Iran.

Journalist James Risen testified Monday at an unusual pretrial hearing in U.S. District Court in Alexandria, where ex-CIA officer Jeffrey Sterling goes on trial next week on charges he illegally leaked national security information to Risen that the journalist used in his 2006 book, "State of War."

For years, Risen has been resisting efforts to compel his testimony, citing an obligation to protect the confidentiality of his sources. Ultimately, a federal appeals court ruled that Risen must testify.

Monday's hearing was designed to determine what exactly would be asked of Risen if he's called as a prosecution witness. The Justice Department, under pressure from free-press advocates, had previously said it would not press Risen on whether Sterling was his confidential source, and would limit its questions.

At the hearing, Risen acknowledged he had written certain newspaper articles and "State of War," and that he had used unnamed sources.

Asked whether he had confidentiality agreements with unnamed sources, he initially refused to answer. Eventually, after Risen consulted with his lawyers, he confirmed that he promised confidentiality to certain sources. He also reiterated to prosecutors that he would not under any circumstances testify about the identity of his sources or information they gave.

Risen was somewhat more cooperative when defense lawyers cross-examined him. He acknowledged under cross-examination that, in previous affidavits, he said he made a conscious decision to publish the material in "State of War" because he felt the public had the right to know about a botched intelligence operation.

That admission is important to defense attorneys because they argue that, under the law and the government's theory of the case, Risen is just as guilty of exposing government secrets as Sterling. Defense lawyers are still seeking to have the case dismissed on the basis of selective prosecution.

After Risen completed his testimony, defense lawyer Edward MacMahon said the case against Sterling, of O'Fallon, Missouri, should be dismissed because Risen's unwillingness to testify in any detail leaves the government unable to prove key elements of the allegations.

It is not entirely clear how Risen's stance affects the government's case. The government possesses email and phone records that show extensive contact between Sterling and Risen. U.S. District Judge Leonie Brinkema has previously suggested the government could rely on those records to establish what it needs without compelling Risen's testimony.

Brinkema said it will now be up to prosecutors whether they call Risen as a witness next week before a jury.