当前位置: 首页>>代码示例>>Java>>正文


Java ActionSupport类代码示例

本文整理汇总了Java中com.opensymphony.xwork2.ActionSupport的典型用法代码示例。如果您正苦于以下问题:Java ActionSupport类的具体用法?Java ActionSupport怎么用?Java ActionSupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ActionSupport类属于com.opensymphony.xwork2包,在下文中一共展示了ActionSupport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testUpload

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
@Test
public void testUpload() throws Exception {
    File file = File.createTempFile("tmp", NON_ZIP_EXTENSION);

    List<File> files = new ArrayList<File>();
    List<String> fileNames = new ArrayList<String>();
    files.add(file);
    fileNames.add(file.getName());
    action.setUpload(files);
    action.setUploadFileName(fileNames);

    MockHttpServletResponse response = new MockHttpServletResponse();
    ServletActionContext.setResponse(response);

    assertEquals(ActionSupport.NONE, action.upload());
    JSONArray jsonResult = JSONArray.fromObject(response.getContentAsString());
    assertEquals(1, jsonResult.size());
    JSONObject map = jsonResult.getJSONObject(0);
    assertEquals(2, map.keySet().size());
    assertTrue(map.get("name").toString().contains(NON_ZIP_EXTENSION));
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:22,代码来源:UploadProjectFilesActionTest.java

示例2: testUpload_UnexpectedError

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
@Test
public void testUpload_UnexpectedError() throws Exception {
    String uploadingErrorKey = UploadProjectFilesAction.UPLOADING_ERROR_KEY;
    File file = File.createTempFile("tmp", ZIP_EXTENSION);

    List<File> files = Lists.newArrayList(file);
    List<String> uploadFileNames = Lists.newArrayList(file.getName());
    action.setUpload(files);
    action.setUploadFileName(uploadFileNames);

    when(
            mockUploadUtils.uploadFiles(any(Project.class), anyListOf(FileWrapper.class))).thenThrow(new IllegalStateException());

    MockHttpServletResponse response = new MockHttpServletResponse();
    ServletActionContext.setResponse(response);

    assertEquals(ActionSupport.NONE, action.upload());
    JSONArray jsonResult = JSONArray.fromObject(response.getContentAsString());
    assertEquals(1, jsonResult.size());
    JSONObject map = jsonResult.getJSONObject(0);
    assertEquals(2, map.keySet().size());
    assertTrue(map.get("name").toString().contains(ZIP_EXTENSION));

    assertTrue(map.get("error").toString(), map.get("error").toString().contains(uploadingErrorKey));
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:26,代码来源:UploadProjectFilesActionTest.java

示例3: newOwner

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
@Test
public void newOwner() {
    OwnershipAction action  = new OwnershipAction();
    String ret = action.newOwner();
    assertEquals("assets", ret);


    action.setGroupIds(Arrays.asList(1L, 2L, 3L));
    action.setProjectIds(Arrays.asList(1L, 2L, 3L));
    User owner = new User();
    owner.setUserId(1L);
    action.setTargetUser(owner);

    ret = action.newOwner();
    assertEquals(ActionSupport.SUCCESS, ret);
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:17,代码来源:OwnershipActionTest.java

示例4: findField

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
/**
 * Tries to find field by name in given class or it super classes up to
 * (excluded) ActionSupport or Object.
 * 
 * @param clazz
 *            Class to start searching a field from.
 * @param fieldName
 *            Name of the field to search.
 * @return Field instance or <code>null</code> if no such field is found.
 */
Field findField(Class<?> clazz, final String fieldName) {
    Field field = null;
    if (clazz != null && fieldName != null) {
        do {
            try {
                field = clazz.getDeclaredField(fieldName);
            } catch (NoSuchFieldException nsfe) {
                if (LOG.isTraceEnabled()) {
                    LOG.trace("In findField", nsfe);
                }
            }
            clazz = clazz.getSuperclass();
        } while (clazz != ActionSupport.class && clazz != Object.class
                && clazz != null && field == null);
    }
    return field;
}
 
开发者ID:aleksandr-m,项目名称:struts2-actionflow,代码行数:28,代码来源:ActionFlowConfigBuilder.java

示例5: testCreatePlot

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
@Test
public void testCreatePlot() throws Exception {
    setupActionVariables();
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    action.setCreatePlotSelected(true);
    assertEquals(ActionSupport.INPUT, action.createPlot());
    action.getKmPlotParameters().setSurvivalValueDefinition(new SurvivalValueDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().setId(Long.valueOf(1));
    action.getKmPlotParameters().getSurvivalValueDefinition().setSurvivalStartDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getSurvivalStartDate().setDataType(AnnotationTypeEnum.DATE);
    action.getKmPlotParameters().getSurvivalValueDefinition().setDeathDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getDeathDate().setDataType(AnnotationTypeEnum.DATE);
    action.getKmPlotParameters().getSurvivalValueDefinition().setLastFollowupDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getLastFollowupDate().setDataType(AnnotationTypeEnum.DATE);
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    verify(analysisService, times(1)).createKMPlot(any(StudySubscription.class), any(AbstractKMParameters.class));
    assertTrue(action.isCreatable());
}
 
开发者ID:NCIP,项目名称:caintegrator,代码行数:19,代码来源:KMPlotQueryBasedActionTest.java

示例6: testCreatePlot

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
@Test
public void testCreatePlot() throws Exception {
    setupActionVariables();
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    action.setCreatePlotSelected(true);
    assertEquals(ActionSupport.INPUT, action.createPlot());
    action.getKmPlotParameters().setSurvivalValueDefinition(new SurvivalValueDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().setId(Long.valueOf(1));
    action.getKmPlotParameters().getSurvivalValueDefinition().setSurvivalStartDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getSurvivalStartDate().setDataType(AnnotationTypeEnum.DATE);
    action.getKmPlotParameters().getSurvivalValueDefinition().setDeathDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getDeathDate().setDataType(AnnotationTypeEnum.DATE);
    action.getKmPlotParameters().getSurvivalValueDefinition().setLastFollowupDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getLastFollowupDate().setDataType(AnnotationTypeEnum.DATE);
    action.getKmPlotParameters().setControlSampleSetName("controls");
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    verify(analysisService, atLeastOnce()).createKMPlot(any(StudySubscription.class), any(AbstractKMParameters.class));

    assertTrue(action.isCreatable());
}
 
开发者ID:NCIP,项目名称:caintegrator,代码行数:21,代码来源:KMPlotGeneExpressionBasedActionTest.java

示例7: testCreatePlot

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
@Test
public void testCreatePlot() throws Exception {
    setupActionVariables();
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    action.setCreatePlotSelected(true);
    assertEquals(ActionSupport.INPUT, action.createPlot());
    action.getPlotParameters().getSelectedValues().clear();
    action.getPlotParameters().getSelectedValues().add(val1);
    action.getPlotParameters().getSelectedValues().add(val2);
    assertEquals(ActionSupport.INPUT, action.createPlot());
    action.getPlotParameters().setGeneSymbol("EGFR");
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    verify(analysisService, atLeastOnce()).createGeneExpressionPlot(any(StudySubscription.class),
            any(AbstractGEPlotParameters.class));
    assertFalse(action.isCreatable());

    action.getGePlotForm().getAnnotationBasedForm().setSelectedAnnotationId("1");
    action.getGePlotForm().getAnnotationBasedForm().setAnnotationGroupSelection("subjectAnnotations");
    assertTrue(action.isCreatable());
}
 
开发者ID:NCIP,项目名称:caintegrator,代码行数:21,代码来源:GEPlotAnnotationBasedActionTest.java

示例8: handleErrorData

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
/**
 * Injects the errors in the action using the ErrorData object from the list
 * @param errorData
 * @param action
 */
public static void handleErrorData(ErrorData errorData, ActionSupport action){
	String fieldName=errorData.getFieldName();
	if (fieldName==null) {
		action.addActionError(createMessage(errorData, action));
	} else {			   
		action.addFieldError(fieldName,createMessage(errorData, action));
	}
	
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:15,代码来源:ErrorHandlerStruts2Adapter.java

示例9: createMessage

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
/**
 * Gets a localized message with no- or more (localized or not localized) parameters  
 * @param errorData
 * @param action
 * @return
 */
private static String createMessage(ErrorData errorData, ActionSupport action){
	String key=errorData.getResourceKey();
	List<Object> params=new LinkedList<Object>();
	if(errorData.getResourceParameters()!=null) {
		for (ErrorParameter parameter : errorData.getResourceParameters()) {
			if(parameter.isResource()){
				params.add(action.getText(parameter.getParameterValue()+""));
			}else{
				params.add(parameter.getParameterValue());
			}
		}
	}
	return action.getText(key, params);
}
 
开发者ID:trackplus,项目名称:Genji,代码行数:21,代码来源:ErrorHandlerStruts2Adapter.java

示例10: testHelloWorld

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
public void testHelloWorld() throws Exception {
    HelloWorld hello_world = new HelloWorld();
    String result = hello_world.execute();
    assertTrue("Expected a success result!",
            ActionSupport.SUCCESS.equals(result));
    assertTrue("Expected the default message!",
            hello_world.getText(HelloWorld.MESSAGE).equals(hello_world.getMessage()));
}
 
开发者ID:wisthy,项目名称:BeeBreedingManager,代码行数:9,代码来源:HelloWorldTest.java

示例11: addFieldErrors

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
public void addFieldErrors(ActionSupport actionAs,
		Collection invalidValuesFromRequest) {
	for (ConstraintViolation constraintViolation : (List<ConstraintViolation>)invalidValuesFromRequest) {
		StringBuilder sbMessage = new StringBuilder(actionAs.getText(constraintViolation.getPropertyPath().toString(),""));
		if (sbMessage.length()>0)
			sbMessage.append(" - ");
		sbMessage.append(actionAs.getText(constraintViolation.getMessage()));
		actionAs.addFieldError(constraintViolation.getPropertyPath().toString(), sbMessage.toString());
	}
}
 
开发者ID:javalover123,项目名称:full-hibernate-plugin-for-struts2,代码行数:11,代码来源:Struts2HibernateValidatorV402.java

示例12: doInvalidFileExceptionTest

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
private void doInvalidFileExceptionTest(String expectedErrorKey, boolean unpackSelected) throws Exception {
    String errorKey = "key";
    String errorMessage = "message";
    String errorUnpackingZipKey = "errors.unpackingErrorWithZip";
    File file = File.createTempFile("tmp", ZIP_EXTENSION);

    List<File> files = Lists.newArrayList(file);
    List<String> uploadFileNames = Lists.newArrayList(file.getName());
    action.setUpload(files);
    action.setUploadFileName(uploadFileNames);

    if (unpackSelected) {
        action.setSelectedFilesToUnpack(Lists.newArrayList(file.getName()));
    }

    when(
            mockUploadUtils.uploadFiles(any(Project.class), anyListOf(FileWrapper.class))).thenThrow(
            new InvalidFileException(file.getName(), errorKey, errorMessage));

    MockHttpServletResponse response = new MockHttpServletResponse();
    ServletActionContext.setResponse(response);

    assertEquals(ActionSupport.NONE, action.upload());
    JSONArray jsonResult = JSONArray.fromObject(response.getContentAsString());
    assertEquals(1, jsonResult.size());
    JSONObject map = jsonResult.getJSONObject(0);
    assertEquals(2, map.keySet().size());
    assertTrue(map.get("name").toString().contains(ZIP_EXTENSION));

    assertTrue(map.get("error").toString(), map.get("error").toString().contains(expectedErrorKey));
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:32,代码来源:UploadProjectFilesActionTest.java

示例13: testPartialUploadCheck

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
@Test
public void testPartialUploadCheck() throws Exception {
    action.setChunkedFileName("testfile");
    action.setChunkedFileSize(1234L);
    CaArrayFile file = new CaArrayFile();
    file.setPartialSize(111L);
    when(fileDao.getPartialFile(anyLong(), eq("testfile"), eq(1234L))).thenReturn(file);
    MockHttpServletResponse response = new MockHttpServletResponse();
    ServletActionContext.setResponse(response);
    assertEquals(ActionSupport.NONE, action.partialUploadCheck());
    JSONObject asdf = JSONObject.fromObject(response.getContentAsString());
    assertEquals(111L, asdf.getLong("size"));
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:14,代码来源:UploadProjectFilesActionTest.java

示例14: testUploadMessages

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
@Test
public void testUploadMessages() throws Exception {
    File file = File.createTempFile("tmp", NON_ZIP_EXTENSION);
    List<File> files = new ArrayList<File>();
    List<String> fileNames = new ArrayList<String>();
    files.add(file);
    fileNames.add(file.getName());
    action.setUpload(files);
    action.setUploadFileName(fileNames);

    // Upload a file and check for success message
    FileProcessingResult result = new FileProcessingResult();
    result.addSuccessfulFile(file.getName());
    when(mockUploadUtils.uploadFiles(any(Project.class), anyListOf(FileWrapper.class))).thenReturn(result);
    assertEquals(ActionSupport.NONE, action.upload());
    List<String> msgs = ActionHelper.getMessages();
    assertEquals(1, msgs.size());
    assertEquals(1 + UploadProjectFilesAction.FILE_UPLOADED_MSG_SUFFIX, msgs.get(0));

    // Upload a second file and check for updated success message
    FileProcessingResult result2 = new FileProcessingResult();
    result2.addSuccessfulFile("file2");
    when(mockUploadUtils.uploadFiles(any(Project.class), anyListOf(FileWrapper.class))).thenReturn(result2);
    assertEquals(ActionSupport.NONE, action.upload());
    msgs = ActionHelper.getMessages();
    assertEquals(1, msgs.size());
    assertEquals(2 + UploadProjectFilesAction.FILE_UPLOADED_MSG_SUFFIX, msgs.get(0));
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:29,代码来源:UploadProjectFilesActionTest.java

示例15: testDownloadDicomFile

import com.opensymphony.xwork2.ActionSupport; //导入依赖的package包/类
@Test
public void testDownloadDicomFile() {
    NCIADicomJob dicomJob = new NCIADicomJob();
    assertEquals(ActionSupport.ERROR, nciaRetrievalAction.downloadDicomFile());
    dicomJob.setCompleted(true);
    dicomJob.setDicomFile(TestDataFiles.VALID_FILE);
    SessionHelper.getInstance().getDisplayableUserWorkspace().setDicomJob(dicomJob);
    assertEquals("dicomFileResult", nciaRetrievalAction.downloadDicomFile());
}
 
开发者ID:NCIP,项目名称:caintegrator,代码行数:10,代码来源:NCIADicomRetrievalActionTest.java


注:本文中的com.opensymphony.xwork2.ActionSupport类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。