Last change
on this file since 161 was 1, checked in by Wouter Pasman, 7 years ago |
Initial import : Genius 9.0.0
|
File size:
1.3 KB
|
Rev | Line | |
---|
[1] | 1 | package genius.domains;
|
---|
| 2 |
|
---|
| 3 | import static org.junit.Assert.assertTrue;
|
---|
| 4 |
|
---|
| 5 | import java.io.File;
|
---|
| 6 | import java.io.IOException;
|
---|
| 7 | import java.net.URISyntaxException;
|
---|
| 8 |
|
---|
| 9 | import org.junit.Test;
|
---|
| 10 |
|
---|
| 11 | public class DomainInstallerTest {
|
---|
| 12 | private final File domainrepo = new File("./domainrepository.xml");
|
---|
| 13 | private final File etc = new File("etc");
|
---|
| 14 | private final File partyprofile = new File("etc/templates/partydomain/party1_utility.xml");
|
---|
| 15 |
|
---|
| 16 | @Test
|
---|
| 17 | public void test() throws IOException, URISyntaxException {
|
---|
| 18 | if (domainrepo.exists()) {
|
---|
| 19 | domainrepo.delete();
|
---|
| 20 | }
|
---|
| 21 | if (etc.exists()) {
|
---|
| 22 | etc.delete();
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | DomainInstaller.run();
|
---|
| 26 | DomainInstaller.copyRecursively("/genius/templates", "etc");
|
---|
| 27 | assertTrue("domainrepo was not copied", domainrepo.exists());
|
---|
| 28 | assertTrue("etc (templates folder) was not copied", etc.exists());
|
---|
| 29 | assertTrue("party profile was not at expected location", partyprofile.exists());
|
---|
| 30 |
|
---|
| 31 | domainrepo.delete();
|
---|
| 32 | deleteFolder(etc);
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | /**
|
---|
| 36 | * Clean up a folder (...)
|
---|
| 37 | *
|
---|
| 38 | * @param folder
|
---|
| 39 | */
|
---|
| 40 | private void deleteFolder(File folder) {
|
---|
| 41 | File[] files = folder.listFiles();
|
---|
| 42 | if (files != null) { // some JVMs return null for empty dirs
|
---|
| 43 | for (File f : files) {
|
---|
| 44 | if (f.isDirectory()) {
|
---|
| 45 | deleteFolder(f);
|
---|
| 46 | } else {
|
---|
| 47 | f.delete();
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
| 51 | folder.delete();
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.