1 package org.apache.torque.generator.outlet.java;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static org.junit.Assert.assertEquals;
23
24 import org.apache.torque.generator.GeneratorException;
25 import org.apache.torque.generator.outlet.OutletResult;
26 import org.apache.torque.generator.qname.QualifiedName;
27 import org.junit.Before;
28 import org.junit.Test;
29
30
31
32
33 public class NewlineOutletTest
34 {
35
36 private NewlineOutlet newlineOutlet;
37
38 @Before
39 public void setUp()
40 {
41 this.newlineOutlet = new NewlineOutlet(new QualifiedName(
42 "org.apache.torque.generator.newlineOutlet"));
43 }
44
45 @Test
46 public void testDefault() throws GeneratorException
47 {
48 OutletResult result = newlineOutlet.execute(null);
49 assertEquals("\n", result.getStringResult());
50 }
51
52 @Test
53 public void testWindowsStyle() throws GeneratorException
54 {
55 newlineOutlet.setWindowsStyle(true);
56 OutletResult result = newlineOutlet.execute(null);
57 assertEquals("\r\n", result.getStringResult());
58 }
59
60 @Test()
61 public void testCountZero() throws GeneratorException
62 {
63 newlineOutlet.setCount(0);
64 OutletResult result = newlineOutlet.execute(null);
65 assertEquals("", result.getStringResult());
66 }
67
68 @Test(expected = GeneratorException.class)
69 public void testCountLessThanZero() throws GeneratorException
70 {
71 newlineOutlet.setCount(-1);
72 OutletResult result = newlineOutlet.execute(null);
73 assertEquals("\n", result.getStringResult());
74 }
75
76 @Test()
77 public void testCountFive() throws GeneratorException
78 {
79 newlineOutlet.setCount(5);
80 OutletResult result = newlineOutlet.execute(null);
81 assertEquals("\n\n\n\n\n", result.getStringResult());
82 }
83 }