2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.rest;
23 import static org.junit.Assert.*;
25 import java.io.BufferedReader;
26 import java.io.IOException;
27 import java.util.ArrayList;
28 import java.util.Hashtable;
29 import java.util.List;
32 import jalview.datamodel.AlignmentI;
33 import jalview.datamodel.AlignmentView;
34 import jalview.gui.AlignFrame;
35 import jalview.io.FileParse;
36 import jalview.ws.rest.InputType;
37 import jalview.ws.rest.params.SeqGroupIndexVector;
39 import org.junit.AfterClass;
40 import org.junit.BeforeClass;
41 import org.junit.Test;
47 public class ShmmrRSBSService
51 public void testSeparatorListToArrayForRestServiceDescriptions()
54 "separatorListToArray is faulty.",
55 RestServiceDescription.separatorListToArray(
56 "foo=',',min='foo',max='1,2,3',fa=','", ",").length == 4);
57 assertTrue("separatorListToArray is faulty.",
58 RestServiceDescription.separatorListToArray(
59 "minsize='2', sep=','", ",").length != 2); // probably should come as 2
63 public void testShmmrService()
67 "Test Rsd Exchange using using default Shmmr service failed.",
68 testRsdExchange("Test using default Shmmr service",
69 RestClient.makeShmmrRestClient().service));
72 public void testShmmrServiceDataprep() throws Exception
74 RestClient _rc = RestClient.makeShmmrRestClient();
76 AlignFrame alf = new jalview.io.FileLoader(false).LoadFileWaitTillLoaded("examples/testdata/smad.fa", jalview.io.FormatAdapter.FILE);
77 assertNotNull("Couldn't find test data.",alf);
78 alf.loadJalviewDataFile("examples/testdata/smad_groups.jva",
79 jalview.io.FormatAdapter.FILE, null, null);
80 assertTrue("Couldn't load the test data's annotation file (should be 5 groups but found "+alf.getViewport().getAlignment().getGroups().size()+").", alf.getViewport().getAlignment().getGroups().size()==5);
82 RestClient rc = new RestClient(_rc.service, alf, true);
86 assertNotNull("Couldn't creat RestClient job.",rc);
87 jalview.bin.Cache.initLogger();
88 RestJob rjb = new RestJob(0, new RestJobThread(rc),rc.av.getAlignment(),null);
89 rjb.setAlignmentForInputs(rc.service.getInputParams().values(), rc.av.getAlignment());
90 for (Map.Entry<String,InputType> e:rc.service.getInputParams().entrySet()) {
91 System.out.println("For Input '"+e.getKey()+":\n"+e.getValue().formatForInput(rjb).getContentLength());
95 private static boolean testRsdExchange(String desc, String servicestring)
99 RestServiceDescription newService = new RestServiceDescription(
101 if (!newService.isValid())
103 throw new Error("Failed to create service from '" + servicestring
104 + "'.\n" + newService.getInvalidMessage());
106 return testRsdExchange(desc, newService);
107 } catch (Throwable x)
109 System.err.println("Failed for service (" + desc + "): "
116 private static boolean testRsdExchange(String desc,
117 RestServiceDescription service)
121 String fromservicetostring = service.toString();
122 RestServiceDescription newService = new RestServiceDescription(
123 fromservicetostring);
124 if (!newService.isValid())
126 throw new Error("Failed to create service from '"
127 + fromservicetostring + "'.\n"
128 + newService.getInvalidMessage());
131 if (!service.equals(newService))
133 System.err.println("Failed for service (" + desc + ").");
134 System.err.println("Original service and parsed service differ.");
135 System.err.println("Original: " + fromservicetostring);
136 System.err.println("Parsed : " + newService.toString());
139 } catch (Throwable x)
141 System.err.println("Failed for service (" + desc + "): "
142 + service.toString());