Skip to content

Commit c7bfc68

Browse files
committed
restore static initailization in xml module
1 parent 03dd1b2 commit c7bfc68

File tree

7 files changed

+52
-117
lines changed

7 files changed

+52
-117
lines changed

google-http-client-xml/src/test/java/com/google/api/client/xml/AtomTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@
4545
@RunWith(JUnit4.class)
4646
public class AtomTest {
4747

48-
private static final String SAMPLE_FEED;
49-
50-
static {
51-
SAMPLE_FEED =
48+
private static final String SAMPLE_FEED =
5249
"<?xml version=\"1.0\" encoding=\"utf-8\"?><feed "
5350
+ "xmlns=\"http://www.w3.org/2005/Atom\"> <title>Example Feed</title> <link href"
5451
+ "=\"http://example.org/\"/> <updated>2003-12-13T18:31:02Z</updated> <author> "
@@ -60,7 +57,6 @@ public class AtomTest {
6057
+ " href=\"http://example.org/2003/12/13/atom02\"/> <id>urn:uuid:1225c695-cfb8-4ebb"
6158
+ "-aaaa-80da344efa62</id> <updated>2003-12-13T18:32:02Z</updated> <summary>Some "
6259
+ "other text.</summary> </entry></feed>";
63-
}
6460

6561
/** Test for checking the Slug Header */
6662
@Test

google-http-client-xml/src/test/java/com/google/api/client/xml/GenericXmlListTest.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,28 @@
4040
@RunWith(JUnit4.class)
4141
public class GenericXmlListTest {
4242

43-
private static final String MULTI_TYPE_WITH_CLASS_TYPE;
44-
private static final String MULTIPLE_STRING_ELEMENT;
45-
private static final String MULTIPLE_INTEGER_ELEMENT;
46-
private static final String MULTIPLE_ENUM_ELEMENT;
47-
private static final String COLLECTION_OF_ARRAY;
48-
49-
static {
50-
MULTI_TYPE_WITH_CLASS_TYPE =
43+
private static final String MULTI_TYPE_WITH_CLASS_TYPE =
5144
"<?xml version=\"1.0\"?><any "
5245
+ "xmlns=\"http://www.w3.org/2005/Atom\"><rep><elem>content1</elem><rep>rep10</rep><rep>"
5346
+ "rep11</rep><value>value1</value></rep><rep><elem>content2</elem><rep>rep20</rep><rep>rep21"
5447
+ "</rep><value>value2</value></rep><rep><elem>content3</elem><rep>rep30</rep><rep>rep31"
5548
+ "</rep><value>value3</value></rep></any>";
56-
MULTIPLE_STRING_ELEMENT =
49+
private static final String MULTIPLE_STRING_ELEMENT =
5750
"<?xml version=\"1.0\"?><any xmlns"
5851
+ "=\"http://www.w3.org/2005/Atom\"><rep>rep1</rep><rep>rep2</rep></any>";
59-
MULTIPLE_INTEGER_ELEMENT =
52+
private static final String MULTIPLE_INTEGER_ELEMENT =
6053
"<?xml version=\"1.0\"?><any xmlns"
6154
+ "=\"http://www.w3.org/2005/Atom\"><rep>1</rep><rep>2</rep></any>";
62-
MULTIPLE_ENUM_ELEMENT =
55+
private static final String ARRAY_TYPE_WITH_PRIMITIVE_ADDED_NESTED =
56+
"<?xml version=\"1.0"
57+
+ "\"?><any xmlns=\"http://www.w3.org/2005/Atom\"><rep>1<nested>something</nested></rep"
58+
+ "><rep>2</rep></any>";
59+
private static final String MULTIPLE_ENUM_ELEMENT =
6360
"<?xml version=\"1.0\"?><any xmlns"
6461
+ "=\"http://www.w3.org/2005/Atom\"><rep>ENUM_1</rep><rep>ENUM_2</rep></any>";
65-
COLLECTION_OF_ARRAY =
62+
private static final String COLLECTION_OF_ARRAY =
6663
"<?xml version=\"1.0\"?><any xmlns"
6764
+ "=\"http://www.w3.org/2005/Atom\"><rep><a>a</a><b>b</b></rep><rep><c>c</c><d>d</d></rep></any>";
68-
}
6965

7066
/** The purpose of this test is to map an XML with an Array of {@link XmlTest.AnyType} objects. */
7167
@SuppressWarnings("unchecked")

google-http-client-xml/src/test/java/com/google/api/client/xml/GenericXmlTest.java

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,49 +46,37 @@
4646
@RunWith(JUnit4.class)
4747
public class GenericXmlTest {
4848

49-
private static final String XML;
50-
private static final String ANY_GENERIC_TYPE_XML;
51-
private static final String SIMPLE_XML;
52-
private static final String SIMPLE_XML_NUMERIC;
53-
private static final String ANY_TYPE_XML;
54-
private static final String ANY_TYPE_XML_PRIMITIVE_INT;
55-
private static final String ANY_TYPE_XML_PRIMITIVE_STR;
56-
private static final String ALL_TYPE;
57-
private static final String ANY_TYPE_XML_NESTED_ARRAY;
58-
59-
static {
60-
XML =
49+
private static final String XML =
6150
"<?xml version=\"1.0\"?><feed xmlns=\"http://www.w3.org"
6251
+ "/2005/Atom\" xmlns:gd=\"http://schemas.google.com/g/2005\"><atom:entry xmlns=\"http"
6352
+ "://schemas.google.com/g/2005\" xmlns:atom=\"http://www.w3.org/2005/Atom\" gd:etag"
6453
+ "=\"abc\"><atom:title>One</atom:title></atom:entry><entry gd:etag=\"def\"><title "
6554
+ "attribute=\"someattribute\">Two</title></entry></feed>";
66-
ANY_GENERIC_TYPE_XML =
55+
private static final String ANY_GENERIC_TYPE_XML =
6756
"<?xml version=\"1.0\"?><any attr=\"value\" "
6857
+ "xmlns=\"http://www.w3.org/2005/Atom\"><elem><rep attr=\"param1\">rep1</rep><rep "
6958
+ "attr=\"param2\">rep2</rep><value>content</value></elem></any>";
70-
SIMPLE_XML = "<any>test</any>";
71-
SIMPLE_XML_NUMERIC = "<any>1</any>";
72-
ANY_TYPE_XML =
59+
private static final String SIMPLE_XML = "<any>test</any>";
60+
private static final String SIMPLE_XML_NUMERIC = "<any>1</any>";
61+
private static final String ANY_TYPE_XML =
7362
"<?xml version=\"1.0\"?><any attr=\"value\" "
7463
+ "xmlns=\"http://www.w3.org/2005/Atom\"><elem>content</elem><rep>rep1</rep><rep>rep2</rep"
7564
+ "><value>content</value></any>";
76-
ANY_TYPE_XML_PRIMITIVE_INT =
65+
private static final String ANY_TYPE_XML_PRIMITIVE_INT =
7766
"<?xml version=\"1.0\"?><any attr"
7867
+ "=\"2\" xmlns=\"http://www.w3.org/2005/Atom\">1<intArray>1</intArray><intArray>2"
7968
+ "</intArray></any>";
80-
ANY_TYPE_XML_PRIMITIVE_STR =
69+
private static final String ANY_TYPE_XML_PRIMITIVE_STR =
8170
"<?xml version=\"1.0\"?><any attr"
8271
+ "=\"2+1\" xmlns=\"http://www.w3.org/2005/Atom\">1+1<strArray>1+1</strArray><strArray>2"
8372
+ "+1</strArray></any>";
84-
ALL_TYPE =
73+
private static final String ALL_TYPE =
8574
"<?xml version=\"1.0\"?><any xmlns=\"\"><integer"
8675
+ "/><str/><genericXml/><anyEnum/><stringArray/><integerCollection/></any>";
87-
ANY_TYPE_XML_NESTED_ARRAY =
76+
private static final String ANY_TYPE_XML_NESTED_ARRAY =
8877
"<?xml version=\"1.0\"?><any attr"
8978
+ "=\"value\" xmlns=\"http://www.w3.org/2005/Atom\"><elem>content</elem><rep><p>rep1</p"
9079
+ "><p>rep2</p></rep><rep><p>rep3</p><p>rep4</p></rep><value>content</value></any>";
91-
}
9280

9381
public GenericXmlTest() {}
9482

google-http-client-xml/src/test/java/com/google/api/client/xml/XmlEnumTest.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,23 @@
3838
@RunWith(JUnit4.class)
3939
public class XmlEnumTest {
4040

41-
private static final String XML;
42-
private static final String XML_ENUM_ELEMENT_ONLY;
43-
private static final String XML_ENUM_ATTRIBUTE_ONLY;
44-
private static final String XML_ENUM_INCORRECT;
45-
private static final String XML_ENUM_ELEMENT_ONLY_NESTED;
46-
47-
static {
48-
XML =
41+
private static final String XML =
4942
"<?xml version=\"1.0\"?><any anyEnum=\"ENUM_1\" attr"
5043
+ "=\"value\" xmlns=\"http://www.w3.org/2005/Atom\"><anotherEnum>ENUM_2</anotherEnum"
5144
+ "><elem>content</elem><rep>rep1</rep><rep>rep2</rep><value>ENUM_1</value></any>";
52-
XML_ENUM_ELEMENT_ONLY =
45+
private static final String XML_ENUM_ELEMENT_ONLY =
5346
"<?xml version=\"1.0\"?><any xmlns"
5447
+ "=\"http://www.w3.org/2005/Atom\"><elementEnum>ENUM_2</elementEnum></any>";
55-
XML_ENUM_ATTRIBUTE_ONLY =
48+
private static final String XML_ENUM_ATTRIBUTE_ONLY =
5649
"<?xml version=\"1.0\"?><any "
5750
+ "attributeEnum=\"ENUM_1\" xmlns=\"http://www.w3.org/2005/Atom\" />";
58-
XML_ENUM_INCORRECT =
51+
private static final String XML_ENUM_INCORRECT =
5952
"<?xml version=\"1.0\"?><any xmlns=\"http"
6053
+ "://www.w3.org/2005/Atom\"><elementEnum>ENUM_3</elementEnum></any>";
61-
XML_ENUM_ELEMENT_ONLY_NESTED =
54+
private static final String XML_ENUM_ELEMENT_ONLY_NESTED =
6255
"<?xml version=\"1.0\"?><any "
6356
+ "xmlns=\"http://www.w3.org/2005/Atom\"><elementEnum>ENUM_2<nested>something</nested"
6457
+ "></elementEnum></any>";
65-
}
6658

6759
@Test
6860
public void testParseAnyType() throws Exception {

google-http-client-xml/src/test/java/com/google/api/client/xml/XmlListTest.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,28 @@
3737
@RunWith(JUnit4.class)
3838
public class XmlListTest {
3939

40-
private static final String MULTI_TYPE_WITH_CLASS_TYPE;
41-
private static final String MULTIPLE_STRING_ELEMENT;
42-
private static final String MULTIPLE_STRING_ELEMENT_IN_COLLECTION;
43-
private static final String MULTIPLE_INTEGER_ELEMENT;
44-
private static final String MULTIPLE_ENUM_ELEMENT;
45-
private static final String COLLECTION_OF_ARRAY;
46-
47-
static {
48-
MULTI_TYPE_WITH_CLASS_TYPE =
40+
private static final String MULTI_TYPE_WITH_CLASS_TYPE =
4941
"<?xml version=\"1.0\"?><any "
5042
+ "xmlns=\"http://www.w3.org/2005/Atom\"><rep><elem>content1</elem><rep>rep10</rep><rep"
5143
+ ">rep11</rep><value>value1</value></rep><rep><elem>content2</elem><rep>rep20</rep><rep"
5244
+ ">rep21</rep><value>value2</value></rep><rep><elem>content3</elem><rep>rep30</rep><rep"
5345
+ ">rep31</rep><value>value3</value></rep></any>";
54-
MULTIPLE_STRING_ELEMENT =
46+
private static final String MULTIPLE_STRING_ELEMENT =
5547
"<?xml version=\"1.0\"?><any xmlns"
5648
+ "=\"http://www.w3.org/2005/Atom\"><rep>rep1</rep><rep>rep2</rep></any>";
57-
MULTIPLE_STRING_ELEMENT_IN_COLLECTION =
49+
private static final String MULTIPLE_STRING_ELEMENT_IN_COLLECTION =
5850
"<?xml version=\"1.0"
5951
+ "\"?><any xmlns=\"http://www.w3.org/2005/Atom\"><coll><rep>rep1</rep><rep>rep2</rep"
6052
+ "></coll></any>";
61-
MULTIPLE_INTEGER_ELEMENT =
53+
private static final String MULTIPLE_INTEGER_ELEMENT =
6254
"<?xml version=\"1.0\"?><any xmlns"
6355
+ "=\"http://www.w3.org/2005/Atom\"><rep>1</rep><rep>2</rep></any>";
64-
MULTIPLE_ENUM_ELEMENT =
56+
private static final String MULTIPLE_ENUM_ELEMENT =
6557
"<?xml version=\"1.0\"?><any xmlns"
6658
+ "=\"http://www.w3.org/2005/Atom\"><rep>ENUM_1</rep><rep>ENUM_2</rep></any>";
67-
COLLECTION_OF_ARRAY =
59+
private static final String COLLECTION_OF_ARRAY =
6860
"<?xml version=\"1.0\"?><any xmlns"
6961
+ "=\"http://www.w3.org/2005/Atom\"><rep><a>a</a><b>b</b></rep><rep><c>c</c><d>d</d></rep></any>";
70-
}
7162

7263
/** The purpose of this test is to map an XML with an Array of {@link XmlTest.AnyType} objects. */
7364
@SuppressWarnings("unchecked")

google-http-client-xml/src/test/java/com/google/api/client/xml/XmlNamespaceDictionaryTest.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,20 @@
3838
@RunWith(JUnit4.class)
3939
public class XmlNamespaceDictionaryTest {
4040

41-
private static final String EXPECTED;
42-
private static final String EXPECTED_EMPTY_MAP;
43-
private static final String EXPECTED_EMPTY_MAP_NS_UNDECLARED;
44-
private static final String EXPECTED_EMPTY_MAP_ATOM_NS;
45-
private static final String EXPECTED_UNKNOWN_NS;
46-
47-
static {
48-
EXPECTED =
41+
private static final String EXPECTED =
4942
"<?xml version=\"1.0\"?><feed xmlns=\"http://www.w3"
5043
+ ".org/2005/Atom\" xmlns:gd=\"http://schemas.google.com/g/2005\"><entry gd:etag=\"abc"
5144
+ "\"><title>One</title></entry><entry gd:etag=\"def\"><title>Two</title></entry></feed>";
52-
EXPECTED_EMPTY_MAP =
45+
private static final String EXPECTED_EMPTY_MAP =
5346
"<?xml version=\"1.0\"?><entry xmlns" + "=\"http://www.w3.org/2005/Atom\" />";
54-
EXPECTED_EMPTY_MAP_NS_UNDECLARED =
47+
private static final String EXPECTED_EMPTY_MAP_NS_UNDECLARED =
5548
"<?xml version=\"1.0\"?><n1" + ":entry xmlns:n1=\"http://www.w3.org/2005/Atom\" />";
56-
EXPECTED_EMPTY_MAP_ATOM_NS =
49+
private static final String EXPECTED_EMPTY_MAP_ATOM_NS =
5750
"<?xml version=\"1.0\"?><atom" + ":entry xmlns:atom=\"http://www.w3.org/2005/Atom\" />";
58-
EXPECTED_UNKNOWN_NS =
51+
private static final String EXPECTED_UNKNOWN_NS =
5952
"<?xml version=\"1.0\"?><feed xmlns"
6053
+ "=\"http://unknown/\" xmlns:gd=\"http://unknown/gd\"><entry gd:etag=\"abc\"><title>One"
6154
+ "</title></entry><entry gd:etag=\"def\"><title>Two</title></entry></feed>";
62-
}
63-
64-
public XmlNamespaceDictionaryTest() {}
6555

6656
@Test
6757
public void testSet() {

google-http-client-xml/src/test/java/com/google/api/client/xml/XmlTest.java

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,74 +42,56 @@
4242
@RunWith(JUnit4.class)
4343
public class XmlTest {
4444

45-
private static final String SIMPLE_XML;
46-
private static final String SIMPLE_XML_NUMERIC;
47-
private static final String START_WITH_TEXT;
48-
private static final String MISSING_END_ELEMENT;
49-
private static final String START_WITH_END_ELEMENT;
50-
private static final String START_WITH_END_ELEMENT_NESTED;
51-
private static final String ANY_TYPE_XML;
52-
private static final String ANY_TYPE_MISSING_XML;
53-
private static final String ANY_TYPE_XML_PRIMITIVE_INT;
54-
private static final String ANY_TYPE_XML_PRIMITIVE_STR;
55-
private static final String NESTED_NS;
56-
private static final String NESTED_NS_SERIALIZED;
57-
private static final String INF_TEST;
58-
private static final String ALL_TYPE;
59-
private static final String ALL_TYPE_WITH_DATA;
60-
private static final String ANY_TYPE_XML_NESTED_ARRAY;
61-
62-
static {
63-
SIMPLE_XML = "<any>test</any>";
64-
SIMPLE_XML_NUMERIC = "<any>1</any>";
65-
START_WITH_TEXT = "<?xml version=\"1.0\"?>start_with_text</any>";
66-
MISSING_END_ELEMENT = "<?xml version=\"1.0\"?><any xmlns=\"\">" + "missing_end_element";
67-
START_WITH_END_ELEMENT =
45+
private static final String SIMPLE_XML = "<any>test</any>";
46+
private static final String SIMPLE_XML_NUMERIC = "<any>1</any>";
47+
private static final String START_WITH_TEXT = "<?xml version=\"1.0\"?>start_with_text</any>";
48+
private static final String MISSING_END_ELEMENT =
49+
"<?xml version=\"1.0\"?><any xmlns=\"\">" + "missing_end_element";
50+
private static final String START_WITH_END_ELEMENT =
6851
"<?xml version=\"1.0\"?></p><any " + "xmlns=\"\">start_with_end_elemtn</any>";
69-
START_WITH_END_ELEMENT_NESTED =
52+
private static final String START_WITH_END_ELEMENT_NESTED =
7053
"<?xml version=\"1.0\"?><any " + "xmlns=\"\"></p>start_with_end_element_nested</any>";
71-
ANY_TYPE_XML =
54+
private static final String ANY_TYPE_XML =
7255
"<?xml version=\"1.0\"?><any attr=\"value\" "
7356
+ "xmlns=\"http://www.w3.org/2005/Atom\"><elem>content</elem><rep>rep1</rep><rep>rep2"
7457
+ "</rep><value>content</value></any>";
75-
ANY_TYPE_MISSING_XML =
58+
private static final String ANY_TYPE_MISSING_XML =
7659
"<?xml version=\"1.0\"?><any attr=\"value\" "
7760
+ "xmlns=\"http://www.w3.org/2005/Atom\"><elem>content</elem><value>content</value"
7861
+ "></any>";
79-
ANY_TYPE_XML_PRIMITIVE_INT =
62+
private static final String ANY_TYPE_XML_PRIMITIVE_INT =
8063
"<?xml version=\"1.0\"?><any attr"
8164
+ "=\"2\" xmlns=\"http://www.w3.org/2005/Atom\">1<intArray>1</intArray><intArray>2"
8265
+ "</intArray></any>";
83-
ANY_TYPE_XML_PRIMITIVE_STR =
66+
private static final String ANY_TYPE_XML_PRIMITIVE_STR =
8467
"<?xml version=\"1.0\"?><any attr"
8568
+ "=\"2+1\" xmlns=\"http://www.w3.org/2005/Atom\">1+1<strArray>1+1</strArray><strArray>2"
8669
+ "+1</strArray></any>";
87-
NESTED_NS =
70+
private static final String NESTED_NS =
8871
"<?xml version=\"1.0\"?><any xmlns=\"http://www.w3"
8972
+ ".org/2005/Atom\"><app:edited xmlns:app='http://www.w3.org/2007/app'>2011-08-09T04:38"
9073
+ ":14.017Z</app:edited></any>";
91-
NESTED_NS_SERIALIZED =
74+
private static final String NESTED_NS_SERIALIZED =
9275
"<?xml version=\"1.0\"?><any xmlns"
9376
+ "=\"http://www.w3.org/2005/Atom\" xmlns:app=\"http://www.w3.org/2007/app\"><app:edited"
9477
+ ">2011-08-09T04:38:14.017Z</app:edited></any>";
95-
INF_TEST =
78+
private static final String INF_TEST =
9679
"<?xml version=\"1.0\"?><any xmlns=\"\"><dblInfNeg"
9780
+ ">-INF</dblInfNeg><dblInfPos>INF</dblInfPos><fltInfNeg>-INF</fltInfNeg><fltInfPos>INF"
9881
+ "</fltInfPos></any>";
99-
ALL_TYPE =
82+
private static final String ALL_TYPE =
10083
"<?xml version=\"1.0\"?><any xmlns=\"\"><integer"
10184
+ "/><str/><genericXml/><anyEnum/><stringArray/><integerCollection/></any>";
102-
ALL_TYPE_WITH_DATA =
85+
private static final String ALL_TYPE_WITH_DATA =
10386
"<?xml version=\"1.0\"?><any xmlns=\"\">"
10487
+ "<anyEnum>ENUM_1</anyEnum><anyEnum>ENUM_2</anyEnum><genericXml><html><head><title"
10588
+ ">Title</title></head><body><p>Test</p></body></html></genericXml><integer>1</integer"
10689
+ "><integerCollection>1</integerCollection><integerCollection>2</integerCollection><str"
10790
+ ">str1</str><stringArray>arr1</stringArray><stringArray>arr2</stringArray></any>";
108-
ANY_TYPE_XML_NESTED_ARRAY =
91+
private static final String ANY_TYPE_XML_NESTED_ARRAY =
10992
"<?xml version=\"1.0\"?><any attr"
11093
+ "=\"value\" xmlns=\"http://www.w3.org/2005/Atom\"><elem>content</elem><rep><p>rep1</p"
11194
+ "><p>rep2</p></rep><rep><p>rep3</p><p>rep4</p></rep><value>content</value></any>";
112-
}
11395

11496
/**
11597
* The purpose of this test is to map a single element to a single field of a destination object.

0 commit comments

Comments
 (0)