update copyright
[fedora-idea.git] / plugins / testng / testSources / com / theoryinpractice / testng / intention / AddTestNGJarFixTest.java
blobc990b7d04b30f83505c1fe3ca0591a09a2047dfd
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * User: anna
19 * Date: 04-Mar-2008
21 package com.theoryinpractice.testng.intention;
23 import com.intellij.codeInsight.intention.IntentionAction;
24 import com.intellij.openapi.application.PluginPathManager;
25 import com.intellij.openapi.roots.LanguageLevelProjectExtension;
26 import com.intellij.openapi.util.Comparing;
27 import com.intellij.pom.java.LanguageLevel;
28 import com.intellij.psi.JavaPsiFacade;
29 import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
30 import com.intellij.testFramework.fixtures.*;
31 import org.jetbrains.annotations.NonNls;
32 import org.testng.Assert;
33 import org.testng.annotations.AfterMethod;
34 import org.testng.annotations.BeforeMethod;
35 import org.testng.annotations.DataProvider;
36 import org.testng.annotations.Test;
38 import java.util.List;
40 @Test
41 public class AddTestNGJarFixTest {
42 protected CodeInsightTestFixture myFixture;
44 private LanguageLevel myLanguageLevel;
46 @BeforeMethod
47 public void setUp() throws Exception {
48 final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
49 final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder = fixtureFactory.createFixtureBuilder();
50 myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(testFixtureBuilder.getFixture());
51 final String dataPath = PluginPathManager.getPluginHomePath("testng") + "/testData";
52 myFixture.setTestDataPath(dataPath);
53 final JavaModuleFixtureBuilder builder = testFixtureBuilder.addModule(JavaModuleFixtureBuilder.class);
55 builder.addContentRoot(myFixture.getTempDirPath()).addSourceRoot("");
56 // builder.addContentRoot(dataPath);
57 builder.setMockJdkLevel(JavaModuleFixtureBuilder.MockJdkLevel.jdk15);
58 myFixture.setUp();
59 final JavaPsiFacade facade = JavaPsiFacade.getInstance(myFixture.getProject());
60 myLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
61 LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
65 @AfterMethod
66 public void tearDown() throws Exception {
67 LanguageLevelProjectExtension.getInstance(myFixture.getProject()).setLanguageLevel(myLanguageLevel);
68 myFixture.tearDown();
69 myFixture = null;
72 @NonNls
73 @DataProvider
74 public Object[][] data() {
75 return new String[][]{new String[]{"InsideReference"}, new String[]{"AfterReference"}};
78 @Test(dataProvider = "data")
79 public void doTest(String testName) throws Throwable {
80 IntentionAction resultAction = null;
81 final List<IntentionAction> actions = myFixture.getAvailableIntentions("intention/testNGJar" + "/" + testName + ".java");
82 for (IntentionAction action : actions) {
83 if (Comparing.strEqual(action.getText(), "Add testng.jar to classpath")) {
84 resultAction = action;
85 break;
88 Assert.assertNotNull(resultAction);