KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > runner > TestIdMap


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  * David Saff (saff@mit.edu) - initial API and implementation
11  * (bug 102632: [JUnit] Support for JUnit 4.)
12  *******************************************************************************/

13
14 package org.eclipse.jdt.internal.junit.runner;
15
16 import java.util.HashMap JavaDoc;
17
18 public class TestIdMap {
19     private HashMap JavaDoc fIdMap= new HashMap JavaDoc();
20
21     private int fNextId= 1;
22
23     public String JavaDoc getTestId(ITestIdentifier identifier) {
24         Object JavaDoc id= fIdMap.get(identifier);
25         if (id != null)
26             return (String JavaDoc) id;
27         String JavaDoc newId= Integer.toString(fNextId++);
28         fIdMap.put(identifier, newId);
29         return newId;
30     }
31
32     public String JavaDoc getTestId(ITestReference ref) {
33         return getTestId(ref.getIdentifier());
34     }
35 }
36
Popular Tags