PageRenderTime 18ms CodeModel.GetById 2ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/testability-explorer/src/test/java/com/google/test/metric/javasrc/QualifierTest.java

http://testability-explorer.googlecode.com/
Java | 62 lines | 35 code | 12 blank | 15 comment | 0 complexity | 35836a75d49f4b71a6110cf91835e726 MD5 | raw file
 1/*
 2 * Copyright 2009 Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 5 * use this file except in compliance with the License. You may obtain a copy of
 6 * the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16 package com.google.test.metric.javasrc;
17
18import junit.framework.TestCase;
19
20public class QualifierTest extends TestCase {
21
22  private Qualifier qualifier = new Qualifier();
23
24  @Override
25  protected void setUp() throws Exception {
26    super.setUp();
27    qualifier.setPackage("pkg");
28    qualifier.addImport("a.B");
29  }
30
31  public void testFullyQualified() throws Exception {
32    assertEquals("a.A", qualifier.qualify("", "a.A"));
33  }
34
35  public void testImortQualified() throws Exception {
36    assertEquals("a.B", qualifier.qualify("", "B"));
37  }
38
39  public void testPackageQualified() throws Exception {
40    assertEquals("pkg.C", qualifier.qualify("", "C"));
41  }
42
43  public void testJavaQualified() throws Exception {
44    assertEquals(String.class.getCanonicalName(), qualifier.qualify("", "String"));
45  }
46
47  public void testInnerClassResolution() throws Exception {
48    qualifier.addAlias("A$My$String", "com.A$My$String");
49    assertEquals("com.A$My$String", qualifier.qualify("com.A", "My.String"));
50  }
51
52  public void testInnerClassResolution2() throws Exception {
53    qualifier.addAlias("My$String", "com.My$String");
54    assertEquals("com.My$String", qualifier.qualify("com.A", "My.String"));
55  }
56
57  public void testInnerClassResolution3() throws Exception {
58    qualifier.addAlias("My$String", "com.My$String");
59    assertEquals("com.My$String", qualifier.qualify("com.A", "com.My.String"));
60  }
61
62}