01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.pluto.util.assemble.war;
18:
19: import java.io.File;
20: import java.io.IOException;
21: import java.net.URL;
22:
23: import org.apache.commons.io.FileUtils;
24: import org.apache.pluto.util.assemble.Assembler;
25: import org.apache.pluto.util.assemble.AssemblerConfig;
26: import org.apache.pluto.util.assemble.ArchiveBasedAssemblyTest;
27:
28: /**
29: * @version $Revision: 539020 $
30: */
31: public class WarAssemblerTest extends ArchiveBasedAssemblyTest {
32:
33: private static final String portletResource = "/org/apache/pluto/util/assemble/war/WarDeployerTestPortlet.war";
34: private File portletFile = null;
35:
36: protected void setUp() throws Exception {
37: final URL portletUrl = this .getClass().getResource(
38: portletResource);
39: this .portletFile = new File(portletUrl.getFile());
40: }
41:
42: protected void tearDown() throws Exception {
43: this .portletFile = null;
44: }
45:
46: public void testAssembleToNewDirectory() throws Exception {
47: AssemblerConfig config = new AssemblerConfig();
48:
49: config.setSource(this .portletFile);
50:
51: final File tempDir = getTempDir();
52: config.setDestination(tempDir);
53:
54: WarAssembler assembler = new WarAssembler();
55: assembler.assemble(config);
56:
57: //How to validate it worked?
58: }
59:
60: public void testAssembleOverSelf() throws Exception {
61: AssemblerConfig config = new AssemblerConfig();
62:
63: final File portletCopy = File.createTempFile(this .portletFile
64: .getName()
65: + ".", ".war");
66: portletCopy.deleteOnExit();
67: FileUtils.copyFile(this .portletFile, portletCopy);
68:
69: config.setSource(portletCopy);
70: config.setDestination(portletCopy.getParentFile());
71:
72: WarAssembler assembler = new WarAssembler();
73: assembler.assemble(config);
74:
75: //How to validate it worked?
76: }
77:
78: private File getTempDir() throws IOException {
79: final File tempFile = File.createTempFile("DoesNotMatter",
80: ".tmp");
81: tempFile.delete();
82: final File tempDir = tempFile.getParentFile();
83: return tempDir;
84: }
85:
86: protected Assembler getAssemblerUnderTest() {
87: return new WarAssembler();
88: }
89:
90: protected File getFileToAssemble() {
91: return portletFile;
92: }
93: }
|