From: gmungoc Date: Fri, 18 Sep 2015 15:35:39 +0000 (+0100) Subject: Merge branch 'develop' of https://source.jalview.org/git/jalview.git into develop X-Git-Tag: Release_2_10_0~394^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=847076c1a2868b171e517753ea5c39326026bde1;hp=4a43369c96bc932961492509c4008972d4d566e5;p=jalview.git Merge branch 'develop' of https://source.jalview.org/git/jalview.git into develop --- diff --git a/build.xml b/build.xml index bb743d6..e1ca55f 100755 --- a/build.xml +++ b/build.xml @@ -19,7 +19,7 @@ --> - + @@ -30,6 +30,8 @@ + + @@ -62,12 +64,12 @@ --> - + - + - + @@ -81,18 +83,20 @@ + + - + - - - - - + + + + + @@ -118,9 +122,9 @@ - - - + + + @@ -145,7 +149,7 @@ - + @@ -162,7 +169,7 @@ - + @@ -170,17 +177,17 @@ - + - + - + @@ -189,20 +196,20 @@ - - - - + + + + - - - + + +
---Jalview Build Details--- -
+ @@ -212,7 +219,7 @@ - + @@ -255,47 +262,34 @@ - - + + - + - - - - - - - - - - - - - - - - - - - - + + + - - - - - + + + + + + + + - - - - + + + + + + + - + @@ -305,7 +299,7 @@ - + @@ -318,11 +312,11 @@ - + - + - + @@ -332,21 +326,21 @@ - + - + - + - + - + - + - + @@ -551,13 +545,11 @@ - + - + @@ -565,7 +557,7 @@ - + @@ -605,7 +597,7 @@ - + @@ -659,10 +651,10 @@ - - - - + + + + @@ -687,27 +679,27 @@ - - - + + + - + - - - + + + - + - - + + @@ -780,13 +772,13 @@ - - - + + + - - - + + + @@ -817,7 +809,7 @@ - + @@ -838,19 +830,23 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/doc/UnitTesting.html b/doc/UnitTesting.html index 5db587b..801f064 100644 --- a/doc/UnitTesting.html +++ b/doc/UnitTesting.html @@ -24,7 +24,7 @@

Unit testing in Jalview

-In June 2015, the Jalview team adopted TestNG as the favourite unit testing framework. Consequently all existing JUnit tests were ported to TestNG. +In June 2015, the Jalview team adopted TestNG for handling unit tests, and all existing JUnit tests were ported to TestNG.

Test Groups

