Skip to content

Commit 4714595

Browse files
committed
Merge branch 'p120ph37-test-case-files'
2 parents d172081 + 93d8982 commit 4714595

File tree

2 files changed

+57
-9
lines changed

2 files changed

+57
-9
lines changed

src/test/java/org/redline_rpm/BuilderTest.java

+27
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
import org.redline_rpm.Scanner;
55
import org.redline_rpm.header.Format;
66
import org.redline_rpm.header.Header.HeaderTag;
7+
import org.redline_rpm.header.Header;
8+
import org.redline_rpm.payload.Directive;
79

810
import java.io.File;
911
import java.util.Arrays;
1012

13+
import static org.junit.Assert.assertArrayEquals;
1114
import static org.junit.Assert.assertEquals;
1215
import static org.junit.Assert.assertArrayEquals;
1316
import static org.redline_rpm.ScannerTest.channelWrapper;
@@ -33,6 +36,30 @@ public void testLongNameTruncation() throws Exception {
3336

3437
assertEquals("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", format.getLead().getName());
3538
}
39+
40+
@Test
41+
public void testFiles() throws Exception {
42+
Builder builder = new Builder();
43+
builder.setPackage("filestest", "1.0", "1");
44+
builder.setBuildHost( "localhost" );
45+
builder.setLicense( "GPL" );
46+
builder.setPlatform( NOARCH, LINUX );
47+
builder.setType( BINARY );
48+
builder.addFile( "/etc", new File("src/test/resources/prein.sh"), 0755, 0755,
49+
new Directive(Directive.RPMFILE_CONFIG | Directive.RPMFILE_DOC | Directive.RPMFILE_NOREPLACE),
50+
"jabberwocky", "vorpal");
51+
52+
builder.build( new File( getTargetDir()));
53+
54+
Format format = new Scanner().run(channelWrapper("target" + File.separator + "filestest-1.0-1.noarch.rpm"));
55+
56+
assertArrayEquals(new String[] { "jabberwocky" },
57+
(String[])format.getHeader().getEntry(Header.HeaderTag.FILEUSERNAME).getValues());
58+
assertArrayEquals(new String[] { "vorpal" },
59+
(String[])format.getHeader().getEntry(Header.HeaderTag.FILEGROUPNAME).getValues());
60+
assertArrayEquals(new int[] { Directive.RPMFILE_CONFIG | Directive.RPMFILE_DOC | Directive.RPMFILE_NOREPLACE },
61+
(int[])format.getHeader().getEntry(Header.HeaderTag.FILEFLAGS).getValues());
62+
}
3663

3764
@Test
3865
public void testBuildWithoutSignature() throws Exception {

src/test/java/org/redline_rpm/ant/RedlineTaskTest.java

+30-9
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,6 @@ public void testScripts() throws Exception {
319319
task.setPreUninstallScript(new File("src/test/resources/preun.sh"));
320320
task.setPostUninstallScript(new File("src/test/resources/postun.sh"));
321321

322-
RpmFileSet fs = new RpmFileSet();
323-
fs.setPrefix("/etc");
324-
fs.setFile(new File("src/test/resources/prein.sh"));
325-
fs.setConfig(true);
326-
fs.setNoReplace(true);
327-
fs.setDoc(true);
328-
329-
task.addRpmfileset(fs);
330-
331322
task.execute();
332323

333324
Format format = getFormat( filename );
@@ -345,6 +336,36 @@ public void testScripts() throws Exception {
345336
assertHeaderEquals("/bin/sh", format, Header.HeaderTag.POSTINPROG);
346337
assertHeaderEquals("/bin/sh", format, Header.HeaderTag.PREUNPROG);
347338
assertHeaderEquals("/usr/bin/perl", format, Header.HeaderTag.POSTUNPROG);
339+
}
340+
341+
@Test
342+
public void testFiles() throws Exception {
343+
344+
File dir = ensureTargetDir();
345+
346+
File filename = new File(dir, "rpmtest-1.0-1.noarch.rpm");
347+
348+
RedlineTask task = createBasicTask( dir );
349+
350+
RpmFileSet fs = new RpmFileSet();
351+
fs.setPrefix("/etc");
352+
fs.setFile(new File("src/test/resources/prein.sh"));
353+
fs.setConfig(true);
354+
fs.setNoReplace(true);
355+
fs.setDoc(true);
356+
fs.setUserName("jabberwocky");
357+
fs.setGroup("vorpal");
358+
359+
task.addRpmfileset(fs);
360+
361+
task.execute();
362+
363+
Format format = getFormat( filename );
364+
365+
assertArrayEquals(new String[] { "jabberwocky" },
366+
(String[])format.getHeader().getEntry(Header.HeaderTag.FILEUSERNAME).getValues());
367+
assertArrayEquals(new String[] { "vorpal" },
368+
(String[])format.getHeader().getEntry(Header.HeaderTag.FILEGROUPNAME).getValues());
348369

349370
int expectedFlags = Directive.RPMFILE_CONFIG | Directive.RPMFILE_DOC
350371
| Directive.RPMFILE_NOREPLACE;

0 commit comments

Comments
 (0)