diff options
Diffstat (limited to 'xml/dom-tests/tests')
7 files changed, 123 insertions, 57 deletions
diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomFileDescriptionTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomFileDescriptionTest.java index 7d76e0e2c9c2..0025c58ff063 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomFileDescriptionTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomFileDescriptionTest.java @@ -1,8 +1,17 @@ /* - * Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved. - */ -/* - * Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved. + * Copyright 2000-2014 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.util.xml; @@ -33,7 +42,7 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { myFooElementFile = new WriteCommandAction<XmlFile>(getProject()) { @Override - protected void run(Result<XmlFile> result) throws Throwable { + protected void run(@NotNull Result<XmlFile> result) throws Throwable { result.setResult((XmlFile)createFile("a.xml", "<a/>")); } }.execute().getResultObject(); @@ -42,7 +51,7 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { myBarElementFile = new WriteCommandAction<XmlFile>(getProject()) { @Override - protected void run(Result<XmlFile> result) throws Throwable { + protected void run(@NotNull Result<XmlFile> result) throws Throwable { result.setResult((XmlFile)createFile("b.xml", "<b/>")); } }.execute().getResultObject(); @@ -63,6 +72,14 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { assertResultsAndClear(); } + @Override + public void tearDown() throws Exception { + myFooElementFile = null; + myBarElementFile = null; + + super.tearDown(); + } + public void testNoInitialDomnessInB() throws Throwable { assertFalse(getDomManager().isDomFile(myBarElementFile)); assertNull(getDomManager().getFileElement(myBarElementFile)); @@ -70,7 +87,7 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { public void testIsDomValue() throws Throwable { final XmlFile file = (XmlFile)createFile("a.xml", "<b>42</b>"); - getDomManager().registerFileDescription(new DomFileDescription(MyElement.class, "b") { + getDomManager().registerFileDescription(new DomFileDescription<MyElement>(MyElement.class, "b") { @Override public boolean isMyFile(@NotNull final XmlFile file, final Module module) { @@ -84,7 +101,7 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { new WriteCommandAction(getProject()) { @Override - protected void run(Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { file.getDocument().getRootTag().getValue().setText("239"); } }.execute(); @@ -97,7 +114,7 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { new WriteCommandAction(getProject()) { @Override - protected void run(Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { file.getDocument().getRootTag().getValue().setText("57121"); } }.execute(); @@ -110,7 +127,7 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { public void testCopyFileDescriptionFromOriginalFile() throws Throwable { final XmlFile file = (XmlFile)createFile("a.xml", "<b>42</b>"); - getDomManager().registerFileDescription(new MockDomFileDescription(MyElement.class, "b", file), getTestRootDisposable()); + getDomManager().registerFileDescription(new MockDomFileDescription<MyElement>(MyElement.class, "b", file), getTestRootDisposable()); file.setName("b.xml"); assertTrue(getDomManager().isDomFile(file)); final XmlFile copy = (XmlFile)file.copy(); @@ -121,9 +138,9 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { public void testDependantFileDescriptionCauseStackOverflow() throws Throwable { final XmlFile interestingFile = (XmlFile)createFile("a.xml", "<b>42</b>"); - getDomManager().registerFileDescription(new MockDomFileDescription(MyElement.class, "b", (XmlFile)null), getTestRootDisposable()); + getDomManager().registerFileDescription(new MockDomFileDescription<MyElement>(MyElement.class, "b", (XmlFile)null), getTestRootDisposable()); for (int i = 0; i < 239; i++) { - getDomManager().registerFileDescription(new MockDomFileDescription(AbstractElement.class, "b", (XmlFile)null) { + getDomManager().registerFileDescription(new MockDomFileDescription<AbstractElement>(AbstractElement.class, "b", (XmlFile)null) { @Override @NotNull public Set getDependencyItems(final XmlFile file) { @@ -137,7 +154,7 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { } public void testCheckNamespace() throws Throwable { - getDomManager().registerFileDescription(new DomFileDescription(NamespacedElement.class, "xxx", "bar"){ + getDomManager().registerFileDescription(new DomFileDescription<NamespacedElement>(NamespacedElement.class, "xxx", "bar"){ @Override protected void initializeFileDescription() { @@ -150,17 +167,16 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { new WriteCommandAction(getProject()) { @Override - protected void run(Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { ((XmlFile)file).getDocument().getRootTag().setAttribute("xmlns", "bar"); } }.execute(); assertTrue(getDomManager().isDomFile(file)); - } public void testCheckDtdPublicId() throws Throwable { - getDomManager().registerFileDescription(new DomFileDescription(NamespacedElement.class, "xxx", "bar"){ + getDomManager().registerFileDescription(new DomFileDescription<NamespacedElement>(NamespacedElement.class, "xxx", "bar"){ @Override protected void initializeFileDescription() { @@ -173,7 +189,7 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { new WriteCommandAction(getProject()) { @Override - protected void run(Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { final Document document = getDocument(file); document.insertString(0, "<!DOCTYPE xxx PUBLIC \"bar\" \"http://java.sun.com/dtd/ejb-jar_2_0.dtd\">\n"); commitDocument(document); @@ -184,7 +200,7 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { } public void testChangeCustomDomness() throws Throwable { - getDomManager().registerFileDescription(new DomFileDescription(MyElement.class, "xxx"){ + getDomManager().registerFileDescription(new DomFileDescription<MyElement>(MyElement.class, "xxx"){ @Override public boolean isMyFile(@NotNull final XmlFile file, @Nullable final Module module) { return file.getText().contains("foo"); @@ -194,7 +210,7 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { final MyElement boy = getDomManager().getFileElement(file, MyElement.class).getRootElement().getBoys().get(0); new WriteCommandAction(getProject()) { @Override - protected void run(Result result) throws Throwable { + protected void run(@NotNull Result result) throws Throwable { file.getDocument().getRootTag().setAttribute("zzz", "bar"); } }.execute(); @@ -228,5 +244,4 @@ public class DomFileDescriptionTest extends DomHardCoreTestCase { } - } diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java index e96d2e40a325..1106a7ae2b4d 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -76,9 +76,10 @@ public class DomHighlightingLiteTest extends DomTestCase { @Override public XmlTag getXmlTag() { - return file.getDocument().getRootTag(); + return file.getRootTag(); } + @NotNull @Override public Type getDomElementType() { return DomElement.class; @@ -109,6 +110,7 @@ public class DomHighlightingLiteTest extends DomTestCase { return rootElement; } + @NotNull @Override public Class getRootElementClass() { return DomElement.class; @@ -121,6 +123,15 @@ public class DomHighlightingLiteTest extends DomTestCase { }; } + @Override + public void tearDown() throws Exception { + myAnnotationsManager = null; + myElement = null; + myInspectionProfile = null; + + super.tearDown(); + } + public void testEmptyProblemDescriptorInTheBeginning() throws Throwable { assertEmptyHolder(myAnnotationsManager.getProblemHolder(myElement)); } @@ -171,7 +182,7 @@ public class DomHighlightingLiteTest extends DomTestCase { } public void testMockAnnotatingDomInspection() throws Throwable { - myElement.setFileDescription(new DomFileDescription(DomElement.class, "a")); + myElement.setFileDescription(new DomFileDescription<DomElement>(DomElement.class, "a")); assertInstanceOf(myAnnotationsManager.getMockInspection(myElement), MockAnnotatingDomInspection.class); } @@ -216,14 +227,14 @@ public class DomHighlightingLiteTest extends DomTestCase { assertEquals(DomHighlightStatus.INSPECTIONS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement)); } public void testHighlightStatus_MockAnnotatingDomInspection() throws Throwable { - myElement.setFileDescription(new DomFileDescription(DomElement.class, "a")); + myElement.setFileDescription(new DomFileDescription<DomElement>(DomElement.class, "a")); myAnnotationsManager.appendProblems(myElement, createHolder(), MockAnnotatingDomInspection.class); assertEquals(DomHighlightStatus.INSPECTIONS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement)); } public void testHighlightStatus_OtherInspections() throws Throwable { - myElement.setFileDescription(new DomFileDescription(DomElement.class, "a")); + myElement.setFileDescription(new DomFileDescription<DomElement>(DomElement.class, "a")); final MyDomElementsInspection inspection = new MyDomElementsInspection() { @Override @@ -248,7 +259,7 @@ public class DomHighlightingLiteTest extends DomTestCase { } public void testHighlightStatus_OtherInspections2() throws Throwable { - myElement.setFileDescription(new DomFileDescription(DomElement.class, "a")); + myElement.setFileDescription(new DomFileDescription<DomElement>(DomElement.class, "a")); final MyDomElementsInspection inspection = new MyDomElementsInspection() { @Override @@ -276,7 +287,7 @@ public class DomHighlightingLiteTest extends DomTestCase { new MyBasicDomElementsInspection().checkDomElement(element.getId(), createHolder(), DomHighlightingHelperImpl.INSTANCE); } - private class MyDomElementsInspection extends DomElementsInspection { + private static class MyDomElementsInspection extends DomElementsInspection<DomElement> { public MyDomElementsInspection() { super(DomElement.class); } @@ -300,7 +311,7 @@ public class DomHighlightingLiteTest extends DomTestCase { } } - private class MyBasicDomElementsInspection extends BasicDomElementsInspection { + private static class MyBasicDomElementsInspection extends BasicDomElementsInspection<DomElement> { public MyBasicDomElementsInspection() { super(DomElement.class); } @@ -330,7 +341,7 @@ public class DomHighlightingLiteTest extends DomTestCase { } - private static class MyNonHighlightingDomFileDescription extends DomFileDescription { + private static class MyNonHighlightingDomFileDescription extends DomFileDescription<DomElement> { public MyNonHighlightingDomFileDescription() { super(DomElement.class, "a"); } diff --git a/xml/dom-tests/tests/com/intellij/util/xml/MockDomElement.java b/xml/dom-tests/tests/com/intellij/util/xml/MockDomElement.java index d861ead47908..0172b6e00113 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/MockDomElement.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/MockDomElement.java @@ -1,5 +1,17 @@ /* - * Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved. + * Copyright 2000-2014 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.util.xml; @@ -8,8 +20,8 @@ import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.xml.XmlElement; import com.intellij.psi.xml.XmlTag; -import com.intellij.util.xml.reflect.DomGenericInfo; import com.intellij.util.xml.reflect.AbstractDomChildrenDescription; +import com.intellij.util.xml.reflect.DomGenericInfo; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -20,7 +32,7 @@ import java.lang.reflect.Type; /** * @author peter */ -public class MockDomElement extends UserDataHolderBase implements DomElement{ +public class MockDomElement extends UserDataHolderBase implements DomElement { @Override @Nullable public XmlTag getXmlTag() { @@ -112,6 +124,7 @@ public class MockDomElement extends UserDataHolderBase implements DomElement{ throw new UnsupportedOperationException("Method getManager is not yet implemented in " + getClass().getName()); } + @NotNull @Override public Type getDomElementType() { throw new UnsupportedOperationException("Method getDomElementType is not yet implemented in " + getClass().getName()); @@ -123,6 +136,7 @@ public class MockDomElement extends UserDataHolderBase implements DomElement{ throw new UnsupportedOperationException("Method getChildDescription is not yet implemented in " + getClass().getName()); } + @NotNull @Override public DomNameStrategy getNameStrategy() { throw new UnsupportedOperationException("Method getNameStrategy is not yet implemented in " + getClass().getName()); diff --git a/xml/dom-tests/tests/com/intellij/util/xml/MockDomFileElement.java b/xml/dom-tests/tests/com/intellij/util/xml/MockDomFileElement.java index b2bbb5f30577..ec16169e73ab 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/MockDomFileElement.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/MockDomFileElement.java @@ -1,5 +1,17 @@ /* - * Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved. + * Copyright 2000-2014 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.util.xml; @@ -9,8 +21,8 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.xml.XmlElement; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; -import com.intellij.util.xml.reflect.DomGenericInfo; import com.intellij.util.xml.reflect.AbstractDomChildrenDescription; +import com.intellij.util.xml.reflect.DomGenericInfo; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -21,11 +33,11 @@ import java.lang.reflect.Type; /** * @author peter */ -public class MockDomFileElement extends UserDataHolderBase implements DomFileElement<DomElement>{ +public class MockDomFileElement extends UserDataHolderBase implements DomFileElement<DomElement> { private long myModCount = 0; - private DomFileDescription myFileDescription; + private DomFileDescription<DomElement> myFileDescription; - public void setFileDescription(final DomFileDescription fileDescription) { + public void setFileDescription(final DomFileDescription<DomElement> fileDescription) { myFileDescription = fileDescription; } @@ -52,14 +64,15 @@ public class MockDomFileElement extends UserDataHolderBase implements DomFileEle throw new UnsupportedOperationException("Method getRootElement is not yet implemented in " + getClass().getName()); } + @NotNull @Override - public Class getRootElementClass() { + public Class<DomElement> getRootElementClass() { throw new UnsupportedOperationException("Method getRootElementType is not yet implemented in " + getClass().getName()); } @Override @NotNull - public DomFileDescription getFileDescription() { + public DomFileDescription<DomElement> getFileDescription() { return myFileDescription; } @@ -153,6 +166,7 @@ public class MockDomFileElement extends UserDataHolderBase implements DomFileEle throw new UnsupportedOperationException("Method getManager is not yet implemented in " + getClass().getName()); } + @NotNull @Override public Type getDomElementType() { throw new UnsupportedOperationException("Method getDomElementType is not yet implemented in " + getClass().getName()); @@ -164,6 +178,7 @@ public class MockDomFileElement extends UserDataHolderBase implements DomFileEle throw new UnsupportedOperationException("Method getChildDescription is not yet implemented in " + getClass().getName()); } + @NotNull @Override public DomNameStrategy getNameStrategy() { throw new UnsupportedOperationException("Method getNameStrategy is not yet implemented in " + getClass().getName()); diff --git a/xml/dom-tests/tests/com/intellij/util/xml/MockGenericAttributeValue.java b/xml/dom-tests/tests/com/intellij/util/xml/MockGenericAttributeValue.java index 15b7a0468d30..22f18218ad85 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/MockGenericAttributeValue.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/MockGenericAttributeValue.java @@ -1,5 +1,17 @@ /* - * Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved. + * Copyright 2000-2014 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.util.xml; @@ -23,7 +35,7 @@ public class MockGenericAttributeValue extends MockDomElement implements Generic @Override @NotNull - public Converter getConverter() { + public Converter<Object> getConverter() { throw new UnsupportedOperationException("Method getConverter is not yet implemented in " + getClass().getName()); } diff --git a/xml/dom-tests/tests/com/intellij/util/xml/ProxyTest.java b/xml/dom-tests/tests/com/intellij/util/xml/ProxyTest.java index 3db1009c15de..c44d9e74eb45 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/ProxyTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/ProxyTest.java @@ -107,6 +107,8 @@ public class ProxyTest extends TestCase { public abstract String getBar(); + @Override + public abstract String foo(); } public void testAddInterfaces() throws Throwable { diff --git a/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java b/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java index 5568b312844c..66a3adaa2ee5 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java @@ -17,7 +17,6 @@ package com.intellij.util.xml.impl; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.psi.xml.XmlTag; -import com.intellij.util.IncorrectOperationException; import com.intellij.util.xml.DomElement; import com.intellij.util.xml.SubTag; import com.intellij.util.xml.events.DomEvent; @@ -36,7 +35,7 @@ public class IncrementalUpdateEventsTest extends DomTestCase { myElement = createElement("<a><child/><child/><child-element/><child-element/></a>"); } - public void testRemove0() throws IncorrectOperationException { + public void testRemove0() { deleteTag(0); putExpected(new DomEvent(myElement, false)); assertResultsAndClear(); @@ -54,13 +53,13 @@ public class IncrementalUpdateEventsTest extends DomTestCase { assertResultsAndClear(); } - public void testRemove1() throws IncorrectOperationException { + public void testRemove1() { deleteTag(1); putExpected(new DomEvent(myElement, false)); assertResultsAndClear(); } - public void testRemove2() throws IncorrectOperationException { + public void testRemove2() { deleteTag(2); putExpected(new DomEvent(myElement, false)); assertResultsAndClear(); @@ -70,37 +69,37 @@ public class IncrementalUpdateEventsTest extends DomTestCase { assertResultsAndClear(); } - public void testRemove3() throws IncorrectOperationException { + public void testRemove3() { deleteTag(3); putExpected(new DomEvent(myElement, false)); assertResultsAndClear(); } - public void testAdd0() throws Throwable { + public void testAdd0() { addChildTag(0); putExpected(new DomEvent(myElement, false)); assertResultsAndClear(); } - public void testAdd1() throws Throwable { + public void testAdd1() { addChildTag(1); putExpected(new DomEvent(myElement, false)); assertResultsAndClear(); } - public void testAdd2() throws Throwable { + public void testAdd2() { addChildElementTag(2); putExpected(new DomEvent(myElement, false)); assertResultsAndClear(); } - public void testAdd3() throws Throwable { + public void testAdd3() { addChildElementTag(3); putExpected(new DomEvent(myElement, false)); assertResultsAndClear(); } - public void testAdd4() throws Throwable { + public void testAdd4() { final XmlTag tag = myElement.getXmlTag(); tag.addAfter(createTag("<child-element/>"), tag.getSubTags()[3]); putExpected(new DomEvent(myElement, false)); @@ -111,18 +110,18 @@ public class IncrementalUpdateEventsTest extends DomTestCase { return myElement.getChildElements().get(index); } - private void addChildTag(int index) throws IncorrectOperationException { + private void addChildTag(int index) { final XmlTag tag = myElement.getXmlTag(); tag.addBefore(createTag("<child/>"), tag.getSubTags()[index]); } - private void addChildElementTag(int index) throws IncorrectOperationException { + private void addChildElementTag(int index) { final XmlTag tag = myElement.getXmlTag(); tag.addBefore(createTag("<child-element/>"), tag.getSubTags()[index]); } - private void deleteTag(final int index) throws IncorrectOperationException { + private void deleteTag(final int index) { WriteCommandAction.runWriteCommandAction(null, new Runnable() { @Override public void run() { @@ -131,7 +130,7 @@ public class IncrementalUpdateEventsTest extends DomTestCase { }); } - private MyElement createElement(final String xml) throws IncorrectOperationException { + private MyElement createElement(final String xml) { return createElement(xml, MyElement.class); } @@ -143,6 +142,4 @@ public class IncrementalUpdateEventsTest extends DomTestCase { List<MyElement> getChildElements(); } - - } |