View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.util.designer;
5   
6   import static org.junit.Assert.assertEquals;
7   import net.sourceforge.pmd.lang.LanguageVersion;
8   import net.sourceforge.pmd.lang.ast.Node;
9   
10  import org.junit.Test;
11  
12  /**
13   * Unit tests for {@link Designer}
14   */
15  public class DesignerTest {
16  
17      /**
18       * Unit test for https://sourceforge.net/p/pmd/bugs/1168/
19       */
20      @Test
21      public void testCopyXmlToClipboard() {
22          Node compilationUnit = Designer.getCompilationUnit(LanguageVersion.JAVA_18.getLanguageVersionHandler(), "public class Foo {}");
23          String xml = Designer.getXmlTreeCode(compilationUnit);
24          assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + 
25                  "<CompilationUnit BeginColumn=\"1\" BeginLine=\"1\" EndColumn=\"19\" EndLine=\"1\" FindBoundary=\"false\"\n" + 
26                  "                 Image=\"\"\n" + 
27                  "                 SingleLine=\"true\"\n" + 
28                  "                 declarationsAreInDefaultPackage=\"true\">\n" + 
29                  "   <TypeDeclaration BeginColumn=\"1\" BeginLine=\"1\" EndColumn=\"19\" EndLine=\"1\" FindBoundary=\"false\"\n" + 
30                  "                    Image=\"\"\n" + 
31                  "                    SingleLine=\"true\">\n" + 
32                  "      <ClassOrInterfaceDeclaration Abstract=\"false\" BeginColumn=\"8\" BeginLine=\"1\" Default=\"false\" EndColumn=\"19\"\n" + 
33                  "                                   EndLine=\"1\"\n" + 
34                  "                                   Final=\"false\"\n" + 
35                  "                                   FindBoundary=\"false\"\n" + 
36                  "                                   Image=\"Foo\"\n" + 
37                  "                                   Interface=\"false\"\n" + 
38                  "                                   Modifiers=\"1\"\n" + 
39                  "                                   Native=\"false\"\n" + 
40                  "                                   Nested=\"false\"\n" + 
41                  "                                   PackagePrivate=\"false\"\n" + 
42                  "                                   Private=\"false\"\n" + 
43                  "                                   Protected=\"false\"\n" + 
44                  "                                   Public=\"true\"\n" + 
45                  "                                   SingleLine=\"true\"\n" + 
46                  "                                   Static=\"false\"\n" + 
47                  "                                   Strictfp=\"false\"\n" + 
48                  "                                   Synchronized=\"false\"\n" + 
49                  "                                   Transient=\"false\"\n" + 
50                  "                                   Volatile=\"false\">\n" + 
51                  "         <ClassOrInterfaceBody BeginColumn=\"18\" BeginLine=\"1\" EndColumn=\"19\" EndLine=\"1\" FindBoundary=\"false\"\n" + 
52                  "                               Image=\"\"\n" + 
53                  "                               SingleLine=\"true\"/>\n" + 
54                  "      </ClassOrInterfaceDeclaration>\n" + 
55                  "   </TypeDeclaration>\n" + 
56                  "</CompilationUnit>", xml);
57      }
58  }