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 String bjsTemplate = null;
27 BioJsHTMLOutput.updateBioJS();
30 // allow the update some three seconds to complete before getting latest
31 // version of BioJS template
32 Thread.sleep(1000 * 3);
33 } catch (InterruptedException e)
37 bjsTemplate = BioJsHTMLOutput.getBioJsTemplateAsString();
38 // System.out.println(bjsTemplate);
39 } catch (IOException e)
43 Assert.assertNotNull(bjsTemplate);
46 @Test(expected = NullPointerException.class)
47 public void expectedNullPointerException()
51 BioJsHTMLOutput.refreshBioJSVersionsInfo(null);
52 } catch (URISyntaxException e)
54 Assert.fail("Expception occured while testing!");
60 public void getBioJsMSAVersions()
62 TreeMap<String, File> versions = null;
66 .refreshBioJSVersionsInfo(BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
67 versions = BioJsHTMLOutput.getBioJsMSAVersions();
68 } catch (URISyntaxException e)
70 Assert.fail("Expception occured while testing!");
73 Assert.assertNotNull("No versions found", versions);
74 Assert.assertTrue("One or more Templates required", versions.size() > 0);
76 .println("Number of discovered versions : "
78 for (String v : versions.keySet())
80 System.out.println("version : " + v);
81 System.out.println("File : " + versions.get(v));
84 System.out.println("\nCurrent latest version : "
85 + BioJsHTMLOutput.getCurrentBJSTemplateFile());
86 Assert.assertNotNull("Latest BioJsMSA version NOT found!",
87 BioJsHTMLOutput.getCurrentBJSTemplateFile());
92 public void testBioJsUpdate()
94 String url = BioJsHTMLOutput.BJS_TEMPLATE_GIT_REPO;
95 Assert.assertTrue("URL not reacable : " + url, urlIsReachable(url));
96 String response = BioJsHTMLOutput.getURLContentAsString(url);
97 Assert.assertNotNull("Null response read from url!", response);
98 BioJSRepositoryPojo repository = new BioJSRepositoryPojo(response);
99 System.out.println(">>> description : " + repository.getDescription());
101 .println(">>> latest version : "
102 + repository.getLatestReleaseVersion());
103 System.out.println(">>> repo count : "
104 + repository.getReleases().size());
105 for (BioJSReleasePojo release : repository.getReleases())
107 System.out.println("repo type : " + release.getType());
108 System.out.println("url : " + release.getUrl());
109 System.out.println("release version : " + release.getVersion());
113 private static boolean urlIsReachable(String urlString)
117 final URL url = new URL(urlString);
118 final URLConnection conn = url.openConnection();
121 } catch (MalformedURLException e)
123 throw new RuntimeException(e);
124 } catch (IOException e)