3 import jalview.json.binding.v1.BioJSReleasePojo;
4 import jalview.json.binding.v1.BioJSRepositoryPojo;
7 import java.io.IOException;
8 import java.net.MalformedURLException;
9 import java.net.URISyntaxException;
11 import java.net.URLConnection;
12 import java.util.TreeMap;
14 import org.junit.Assert;
15 import org.junit.Test;
18 public class BioJsHTMLOutputTest
22 public void getJalviewAlignmentAsJsonString()
24 BioJsHTMLOutput bioJsHtmlOutput = new BioJsHTMLOutput(null, null);
25 String bjsTemplate = null;
28 bioJsHtmlOutput.updateBioJS();
29 bjsTemplate = BioJsHTMLOutput.getBioJsTemplateAsString();
30 // System.out.println(bjsTemplate);
31 } catch (IOException e)
35 Assert.assertNotNull(bjsTemplate);
38 @Test(expected = NullPointerException.class)
39 public void expectedNullPointerException()
41 BioJsHTMLOutput bjs = new BioJsHTMLOutput(null, null);
44 bjs.refreshBioJSVersionsInfo(null);
45 } catch (URISyntaxException e)
47 Assert.fail("Expception occured while testing!");
53 public void getBioJsMSAVersions()
55 BioJsHTMLOutput bjs = new BioJsHTMLOutput(null, null);
56 TreeMap<String, File> versions = null;
59 bjs.refreshBioJSVersionsInfo(BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
60 versions = BioJsHTMLOutput.getBioJsMSAVersions();
61 } catch (URISyntaxException e)
63 Assert.fail("Expception occured while testing!");
66 Assert.assertNotNull("No versions found", versions);
67 Assert.assertTrue("One or more Templates required", versions.size() > 0);
69 .println("Number of discovered versions : "
71 for (String v : versions.keySet())
73 System.out.println("version : " + v);
74 System.out.println("File : " + versions.get(v));
77 System.out.println("\nCurrent latest version : "
78 + BioJsHTMLOutput.getCurrentBJSTemplateFile());
79 Assert.assertNotNull("Latest BioJsMSA version NOT found!",
80 BioJsHTMLOutput.getCurrentBJSTemplateFile());
85 public void testBioJsUpdate()
87 String url = BioJsHTMLOutput.BJS_TEMPLATE_GIT_REPO;
88 Assert.assertTrue("URL not reacable : " + url, urlIsReachable(url));
89 String response = BioJsHTMLOutput.getURLContentAsString(url);
90 Assert.assertNotNull("Null response read from url!", response);
91 BioJSRepositoryPojo repository = new BioJSRepositoryPojo(response);
92 System.out.println(">>> description : " + repository.getDescription());
94 .println(">>> latest version : "
95 + repository.getLatestReleaseVersion());
96 System.out.println(">>> repo count : "
97 + repository.getReleases().size());
98 for (BioJSReleasePojo release : repository.getReleases())
100 System.out.println("repo type : " + release.getType());
101 System.out.println("url : " + release.getUrl());
102 System.out.println("release version : " + release.getVersion());
106 private static boolean urlIsReachable(String urlString)
110 final URL url = new URL(urlString);
111 final URLConnection conn = url.openConnection();
114 } catch (MalformedURLException e)
116 throw new RuntimeException(e);
117 } catch (IOException e)