package be.iminds.ilabt.jfed.experimenter_gui.tasks;

import be.iminds.ilabt.jfed.rspec.model.ModelRspecType;
import be.iminds.ilabt.jfed.rspec.model.StringRspec;
import be.iminds.ilabt.jfed.rspec.model.javafx_impl.FXRspecFactory;
import be.iminds.ilabt.jfed.rspec.rspec_source.ManifestRspecMerger;
import be.iminds.ilabt.jfed.rspec.rspec_source.ManifestRspecSource;
import be.iminds.ilabt.jfed.rspec.rspec_source.RequestRspecSource;
import be.iminds.ilabt.jfed.util.GeniUrn;
import javafx.embed.swing.JFXPanel;
import junit.framework.Assert;
import org.testng.SkipException;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

import static org.testng.Assert.*;

/**
 * Created by Thijs on 3/7/2017.
 */
public class RecoverSliceTaskTest {

    protected final FXRspecFactory fxRspecFactory = FXRspecFactory.getInstance();

    @BeforeSuite
    public void setUpSuite() {
        //force initialization of JavaFX
        try {
            new JFXPanel();
        }catch(RuntimeException ex){
            throw new SkipException("Could not successfully load JavaFX toolkit..");
        }
    }

    @Test
    public void testMerge() throws Exception {

        ManifestRspecMerger merger = new ManifestRspecMerger(ModelRspecType.FX);

        ManifestRspecSource manifest = new ManifestRspecSource(new StringRspec("<rspec expires=\"2017-03-07T10:02:20Z\" type=\"manifest\"\n" +
                "    xmlns=\"http://www.geni.net/resources/rspec/3\"\n" +
                "    xmlns:client=\"http://www.protogeni.net/resources/rspec/ext/client/1\"\n" +
                "    xmlns:delay=\"http://www.protogeni.net/resources/rspec/ext/delay/1\"\n" +
                "    xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\"\n" +
                "    xmlns:jfed=\"http://jfed.iminds.be/rspec/ext/jfed/1\"\n" +
                "    xmlns:jfed-command=\"http://jfed.iminds.be/rspec/ext/jfed-command/1\"\n" +
                "    xmlns:jfed-ssh-keys=\"http://jfed.iminds.be/rspec/ext/jfed-ssh-keys/1\"\n" +
                "    xmlns:jfedBonfire=\"http://jfed.iminds.be/rspec/ext/jfed-bonfire/1\"\n" +
                "    xmlns:sharedvlan=\"http://www.protogeni.net/resources/rspec/ext/shared-vlan/1\"\n" +
                "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.geni.net/resources/rspec/3 http://www.geni.net/resources/rspec/3/manifest.xsd\">\n" +
                "    <node client_id=\"ue1\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n061-06b\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120859\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"ue1:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06b:eth2\"\n" +
                "            mac_address=\"00259065bcc8\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120898\">\n" +
                "            <ip address=\"192.168.10.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"ue1:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06b:eth3\"\n" +
                "            mac_address=\"00259065bcc9\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120904\">\n" +
                "            <ip address=\"192.168.12.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen03-4p\" name=\"n061-06b\"/>\n" +
                "        <host name=\"ue1.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n061-06b.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"enb12\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n061-02a\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120857\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"enb12:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-02a:eth3\"\n" +
                "            mac_address=\"00259065bcbd\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120899\">\n" +
                "            <ip address=\"192.168.10.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"enb12:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-02a:eth4\"\n" +
                "            mac_address=\"00259065bcbe\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120907\">\n" +
                "            <ip address=\"192.168.13.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"enb12:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-02a:eth5\"\n" +
                "            mac_address=\"00259065bcbf\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120910\">\n" +
                "            <ip address=\"192.168.14.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen03-4p\" name=\"n061-02a\"/>\n" +
                "        <host name=\"enb12.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n061-02a.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"enb11\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n061-08b\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120856\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"enb11:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-08b:eth5\"\n" +
                "            mac_address=\"00259064f95b\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120886\">\n" +
                "            <ip address=\"192.168.6.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"enb11:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-08b:eth3\"\n" +
                "            mac_address=\"00259064f959\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120905\">\n" +
                "            <ip address=\"192.168.12.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"enb11:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-08b:eth4\"\n" +
                "            mac_address=\"00259064f95a\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120911\">\n" +
                "            <ip address=\"192.168.14.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen03-4p\" name=\"n061-08b\"/>\n" +
                "        <host name=\"enb11.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n061-08b.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"spgw1\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n061-06a\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120867\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"spgw1:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06a:eth4\"\n" +
                "            mac_address=\"00259064f7ea\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120883\">\n" +
                "            <ip address=\"192.168.5.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"spgw1:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06a:eth5\"\n" +
                "            mac_address=\"00259064f7eb\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120887\">\n" +
                "            <ip address=\"192.168.6.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"spgw1:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06a:eth3\"\n" +
                "            mac_address=\"00259064f7e9\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120901\">\n" +
                "            <ip address=\"192.168.11.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"spgw1:if3\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06a:eth2\"\n" +
                "            mac_address=\"00259064f7e8\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120908\">\n" +
                "            <ip address=\"192.168.13.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen03-4p\" name=\"n061-06a\"/>\n" +
                "        <host name=\"spgw1.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n061-06a.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"mme1\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n061-09a\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120864\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"mme1:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-09a:eth2\"\n" +
                "            mac_address=\"002590697744\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120889\">\n" +
                "            <ip address=\"192.168.7.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"mme1:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-09a:eth5\"\n" +
                "            mac_address=\"002590697747\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120902\">\n" +
                "            <ip address=\"192.168.11.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen03-4p\" name=\"n061-09a\"/>\n" +
                "        <host name=\"mme1.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n061-09a.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"hss1\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n062-01b\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120865\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"hss1:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n062-01b:eth1\"\n" +
                "            mac_address=\"0025904c740b\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120890\">\n" +
                "            <ip address=\"192.168.7.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen03-1p\" name=\"n062-01b\"/>\n" +
                "        <host name=\"hss1.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n062-01b.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"metropop\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n084-20\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120866\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"metropop:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-20:eth2\"\n" +
                "            mac_address=\"0025903ce86e\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120884\">\n" +
                "            <ip address=\"192.168.5.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"metropop:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-20:eth3\"\n" +
                "            mac_address=\"0025903ce86f\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120916\">\n" +
                "            <ip address=\"192.168.16.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen05\" name=\"n084-20\"/>\n" +
                "        <host name=\"metropop.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n084-20.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"ue2\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n084-17\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120860\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"ue2:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-17:eth2\"\n" +
                "            mac_address=\"00259064f91e\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120874\">\n" +
                "            <ip address=\"192.168.2.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"ue2:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-17:eth3\"\n" +
                "            mac_address=\"00259064f91f\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120877\">\n" +
                "            <ip address=\"192.168.3.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen05\" name=\"n084-17\"/>\n" +
                "        <host name=\"ue2.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n084-17.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"enb21\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n084-23\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120862\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"enb21:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-23:eth1\"\n" +
                "            mac_address=\"0025903ce911\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120878\">\n" +
                "            <ip address=\"192.168.3.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"enb21:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-23:eth3\"\n" +
                "            mac_address=\"0025903ce913\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120880\">\n" +
                "            <ip address=\"192.168.4.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"enb21:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-23:eth2\"\n" +
                "            mac_address=\"0025903ce912\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120892\">\n" +
                "            <ip address=\"192.168.8.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen05\" name=\"n084-23\"/>\n" +
                "        <host name=\"enb21.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n084-23.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"enb22\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n084-18\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120861\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"enb22:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-18:eth2\"\n" +
                "            mac_address=\"00259065bcf6\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120871\">\n" +
                "            <ip address=\"192.168.1.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"enb22:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-18:eth0\"\n" +
                "            mac_address=\"00259065bcf4\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120875\">\n" +
                "            <ip address=\"192.168.2.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"enb22:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-18:eth1\"\n" +
                "            mac_address=\"00259065bcf5\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120881\">\n" +
                "            <ip address=\"192.168.4.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen05\" name=\"n084-18\"/>\n" +
                "        <host name=\"enb22.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n084-18.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"spgw2\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n061-01b\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120858\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"spgw2:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-01b:eth3\"\n" +
                "            mac_address=\"00259065bcb5\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120872\">\n" +
                "            <ip address=\"192.168.1.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"spgw2:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-01b:eth4\"\n" +
                "            mac_address=\"00259065bcb6\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120893\">\n" +
                "            <ip address=\"192.168.8.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"spgw2:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-01b:eth5\"\n" +
                "            mac_address=\"00259065bcb7\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120895\">\n" +
                "            <ip address=\"192.168.9.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"spgw2:if3\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-01b:eth2\"\n" +
                "            mac_address=\"00259065bcb4\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120917\">\n" +
                "            <ip address=\"192.168.16.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen03-4p\" name=\"n061-01b\"/>\n" +
                "        <host name=\"spgw2.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n061-01b.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"mme2\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n064-01\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120868\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"mme2:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n064-01:eth6\"\n" +
                "            mac_address=\"002590e3672a\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120896\">\n" +
                "            <ip address=\"192.168.9.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <interface client_id=\"mme2:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n064-01:eth4\"\n" +
                "            mac_address=\"002590e36728\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120913\">\n" +
                "            <ip address=\"192.168.15.1\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen04\" name=\"n064-01\"/>\n" +
                "        <host name=\"mme2.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n064-01.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <node client_id=\"hss2\"\n" +
                "        component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+node+n064-03\"\n" +
                "        component_manager_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"\n" +
                "        exclusive=\"true\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120863\" xmlns:emulab=\"http://www.protogeni.net/resources/rspec/ext/emulab/1\">\n" +
                "        <sliver_type name=\"raw-pc\"/>\n" +
                "        <interface client_id=\"hss2:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n064-03:eth5\"\n" +
                "            mac_address=\"002590e35ed9\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120914\">\n" +
                "            <ip address=\"192.168.15.2\" type=\"ipv4\"/>\n" +
                "        </interface>\n" +
                "        <emulab:vnode hardware_type=\"pcgen04\" name=\"n064-03\"/>\n" +
                "        <host name=\"hss2.lte2.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be\"/>\n" +
                "        <services>\n" +
                "            <login authentication=\"ssh-keys\"\n" +
                "                hostname=\"n064-03.wall2.ilabt.iminds.be\" port=\"22\" username=\"sander\"/>\n" +
                "        </services>\n" +
                "    </node>\n" +
                "    <link client_id=\"enb22-spgw2\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120870\" vlantag=\"39\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"enb22:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-18:eth2\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120871\"/>\n" +
                "        <interface_ref client_id=\"spgw2:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-01b:eth3\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120872\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"ue2-enb22\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120873\" vlantag=\"47\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"ue2:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-17:eth2\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120874\"/>\n" +
                "        <interface_ref client_id=\"enb22:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-18:eth0\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120875\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"ue2-enb21\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120876\" vlantag=\"51\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"ue2:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-17:eth3\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120877\"/>\n" +
                "        <interface_ref client_id=\"enb21:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-23:eth1\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120878\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"enb21-enb22\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120879\" vlantag=\"46\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"enb21:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-23:eth3\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120880\"/>\n" +
                "        <interface_ref client_id=\"enb22:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-18:eth1\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120881\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"spgw1-metropop\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120882\" vlantag=\"45\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"spgw1:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06a:eth4\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120883\"/>\n" +
                "        <interface_ref client_id=\"metropop:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-20:eth2\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120884\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"enb11-spgw1\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120885\" vlantag=\"30\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"enb11:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-08b:eth5\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120886\"/>\n" +
                "        <interface_ref client_id=\"spgw1:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06a:eth5\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120887\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"mme1-hss1\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120888\" vlantag=\"38\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"mme1:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-09a:eth2\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120889\"/>\n" +
                "        <interface_ref client_id=\"hss1:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n062-01b:eth1\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120890\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"enb21-spgw2\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120891\" vlantag=\"43\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"enb21:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-23:eth2\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120892\"/>\n" +
                "        <interface_ref client_id=\"spgw2:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-01b:eth4\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120893\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"spgw2-mme2\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120894\" vlantag=\"40\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"spgw2:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-01b:eth5\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120895\"/>\n" +
                "        <interface_ref client_id=\"mme2:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n064-01:eth6\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120896\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"ue1-enb12\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120897\" vlantag=\"49\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"ue1:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06b:eth2\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120898\"/>\n" +
                "        <interface_ref client_id=\"enb12:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-02a:eth3\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120899\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"spgw1-mme1\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120900\" vlantag=\"44\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"spgw1:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06a:eth3\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120901\"/>\n" +
                "        <interface_ref client_id=\"mme1:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-09a:eth5\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120902\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"ue1-enb11\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120903\" vlantag=\"37\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"ue1:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06b:eth3\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120904\"/>\n" +
                "        <interface_ref client_id=\"enb11:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-08b:eth3\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120905\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"enb12-spgw1\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120906\" vlantag=\"48\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"enb12:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-02a:eth4\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120907\"/>\n" +
                "        <interface_ref client_id=\"spgw1:if3\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-06a:eth2\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120908\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"enb12-enb11\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120909\" vlantag=\"29\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"enb12:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-02a:eth5\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120910\"/>\n" +
                "        <interface_ref client_id=\"enb11:if2\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-08b:eth4\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120911\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"mme2-hss2\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120912\" vlantag=\"41\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"mme2:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n064-01:eth4\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120913\"/>\n" +
                "        <interface_ref client_id=\"hss2:if0\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n064-03:eth5\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120914\"/>\n" +
                "    </link>\n" +
                "    <link client_id=\"metropop-spgw2\"\n" +
                "        sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120915\" vlantag=\"50\">\n" +
                "        <component_manager_id name=\"urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm\"/>\n" +
                "        <interface_ref client_id=\"metropop:if1\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n084-20:eth3\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120916\"/>\n" +
                "        <interface_ref client_id=\"spgw2:if3\"\n" +
                "            component_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+interface+n061-01b:eth2\" sliver_id=\"urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120917\"/>\n" +
                "    </link>\n" +
                "    <rs:site_info xmlns:rs=\"http://www.protogeni.net/resources/rspec/ext/site-info/1\">\n" +
                "        <rs:location country=\"BE\" latitude=\"51.013156\" longitude=\"3.707924\"/>\n" +
                "    </rs:site_info>\n" +
                "</rspec>\n"));


        GeniUrn authorityUrn = new GeniUrn("urn:publicid:IDN+wall2.ilabt.iminds.be+authority+cm");
        merger.setManifest(authorityUrn, manifest);
        merger.setRequest(RecoverSliceTask.tryMakeModelBasedRspecSource(
                new RequestRspecSource(manifest.getStringRspec(), ModelRspecType.FX)));


        ManifestRspecSource mergedManifest = merger.getMergedManifest();


        GeniUrn linkUrn = new GeniUrn("urn:publicid:IDN+wall2.ilabt.iminds.be+sliver+120870");

        Assert.assertTrue(ManifestRspecMerger.isAuthoritative(linkUrn, authorityUrn));
        Assert.assertTrue(ManifestRspecMerger.isAuthoritative(authorityUrn, authorityUrn));

    }


}