X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fws%2Fdbsources%2FPDBRestClientTest.java;h=679cfe49f4761064ceb5d9ff1347b09027fcdaf0;hb=838e4f91d4a53dd315640dbc9ff6ef7a815ee576;hp=a97f3e0e89439172771d267eca6faac108ea03c1;hpb=041905b00ec635c1764f565a22b2ecf762a9a75b;p=jalview.git diff --git a/test/jalview/ws/dbsources/PDBRestClientTest.java b/test/jalview/ws/dbsources/PDBRestClientTest.java index a97f3e0..679cfe4 100644 --- a/test/jalview/ws/dbsources/PDBRestClientTest.java +++ b/test/jalview/ws/dbsources/PDBRestClientTest.java @@ -1,8 +1,28 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1) + * Copyright (C) 2015 The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.ws.dbsources; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + import jalview.ws.dbsources.PDBRestClient.PDBDocField; import jalview.ws.uimodel.PDBRestRequest; import jalview.ws.uimodel.PDBRestResponse; @@ -20,9 +40,10 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; @@ -33,17 +54,17 @@ import com.sun.jersey.api.client.config.DefaultClientConfig; public class PDBRestClientTest { - @Before + @BeforeMethod(alwaysRun = true) public void setUp() throws Exception { } - @After + @AfterMethod public void tearDown() throws Exception { } - @Test + @Test(groups = { "External", "Network" }) public void executeRequestTest() { List wantedFields = new ArrayList(); @@ -67,7 +88,7 @@ public class PDBRestClientTest } catch (Exception e) { e.printStackTrace(); - fail("Couldn't execute webservice call!"); + Assert.fail("Couldn't execute webservice call!"); return; } assertTrue(response.getNumberOfItemsFound() > 99); @@ -75,7 +96,7 @@ public class PDBRestClientTest assertTrue(response.getSearchSummary().size() > 99); } - @Test + @Test(groups = { "Functional" }) public void getPDBDocFieldsAsCommaDelimitedStringTest() { List wantedFields = new ArrayList(); @@ -92,7 +113,7 @@ public class PDBRestClientTest assertEquals("", expectedResult, actualResult); } - @Test + @Test(groups = { "External, Network" }) public void parsePDBJsonExceptionStringTest() { List wantedFields = new ArrayList(); @@ -130,7 +151,9 @@ public class PDBRestClientTest assertEquals(expectedErrorMsg, parsedErrorResponse); } - @Test(expected = Exception.class) + @Test( + groups = { "External", "Network" }, + expectedExceptions = Exception.class) public void testForExpectedRuntimeException() throws Exception { List wantedFields = new ArrayList(); @@ -143,7 +166,7 @@ public class PDBRestClientTest new PDBRestClient().executeRequest(request); } - @Test + @Test(groups = { "External" }) public void parsePDBJsonResponseTest() { List wantedFields = new ArrayList(); @@ -172,7 +195,7 @@ public class PDBRestClientTest assertTrue(response.getSearchSummary().size() == 14); } - @Test + @Test(groups = { "Functional" }) public void getPDBIdColumIndexTest() { List wantedFields = new ArrayList(); @@ -185,7 +208,7 @@ public class PDBRestClientTest assertEquals(4, PDBRestClient.getPDBIdColumIndex(wantedFields, false)); } - @Test + @Test(groups = { "External" }) public void externalServiceIntegrationTest() { ClientConfig clientConfig = new DefaultClientConfig(); @@ -207,7 +230,7 @@ public class PDBRestClientTest // Check the response status and report exception if one occurs if (clientResponse.getStatus() != 200) { - fail("Webservice call failed!!!"); + Assert.fail("Webservice call failed!!!"); } else { @@ -241,14 +264,14 @@ public class PDBRestClientTest if (pdbJsonDoc.get(field.getCode()) == null) { // System.out.println(">>>\t" + field.getCode()); - assertTrue(field.getClass() + assertTrue(field.getCode() + " has been removed from PDB doc Entity", !pdbJsonResponseString.contains(field.getCode())); } } } catch (ParseException e) { - fail(">>> Test failed due to exception while parsing pdb response json !!!"); + Assert.fail(">>> Test failed due to exception while parsing pdb response json !!!"); e.printStackTrace(); } } @@ -268,7 +291,7 @@ public class PDBRestClientTest sb.append(line); sb.append(System.lineSeparator()); line = br.readLine(); - } + } fileContent = sb.toString(); } finally {