mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
merge idea90 branch into trunk
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.module;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.module.*;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ModulePointerTest extends PlatformTestCase {
|
||||
public void testCreateByName() throws Exception {
|
||||
final ModulePointer pointer = getPointerManager().create("m");
|
||||
assertNull(pointer.getModule());
|
||||
assertEquals("m", pointer.getModuleName());
|
||||
|
||||
final Module module = addModule("m");
|
||||
|
||||
assertSame(module, pointer.getModule());
|
||||
assertEquals("m", pointer.getModuleName());
|
||||
}
|
||||
|
||||
public void testCreateByModule() throws Exception {
|
||||
final Module module = addModule("x");
|
||||
final ModulePointer pointer = getPointerManager().create(module);
|
||||
assertSame(module, pointer.getModule());
|
||||
assertEquals("x", pointer.getModuleName());
|
||||
|
||||
ModifiableModuleModel model = getModuleManager().getModifiableModel();
|
||||
model.disposeModule(module);
|
||||
commitModel(model);
|
||||
|
||||
assertNull(pointer.getModule());
|
||||
assertEquals("x", pointer.getModuleName());
|
||||
}
|
||||
|
||||
public void testRenameModule() throws Exception {
|
||||
final ModulePointer pointer = getPointerManager().create("abc");
|
||||
final Module module = addModule("abc");
|
||||
ModifiableModuleModel model = getModuleManager().getModifiableModel();
|
||||
model.renameModule(module, "xyz");
|
||||
commitModel(model);
|
||||
assertSame(module, pointer.getModule());
|
||||
assertEquals("xyz", pointer.getModuleName());
|
||||
}
|
||||
|
||||
public void testDisposePointerFromUncommitedModifiableModel() throws Exception {
|
||||
final ModifiableModuleModel modifiableModel = getModuleManager().getModifiableModel();
|
||||
final Module module = modifiableModel.newModule(myProject.getBaseDir().getPath() + "/xxx.iml", EmptyModuleType.getInstance());
|
||||
final ModulePointer pointer = getPointerManager().create(module);
|
||||
|
||||
assertSame(module, pointer.getModule());
|
||||
assertEquals("xxx", pointer.getModuleName());
|
||||
|
||||
modifiableModel.dispose();
|
||||
|
||||
assertNull(pointer.getModule());
|
||||
assertEquals("xxx", pointer.getModuleName());
|
||||
}
|
||||
|
||||
private ModuleManager getModuleManager() {
|
||||
return ModuleManager.getInstance(myProject);
|
||||
}
|
||||
|
||||
private Module addModule(final String name) {
|
||||
final ModifiableModuleModel model = getModuleManager().getModifiableModel();
|
||||
final Module module = model.newModule(myProject.getBaseDir().getPath() + "/" + name + ".iml", EmptyModuleType.getInstance());
|
||||
commitModel(model);
|
||||
disposeOnTearDown(new Disposable() {
|
||||
public void dispose() {
|
||||
if (!module.isDisposed()) {
|
||||
getModuleManager().disposeModule(module);
|
||||
}
|
||||
}
|
||||
});
|
||||
return module;
|
||||
}
|
||||
|
||||
private static void commitModel(final ModifiableModuleModel model) {
|
||||
new WriteAction() {
|
||||
protected void run(final Result result) {
|
||||
model.commit();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private ModulePointerManager getPointerManager() {
|
||||
return ModulePointerManager.getInstance(myProject);
|
||||
}
|
||||
}
|
||||
@@ -420,6 +420,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRecursiveCallToExtracted() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doPrepareErrorTest(final String expectedMessage) throws Exception {
|
||||
String expectedError = null;
|
||||
try {
|
||||
|
||||
@@ -166,7 +166,7 @@ public class IntroduceParameterTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
|
||||
public void testParameterJavaDocBeforeVararg() throws Exception {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true, false);
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, true, false, "Incomplete call(method()): 1 parameters expected but only 0 found");
|
||||
}
|
||||
|
||||
public void testIncorrectScope() throws Exception {
|
||||
@@ -230,7 +230,8 @@ public class IntroduceParameterTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
|
||||
public void testIncompleteEnumDefinition() throws Exception {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false);
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false, "Incomplete call(Root()): 2 parameters expected but only 0 found\n" +
|
||||
"Incomplete call(Root()): expected to delete the 1 parameter but only 0 parameters found");
|
||||
}
|
||||
|
||||
private void doTestThroughHandler() throws Exception {
|
||||
|
||||
@@ -143,6 +143,10 @@ public class InlineMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStaticMethodWithoutParams() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk15("java 1.5");
|
||||
|
||||
Reference in New Issue
Block a user