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.testng.Assert;
15 import org.testng.AssertJUnit;
16 import org.testng.annotations.Test;
19 public class BioJsHTMLOutputTest
23 public void getJalviewAlignmentAsJsonString()
25 String bjsTemplate = null;
28 BioJsHTMLOutput.updateBioJS();
31 // allow the update some three seconds to complete before getting latest
32 // version of BioJS template
33 Thread.sleep(1000 * 3);
34 } catch (InterruptedException e)
38 bjsTemplate = BioJsHTMLOutput.getBioJsTemplateAsString();
39 // System.out.println(bjsTemplate);
40 } catch (IOException e)
44 Assert.assertNotNull(bjsTemplate);
47 @Test(expectedExceptions = NullPointerException.class)
48 public void expectedNullPointerException()
52 BioJsHTMLOutput.refreshBioJSVersionsInfo(null);
53 } catch (URISyntaxException e)
55 AssertJUnit.fail("Expception occured while testing!");
61 public void getBioJsMSAVersions()
63 TreeMap<String, File> versions = null;
67 .refreshBioJSVersionsInfo(BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY);
68 versions = BioJsHTMLOutput.getBioJsMSAVersions();
69 } catch (URISyntaxException e)
71 AssertJUnit.fail("Expception occured while testing!");
74 AssertJUnit.assertNotNull("No versions found", versions);
75 AssertJUnit.assertTrue("One or more Templates required", versions.size() > 0);
77 .println("Number of discovered versions : "
79 for (String v : versions.keySet())
81 System.out.println("version : " + v);
82 System.out.println("File : " + versions.get(v));
85 System.out.println("\nCurrent latest version : "
86 + BioJsHTMLOutput.getCurrentBJSTemplateFile());
87 AssertJUnit.assertNotNull("Latest BioJsMSA version NOT found!",
88 BioJsHTMLOutput.getCurrentBJSTemplateFile());
93 public void testBioJsUpdate()
95 String url = BioJsHTMLOutput.BJS_TEMPLATE_GIT_REPO;
96 AssertJUnit.assertTrue("URL not reacable : " + url, urlIsReachable(url));
97 String response = BioJsHTMLOutput.getURLContentAsString(url);
98 AssertJUnit.assertNotNull("Null response read from url!", response);
99 BioJSRepositoryPojo repository = new BioJSRepositoryPojo(response);
100 System.out.println(">>> description : " + repository.getDescription());
102 .println(">>> latest version : "
103 + repository.getLatestReleaseVersion());
104 System.out.println(">>> repo count : "
105 + repository.getReleases().size());
106 for (BioJSReleasePojo release : repository.getReleases())
108 System.out.println("repo type : " + release.getType());
109 System.out.println("url : " + release.getUrl());
110 System.out.println("release version : " + release.getVersion());
114 private static boolean urlIsReachable(String urlString)
118 final URL url = new URL(urlString);
119 final URLConnection conn = url.openConnection();
122 } catch (MalformedURLException e)
124 throw new RuntimeException(e);
125 } catch (IOException e)