| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.rendering.internal.parser.reference; |
| 21 |
|
|
| 22 |
|
import org.junit.Assert; |
| 23 |
|
import org.junit.Test; |
| 24 |
|
import org.xwiki.rendering.listener.reference.ResourceReference; |
| 25 |
|
import org.xwiki.rendering.listener.reference.ResourceType; |
| 26 |
|
import org.xwiki.rendering.parser.ResourceReferenceParser; |
| 27 |
|
import org.xwiki.rendering.wiki.WikiModel; |
| 28 |
|
import org.xwiki.test.jmock.AbstractComponentTestCase; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
@link |
| 32 |
|
|
| 33 |
|
@version |
| 34 |
|
@since |
| 35 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (30) |
Complexity: 3 |
Complexity Density: 0.11 |
|
| 36 |
|
public class DefaultImageReferenceParserTest extends AbstractComponentTestCase |
| 37 |
|
{ |
| 38 |
|
private ResourceReferenceParser parser; |
| 39 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 40 |
2 |
@Override... |
| 41 |
|
protected void registerComponents() throws Exception |
| 42 |
|
{ |
| 43 |
|
|
| 44 |
2 |
registerMockComponent(WikiModel.class); |
| 45 |
|
|
| 46 |
2 |
this.parser = getComponentManager().getInstance(ResourceReferenceParser.class, "image"); |
| 47 |
|
} |
| 48 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
| 49 |
1 |
@Test... |
| 50 |
|
public void testParseImagesCommon() throws Exception |
| 51 |
|
{ |
| 52 |
|
|
| 53 |
1 |
ResourceReference reference = this.parser.parse("wiki:space.page@filename"); |
| 54 |
1 |
Assert.assertEquals(ResourceType.ATTACHMENT, reference.getType()); |
| 55 |
1 |
Assert.assertEquals("wiki:space.page@filename", reference.getReference()); |
| 56 |
1 |
Assert.assertEquals("Typed = [false] Type = [attach] Reference = [wiki:space.page@filename]", |
| 57 |
|
reference.toString()); |
| 58 |
1 |
Assert.assertFalse(reference.isTyped()); |
| 59 |
|
|
| 60 |
|
|
| 61 |
1 |
reference = this.parser.parse("scheme://server/path/to/image"); |
| 62 |
1 |
Assert.assertEquals(ResourceType.URL, reference.getType()); |
| 63 |
1 |
Assert.assertEquals("scheme://server/path/to/image", reference.getReference()); |
| 64 |
1 |
Assert.assertEquals("Typed = [false] Type = [url] Reference = [scheme://server/path/to/image]", |
| 65 |
|
reference.toString()); |
| 66 |
1 |
Assert.assertFalse(reference.isTyped()); |
| 67 |
|
} |
| 68 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
| 69 |
1 |
@Test... |
| 70 |
|
public void testParseImages() throws Exception |
| 71 |
|
{ |
| 72 |
1 |
ResourceReference reference = this.parser.parse("attach:wiki:space.page@filename"); |
| 73 |
1 |
Assert.assertEquals(ResourceType.ATTACHMENT, reference.getType()); |
| 74 |
1 |
Assert.assertEquals("wiki:space.page@filename", reference.getReference()); |
| 75 |
1 |
Assert.assertTrue(reference.isTyped()); |
| 76 |
1 |
Assert.assertEquals("Typed = [true] Type = [attach] Reference = [wiki:space.page@filename]", |
| 77 |
|
reference.toString()); |
| 78 |
|
|
| 79 |
|
|
| 80 |
1 |
reference = this.parser.parse("path:/some/image"); |
| 81 |
1 |
Assert.assertEquals(ResourceType.PATH, reference.getType()); |
| 82 |
1 |
Assert.assertEquals("/some/image", reference.getReference()); |
| 83 |
1 |
Assert.assertTrue(reference.isTyped()); |
| 84 |
1 |
Assert.assertEquals("Typed = [true] Type = [path] Reference = [/some/image]", reference.toString()); |
| 85 |
|
|
| 86 |
|
|
| 87 |
1 |
reference = this.parser.parse("icon:name"); |
| 88 |
1 |
Assert.assertEquals(ResourceType.ICON, reference.getType()); |
| 89 |
1 |
Assert.assertEquals("name", reference.getReference()); |
| 90 |
1 |
Assert.assertTrue(reference.isTyped()); |
| 91 |
1 |
Assert.assertEquals("Typed = [true] Type = [icon] Reference = [name]", reference.toString()); |
| 92 |
|
} |
| 93 |
|
} |