diff --git a/bin/slubsipbuilder.pl b/bin/slubsipbuilder.pl
index 932b8e3661bdb52e39eecbf93024d705ce87e006..2e0366445e4c6bbf278b2b0450eb9eba1a41233f 100755
--- a/bin/slubsipbuilder.pl
+++ b/bin/slubsipbuilder.pl
@@ -10,7 +10,7 @@
 # REQUIREMENTS: ---
 #         BUGS: ---
 #        NOTES: related to official document
-#               "SIP Spezifikation (v1.4.2)"
+#               "SIP Spezifikation (v1.5)"
 #       AUTHOR: Andreas Romeyke (romeyke@slub-dresden.de)
 # ORGANIZATION: SLUB
 #      VERSION: 1.1
@@ -18,7 +18,6 @@
 #===============================================================================
 
 
-
 use strict;
 use warnings;
 use Carp;
@@ -34,6 +33,8 @@ package SLUB::LZA::SIPBuilder;
     use XML::LibXSLT;
     use XML::XPath;
     use Carp;
+	use Encode;
+	
     my $marc_mods_url = 'http://www.loc.gov/standards/mods/v3/MARC21slim2MODS3-6.xsl';
     my $marc_utils_url = 'http://www.loc.gov/standards/marcxml/xslt/MARC21slimUtils.xsl';
     my $swb_url = 'https://sru.bsz-bw.de/swb';
