1818
1919import static org .junit .Assert .assertEquals ;
2020
21+ import com .google .cloud .tools .eclipse .test .util .project .TestProjectCreator ;
2122import java .io .ByteArrayInputStream ;
2223import org .eclipse .core .resources .IContainer ;
2324import org .eclipse .core .resources .IFile ;
3435import org .junit .Test ;
3536import org .xml .sax .SAXException ;
3637import org .xml .sax .SAXParseException ;
37- import com .google .cloud .tools .eclipse .test .util .project .TestProjectCreator ;
3838
3939public class AbstractXmlValidatorTest {
4040
4141 private final String ELEMENT_MESSAGE = "Project ID should be specified at deploy time." ;
4242 private static IResource resource ;
4343 private static IProject project ;
44-
44+
4545 @ ClassRule public static TestProjectCreator projectCreator = new TestProjectCreator ();
46-
46+
4747 @ BeforeClass
4848 public static void setUp () throws CoreException {
4949 project = projectCreator .getProject ();
@@ -52,39 +52,37 @@ public static void setUp() throws CoreException {
5252 webXml .create (new ByteArrayInputStream (new byte [0 ]), true , null );
5353 resource = webXml ;
5454 }
55-
55+
5656 @ After
5757 public void tearDown () throws CoreException {
5858 if (resource != null ) {
5959 resource .deleteMarkers (IMarker .PROBLEM , true , IResource .DEPTH_ZERO );
6060 }
6161 }
62-
62+
6363 @ Test
6464 public void testCreateMarker () throws CoreException {
6565 BannedElement element = new BannedElement (ELEMENT_MESSAGE );
66- String markerId = "org.eclipse.core.resources.problemmarker" ;
6766 AppEngineWebXmlValidator .createMarker (resource , element , 0 );
68- IMarker [] markers = resource .findMarkers (markerId , true , IResource .DEPTH_ZERO );
69- assertEquals (ELEMENT_MESSAGE , ( String ) markers [0 ].getAttribute (IMarker .MESSAGE ));
67+ IMarker [] markers = resource .findMarkers (IMarker . PROBLEM , true , IResource .DEPTH_ZERO );
68+ assertEquals (ELEMENT_MESSAGE , markers [0 ].getAttribute (IMarker .MESSAGE ));
7069 }
71-
70+
7271 @ Test
7372 public void testCreateSAXErrorMessage () throws CoreException {
7473 SAXParseException spe = new SAXParseException ("" , "" , "" , 1 , 1 );
7574 SAXException ex = new SAXException (ELEMENT_MESSAGE , spe );
7675 AppEngineWebXmlValidator .createSaxErrorMessage (resource , ex );
77- String problemMarker = "org.eclipse.core.resources.problemmarker" ;
78- IMarker [] markers = resource .findMarkers (problemMarker , true , IResource .DEPTH_ZERO );
79- assertEquals (ELEMENT_MESSAGE , (String ) markers [0 ].getAttribute (IMarker .MESSAGE ));
76+ IMarker [] markers = resource .findMarkers (IMarker .PROBLEM , true , IResource .DEPTH_ZERO );
77+ assertEquals (ELEMENT_MESSAGE , markers [0 ].getAttribute (IMarker .MESSAGE ));
8078 }
81-
79+
8280 private static void createFolders (IContainer parent , IPath path ) throws CoreException {
8381 if (!path .isEmpty ()) {
8482 IFolder folder = parent .getFolder (new Path (path .segment (0 )));
8583 folder .create (true , true , null );
8684 createFolders (folder , path .removeFirstSegments (1 ));
8785 }
8886 }
89-
87+
9088}
0 commit comments