diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/UrlParamsHelper.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/UrlParamsHelper.java index dbc3bc189420f7091530fe33bca79b976d67fdde..338cf589d0742b6d4ac61bd7b17b572393c52161 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/UrlParamsHelper.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/UrlParamsHelper.java @@ -131,6 +131,14 @@ public final class UrlParamsHelper setUrlParams(parseParamString(nonEmptyParameterString)); } + /** + * A public version of initializeUrlParamters used by a test case + */ + public final void initializeUrlParametersForTest(String nonEmptyParameterString) + { + initializeUrlParameters(nonEmptyParameterString); + } + public final IDelegatedAction getOpenInitialTabAction() { return new OpenInitialTabAction(); @@ -138,9 +146,9 @@ public final class UrlParamsHelper /** * An action that opens the initial tab specified by the URL parameters. This class is given - * package visibility so it can be used by a test. + * public visibility so it can be used by a test. */ - class OpenInitialTabAction implements IDelegatedAction + public class OpenInitialTabAction implements IDelegatedAction { public void execute() @@ -164,10 +172,9 @@ public final class UrlParamsHelper } /** - * Opens an initial tab if a parameter is specified in URL. Given package visibility so it - * can be used by a test. + * Opens an initial tab if a parameter is specified in URL. */ - void openInitialTabUnderExceptionHandler() throws UserFailureException + private void openInitialTabUnderExceptionHandler() throws UserFailureException { // If a permlink has been specified, open a viewer on the specified object String entityKindValueOrNull = @@ -191,6 +198,14 @@ public final class UrlParamsHelper } } + /** + * A public version of openInitialTabUnderExceptionHandler() used by the test case. + */ + public void openInitialTabUnderExceptionHandlerForTest() throws UserFailureException + { + openInitialTabUnderExceptionHandler(); + } + /** * Open the entity details tab for the specified entity kind and permId. */ diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/UrlParamsHelperTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/clientnonjs/UrlParamsHelperTest.java similarity index 86% rename from openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/UrlParamsHelperTest.java rename to openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/clientnonjs/UrlParamsHelperTest.java index 7699136e4a6beb4c55f4feba3d5257a4ea309b11..1a36d2094ede85b9e86cf9ec7da702bb0627426d 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/UrlParamsHelperTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/clientnonjs/UrlParamsHelperTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application; +package ch.systemsx.cisd.openbis.generic.client.web.clientnonjs; import org.jmock.Expectations; import org.jmock.Mockery; @@ -24,6 +24,9 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.UrlParamsHelper; import ch.systemsx.cisd.openbis.generic.client.web.client.application.UrlParamsHelper.OpenInitialTabAction; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ListSampleDisplayCriteria; @@ -76,7 +79,7 @@ public class UrlParamsHelperTest extends AssertJUnit }); final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext); - urlParamsHelper.initializeUrlParameters("entity=SAMPLE&permId=20100104150239401-871"); + urlParamsHelper.initializeUrlParametersForTest("entity=SAMPLE&permId=20100104150239401-871"); IDelegatedAction action = urlParamsHelper.getOpenInitialTabAction(); action.execute(); @@ -102,12 +105,12 @@ public class UrlParamsHelperTest extends AssertJUnit // No permId supplied urlParamsHelper = new UrlParamsHelper(viewContext); - urlParamsHelper.initializeUrlParameters("entity=SAMPLE"); + urlParamsHelper.initializeUrlParametersForTest("entity=SAMPLE"); action = (OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction(); try { - action.openInitialTabUnderExceptionHandler(); + action.openInitialTabUnderExceptionHandlerForTest(); fail("A URL with no permId should result in an exception."); } catch (UserFailureException expected) { @@ -116,12 +119,12 @@ public class UrlParamsHelperTest extends AssertJUnit // No entity supplied urlParamsHelper = new UrlParamsHelper(viewContext); - urlParamsHelper.initializeUrlParameters("permId=20100104150239401-871"); + urlParamsHelper.initializeUrlParametersForTest("permId=20100104150239401-871"); action = (OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction(); try { - action.openInitialTabUnderExceptionHandler(); + action.openInitialTabUnderExceptionHandlerForTest(); fail("A URL with no entity should result in an exception."); } catch (UserFailureException expected) { @@ -147,12 +150,12 @@ public class UrlParamsHelperTest extends AssertJUnit UrlParamsHelper.OpenInitialTabAction action; urlParamsHelper = new UrlParamsHelper(viewContext); - urlParamsHelper.initializeUrlParameters("entity=JUNK"); + urlParamsHelper.initializeUrlParametersForTest("entity=JUNK"); action = (OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction(); try { - action.openInitialTabUnderExceptionHandler(); + action.openInitialTabUnderExceptionHandlerForTest(); fail("A URL with invalid entity should result in an exception."); } catch (UserFailureException expected) { @@ -180,7 +183,7 @@ public class UrlParamsHelperTest extends AssertJUnit }); final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext); - urlParamsHelper.initializeUrlParameters("searchEntity=SAMPLE&code=CL1"); + urlParamsHelper.initializeUrlParametersForTest("searchEntity=SAMPLE&code=CL1"); IDelegatedAction action = urlParamsHelper.getOpenInitialTabAction(); action.execute(); @@ -206,7 +209,7 @@ public class UrlParamsHelperTest extends AssertJUnit }); final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext); - urlParamsHelper.initializeUrlParameters("searchEntity=SAMPLE"); + urlParamsHelper.initializeUrlParametersForTest("searchEntity=SAMPLE"); IDelegatedAction action = urlParamsHelper.getOpenInitialTabAction(); action.execute(); @@ -227,14 +230,14 @@ public class UrlParamsHelperTest extends AssertJUnit }); final UrlParamsHelper urlParamsHelper = new UrlParamsHelper(viewContext); - urlParamsHelper.initializeUrlParameters("searchEntity=DATA_SET"); + urlParamsHelper.initializeUrlParametersForTest("searchEntity=DATA_SET"); OpenInitialTabAction action = (OpenInitialTabAction) urlParamsHelper.getOpenInitialTabAction(); try { - action.openInitialTabUnderExceptionHandler(); + action.openInitialTabUnderExceptionHandlerForTest(); fail("Only SAMPLE is supported by the search link mechanism right now."); } catch (UserFailureException expected) {