Skip to content

Commit f8f7a57

Browse files
committed
Migrate property tests to text blocks
1 parent 9886615 commit f8f7a57

50 files changed

Lines changed: 5483 additions & 6023 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/creation/ConstructorCreationSupportTest.java

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -771,20 +771,20 @@ public void run(ComponentInfo copy) throws Exception {
771771
*/
772772
@Test
773773
public void test_getSource_forCreationId() throws Exception {
774-
setJavaContentSrc("test", "MyButton", new String[]{
775-
"public class MyButton extends JButton {",
776-
" public MyButton(boolean b) {",
777-
" }",
778-
"}"}, new String[]{
779-
"<?xml version='1.0' encoding='UTF-8'?>",
780-
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
781-
" <creation>",
782-
" <source><![CDATA[new test.MyButton(false)]]></source>",
783-
" </creation>",
784-
" <creation id='true'>",
785-
" <source><![CDATA[new test.MyButton(true)]]></source>",
786-
" </creation>",
787-
"</component>"});
774+
setJavaContentSrc("test", "MyButton", """
775+
public class MyButton extends JButton {
776+
public MyButton(boolean b) {
777+
}
778+
}""", """
779+
<?xml version="1.0" encoding="UTF-8"?>
780+
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
781+
<creation>
782+
<source><![CDATA[new test.MyButton(false)]]></source>
783+
</creation>
784+
<creation id="true">
785+
<source><![CDATA[new test.MyButton(true)]]></source>
786+
</creation>
787+
</component>""");
788788
String[] lines = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
789789
// parse
790790
parseContainer(lines);
@@ -809,11 +809,11 @@ public void test_getSource_forCreationId() throws Exception {
809809
*/
810810
@Test
811811
public void test_getSource_forSource() throws Exception {
812-
setJavaContentSrc("test", "MyButton", new String[]{
813-
"public class MyButton extends JButton {",
814-
" public MyButton(boolean b) {",
815-
" }",
816-
"}"}, null);
812+
setJavaContentSrc("test", "MyButton", """
813+
public class MyButton extends JButton {
814+
public MyButton(boolean b) {
815+
}
816+
}""", null);
817817
String[] lines = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
818818
// parse
819819
parseContainer(lines);
@@ -827,18 +827,18 @@ public void test_getSource_forSource() throws Exception {
827827

828828
@Test
829829
public void test_CREATE_noInvocations() throws Exception {
830-
setJavaContentSrc("test", "MyButton", new String[]{
831-
"public class MyButton extends JButton {",
832-
" public MyButton() {",
833-
" }",
834-
"}"}, new String[]{
835-
"<?xml version='1.0' encoding='UTF-8'?>",
836-
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
837-
" <creation>",
838-
" <source><![CDATA[new test.MyButton()]]></source>",
839-
" <invocation signature='setEnabled(boolean)'><![CDATA[false]]></invocation>",
840-
" </creation>",
841-
"</component>"});
830+
setJavaContentSrc("test", "MyButton", """
831+
public class MyButton extends JButton {
832+
public MyButton() {
833+
}
834+
}""", """
835+
<?xml version="1.0" encoding="UTF-8"?>
836+
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
837+
<creation>
838+
<source><![CDATA[new test.MyButton()]]></source>
839+
<invocation signature="setEnabled(boolean)"><![CDATA[false]]></invocation>
840+
</creation>
841+
</component>""");
842842
String[] lines1 = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
843843
// parse
844844
ContainerInfo panel = parseContainer(lines1);
@@ -879,18 +879,18 @@ public void test_CREATE_noInvocations() throws Exception {
879879

880880
@Test
881881
public void test_CREATE_addInvocations() throws Exception {
882-
setJavaContentSrc("test", "MyButton", new String[]{
883-
"public class MyButton extends JButton {",
884-
" public MyButton() {",
885-
" }",
886-
"}"}, new String[]{
887-
"<?xml version='1.0' encoding='UTF-8'?>",
888-
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
889-
" <creation>",
890-
" <source><![CDATA[new test.MyButton()]]></source>",
891-
" <invocation signature='setEnabled(boolean)'><![CDATA[false]]></invocation>",
892-
" </creation>",
893-
"</component>"});
882+
setJavaContentSrc("test", "MyButton", """
883+
public class MyButton extends JButton {
884+
public MyButton() {
885+
}
886+
}""", """
887+
<?xml version="1.0" encoding="UTF-8"?>
888+
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
889+
<creation>
890+
<source><![CDATA[new test.MyButton()]]></source>
891+
<invocation signature="setEnabled(boolean)"><![CDATA[false]]></invocation>
892+
</creation>
893+
</component>""");
894894
String[] lines1 = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
895895
// parse
896896
ContainerInfo panel = parseContainer(lines1);
@@ -918,19 +918,19 @@ public void test_CREATE_addInvocations() throws Exception {
918918

919919
@Test
920920
public void test_template_index() throws Exception {
921-
setJavaContentSrc("test", "MyButton", new String[]{
922-
"public class MyButton extends JButton {",
923-
" public MyButton(String value) {",
924-
" }",
925-
" public void setValue(String value) {",
926-
" }",
927-
"}"}, new String[]{
928-
"<?xml version='1.0' encoding='UTF-8'?>",
929-
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
930-
" <creation>",
931-
" <source><![CDATA[new test.MyButton(\"value_%index%\")]]></source>",
932-
" </creation>",
933-
"</component>"});
921+
setJavaContentSrc("test", "MyButton", """
922+
public class MyButton extends JButton {
923+
public MyButton(String value) {
924+
}
925+
public void setValue(String value) {
926+
}
927+
}""", """
928+
<?xml version="1.0" encoding="UTF-8"?>
929+
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
930+
<creation>
931+
<source><![CDATA[new test.MyButton(\"value_%index%\")]]></source>
932+
</creation>
933+
</component>""");
934934
String[] lines1 = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
935935
// parse
936936
ContainerInfo panel = parseContainer(lines1);
@@ -1020,22 +1020,22 @@ public void test_getAssociation_noParent() throws Exception {
10201020
*/
10211021
@Test
10221022
public void test_getAssociation_hasParent() throws Exception {
1023-
setJavaContentSrc("test", "MyButton", new String[]{
1024-
"public class MyButton extends JButton {",
1025-
" public MyButton(JPanel parent) {",
1026-
" }",
1027-
"}"}, new String[]{
1028-
"<?xml version='1.0' encoding='UTF-8'?>",
1029-
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
1030-
" <creation>",
1031-
" <source><![CDATA[new test.MyButton(%parent%)]]></source>",
1032-
" </creation>",
1033-
" <constructors>",
1034-
" <constructor>",
1035-
" <parameter type='javax.swing.JPanel' parent='true'/>",
1036-
" </constructor>",
1037-
" </constructors>",
1038-
"</component>"});
1023+
setJavaContentSrc("test", "MyButton", """
1024+
public class MyButton extends JButton {
1025+
public MyButton(JPanel parent) {
1026+
}
1027+
}""", """
1028+
<?xml version="1.0" encoding="UTF-8"?>
1029+
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
1030+
<creation>
1031+
<source><![CDATA[new test.MyButton(%parent%)]]></source>
1032+
</creation>
1033+
<constructors>
1034+
<constructor>
1035+
<parameter type="javax.swing.JPanel" parent="true"/>
1036+
</constructor>
1037+
</constructors>
1038+
</component>""");
10391039
String[] lines = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
10401040
// parse
10411041
parseContainer(lines);

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/description/ComponentDescriptionIbmTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011 Google, Inc.
2+
* Copyright (c) 2011, 2026 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -108,19 +108,19 @@ public static void tearDownClass() throws Exception {
108108
//
109109
////////////////////////////////////////////////////////////////////////////
110110
private ContainerInfo createDefaultProjectContents() throws Exception {
111-
setJavaContentSrc("test", "TestPanel", new String[]{
112-
"public class TestPanel extends JPanel {",
113-
" public TestPanel(){",
114-
" }",
115-
" protected void setTestProperty(int value){",
116-
" }",
117-
"}"}, new String[]{
118-
"<?xml version='1.0' encoding='UTF-8'?>",
119-
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
120-
" <property id='setTestProperty(int)'>",
121-
" <defaultValue value='7'/>",
122-
" </property>",
123-
"</component>"});
111+
setJavaContentSrc("test", "TestPanel", """
112+
public class TestPanel extends JPanel {
113+
public TestPanel(){
114+
}
115+
protected void setTestProperty(int value){
116+
}
117+
}""", """
118+
<?xml version="1.0" encoding="UTF-8"?>
119+
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
120+
<property id="setTestProperty(int)">
121+
<defaultValue value="7"/>
122+
</property>
123+
</component>""");
124124
return parseContainer(
125125
"// filler filler filler",
126126
"public class Test extends TestPanel {",

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/parser/ExecuteOnParseTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2024 Google, Inc. and others.
2+
* Copyright (c) 2011, 2026 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -2685,20 +2685,20 @@ public void test_dontVisit_AnonymouseClassDeclaration() throws Exception {
26852685
*/
26862686
@Test
26872687
public void test_createAssociateAndInvokeMethod() throws Exception {
2688-
setJavaContentSrc("test", "MyButton", new String[]{
2689-
"public class MyButton extends JButton {",
2690-
" public MyButton(Container container) {",
2691-
" container.add(this);",
2692-
" }",
2693-
"}"}, new String[]{
2694-
"<?xml version='1.0' encoding='UTF-8'?>",
2695-
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
2696-
" <constructors>",
2697-
" <constructor>",
2698-
" <parameter type='java.awt.Container' parent='true'/>",
2699-
" </constructor>",
2700-
" </constructors>",
2701-
"</component>"});
2688+
setJavaContentSrc("test", "MyButton", """
2689+
public class MyButton extends JButton {
2690+
public MyButton(Container container) {
2691+
container.add(this);
2692+
}
2693+
}""", """
2694+
<?xml version="1.0" encoding="UTF-8"?>
2695+
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
2696+
<constructors>
2697+
<constructor>
2698+
<parameter type="java.awt.Container" parent="true"/>
2699+
</constructor>
2700+
</constructors>
2701+
</component>""");
27022702
// parse
27032703
ContainerInfo panel =
27042704
parseContainer(

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/parser/SwingParserTest.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011, 2024 Google, Inc. and others.
2+
* Copyright (c) 2011, 2026 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -1378,17 +1378,17 @@ public void test_AbstractButton_setModel_null() throws Exception {
13781378
*/
13791379
@Test
13801380
public void test_preferredRoot_singlePreferred() throws Exception {
1381-
setJavaContentSrc("test", "MyPanel", new String[]{
1382-
"public class MyPanel extends JPanel {",
1383-
" public MyPanel() {",
1384-
" }",
1385-
"}"}, new String[]{
1386-
"<?xml version='1.0' encoding='UTF-8'?>",
1387-
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
1388-
" <parameters>",
1389-
" <parameter name='parser.preferredRoot'>true</parameter>",
1390-
" </parameters>",
1391-
"</component>"});
1381+
setJavaContentSrc("test", "MyPanel", """
1382+
public class MyPanel extends JPanel {
1383+
public MyPanel() {
1384+
}
1385+
}""", """
1386+
<?xml version="1.0" encoding="UTF-8"?>
1387+
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
1388+
<parameters>
1389+
<parameter name="parser.preferredRoot">true</parameter>
1390+
</parameters>
1391+
</component>""");
13921392
// standard JPanel has bigger hierarchy, so without "parser.preferredRoot" is would be selected
13931393
parseContainer(
13941394
"public class Test {",
@@ -1411,17 +1411,17 @@ public void test_preferredRoot_singlePreferred() throws Exception {
14111411
*/
14121412
@Test
14131413
public void test_preferredRoot_twoPreferred() throws Exception {
1414-
setJavaContentSrc("test", "MyPanel", new String[]{
1415-
"public class MyPanel extends JPanel {",
1416-
" public MyPanel() {",
1417-
" }",
1418-
"}"}, new String[]{
1419-
"<?xml version='1.0' encoding='UTF-8'?>",
1420-
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
1421-
" <parameters>",
1422-
" <parameter name='parser.preferredRoot'>true</parameter>",
1423-
" </parameters>",
1424-
"</component>"});
1414+
setJavaContentSrc("test", "MyPanel", """
1415+
public class MyPanel extends JPanel {
1416+
public MyPanel() {
1417+
}
1418+
}""", """
1419+
<?xml version="1.0" encoding="UTF-8"?>
1420+
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
1421+
<parameters>
1422+
<parameter name="parser.preferredRoot">true</parameter>
1423+
</parameters>
1424+
</component>""");
14251425
parseContainer(
14261426
"public class Test {",
14271427
" public static void main(String[] args) {",

org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/ComponentClassPropertyTest.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2011 Google, Inc.
2+
* Copyright (c) 2011, 2026 Google, Inc. and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -39,25 +39,23 @@ public class ComponentClassPropertyTest extends SwingModelTest {
3939
*/
4040
@Test
4141
public void test_noForNullClass() throws Exception {
42-
ContainerInfo panel =
43-
parseContainer(
44-
"public class Test extends JPanel {",
45-
" public Test() {",
46-
" setLayout(null);",
47-
" }",
48-
"}");
42+
ContainerInfo panel = parseContainer("""
43+
public class Test extends JPanel {
44+
public Test() {
45+
setLayout(null);
46+
}
47+
}""");
4948
assertNull(panel.getLayout().getPropertyByTitle("Class"));
5049
}
5150

5251
@Test
5352
public void test_property() throws Exception {
54-
ContainerInfo panel =
55-
parseContainer(
56-
"// filler filler filler",
57-
"public class Test extends JPanel {",
58-
" public Test() {",
59-
" }",
60-
"}");
53+
ContainerInfo panel = parseContainer("""
54+
// filler filler filler
55+
public class Test extends JPanel {
56+
public Test() {
57+
}
58+
}""");
6159
// property
6260
ComponentClassProperty property = (ComponentClassProperty) panel.getPropertyByTitle("Class");
6361
assertNotNull(property);

0 commit comments

Comments
 (0)