1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codehaus.mojo.sql;
17
18 import java.util.Vector;
19
20 import org.apache.maven.plugin.MojoExecutionException;
21 import org.junit.Test;
22 import org.springframework.core.io.DefaultResourceLoader;
23 import org.springframework.core.io.Resource;
24
25
26
27
28 public class SqlExecMojoTest {
29 private SqlExecMojo mojo = new SqlExecMojo();
30
31 @Test
32 public void test1() throws MojoExecutionException {
33 try {
34 mojo.setResourceListingLocation("classpath:locations.listing");
35 SqlResource[] resources = mojo.getResources(null, mojo.getResourceListingLocation());
36 System.out.println(resources.length);
37 for (SqlResource resource : resources) {
38 System.out.println(resource.getResource().getDescription());
39 }
40 } catch (Exception e) {
41 e.printStackTrace();
42 }
43 }
44
45 @Test
46 public void test2() throws MojoExecutionException {
47 try {
48 mojo.setResourceListingLocation("classpath:locations.listing");
49 String[] locations = new String[] { "classpath:a.properties" };
50 SqlResource[] resources = mojo.getResources(locations, mojo.getResourceListingLocation());
51 System.out.println(resources.length);
52 for (SqlResource resource : resources) {
53 System.out.println(resource.getResource().getDescription());
54 }
55 } catch (Exception e) {
56 e.printStackTrace();
57 }
58 }
59
60 @Test
61 public void test3() throws MojoExecutionException {
62 try {
63 mojo.setResourceListingLocation("classpath:locations.listing");
64 mojo.addResourcesToTransactions();
65 Vector<SqlExecMojo.Transaction> transactions = mojo.transactions;
66 System.out.println(transactions.size());
67 for (SqlExecMojo.Transaction transaction : transactions) {
68 System.out.println("[" + transaction.resource.location + "] [" + transaction.resource.getResource().getURI() + "]");
69 }
70 DefaultResourceLoader loader = new DefaultResourceLoader();
71 Resource resource = loader.getResource(mojo.getResourceListingLocation());
72 System.out.println(resource.getURI());
73 } catch (Exception e) {
74 e.printStackTrace();
75 }
76 }
77 }