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

http://testability-explorer.googlecode.com/ · Java · 52 lines · 29 code · 8 blank · 15 comment · 0 complexity · 1eaa0f3e4be05a36ff4fe8a65a9183e5 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. import java.util.ArrayList;
  18. import junit.framework.TestCase;
  19. import com.google.test.metric.ClassRepository;
  20. import com.google.test.metric.JavaClassRepository;
  21. import com.google.test.metric.Type;
  22. public class JavaClassInfoBuilderTest extends TestCase {
  23. ClassRepository parent = new JavaClassRepository();
  24. JavaSrcRepository repository = new JavaSrcRepository(parent, null);
  25. Qualifier qualifier = new Qualifier();
  26. CompilationUnitBuilder builder = new CompilationUnitBuilder(repository, qualifier, "");
  27. public void testClassNameIsConcatinationOfPackageAndType() throws Exception {
  28. qualifier.setPackage("pkg");
  29. builder.startType(0, "A", null, new ArrayList<Type>());
  30. builder.endType();
  31. assertNull(builder.type);
  32. assertEquals("pkg.A", repository.getClass("pkg.A").getName());
  33. }
  34. public void testInnerClass() throws Exception {
  35. qualifier.setPackage("pkg");
  36. qualifier.addAlias("B", "pkg.A$B");
  37. builder.startType(0, "A", null, new ArrayList<Type>());
  38. builder.startType(0, "B", null, new ArrayList<Type>());
  39. builder.endType();
  40. builder.endType();
  41. assertNull(builder.type);
  42. assertEquals("pkg.A$B", repository.getClass("pkg.A$B").getName());
  43. }
  44. }