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
65 public void testShmmrService()
69 "Test Rsd Exchange using using default Shmmr service failed.",
70 testRsdExchange("Test using default Shmmr service",
71 RestClient.makeShmmrRestClient().service));
75 public void testShmmrServiceDataprep() throws Exception
77 RestClient _rc = RestClient.makeShmmrRestClient();
79 AlignFrame alf = new jalview.io.FileLoader(false)
80 .LoadFileWaitTillLoaded("examples/testdata/smad.fa",
81 jalview.io.FormatAdapter.FILE);
82 assertNotNull("Couldn't find test data.", alf);
83 alf.loadJalviewDataFile("examples/testdata/smad_groups.jva",
84 jalview.io.FormatAdapter.FILE, null, null);
86 "Couldn't load the test data's annotation file (should be 5 groups but found "
87 + alf.getViewport().getAlignment().getGroups().size()
88 + ").", alf.getViewport().getAlignment().getGroups()
91 RestClient rc = new RestClient(_rc.service, alf, true);
93 assertNotNull("Couldn't creat RestClient job.", rc);
94 jalview.bin.Cache.initLogger();
95 RestJob rjb = new RestJob(0, new RestJobThread(rc),
96 rc.av.getAlignment(), null);
97 rjb.setAlignmentForInputs(rc.service.getInputParams().values(),
98 rc.av.getAlignment());
99 for (Map.Entry<String, InputType> e : rc.service.getInputParams()
102 System.out.println("For Input '" + e.getKey() + ":\n"
103 + e.getValue().formatForInput(rjb).getContentLength());
107 private static boolean testRsdExchange(String desc, String servicestring)
111 RestServiceDescription newService = new RestServiceDescription(
113 if (!newService.isValid())
115 throw new Error("Failed to create service from '" + servicestring
116 + "'.\n" + newService.getInvalidMessage());
118 return testRsdExchange(desc, newService);
119 } catch (Throwable x)
121 System.err.println("Failed for service (" + desc + "): "
128 private static boolean testRsdExchange(String desc,
129 RestServiceDescription service)
133 String fromservicetostring = service.toString();
134 RestServiceDescription newService = new RestServiceDescription(
135 fromservicetostring);
136 if (!newService.isValid())
138 throw new Error("Failed to create service from '"
139 + fromservicetostring + "'.\n"
140 + newService.getInvalidMessage());
143 if (!service.equals(newService))
145 System.err.println("Failed for service (" + desc + ").");
146 System.err.println("Original service and parsed service differ.");
147 System.err.println("Original: " + fromservicetostring);
148 System.err.println("Parsed : " + newService.toString());
151 } catch (Throwable x)
153 System.err.println("Failed for service (" + desc + "): "
154 + service.toString());