MCPcopy Create free account
hub / github.com/apache/nutch / testAdd

Method testAdd

src/test/org/apache/nutch/metadata/TestMetadata.java:73–100  ·  view source on GitHub ↗

Test for the add(String, String) method.

()

Source from the content-addressed store, hash-verified

71
72 /** Test for the <code>add(String, String)</code> method. */
73 @Test
74 public void testAdd() {
75 String[] values = null;
76 Metadata meta = new Metadata();
77
78 values = meta.getValues(CONTENTTYPE);
79 assertEquals(0, values.length);
80
81 meta.add(CONTENTTYPE, "value1");
82 values = meta.getValues(CONTENTTYPE);
83 assertEquals(1, values.length);
84 assertEquals("value1", values[0]);
85
86 meta.add(CONTENTTYPE, "value2");
87 values = meta.getValues(CONTENTTYPE);
88 assertEquals(2, values.length);
89 assertEquals("value1", values[0]);
90 assertEquals("value2", values[1]);
91
92 // NOTE : For now, the same value can be added many times.
93 // Should it be changed?
94 meta.add(CONTENTTYPE, "value1");
95 values = meta.getValues(CONTENTTYPE);
96 assertEquals(3, values.length);
97 assertEquals("value1", values[0]);
98 assertEquals("value2", values[1]);
99 assertEquals("value1", values[2]);
100 }
101
102 /** Test for the <code>set(String, String)</code> method. */
103 @Test

Callers

nothing calls this directly

Calls 2

getValuesMethod · 0.95
addMethod · 0.95

Tested by

no test coverage detected