@@ -89,12 +89,11 @@ The TestNG tests for Jalview can be executed in any of the following ways: A more detailed guide for installing and executing TestNG in eclipse is available at testng.org/doc/eclipse.html
 
  • From Ant: -
    To execute Jalview unit test from ant please take the following steps: +
    The ant task 'testng' will run Jalview's tests. You should:
    • Ensure that you have ant installed
    • Ensure that your test classes are error free and properly annotated
    • -
    • Ensure that the test class or group is available in the TestNG config file. For Jalview this is located in jalview/utils/jalview_testng.xml
    • -
    • Add a TestNG run target to your main ant build file, and execute the target.
    • +
    • Specify the desired group of tests by passing a comma separated list of one or more groups via -Dtestng-groups=""
    A more detailed guide for executing TestNG from ant is available at http://testng.org/doc/ant.html
  • diff --git a/src/com/stevesoft/pat/RegexWriter.java b/src/com/stevesoft/pat/RegexWriter.java index 61bcdf6..57e2170 100755 --- a/src/com/stevesoft/pat/RegexWriter.java +++ b/src/com/stevesoft/pat/RegexWriter.java @@ -8,6 +8,7 @@ package com.stevesoft.pat; import java.io.IOException; +import java.io.StringWriter; import java.io.Writer; import com.stevesoft.pat.wrap.WriterWrap; @@ -231,4 +232,51 @@ public class RegexWriter extends Writer { bufferSize = i; } + + static void test(String re, String inp, int n) throws Exception + { + StringWriter sw = new StringWriter(); + Regex rex = Regex.perlCode(re); + String res1 = rex.replaceAll(inp); + RegexWriter rw = new RegexWriter(rex, sw); + for (int i = 0; i < inp.length(); i++) + { + rw.write(inp.charAt(i)); + } + rw.close(); + String res2 = sw.toString(); + if (!res1.equals(res2)) + { + System.out.println("nmax=" + n); + System.out.println("re=" + re); + System.out.println("inp=" + inp); + System.out.println("res1=" + res1); + System.out.println("res2=" + res2); + System.exit(255); + } + } + + public static void main(String[] args) throws Exception + { + for (int n = 1; n <= 1; n++) + { + test("s/x/y/", "-----x123456789", n); + test("s/x/y/", "x123456789", n); + test("s/x/y/", "-----x", n); + test("s/x.*?x/y/", ".xx..x..x...x...x....x....x", n); + test("s/x.*x/[$&]/", "--x........x--xx", n); + test("s/x.*x/[$&]/", "--x........x------", n); + test("s/.$/a/m", "bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbbbbbbbbbbbb", n); + test("s/.$/a/", "123", n); + test("s/.$/a/", "bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbb", n); + test("s/^./a/", "bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbb", n); + test("s/$/a/", "bbb", n); + test("s/^/a/", "bbb", n); + test("s/^/a/", "", n); + test("s{.*}{N}", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", n); + test("s/.{0,7}/y/", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", n); + test("s/x/$&/", "xxx", n); + } + System.out.println("Success!!!"); + } } diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index c9183d5..2a2fc81 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -105,6 +105,8 @@ import java.util.Map; import java.util.StringTokenizer; import java.util.Vector; +import javax.swing.JOptionPane; + import org.jmol.viewer.Viewer; public class AlignFrame extends EmbmenuFrame implements ActionListener, @@ -2061,9 +2063,25 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, seqs.addElement(seq); } - // If the cut affects all sequences, remove highlighted columns - if (sg.getSize() == viewport.getAlignment().getHeight()) + /* + * If the cut affects all sequences, warn, remove highlighted columns + */if (sg.getSize() == viewport.getAlignment().getHeight()) { + boolean isEntireAlignWidth = (((sg.getEndRes() - sg.getStartRes()) + 1) == viewport + .getAlignment().getWidth()) ? true : false; + if (isEntireAlignWidth) + { + int confirm = JOptionPane.showConfirmDialog(this, + MessageManager.getString("warn.delete_all"), // $NON-NLS-1$ + MessageManager.getString("label.delete_all"), // $NON-NLS-1$ + JOptionPane.OK_CANCEL_OPTION); + + if (confirm == JOptionPane.CANCEL_OPTION + || confirm == JOptionPane.CLOSED_OPTION) + { + return; + } + } viewport.getColumnSelection().removeElements(sg.getStartRes(), sg.getEndRes() + 1); } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index e40e936..eda4a1c 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -2370,26 +2370,26 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, /* * If the cut affects all sequences, warn, remove highlighted columns */ - - boolean isEntireAlignWidth = (((sg.getEndRes() - sg.getStartRes()) + 1) == viewport - .getAlignment().getWidth()) ? true : false; - if (sg.getSize() == viewport.getAlignment().getHeight() - && isEntireAlignWidth) + if (sg.getSize() == viewport.getAlignment().getHeight()) { - int confirm = JOptionPane.showConfirmDialog(this, - MessageManager.getString("warn.delete_all"), // $NON-NLS-1$ - MessageManager.getString("label.delete_all"), // $NON-NLS-1$ - JOptionPane.OK_CANCEL_OPTION); - - if (confirm == JOptionPane.CANCEL_OPTION - || confirm == JOptionPane.CLOSED_OPTION) + boolean isEntireAlignWidth = (((sg.getEndRes() - sg.getStartRes()) + 1) == viewport + .getAlignment().getWidth()) ? true : false; + if (isEntireAlignWidth) { - return; + int confirm = JOptionPane.showConfirmDialog(this, + MessageManager.getString("warn.delete_all"), // $NON-NLS-1$ + MessageManager.getString("label.delete_all"), // $NON-NLS-1$ + JOptionPane.OK_CANCEL_OPTION); + + if (confirm == JOptionPane.CANCEL_OPTION + || confirm == JOptionPane.CLOSED_OPTION) + { + return; + } } viewport.getColumnSelection().removeElements(sg.getStartRes(), sg.getEndRes() + 1); } - SequenceI[] cut = sg.getSequences() .toArray(new SequenceI[sg.getSize()]); @@ -2401,7 +2401,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, viewport.setSelectionGroup(null); viewport.sendSelection(); viewport.getAlignment().deleteGroup(sg); - viewport.getColumnSelection().clear(); viewport.firePropertyChange("alignment", null, viewport.getAlignment() .getSequences()); diff --git a/src/jalview/json/binding/biojson/v1/SequencePojo.java b/src/jalview/json/binding/biojson/v1/SequencePojo.java index 3b9e798..98fed15 100644 --- a/src/jalview/json/binding/biojson/v1/SequencePojo.java +++ b/src/jalview/json/binding/biojson/v1/SequencePojo.java @@ -28,7 +28,7 @@ public class SequencePojo required = true, minLength = 3, maxLength = 2147483647, - description = "Sequence residue characters. An aligned sequence may contain
    one of the following gap characters “.â€?, “-â€? or “ â€?") + description = "Sequence residue characters. An aligned sequence may contain
    one of the following gap characters “.”, “-” or “ ”") private String seq; @Attributes(required = true, description = "Sequence name") diff --git a/test/com/stevesoft/pat/RegexWriterTest.java b/test/com/stevesoft/pat/RegexWriterTest.java deleted file mode 100644 index 4c06f66..0000000 --- a/test/com/stevesoft/pat/RegexWriterTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ 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 com.stevesoft.pat; - -import static org.testng.AssertJUnit.assertEquals; - -import java.io.IOException; -import java.io.StringWriter; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test class refactored from RegexWriter main method - */ -public class RegexWriterTest -{ - - /** - * Asserts that the result of performing 'replaceAll' on the input using the - * regular expression is the same as the output of a RegexWriter, constructed - * from the regular expression, writing out each character of the input - * string. - * - * @param re - * a regular expression - * @param inp - * an input string - * @throws Exception - */ - - @Test(groups = { "Functional" }, dataProvider = "testWriteParam") - void test(String re, String inp) throws IOException - { - StringWriter sw = new StringWriter(); - Regex rex = Regex.perlCode(re); - String res1 = rex.replaceAll(inp); - RegexWriter rw = new RegexWriter(rex, sw); - for (int i = 0; i < inp.length(); i++) - { - rw.write(inp.charAt(i)); - } - rw.close(); - String res2 = sw.toString(); - if (!res1.equals(res2)) - { - System.out.println("re=" + re); - System.out.println("inp=" + inp); - System.out.println("res1=" + res1); - System.out.println("res2=" + res2); - assertEquals(res1, res2); - } - } - - // @Test(groups ={ "Functional" }) - // public void testWrite() throws IOException - // { - // for (int n = 1; n <= 1; n++) - // { - // test("s/x/y/", "-----x123456789"); - // test("s/x/y/", "x123456789"); - // test("s/x/y/", "-----x"); - // test("s/x.*?x/y/", ".xx..x..x...x...x....x....x"); - // test("s/x.*x/[$&]/", "--x........x--xx"); - // test("s/x.*x/[$&]/", "--x........x------"); - // test("s/.$/a/m", "bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbbbbbbbbbbbb"); - // test("s/.$/a/", "123"); - // test("s/.$/a/", "bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbb"); - // test("s/^./a/", "bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbb"); - // test("s/$/a/", "bbb"); - // test("s/^/a/", "bbb"); - // test("s/^/a/", ""); - // test("s{.*}{N}", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - // test("s/.{0,7}/y/", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - // test("s/x/$&/", "xxx"); - // } - // } - - @DataProvider(name = "testWriteParam") - public Object[][] regexTestParams() - { - return new Object[][] { { "s/x/y/", "-----x123456789" }, - { "s/x/y/", "x123456789" }, { "s/x/y/", "-----x" }, - { "s/x.*?x/y/", ".xx..x..x...x...x....x....x" }, - { "s/x.*x/[$&]/", "--x........x--xx" }, - { "s/x.*x/[$&]/", "--x........x------" }, - { "s/.$/a/m", "bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbbbbbbbbbbbb" }, - { "s/.$/a/", "123" }, - { "s/.$/a/", "bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbb" }, - { "s/^./a/", "bb\nbbb\nbbbb\nbbbbb\nbbbbbb\nbb" }, - { "s/$/a/", "bbb" }, { "s/^/a/", "bbb" }, { "s/^/a/", "" }, - { "s{.*}{N}", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, - { "s/.{0,7}/y/", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" }, - { "s/x/$&/", "xxx" } }; - } -} diff --git a/utils/jalview_testng.xml b/utils/jalview_testng.xml deleted file mode 100644 index ba9e660..0000000 --- a/utils/jalview_testng.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -