2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.ws.rest;
21 import static org.junit.Assert.*;
23 import java.io.BufferedReader;
24 import java.io.IOException;
25 import java.util.ArrayList;
26 import java.util.Hashtable;
27 import java.util.List;
30 import jalview.datamodel.AlignmentI;
31 import jalview.datamodel.AlignmentView;
32 import jalview.gui.AlignFrame;
33 import jalview.io.FileParse;
34 import jalview.ws.rest.InputType;
35 import jalview.ws.rest.params.SeqGroupIndexVector;
37 import org.junit.AfterClass;
38 import org.junit.BeforeClass;
39 import org.junit.Test;
45 public class ShmmrRSBSService
49 public void testSeparatorListToArrayForRestServiceDescriptions()
52 "separatorListToArray is faulty.",
53 RestServiceDescription.separatorListToArray(
54 "foo=',',min='foo',max='1,2,3',fa=','", ",").length == 4);
55 assertTrue("separatorListToArray is faulty.",
56 RestServiceDescription.separatorListToArray(
57 "minsize='2', sep=','", ",").length != 2); // probably should come as 2
61 public void testShmmrService()
65 "Test Rsd Exchange using using default Shmmr service failed.",
66 testRsdExchange("Test using default Shmmr service",
67 RestClient.makeShmmrRestClient().service));
70 public void testShmmrServiceDataprep() throws Exception
72 RestClient _rc = RestClient.makeShmmrRestClient();
74 AlignFrame alf = new jalview.io.FileLoader(false).LoadFileWaitTillLoaded("examples/testdata/smad.fa", jalview.io.FormatAdapter.FILE);
75 assertNotNull("Couldn't find test data.",alf);
76 alf.loadJalviewDataFile("examples/testdata/smad_groups.jva",
77 jalview.io.FormatAdapter.FILE, null, null);
78 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);
80 RestClient rc = new RestClient(_rc.service, alf, true);
84 assertNotNull("Couldn't creat RestClient job.",rc);
85 jalview.bin.Cache.initLogger();
86 RestJob rjb = new RestJob(0, new RestJobThread(rc),rc.av.getAlignment(),null);
87 rjb.setAlignmentForInputs(rc.service.getInputParams().values(), rc.av.getAlignment());
88 for (Map.Entry<String,InputType> e:rc.service.getInputParams().entrySet()) {
89 System.out.println("For Input '"+e.getKey()+":\n"+e.getValue().formatForInput(rjb).getContentLength());
93 private static boolean testRsdExchange(String desc, String servicestring)
97 RestServiceDescription newService = new RestServiceDescription(
99 if (!newService.isValid())
101 throw new Error("Failed to create service from '" + servicestring
102 + "'.\n" + newService.getInvalidMessage());
104 return testRsdExchange(desc, newService);
105 } catch (Throwable x)
107 System.err.println("Failed for service (" + desc + "): "
114 private static boolean testRsdExchange(String desc,
115 RestServiceDescription service)
119 String fromservicetostring = service.toString();
120 RestServiceDescription newService = new RestServiceDescription(
121 fromservicetostring);
122 if (!newService.isValid())
124 throw new Error("Failed to create service from '"
125 + fromservicetostring + "'.\n"
126 + newService.getInvalidMessage());
129 if (!service.equals(newService))
131 System.err.println("Failed for service (" + desc + ").");
132 System.err.println("Original service and parsed service differ.");
133 System.err.println("Original: " + fromservicetostring);
134 System.err.println("Parsed : " + newService.toString());
137 } catch (Throwable x)
139 System.err.println("Failed for service (" + desc + "): "
140 + service.toString());