KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > driver > velocity > VelocityScriptTest


1 /*
2  * Copyright 2006-2007 The Scriptella Project Team.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package scriptella.driver.velocity;
17
18 import scriptella.DBTestCase;
19 import scriptella.execution.EtlExecutor;
20 import scriptella.execution.EtlExecutorException;
21
22 import java.io.ByteArrayOutputStream JavaDoc;
23 import java.io.InputStream JavaDoc;
24 import java.io.OutputStream JavaDoc;
25 import java.net.URL JavaDoc;
26
27 /**
28  * Tests a script with velocity elements.
29  *
30  * @author Fyodor Kupolov
31  * @version 1.0
32  */

33 public class VelocityScriptTest extends DBTestCase {
34     /**
35      * This test runs a script and checks the output produces by the velocity connection.
36      * In-memory test URL tst:// is used to avoid file system operations.
37      */

38     public void test() throws EtlExecutorException {
39         final ByteArrayOutputStream JavaDoc out = new ByteArrayOutputStream JavaDoc();
40         testURLHandler = new TestURLHandler() {
41             public InputStream JavaDoc getInputStream(final URL JavaDoc u) {
42                 throw new UnsupportedOperationException JavaDoc();
43             }
44
45             public OutputStream JavaDoc getOutputStream(final URL JavaDoc u) {
46                 return out;
47             }
48
49             public int getContentLength(final URL JavaDoc u) {
50                 throw new UnsupportedOperationException JavaDoc();
51             }
52         };
53         getConnection("velocity");//just to shutdown at the end of the test
54
final EtlExecutor se = newEtlExecutor();
55         se.execute();
56         final String JavaDoc s = out.toString();
57         assertEquals("102030",s);
58     }
59
60 }
61
Popular Tags