@@ -45,7 +46,12 @@ package SLUB::LZA::SIPBuilder;
 
     # write data to file (UTF-8)
     sub write_file($$) {
-        my $filename = $_[0];
+		if(! defined $_[0]) { croak "filename not defined!"; }
+		if(! defined $_[1]) { croak "value not defined!"; }
+		if($_[0] eq "" || $_[1] eq ""){
+			die "invalid parameters.";
+		}
+		my $filename = $_[0];
         my $value = $_[1];
         open(my $fh, '>:encoding(UTF-8)', $filename) || (croak "Can't open '$filename', $!");
         print $fh $value;
@@ -55,6 +61,8 @@ package SLUB::LZA::SIPBuilder;
 
     # this will patch the mods-xml as a workaround for bugs in LOCs xslt files
     sub patch_mods($) {
+		if(! defined $_[0]) { croak "modsobject not defined!"; }
+		if($_[0] eq ""){ die "invalid parameters."; }
         my $modsobj = shift; # mods expected as XML Parser object
         # TODO: Bugfix for /mets:mets/mets:dmdSec[1]/mets:mdWrap[1]/mets:xmlData[1]/mods:modsCollection[1]/mods:mods[1]/mods:relatedItem[2]/mods:internetMediaType[1]
         my $xslt_patch_string = <<'PATCH';
@@ -86,6 +94,8 @@ PATCH
     }
 
     sub patch_marc_response($) {
+		if(! defined $_[0]) { croak "marcobject not defined!"; }
+		if($_[0] eq ""){ die "invalid parameters."; }
         my $marcobj = shift; # marcobj expected as XML Parser object
         my $xslt_patch_string = <<'PATCH2';
 <?xml version="1.0" encoding="UTF-8"?>
@@ -121,6 +131,11 @@ PATCH2
 
     # check MARC21 utility xsl
     sub check_marc21_utility {
+		if(! defined $_[0]) { croak "xsl directory not defined!"; }
+		if(! defined $_[1]) { croak "user agent not defined!"; }
+		if($_[0] eq "" || $_[1] eq ""){
+			die "invalid parameters.";
+		}
         my $xsl_dir = shift;
         my $ua = shift;
         my $marc_utils_basename = path($marc_utils_url)->basename;
@@ -140,6 +155,11 @@ PATCH2
 
     # check MARC21->MODS xsl
     sub check_marc21_mods_xsl {
+		if(! defined $_[0]) { croak "xsl directory not defined!"; }
+		if(! defined $_[1]) { croak "user agent not defined!"; }
+		if($_[0] eq "" || $_[1] eq ""){
+			die "invalid parameters.";
+		}
         my $xsl_dir = shift;
         my $ua = shift;
         my $marc_mods_basename = path($marc_mods_url)->basename;
@@ -176,18 +196,21 @@ PATCH2
 
     # specification SRU/SRW BSZ: https://wiki.k10plus.de/pages/viewpage.action?pageId=132874251
     sub get_mods_from($$$$) {
+		if(! defined $_[0]) { croak "url not defined!"; }
+		if(! defined $_[1]) { croak "ppn not defined!"; }
+		if(! defined $_[2]) { croak "key not defined!"; }
+		if(! defined $_[3]) { croak "schema not defined!"; }
+		if($_[0] eq "" || $_[1] eq "" || $_[2] eq "" || $_[3] eq ""){
+			die "invalid parameters.";
+		}
         # $mods = ($url, $ppn, $searchkey, $recordschema)
         my $url = shift;
         my $ppn = shift; # example: "457035137"  for "Der Fichtelberg"
         my $key = shift;
         my $schema = shift;
 
-
         #### where to find XSLT
-
-
-
-
+		
         my $ua = LWP::UserAgent->new;
         $ua->agent("MyApp/0.1 ");
         $ua->timeout(3600); #1h
@@ -196,7 +219,6 @@ PATCH2
         check_marc21_utility($xsl_dir, $ua);
         check_marc21_mods_xsl($xsl_dir, $ua);
 
-
         my $srubase = $url;      # host
         my $srusearchkey = $key; # SRU search key
         my $sruvalue = $ppn;
@@ -226,6 +248,7 @@ PATCH2
                 say "write DEBUG_${ppn}_marc.xml";
                 write_file("DEBUG_${ppn}_marc.xml", $marcblob_patched);
             }
+
             my $marc_mods_patched_path = check_marc21_mods_xsl($xsl_dir, $ua);
             my $xslt = XML::LibXSLT->new();
             my $marcmods = XML::LibXML->load_xml(location => $marc_mods_patched_path, no_cdata => 1);
@@ -236,7 +259,6 @@ PATCH2
                 say "write DEBUG_${ppn}_unpatched_mods.xml";
                 write_file("DEBUG_${ppn}_unpatched_mods.xml", $stylesheet->output_string($result));
             }
-
             $result = patch_mods($result);
             my $result_string = $stylesheet->output_string($result);
             return $result_string;
@@ -246,41 +268,47 @@ PATCH2
         }
         return;
     }
-
-sub create_filecopyhash {
-    my $directory = shift;
-    my $content = shift;
-    my %filecopyhash;
-    my $wanted=sub {
-        if (-d $_) {
-            # dir, do nothing
-            ();
-        } else {
-            my $file=$File::Find::name;
-            if ($file !~ m#^[-A-Za-z0-9_\.:\\/]+$#) {
-                confess("file '$file' does not match regex '^[-A-Za-z0-9_\.:\\/]+\$'");
-            }
-            my $source = $file;
-            $filecopyhash{$source}->{'source'}=$file;
-            $file=~s#^$directory/?##;
-            $filecopyhash{$source}{'relative'}="data/$file";
-            $filecopyhash{$source}{'target'}="$content/$file";
-            my $fh;
-            open($fh, "<", $source) or confess ("Can't open '$source', $!");
-            binmode($fh);
-            my $ctx = Digest::MD5->new;
-            $ctx->addfile(*$fh);
-            close ($fh);
-            my $md5 = $ctx->hexdigest;
-            $filecopyhash{$source}{'md5sum'}=$md5;
-        }
-    };
-
-    finddepth($wanted, $directory);
-    return \%filecopyhash;
-}
-
-    sub prepare_dmd_section_with_ppn ($) {
+	
+	sub create_filecopyhash {
+		if(! defined $_[0]) { croak "directory not defined!"; }
+		if(! defined $_[1]) { croak "content not defined!"; }
+		if($_[0] eq "" || $_[1] eq ""){
+			die "invalid parameters.";
+		}
+		my $directory = shift;
+		my $content = shift;
+		my %filecopyhash;
+		my $wanted=sub {
+			if (-d $_) {
+				# dir, do nothing
+				();
+			} else {
+				my $file=$File::Find::name;
+				# system unabhängige pfade
+				if ($file !~ m#^[-A-Za-z0-9_\.:\\/]+$#) {
+					confess("file '$file' does not match regex '^[-A-Za-z0-9_\.:\\/]+\$'");
+				}
+				my $source = $file;
+				$filecopyhash{$source}->{'source'}=$file;
+				$file=~s#^$directory/?##;
+				$filecopyhash{$source}{'relative'}="data/$file";
+				$filecopyhash{$source}{'target'}="$content/$file";
+				my $fh;
+				open($fh, "<", $source) or confess ("Can't open '$source', $!");
+				binmode($fh);
+				my $ctx = Digest::MD5->new;
+				$ctx->addfile(*$fh);
+				close ($fh);
+				my $md5 = $ctx->hexdigest;
+				$filecopyhash{$source}{'md5sum'}=$md5;
+			}
+		};
+		finddepth($wanted, $directory);
+		return \%filecopyhash;
+	}
+
+    sub prepare_dmd_section_with_ppn($) {
+		if(! defined $_[0]) { croak "ppn not defined!"; }
         my $ppn = shift;
         my $mods = SLUB::LZA::SIPBuilder::get_mods_from($swb_url, $ppn, $searchkey, $recordschema);
         if ($with_debug) {
@@ -301,7 +329,8 @@ DMD
         return $dmd;
     }
 
-    sub prepare_dmd_section_with_noppn ($) {
+    sub prepare_dmd_section_with_noppn($) {
+		if(! defined $_[0]) { croak "noppn not defined!"; }
         my $noppn = shift;
         my $mods =<<"MODS";
 <mods version="3.6"
@@ -325,19 +354,50 @@ DMD
     }
 
     sub prepare_amd_section($$$$$$) {
+		if(! defined $_[0]) { croak "export to archive date not defined!"; }
+		if(! defined $_[1]) { croak "external workflow not defined!"; }
+		if(! defined $_[2]) { croak "external id not defined!"; }
+		if(! defined $_[3]) { croak "external conservation flag not defined!"; }
+		if(! defined $_[4]) { croak "external isil not defined!"; }
+		if(! defined $_[5]) { croak "external value description not defined!"; }
+		if($_[0] eq "" || $_[1] eq "" || $_[2] eq "" || $_[3] eq "" || $_[5] eq ""){
+			die "invalid parameters.";
+		}
         my $export_to_archive_date = shift;
         my $external_workflow = shift;
         my $external_id = shift;
         my $external_conservation_flag = shift;
         my $external_isil = shift;
-        my $external_value_descr = shift;
-        my $amd =<<"AMD";
+        my $external_value_descr = decode_utf8(shift);
+		my $amd;
+		
+		if ($external_isil eq '') {
+			$amd =<<"AMD";
+<mets:amdSec ID="AMD">
+        <!-- SIP metadata for automated processing by submission application -->
+        <mets:techMD ID="ARCHIVE">
+            <mets:mdWrap MDTYPE="OTHER" MIMETYPE="text/xml" OTHERMDTYPE="ARCHIVE">
+                <mets:xmlData>
+                    <archive:record version="v2019.2" xmlns:archive="http://slub-dresden.de/slubarchiv">
+                        <archive:exportToArchiveDate>$export_to_archive_date</archive:exportToArchiveDate>
+                        <archive:externalId>$external_id</archive:externalId>
+                        <archive:externalWorkflow>$external_workflow</archive:externalWorkflow>
+                        <archive:hasConservationReason>$external_conservation_flag</archive:hasConservationReason>
+                        <archive:archivalValueDescription>$external_value_descr</archive:archivalValueDescription>
+                    </archive:record>
+                </mets:xmlData>
+            </mets:mdWrap>
+        </mets:techMD>
+    </mets:amdSec>
+AMD
+		} else {
+			$amd =<<"AMD";
 <mets:amdSec ID="AMD">
         <!-- SIP metadata for automated processing by submission application -->
         <mets:techMD ID="ARCHIVE">
             <mets:mdWrap MDTYPE="OTHER" MIMETYPE="text/xml" OTHERMDTYPE="ARCHIVE">
                 <mets:xmlData>
-                    <archive:record version="v2017.1" xmlns:archive="http://slub-dresden.de/slubarchiv">
+                    <archive:record version="v2019.2" xmlns:archive="http://slub-dresden.de/slubarchiv">
                         <archive:exportToArchiveDate>$export_to_archive_date</archive:exportToArchiveDate>
                         <archive:externalId>$external_id</archive:externalId>
                         <archive:externalWorkflow>$external_workflow</archive:externalWorkflow>
@@ -350,10 +410,12 @@ DMD
         </mets:techMD>
     </mets:amdSec>
 AMD
+		}
         return $amd;
     }
 
     sub prepare_files_sections($) {
+		if(! defined $_[0]) { croak "filecopyhash not defined!"; }
         my $filecopyhash = shift;
         my @fsec;
         my $i=0;
@@ -375,6 +437,7 @@ FILESEC
     }
 
     sub prepare_struct_map($) {
+		if(! defined $_[0]) { croak "filecopyhash not defined!"; }
         my $filecopyhash = shift;
         my @ssec;
         my $i=0;
@@ -395,6 +458,62 @@ STRUCTMAP
         return $structmap;
     }
 
+	sub check_directory($$) {
+		if(! defined $_[0]) { croak "fullname not defined!"; }
+		if(! defined $_[1]) { croak "entry not defined!"; }
+		if($_[0] eq "" || $_[1] eq ""){
+			die "invalid parameters.";
+		}
+		my $fullname = shift;
+		my $entry = shift;
+		my $dir_err = '';
+		# Die Gesamtlänge der relativen Pfade darf jeweils 255 Zeichen nicht übersteigen. 
+		if (length($fullname) > 255){ 
+			return $dir_err = "path to file: $fullname is too long, expected maximum 255 characters"; 
+		}
+		# Als Dateinamen und Verzeichnisnamen sind für die zu archivierenden Dateien die Zeichen A-Za-z0-9_.- sowie / für Verzeichnistrenner erlaubt.
+		if ($entry !~ m#^[A-Za-z0-9_.-]+$#){ 
+			return $dir_err = "you need to specify a valid file or directory (name: $entry) to (^[A-Za-z0-9_.-]+\$)"; 
+		}
+		# Relative Pfade mit Bestandteilen der Form "../" sind nicht erlaubt.
+		if ($fullname =~ /\.\.\//){ 
+			return $dir_err = "relativ path($fullname) in form '../' is not allowed"; 
+		}
+		return $dir_err;
+	}
+	
+	sub validate_directory($) {
+		if(! defined $_[0]) { croak "directory not defined!"; }
+		if(! -d $_[0]){
+			die "Could not find directory";
+		}
+		my $directory = shift;
+		my @dirs = ($directory);
+		my $dir_err = '';
+		while (@dirs && ($dir_err eq '')) {
+			my $thisdir = shift @dirs;
+			if (!($thisdir)) {
+				# dir, do nothing
+				return $dir_err='';
+			}
+			opendir (my $dh, $thisdir) or die "Could not find $thisdir";
+			while (my $entry = readdir $dh && ($dir_err eq '')) {
+				next if $entry eq '.';
+				next if $entry eq '..';
+				
+				my $fullname = "$thisdir/$entry";
+
+				$dir_err = check_directory($fullname, $entry);
+
+				if (-d $fullname) {
+					push @dirs, $fullname;
+				}
+			}
+			closedir $dh;
+		}
+		return $dir_err;
+	}
+
     # end package
 
 package main;
@@ -405,7 +524,6 @@ BEGIN{
 }
 return 1 if caller; # avoids main code running if module stuff is needed
 use SLUB::LZA::SIPBuilder;
-use Archive::Zip::SimpleZip qw($SimpleZipError);
 use Getopt::Long;
 use Path::Tiny;
 use Digest::MD5;
@@ -418,7 +536,6 @@ my $directory;
 my $ppn;
 my $noppn;
 my $output;
-my $as_zip;
 my $external_id;
 my $external_workflow;
 my $external_isil="";
@@ -428,52 +545,53 @@ my $external_conservation_flag;
 my $help;
 my $man;
 
-
 GetOptions(
-    "IE_directory=s"                => \$directory,                     # required
-    "ppn=s"                         => \$ppn,                           # semi-optional (choice 1 of 2)
-    "noppn=s"                       => \$noppn,                         # semi-optional (choice 2 of 2)
-    "SIP_output_path=s"             => \$output,                        # required
-    "as_zip"                        => \$as_zip,                        # optional, default: do not zip
-    "external_id=s"                 => \$external_id,                   # required
-    "external_workflow=s"           => \$external_workflow,             # required
-    "external_ISIL=s"               => \$external_isil,                 # optional, default: no ISIL
-    "external_value_descr=s"        => \$external_value_descr,          # required
-    "external_conservation_flag"    => \$external_conservation_flag,    # optional, default: no special conservation
-    "debug"                         => \$SLUB::LZA::SIPBuilder::with_debug,                    # optional
-    "help|?"                        => \$help,                          # optional
-    "man"                           => \$man,                           # optional
+    "IE_directory=s"                => \$directory,                     	# required
+    "ppn=s"                         => \$ppn,                           	# semi-optional (choice 1 of 2)
+    "noppn=s"                       => \$noppn,                         	# semi-optional (choice 2 of 2)
+    "SIP_output_path=s"             => \$output,                        	# required
+    "external_id=s"                 => \$external_id,                   	# required
+    "external_workflow=s"           => \$external_workflow,             	# required
+    "external_ISIL=s"               => \$external_isil,                 	# optional, default: no ISIL
+    "external_value_descr=s"        => \$external_value_descr,          	# required
+    "external_conservation_flag"    => \$external_conservation_flag,    	# optional, default: no special conservation
+    "debug"                         => \$SLUB::LZA::SIPBuilder::with_debug, # optional
+    "help|?"                        => \$help,                          	# optional
+    "man"                           => \$man,                           	# optional
 ) or pod2usage(2);
 
+my $dir_err = SLUB::LZA::SIPBuilder::validate_directory($directory);
+
 if ($help)                                  { pod2usage(1); }
 if ($man)                                   { pod2usage(-exitval => 0, -verbose => 2); }
 if (!defined $directory)                    { confess("you need to specify an IE directory, which needs to be archived"); }
+if ((defined $directory) && ($dir_err ne '')) { confess($dir_err); }
 if ((defined $ppn) && (defined $noppn))     { confess("you can only specify either -ppn or -noppn"); }
 if ((!defined $ppn) && (!defined $noppn))   { confess("you need to specify a PPN with -ppn or use --noppn"); }
 if (!defined $output)                       { confess("you need to specify an output path, where the SIP will be stored"); }
+if (!defined $external_id)					{ confess("you need to specify external ID"); }
+if ((defined $external_id) && ($external_id !~ m#^[a-z0-9_-]+$#)) { confess("you need to specify a valid external ID (^[a-z0-9_-]+\$)"); }
+if (!defined $external_workflow)			{ confess("you need to specify external workflow"); }
+if ((defined $external_workflow) && ($external_workflow !~ m#^[a-z0-9_-]+$#)) { confess("you need to specify a valid external workflow (^[a-z0-9_-]+\$)"); }
+if (!$external_value_descr)                 { confess("you need to specify an external value description (reason for archiving)"); }
 if (!defined $external_conservation_flag)   { $external_conservation_flag="false"; } else { $external_conservation_flag="true"; }
 if (! -d $directory)                        { confess("you need to specify an IE directory, which needs to be archived, $!"); }
 $directory = path($directory)->realpath->stringify;
 path($output)->mkpath;
 $output = path($output)->realpath->stringify;
-if ($external_id !~ m#^[a-z0-9]+$#)         { confess("you need to specify a valid external ID (^[a-z0-9]+\$)"); }
-if ($external_workflow !~ m#^[a-z0-9]+$#)   { confess("you need to specify a valid external workflow (^[a-z0-9]+\$)"); }
-if (!$external_value_descr)                 { confess("you need to specify an external value description (reason for archiving)"); }
 
 #===============================================================================
 
 sub main {
     # get date
-    my $export_to_archive_date = DateTime->now->iso8601();
+    my $export_to_archive_date = DateTime->now(time_zone=>'local')->iso8601();
     my $file_date = $export_to_archive_date;
     $file_date =~ s/T/_/g; # replace 'T' with '_'
     $file_date =~ s/:/-/g; # replace ':' with '-'
     # prepare dirs
     my $sip_root_dir = (defined $ppn)? "PPN-${ppn}_${file_date}" : "ID-${noppn}_${file_date}";
     my $content = path($output)->child($sip_root_dir)->child("data")->stringify;
-    if (!defined $as_zip) {
-        path($content)->mkpath;
-    }
+    path($content)->mkpath;
     my $filecopyhash = SLUB::LZA::SIPBuilder::create_filecopyhash($directory, $content);
 
     # prepare dmd-sec
@@ -505,34 +623,18 @@ sub main {
 METS
 
     # write stuff out
-    if (!defined $as_zip) {
-        SLUB::LZA::SIPBuilder::write_file( path($output)->child($sip_root_dir)->child("sip.xml")->stringify, $sip );
-        # copy source to target
-        foreach my $source (sort keys (%{$filecopyhash})) {
-            my $target = path($filecopyhash->{$source}->{"target"})->stringify; # CHECK ON WINDOWS
-            my $basename = path($target)->parent->stringify;
-            if (! -d $basename) {
-                path($basename)->mkpath;
-            }
-            cp($source, $target, buffer) || confess ("could not copy from '$source' to '$target', $!");
-        }
-        say "SIP '$sip_root_dir' build successfully in '$output'";
-    } else {
-        # compress it
-        my $zip_file_path = path($output)->child("$sip_root_dir.zip")->stringify;
-        my $zip = Archive::Zip::SimpleZip->new( $zip_file_path, Zip64=>1 );
-        $zip->addString($sip, Name=>path($sip_root_dir)->child("sip.xml")->stringify);
-        # copy source to target
-        foreach my $source (sort keys (%{$filecopyhash})) {
-            my $target = path($sip_root_dir)->child($filecopyhash->{$source}->{"relative"})->stringify; # CHECK ON WINDOWS
-            my $basename = path($target)->parent->stringify;
-            $zip->add( $source, Name=> $target) || confess ("could not zip copy from '$source' to '$target', $!");
-        }
-        unless ( $zip->close()) {
-               confess "write error to '$zip_file_path', $SimpleZipError, $!";
-        }
-        say "SIP '$sip_root_dir' build successfully in '$zip_file_path'";
-    }
+	SLUB::LZA::SIPBuilder::write_file( path($output)->child($sip_root_dir)->child("sip.xml")->stringify, $sip );
+	# copy source to target
+	foreach my $source (sort keys (%{$filecopyhash})) {
+		my $target = path($filecopyhash->{$source}->{"target"})->stringify; # CHECK ON WINDOWS
+		my $basename = path($target)->parent->stringify;
+		if (! -d $basename) {
+			path($basename)->mkpath;
+		}
+		cp($source, $target, buffer) || confess ("could not copy from '$source' to '$target', $!");
+	}
+	say "SIP '$sip_root_dir' build successfully in '$output'";
+    
     return;
 }
 
@@ -563,7 +665,6 @@ slubsipbuilder.pl  [options]
         -IE_directory=<IE dir>          existing IE directory (absolute path!)
         -ppn=<ppn>|-noppn=<noppn>       SWB-PPN or any identifier (uses minimalistic MODS)
         -SIP_output_path=<target dir>   where to put the SIP dir (absolute path!)
-        -as_zip                         optional, if set a ZIP will be created
         -external_id=<id>               mandatory, should be uniqe ID
         -external_workflow=<workflow>   mandatory, should be uniqe workflow name
         -external_ISIL=<isil>           optional, ISIL number of library
diff --git a/t/slubsipbuilder.t b/t/slubsipbuilder.t
old mode 100644
new mode 100755
index 30945bcd0abe33b68370ab5210f351f0f4a5525f..ced09ce006cbae2d61af23b3f0fba1c415121a11
--- a/t/slubsipbuilder.t
+++ b/t/slubsipbuilder.t
@@ -3,11 +3,16 @@ use strict;
 use warnings;
 use diagnostics;
 
-use Test::More tests => 8;
+use Test::More tests => 78;
+use Test::Output;
 use Test::Exception;
 use Test::File;
 use Path::Tiny;
 
+# *** Read before running tests ***
+# Warning: While running project "SLUB_SIP_Builder" two directories "export_dir_kitodo" and "tmp/mysip" will be created.
+# Start scipt in the project directory to run all tests properly. 
+
 ### prepare
 BEGIN {
     use Path::Tiny;
@@ -310,17 +315,382 @@ my $patched_marcblob =<<'PATCHED_MARCBLOB';
 PATCHED_MARCBLOB
 my $unpatched_marcblob_obj = XML::LibXML->load_xml(string => $unpatched_marcblob);
 
-### tests
-BEGIN { use_ok("SLUB::LZA::SIPBuilder"); }
-like(SLUB::LZA::SIPBuilder::get_mods_from("https://sru.bsz-bw.de/swb", "457035137", "pica.swn", "marcxmlvbos"), qr//, "get_mods_from()");
-is(SLUB::LZA::SIPBuilder::patch_mods($unpatched_mods_obj), $patched_mods, "patch_mods()" );
-is(SLUB::LZA::SIPBuilder::patch_marc_response($unpatched_marcblob_obj), $patched_marcblob, "patch_marc_response()");
-# ensure no dir exists, then run test
+my $unpatched_marc21slimutils = <<'UNPATCHED_MARC21SLIMUTIL';
+<?xml version='1.0'?>
+<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+	<!-- 08/08/08: tmee added corrected chopPunctuation templates for 260c -->
+	<!-- 08/19/04: ntra added "marc:" prefix to datafield element -->
+	<!-- 12/14/07: ntra added url encoding template -->
+	<!-- url encoding -->
+
+	<xsl:variable name="ascii">
+		<xsl:text> !"#$%&amp;'()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</xsl:text>
+	</xsl:variable>
+
+	<xsl:variable name="latin1">
+		<xsl:text> ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ</xsl:text>
+	</xsl:variable>
+	<!-- Characters that usually don't need to be escaped -->
+	<xsl:variable name="safe">
+		<xsl:text>!'()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~</xsl:text>
+	</xsl:variable>
+
+	<xsl:variable name="hex">0123456789ABCDEF</xsl:variable>
+
+
+	<xsl:template name="datafield">
+		<xsl:param name="tag"/>
+		<xsl:param name="ind1">
+			<xsl:text> </xsl:text>
+		</xsl:param>
+		<xsl:param name="ind2">
+			<xsl:text> </xsl:text>
+		</xsl:param>
+		<xsl:param name="subfields"/>
+		<xsl:element name="marc:datafield">
+			<xsl:attribute name="tag">
+				<xsl:value-of select="$tag"/>
+			</xsl:attribute>
+			<xsl:attribute name="ind1">
+				<xsl:value-of select="$ind1"/>
+			</xsl:attribute>
+			<xsl:attribute name="ind2">
+				<xsl:value-of select="$ind2"/>
+			</xsl:attribute>
+			<xsl:copy-of select="$subfields"/>
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template name="subfieldSelect">
+		<xsl:param name="codes">abcdefghijklmnopqrstuvwxyz</xsl:param>
+		<xsl:param name="delimeter">
+			<xsl:text> </xsl:text>
+		</xsl:param>
+		<xsl:variable name="str">
+			<xsl:for-each select="marc:subfield">
+				<xsl:if test="contains($codes, @code)">
+					<xsl:value-of select="text()"/>
+					<xsl:value-of select="$delimeter"/>
+				</xsl:if>
+			</xsl:for-each>
+		</xsl:variable>
+		<xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
+	</xsl:template>
+
+	<xsl:template name="buildSpaces">
+		<xsl:param name="spaces"/>
+		<xsl:param name="char">
+			<xsl:text> </xsl:text>
+		</xsl:param>
+		<xsl:if test="$spaces>0">
+			<xsl:value-of select="$char"/>
+			<xsl:call-template name="buildSpaces">
+				<xsl:with-param name="spaces" select="$spaces - 1"/>
+				<xsl:with-param name="char" select="$char"/>
+			</xsl:call-template>
+		</xsl:if>
+	</xsl:template>
+
+	<xsl:template name="chopPunctuation">
+		<xsl:param name="chopString"/>
+		<xsl:param name="punctuation">
+			<xsl:text>.:,;/ </xsl:text>
+		</xsl:param>
+		<xsl:variable name="length" select="string-length($chopString)"/>
+		<xsl:choose>
+			<xsl:when test="$length=0"/>
+			<xsl:when test="contains($punctuation, substring($chopString,$length,1))">
+				<xsl:call-template name="chopPunctuation">
+					<xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
+					<xsl:with-param name="punctuation" select="$punctuation"/>
+				</xsl:call-template>
+			</xsl:when>
+			<xsl:when test="not($chopString)"/>
+			<xsl:otherwise>
+				<xsl:value-of select="$chopString"/>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+
+	<xsl:template name="chopPunctuationFront">
+		<xsl:param name="chopString"/>
+		<xsl:variable name="length" select="string-length($chopString)"/>
+		<xsl:choose>
+			<xsl:when test="$length=0"/>
+			<xsl:when test="contains('.:,;/[ ', substring($chopString,1,1))">
+				<xsl:call-template name="chopPunctuationFront">
+					<xsl:with-param name="chopString" select="substring($chopString,2,$length - 1)"
+					/>
+				</xsl:call-template>
+			</xsl:when>
+			<xsl:when test="not($chopString)"/>
+			<xsl:otherwise>
+				<xsl:value-of select="$chopString"/>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+
+	<xsl:template name="chopPunctuationBack">
+		<xsl:param name="chopString"/>
+		<xsl:param name="punctuation">
+			<xsl:text>.:,;/] </xsl:text>
+		</xsl:param>
+		<xsl:variable name="length" select="string-length($chopString)"/>
+		<xsl:choose>
+			<xsl:when test="$length=0"/>
+			<xsl:when test="contains($punctuation, substring($chopString,$length,1))">
+				<xsl:call-template name="chopPunctuation">
+					<xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
+					<xsl:with-param name="punctuation" select="$punctuation"/>
+				</xsl:call-template>
+			</xsl:when>
+			<xsl:when test="not($chopString)"/>
+			<xsl:otherwise>
+				<xsl:value-of select="$chopString"/>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+
+	<!-- nate added 12/14/2007 for lccn.loc.gov: url encode ampersand, etc. -->
+	<xsl:template name="url-encode">
+
+		<xsl:param name="str"/>
+
+		<xsl:if test="$str">
+			<xsl:variable name="first-char" select="substring($str,1,1)"/>
+			<xsl:choose>
+				<xsl:when test="contains($safe,$first-char)">
+					<xsl:value-of select="$first-char"/>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:variable name="codepoint">
+						<xsl:choose>
+							<xsl:when test="contains($ascii,$first-char)">
+								<xsl:value-of
+									select="string-length(substring-before($ascii,$first-char)) + 32"
+								/>
+							</xsl:when>
+							<xsl:when test="contains($latin1,$first-char)">
+								<xsl:value-of
+									select="string-length(substring-before($latin1,$first-char)) + 160"/>
+								<!-- was 160 -->
+							</xsl:when>
+							<xsl:otherwise>
+								<xsl:message terminate="no">Warning: string contains a character
+									that is out of range! Substituting "?".</xsl:message>
+								<xsl:text>63</xsl:text>
+							</xsl:otherwise>
+						</xsl:choose>
+					</xsl:variable>
+					<xsl:variable name="hex-digit1"
+						select="substring($hex,floor($codepoint div 16) + 1,1)"/>
+					<xsl:variable name="hex-digit2" select="substring($hex,$codepoint mod 16 + 1,1)"/>
+					<!-- <xsl:value-of select="concat('%',$hex-digit2)"/> -->
+					<xsl:value-of select="concat('%',$hex-digit1,$hex-digit2)"/>
+				</xsl:otherwise>
+			</xsl:choose>
+			<xsl:if test="string-length($str) &gt; 1">
+				<xsl:call-template name="url-encode">
+					<xsl:with-param name="str" select="substring($str,2)"/>
+				</xsl:call-template>
+			</xsl:if>
+		</xsl:if>
+	</xsl:template>
+</xsl:stylesheet>
+<!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
+<metaInformation>
+<scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
+</metaInformation>
+-->
+UNPATCHED_MARC21SLIMUTIL
+
+my $structmap_res = "<mets:structMap TYPE=\"PHYSICAL\">
+  <mets:div ID=\"PHYS_0000\" TYPE=\"ieDir\">
+  <mets:div ID=\"PHYS_000000000000000_LZA\" TYPE=\"fileorderSequence\">
+<mets:fptr FILEID=\"FILE_000000000000000_LZA\" />
+</mets:div>
+  </mets:div>
+</mets:structMap>
+";
+
+my $filesec_res = "<mets:fileSec>
+  <mets:fileGrp USE=\"LZA\">
+  <mets:file ID=\"FILE_000000000000000_LZA\" CHECKSUMTYPE=\"MD5\" CHECKSUM=\"d41d8cd98f00b204e9800998ecf8427e\">
+<mets:FLocat xmlns:xlink=\"http://www.w3.org/1999/xlink\" LOCTYPE=\"URL\" xlink:href=\"file://data/test.txt\"/>
+</mets:file>
+  </mets:fileGrp>
+</mets:fileSec>
+";
+
+my $noppn_dmd_res = "<mets:dmdSec ID=\"DMDLOG_0000\">
+  <!-- bibliographic metadata -->
+  <mets:mdWrap MDTYPE=\"MODS\">
+    <mets:xmlData>
+      <mods version=\"3.6\"
+    xmlns=\"http://www.loc.gov/mods/v3\"
+    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
+    xsi:schemaLocation=\"http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd\">
+    <identifier>string</identifier>
+</mods>
+
+    </mets:xmlData>
+  </mets:mdWrap>
+</mets:dmdSec>
+";
+
+# preparation
 my $xsl_path = path(__FILE__)->parent->parent->child('xsl');
+my $export_dir_kitodo_path = path(__FILE__)->parent->parent->child('export_dir_kitodo');
+my $valid_ie_dir = "10_00-8";
+my $not_valid_ie_dir = "10_00-8+";
+my $valid_ie_dir_path = $export_dir_kitodo_path->absolute . "/" . $valid_ie_dir;
+my $not_valid_ie_dir_path = $export_dir_kitodo_path->absolute . "/" . $not_valid_ie_dir;
+my $file = "test.txt";
+my $file2 = "test+.txt";
+if(! -d $export_dir_kitodo_path) { 
+	mkdir $export_dir_kitodo_path or die "Error creating directory: $export_dir_kitodo_path";
+	if(! -d $export_dir_kitodo_path->child($valid_ie_dir)) {
+		mkdir $export_dir_kitodo_path->child($valid_ie_dir) or die "Error creating directory: $export_dir_kitodo_path->child($valid_ie_dir)";
+		if(! -f $export_dir_kitodo_path->child($valid_ie_dir)->child($file)) { 
+			open FILE, '>'.$export_dir_kitodo_path->child($valid_ie_dir)->child($file) or die "Unable to create $file"; 
+			close FILE; 
+		}
+	}
+	if(! -d $export_dir_kitodo_path->child($not_valid_ie_dir)) {
+		mkdir $export_dir_kitodo_path->child($not_valid_ie_dir) or die "Error creating directory: $export_dir_kitodo_path->child($not_valid_ie_dir)";
+		if(! -f $export_dir_kitodo_path->child($not_valid_ie_dir)->child($file2)) { 
+			open FILE, '>'.$export_dir_kitodo_path->child($not_valid_ie_dir)->child($file2) or die "Unable to create $file"; 
+			close FILE; 
+		}
+	}
+}
+my $mysip_path = path(__FILE__)->parent->parent->child('tmp')->child('mysip');
+if(! -d $mysip_path->parent) { mkdir $mysip_path->parent or die "Error creating directory: tmp";}
+if(! -d $mysip_path) { mkdir $mysip_path or die "Error creating directory: $mysip_path";}
+
+#~ structure of input output folders
+#~ .
+#~ ├── export_dir_kitodo
+#~ │   ├── 10_00-8
+#~ │   │   └── test.txt
+#~ │   │   
+#~ │   └── 10_00-8+
+#~ │	   └── test+.txt
+#~ └── tmp
+#~	   └── mysip
+
+my $ua = LWP::UserAgent->new;
+my $request = HTTP::Request->new('GET' => "https://sru.bsz-bw.de/swbf");
+my $response = $ua->request($request);
+my $marc21slimutils_file = $xsl_path->child('MARC21slimUtils.xsl');
+my $useragent_obj = LWP::UserAgent->new;
+$useragent_obj->agent("MyApp/0.1 ");
+$useragent_obj->timeout(3600); #1h
+my $filecopyhash = SLUB::LZA::SIPBuilder::create_filecopyhash($valid_ie_dir_path, $mysip_path->absolute . "/PPN-457035137_2019-10-14_08-46-50/data");
+# ensure no dir exists, then run test
 if ($xsl_path->is_dir) { $xsl_path->remove_tree; }
+
+### tests
+BEGIN { use_ok("SLUB::LZA::SIPBuilder"); }
+#
 is(SLUB::LZA::SIPBuilder::check_xsl_directory(), $xsl_path->absolute, "check_xsl_directory(), return value if not exist");
 ok($xsl_path->is_dir, "check_xsl_directory(), created if not exist");
 is(SLUB::LZA::SIPBuilder::check_xsl_directory(), $xsl_path->absolute, "check_xsl_directory(), return value if exist");
 ok($xsl_path->is_dir, "check_xsl_directory(), untouched if exist");
+#
+SKIP: {
+	skip "No response from server https://sru.bsz-bw.de/swb", 1 unless ! $response->is_error;
+	like(SLUB::LZA::SIPBuilder::get_mods_from("https://sru.bsz-bw.de/swb", "457035137", "pica.swn", "marcxmlvbos"), qr//, "get_mods_from()");
+};
+throws_ok{ SLUB::LZA::SIPBuilder::get_mods_from("", "457035137", "pica.swn", "marcxmlvbos"); } qr/invalid parameters/, "get_mods_from(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::get_mods_from("https://sru.bsz-bw.de/swb", "", "pica.swn", "marcxmlvbos"); } qr/invalid parameters/, "get_mods_from(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::get_mods_from("https://sru.bsz-bw.de/swb", "457035137", "", "marcxmlvbos"); } qr/invalid parameters/, "get_mods_from(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::get_mods_from("https://sru.bsz-bw.de/swb", "457035137", "pica.swn", ""); } qr/invalid parameters/, "get_mods_from(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::get_mods_from(undef, "457035137", "pica.swn", "marcxmlvbos"); } qr/url not defined/, "get_mods_from(\$url, \$ppn, \$key, \$schema), url undef";
+throws_ok{ SLUB::LZA::SIPBuilder::get_mods_from("https://sru.bsz-bw.de/swb", undef, "pica.swn", "marcxmlvbos"); } qr/ppn not defined/, "get_mods_from(\$url, \$ppn, \$key, \$schema), ppn undef";
+throws_ok{ SLUB::LZA::SIPBuilder::get_mods_from("https://sru.bsz-bw.de/swb", "457035137", undef, "marcxmlvbos"); } qr/key not defined/, "get_mods_from(\$url, \$ppn, \$key, \$schema), key undef";
+throws_ok{ SLUB::LZA::SIPBuilder::get_mods_from("https://sru.bsz-bw.de/swb", "457035137", "pica.swn", undef); } qr/schema not defined/, "get_mods_from(\$url, \$ppn, \$key, \$schema), schema undef";
+#
+ok(SLUB::LZA::SIPBuilder::write_file($marc21slimutils_file, $unpatched_marc21slimutils), "write_file()");
+throws_ok{ SLUB::LZA::SIPBuilder::write_file("", $unpatched_marc21slimutils); } qr/invalid parameters/, "write_file(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::write_file($marc21slimutils_file, ""); } qr/invalid parameters/, "write_file(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::write_file(undef, $unpatched_marc21slimutils); } qr/filename not defined/, "write_file(\$filename, \$value), filename undef";
+throws_ok{ SLUB::LZA::SIPBuilder::write_file($marc21slimutils_file, undef); } qr/value not defined/, "write_file(\$filename, \$value), value undef";
+#
+is(SLUB::LZA::SIPBuilder::patch_mods($unpatched_mods_obj), $patched_mods, "patch_mods()");
+throws_ok{ SLUB::LZA::SIPBuilder::patch_mods(""); } qr/invalid parameters/, "patch_mods(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::patch_mods(undef); } qr/modsobject not defined/, "patch_mods(\$modsobj), modsobj undef";
+#
+is(SLUB::LZA::SIPBuilder::patch_marc_response($unpatched_marcblob_obj), $patched_marcblob, "patch_marc_response()");
+throws_ok{ SLUB::LZA::SIPBuilder::patch_marc_response(""); } qr/invalid parameters/, "patch_marc_response(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::patch_marc_response(undef); } qr/marcobject not defined/, "patch_marc_response(\$marcobj), marcobj undef";
+#
+is(SLUB::LZA::SIPBuilder::check_marc21_utility($xsl_path, $useragent_obj), $marc21slimutils_file , "check_marc21_utility()");
+throws_ok{ SLUB::LZA::SIPBuilder::check_marc21_utility("", $useragent_obj); } qr/invalid parameters/, "check_marc21_utility(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::check_marc21_utility($xsl_path, ""); } qr/invalid parameters/, "check_marc21_utility(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::check_marc21_utility(undef, $useragent_obj); } qr/xsl directory not defined/, "check_marc21_utility(\$xsl_dir, \$useragent), xsl_dir undef";
+throws_ok{ SLUB::LZA::SIPBuilder::check_marc21_utility($xsl_path, undef); } qr/user agent not defined/, "check_marc21_utility(\$xsl_dir, \$useragent), useragent undef";
+#
+is(SLUB::LZA::SIPBuilder::check_marc21_mods_xsl($xsl_path, $useragent_obj), 'xsl/MARC21slim2MODS3-6.patched.xsl' , "check_marc21_mods_xsl()");
+throws_ok{ SLUB::LZA::SIPBuilder::check_marc21_mods_xsl("", $useragent_obj); } qr/invalid parameters/, "check_marc21_mods_xsl(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::check_marc21_mods_xsl($xsl_path, ""); } qr/invalid parameters/, "check_marc21_mods_xsl(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::check_marc21_mods_xsl(undef, $useragent_obj); } qr/xsl directory not defined/, "check_marc21_mods_xsl(\$xsl_dir, \$useragent), xsl_dir undef";
+throws_ok{ SLUB::LZA::SIPBuilder::check_marc21_mods_xsl($xsl_path, undef); } qr/user agent not defined/, "check_marc21_mods_xsl(\$xsl_dir, \$useragent), useragent undef";
+#
+like(SLUB::LZA::SIPBuilder::create_filecopyhash($valid_ie_dir_path, $mysip_path->absolute . "/PPN-457035137_2019-10-14_08-46-50/data"), qr/HASH/, "create_filecopyhash()");
+throws_ok{ SLUB::LZA::SIPBuilder::create_filecopyhash("", $mysip_path->absolute . "/PPN-457035137_2019-10-14_08-46-50/data"); } qr/invalid parameters/, "create_filecopyhash(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::create_filecopyhash($valid_ie_dir_path, ""); } qr/invalid parameters/, "create_filecopyhash(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::create_filecopyhash($valid_ie_dir_path, undef); } qr/content not defined/, "create_filecopyhash(\$directory, \$content), content undef";
+throws_ok{ SLUB::LZA::SIPBuilder::create_filecopyhash(undef, $mysip_path->absolute . "/PPN-number_date_time/data"); } qr/directory not defined/, "create_filecopyhash(\$directory, \$content), directory undef";
+#
+SKIP: {
+	skip "No response from server https://sru.bsz-bw.de/swb", 1 unless ! $response->is_error;
+	like(SLUB::LZA::SIPBuilder::prepare_dmd_section_with_ppn("457035137"), qr//, "prepare_dmd_section_with_ppn()");
+};
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_dmd_section_with_ppn(""); } qr/invalid parameters/, "prepare_dmd_section_with_ppn(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_dmd_section_with_ppn(undef); } qr/ppn not defined/, "prepare_dmd_section_with_ppn(\$ppn), ppn undef";
+#
+ok(SLUB::LZA::SIPBuilder::prepare_dmd_section_with_noppn("string") eq $noppn_dmd_res, "prepare_dmd_section_with_noppn()");
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_files_sections(""); } qr/Can't use string/, "prepare_dmd_section_with_noppn(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_dmd_section_with_noppn(undef); } qr/noppn not defined/, "prepare_dmd_section_with_noppn(\$noppn), noppn undef";
+#
+like(SLUB::LZA::SIPBuilder::prepare_amd_section("2019-10-14T13:33:56", "kitodo", "10008", "false", "DE-14", "Gesetzlicher Auftrag"), qr//, "prepare_amd_section()");
+like(SLUB::LZA::SIPBuilder::prepare_amd_section("2019-10-14T13:33:56", "kitodo", "10008", "false", "", "Gesetzlicher Auftrag"), qr//, "prepare_amd_section() with no externel_isil");
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_amd_section("", "kitodo", "10008", "false", "DE-14", "Gesetzlicher Auftrag"); } qr/invalid parameters/, "prepare_amd_section(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_amd_section("2019-10-14T13:33:56", "", "10008", "false", "DE-14", "Gesetzlicher Auftrag"); } qr/invalid parameters/, "prepare_amd_section(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_amd_section("2019-10-14T13:33:56", "kitodo", "", "false", "DE-14", "Gesetzlicher Auftrag"); } qr/invalid parameters/, "prepare_amd_section(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_amd_section("2019-10-14T13:33:56", "kitodo", "10008", "", "DE-14", "Gesetzlicher Auftrag"); } qr/invalid parameters/, "prepare_amd_section(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_amd_section("2019-10-14T13:33:56", "kitodo", "10008", "false", "DE-14", ""); } qr/invalid parameters/, "prepare_amd_section(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_amd_section(undef, "kitodo", "10008", "false", "DE-14", "Gesetzlicher Auftrag"); } qr/export to archive date not defined/, "prepare_amd_section(\$export_to_archive_date, \$external_workflow, \$external_id, \$external_conservation_flag, \$external_isil, \$external_value_descr), export_to_archive_date undef";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_amd_section("2019-10-14T13:33:56", undef, "10008", "false", "DE-14", "Gesetzlicher Auftrag"); } qr/external workflow not defined/, "prepare_amd_section(\$export_to_archive_date, \$external_workflow, \$external_id, \$external_conservation_flag, \$external_isil, \$external_value_descr), external_workflow undef";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_amd_section("2019-10-14T13:33:56", "kitodo", undef, "false", "DE-14", "Gesetzlicher Auftrag"); } qr/external id not defined/, "prepare_amd_section(\$export_to_archive_date, \$external_workflow, \$external_id, \$external_conservation_flag, \$external_isil, \$external_value_descr), external_id undef";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_amd_section("2019-10-14T13:33:56", "kitodo", "10008", undef, "DE-14", "Gesetzlicher Auftrag"); } qr/external conservation flag not defined/, "prepare_amd_section(\$export_to_archive_date, \$external_workflow, \$external_id, \$external_conservation_flag, \$external_isil, \$external_value_descr), external_conservation_flag undef";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_amd_section("2019-10-14T13:33:56", "kitodo", "10008", "false", undef, "Gesetzlicher Auftrag"); } qr/external isil not defined/, "prepare_amd_section(\$export_to_archive_date, \$external_workflow, \$external_id, \$external_conservation_flag, \$external_isil, \$external_value_descr), external_isil undef";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_amd_section("2019-10-14T13:33:56", "kitodo", "10008", "false", "DE-14", undef); } qr/external value description not defined/, "prepare_amd_section(\$export_to_archive_date, \$external_workflow, \$external_id, \$external_conservation_flag, \$external_isil, \$external_value_descr), external_value_descr undef";
+#
+ok(SLUB::LZA::SIPBuilder::prepare_files_sections($filecopyhash) eq $filesec_res, "prepare_files_sections()");
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_files_sections(""); } qr/Can't use string/, "prepare_files_sections(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_files_sections(\$filecopyhash); } qr/Not a HASH reference/, "prepare_files_sections(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_files_sections(undef); } qr/filecopyhash not defined/, "prepare_files_sections(\$filecopyhash), filecopyhash undef";
+#
+ok(SLUB::LZA::SIPBuilder::prepare_struct_map($filecopyhash) eq $structmap_res, "prepare_struct_map()");
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_struct_map(""); } qr/Can't use string/, "prepare_struct_map(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_struct_map(\$filecopyhash); } qr/Not a HASH reference/, "prepare_struct_map(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::prepare_struct_map(undef); } qr/filecopyhash not defined/, "prepare_struct_map(\$filecopyhash), filecopyhash undef";
+#
+is(SLUB::LZA::SIPBuilder::check_directory($valid_ie_dir_path, $valid_ie_dir), "", "check_directory()");
+throws_ok{ SLUB::LZA::SIPBuilder::check_directory("", $valid_ie_dir); } qr/invalid parameters/, "check_directory(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::check_directory($valid_ie_dir_path, ""); } qr/invalid parameters/, "check_directory(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::check_directory(undef, $valid_ie_dir); } qr/fullname not defined/, "check_directory(\$valid_ie_dir_path, \$valid_ie_dir), valid_ie_dir_path undef";
+throws_ok{ SLUB::LZA::SIPBuilder::check_directory($valid_ie_dir_path, undef); } qr/entry not defined/, "check_directory(\$valid_ie_dir_path, \$valid_ie_dir), valid_ie_dir undef";
+like(SLUB::LZA::SIPBuilder::check_directory($export_dir_kitodo_path->absolute . "/LFvNRFgzZQ6nXnK0wvOXqYGA3jBuHrQWWkw2ngWL/5CglQ5VNjq1kCNTVPhcRDYy59PpQg/0g9XWHBkgunA4FXGefoX5RToHrXgE6cY35wLdviFjE2gAf9mpQSTnC/hpH4omOsAl6I9UfU4HYoo4drqLGjn0QP80SPm6TRWThtKmb6dj7iWm1UfFOo9W19vcCQQIcz/1Aa_080B-", "1Aa_080B-"), qr/expected maximum 255 characters/, "validate_directory(\$valid_ie_dir_path, \$valid_ie_dir), expected valid_ie_dir_path max 255 characters");
+like(SLUB::LZA::SIPBuilder::check_directory($not_valid_ie_dir_path, $not_valid_ie_dir), qr/you need to specify/, "check_directory(\$valid_ie_dir_path, \$valid_ie_dir), file or directory must be valid to (^[A-Za-z0-9_.-]+\$)");
+like(SLUB::LZA::SIPBuilder::check_directory($valid_ie_dir_path . "/../", $valid_ie_dir), qr/relativ path/, "check_directory(\$valid_ie_dir_path, \$valid_ie_dir), relative path in form ../ is not allowed");
+#
+is(SLUB::LZA::SIPBuilder::validate_directory($valid_ie_dir_path), "", "validate_directory()");
+throws_ok{ SLUB::LZA::SIPBuilder::validate_directory(""); } qr/Could not find/, "validate_directory(), invalid parameters";
+throws_ok{ SLUB::LZA::SIPBuilder::validate_directory(undef); } qr/directory not defined/, "validate_directory(\$directory), directory undef";
 
 1;