Files
openide/java/java-tests/testSrc/com/intellij/roots/ProjectRootManagerImplTest.java
Eugene Petrenko 327d4890c6 IDEA-232634
GitOrigin-RevId: 15563dedeef7437e060c04ee98111d04d25648ff
2020-03-20 00:40:48 +00:00

35 lines
1.4 KiB
Java

// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.roots;
import com.intellij.idea.TestFor;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.impl.LaterInvocator;
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
import com.intellij.openapi.roots.impl.ProjectRootManagerImpl;
import com.intellij.testFramework.HeavyPlatformTestCase;
import org.jdom.Element;
import java.util.concurrent.atomic.AtomicInteger;
import static com.intellij.testFramework.assertions.Assertions.assertThat;
public class ProjectRootManagerImplTest extends HeavyPlatformTestCase {
@TestFor(issues = "IDEA-232634")
public void testLoadStateFiresJdkChange() {
AtomicInteger count = new AtomicInteger(0);
ProjectRootManagerEx.getInstanceEx(myProject).addProjectJdkListener(() -> {
ApplicationManager.getApplication().assertWriteAccessAllowed();
count.incrementAndGet();
});
ProjectRootManagerImpl impl = ProjectRootManagerImpl.getInstanceImpl(myProject);
Element oldState = impl.getState();
impl.loadState(new Element("empty"));
LaterInvocator.dispatchPendingFlushes();
impl.loadState(oldState);
LaterInvocator.dispatchPendingFlushes();
assertThat(count).hasValueGreaterThanOrEqualTo(2);
}
}