| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.velocity.internal.util; |
| 21 |
|
|
| 22 |
|
import org.junit.Assert; |
| 23 |
|
import org.junit.Before; |
| 24 |
|
import org.junit.Test; |
| 25 |
|
import org.xwiki.velocity.internal.util.VelocityBlock.VelocityType; |
| 26 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 5 |
Complexity Density: 0.19 |
|
| 27 |
|
public class VelocityParserTest |
| 28 |
|
{ |
| 29 |
|
private VelocityParser parser; |
| 30 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 31 |
4 |
@Before... |
| 32 |
|
public void setUp() |
| 33 |
|
{ |
| 34 |
4 |
this.parser = new VelocityParser(); |
| 35 |
|
} |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
| 39 |
1 |
@Test... |
| 40 |
|
public void isValidVelocityIdentifierChar() |
| 41 |
|
{ |
| 42 |
1 |
Assert.assertTrue(this.parser.isValidVelocityIdentifierChar('a')); |
| 43 |
1 |
Assert.assertTrue(this.parser.isValidVelocityIdentifierChar('_')); |
| 44 |
1 |
Assert.assertTrue(this.parser.isValidVelocityIdentifierChar('-')); |
| 45 |
|
|
| 46 |
1 |
Assert.assertFalse(this.parser.isValidVelocityIdentifierChar('.')); |
| 47 |
|
} |
| 48 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 49 |
1 |
@Test... |
| 50 |
|
public void getKeyWordComment() throws InvalidVelocityException |
| 51 |
|
{ |
| 52 |
1 |
VelocityParserContext context = new VelocityParserContext(); |
| 53 |
1 |
StringBuffer buffer = new StringBuffer(); |
| 54 |
|
|
| 55 |
1 |
int index = this.parser.getKeyWord("## some comment\n ".toCharArray(), 0, buffer, context); |
| 56 |
|
|
| 57 |
1 |
Assert.assertEquals("## some comment\n".length(), index); |
| 58 |
1 |
Assert.assertEquals("## some comment\n", buffer.toString()); |
| 59 |
1 |
Assert.assertFalse(context.isInVelocityBlock()); |
| 60 |
1 |
Assert.assertEquals(VelocityType.COMMENT, context.getType()); |
| 61 |
|
} |
| 62 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 63 |
1 |
@Test... |
| 64 |
|
public void getKeyWordMultiLinesComment() throws InvalidVelocityException |
| 65 |
|
{ |
| 66 |
1 |
VelocityParserContext context = new VelocityParserContext(); |
| 67 |
1 |
StringBuffer buffer = new StringBuffer(); |
| 68 |
|
|
| 69 |
1 |
int index = this.parser.getKeyWord("#*\n some comment\n*# ".toCharArray(), 0, buffer, context); |
| 70 |
|
|
| 71 |
1 |
Assert.assertEquals("#*\n some comment\n*#".length(), index); |
| 72 |
1 |
Assert.assertEquals("#*\n some comment\n*#", buffer.toString()); |
| 73 |
1 |
Assert.assertFalse(context.isInVelocityBlock()); |
| 74 |
1 |
Assert.assertEquals(VelocityType.COMMENT, context.getType()); |
| 75 |
|
} |
| 76 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 77 |
1 |
@Test... |
| 78 |
|
public void getKeyWordDirective() throws InvalidVelocityException |
| 79 |
|
{ |
| 80 |
1 |
VelocityParserContext context = new VelocityParserContext(); |
| 81 |
1 |
StringBuffer buffer = new StringBuffer(); |
| 82 |
|
|
| 83 |
1 |
int index = this.parser.getKeyWord("#directive(param1 param2, param2) ".toCharArray(), 0, buffer, context); |
| 84 |
|
|
| 85 |
1 |
Assert.assertEquals("#directive(param1 param2, param2)".length(), index); |
| 86 |
1 |
Assert.assertEquals("#directive(param1 param2, param2)", buffer.toString()); |
| 87 |
1 |
Assert.assertFalse(context.isInVelocityBlock()); |
| 88 |
1 |
Assert.assertEquals(VelocityType.MACRO, context.getType()); |
| 89 |
|
} |
| 90 |
|
} |