PageRenderTime 22ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/eclipse-plugin/com.google.test.metric.eclipse.test/src/main/java/com/google/test/metric/eclipse/internal/core/TestabilityLauncherTest.java

http://testability-explorer.googlecode.com/
Java | 88 lines | 57 code | 12 blank | 19 comment | 0 complexity | bcb84449fef980e51758c55fdd7d9bfa MD5 | raw file
Possible License(s): Apache-2.0
  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.eclipse.internal.core;
  17. import static org.easymock.EasyMock.expect;
  18. import junit.framework.TestCase;
  19. import org.easymock.EasyMock;
  20. import org.easymock.IMocksControl;
  21. import org.eclipse.core.runtime.Path;
  22. import org.eclipse.jdt.core.IClasspathEntry;
  23. import org.eclipse.jdt.core.IJavaProject;
  24. /**
  25. * @author klundberg@google.com (Karin Lundberg)
  26. *
  27. */
  28. public class TestabilityLauncherTest extends TestCase {
  29. private TestabilityLauncher launcher;
  30. private IJavaProject javaProject;
  31. private IMocksControl control;
  32. @Override
  33. protected void setUp() throws Exception {
  34. launcher = new TestabilityLauncher();
  35. control = EasyMock.createControl();
  36. javaProject = control.createMock(IJavaProject.class);
  37. }
  38. public void testGetClassPathsReturnsDefaultOutputPath() throws Exception {
  39. expect(javaProject.getRawClasspath()).andReturn(new IClasspathEntry[0]);
  40. expect(javaProject.getOutputLocation()).andReturn(new Path("/expected"));
  41. control.replay();
  42. String[] results = launcher.getClassPaths(javaProject, "whatever");
  43. assertEquals(1, results.length);
  44. assertEquals("whatever/expected", results[0]);
  45. control.verify();
  46. }
  47. public void testGetClassPathsReturnsAbsoluePathWhenOutputPathNull() throws Exception {
  48. IClasspathEntry[] entries = new IClasspathEntry[1];
  49. entries[0] = control.createMock(IClasspathEntry.class);
  50. expect(entries[0].getOutputLocation()).andReturn(null);
  51. expect(entries[0].getPath()).andReturn(new Path("/expectedpath"));
  52. expect(javaProject.getRawClasspath()).andReturn(entries);
  53. expect(javaProject.getOutputLocation()).andReturn(new Path("/expected2"));
  54. control.replay();
  55. String projectLocation = "location";
  56. String[] results = launcher.getClassPaths(javaProject, projectLocation);
  57. assertEquals(2, results.length);
  58. assertEquals(projectLocation + "/expectedpath", results[0]);
  59. assertEquals(projectLocation + "/expected2", results[1]);
  60. control.verify();
  61. }
  62. public void testGetClassPathsReturnsAbsoluePathWhenOutputPathNotNull() throws Exception {
  63. IClasspathEntry[] entries = new IClasspathEntry[1];
  64. entries[0] = control.createMock(IClasspathEntry.class);
  65. expect(entries[0].getOutputLocation()).andReturn(new Path("/expected"));
  66. expect(javaProject.getRawClasspath()).andReturn(entries);
  67. expect(javaProject.getOutputLocation()).andReturn(new Path("/expected2"));
  68. control.replay();
  69. String projectLocation = "location";
  70. String[] results = launcher.getClassPaths(javaProject, projectLocation);
  71. assertEquals(2, results.length);
  72. assertEquals(projectLocation + "/expected", results[0]);
  73. assertEquals(projectLocation + "/expected2", results[1]);
  74. control.verify();
  75. }
  76. }