File: 05dsml.t

package info (click to toggle)
libnet-ldap-perl 1%3A0.6500%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,660 kB
  • ctags: 731
  • sloc: perl: 15,059; sh: 76; makefile: 5
file content (51 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!perl

use Test::More;
use File::Compare qw(compare_text);

BEGIN { require "t/common.pl" }


(eval { require XML::SAX::Base } && eval { require XML::SAX::Writer })
? plan tests => 1
: plan skip_all => 'XML::SAX::Base and XML::SAX::Writer need to be installed';


require Net::LDAP::LDIF;
require Net::LDAP::DSML;

my $infile   = "data/00-in.ldif";
my $outfile1 = "$TEMPDIR/05-out1.dsml";
my $cmpfile1 = "data/05-cmp.dsml";

my $ldif = Net::LDAP::LDIF->new($infile,"r");

@entry = $ldif->read;

open(FH,">$outfile1");
binmode FH;
my $dsml = Net::LDAP::DSML->new(output => \*FH,pretty_print => 1);

$dsml->write_entry($_) for @entry;

$dsml->end_dsml;
close(FH);

# postprocess generated DSML file for more flexible comparison
# (don't rely on unpatched XML::SAX::Writer [e.g. Debian])
{
open(FH, "+<$outfile1");
binmode FH;
local $/;	# slurp mode
my $txt = <FH>;

$txt =~ s/>\n[\n\t ]+/>\n/g;	# remove empty lines & leading spaces after tags
$txt =~ s/\"/'/g;	# convert " to ' in tag attribute values

seek(FH, 0, 0);
print FH $txt;
truncate(FH, length($txt));
close(FH);
}

ok(!compare_text($cmpfile1,$outfile1), $cmpfile1);