2

I had a dynamic web project which I configured to use Maven. Now I am trying to run unit testing the login servlet(with JUnit, without spring), but eclipse always gives me the same error when I try to run the test case. The error is: 'An internal error occurred during: "Launching LoginPatientTest". Cannot invoke "org.eclipse.m2e.core.project.IMavenProjectFacade.getMavenProject (org.eclipse.core.runtime.IProgressMonitor)" because "facade" is null'. My test case is :

package control;

import static org.mockito.Mockito.*;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import model.ProfileManager;
import model.Bean.PatientBean;

public class LoginPatientTest {

    String fiscal_code;
    String user_password;
    
    @Before
    public void setUp() throws Exception {
        fiscal_code = "aaaaaaa";
        user_password = "bbbbb";
    }

    @After
    public void tearDown() throws Exception {
    }

    @Test
    public void testPresent() throws IOException, ServletException{
           HttpServletRequest req = mock(HttpServletRequest.class);
           HttpServletResponse res = mock(HttpServletResponse.class);
           HttpSession session = mock(HttpSession.class);
           when(req.getSession()).thenReturn(session);
           ProfileManager pm = mock(ProfileManager.class);
           when(pm.ReturnPatientByKey(fiscal_code, user_password)).thenReturn(new PatientBean());
           LoginPatient servlet = new LoginPatient();
           servlet.doPost(req, res);
        }

}

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Martha
  • 35
  • 1
  • 8
  • See the fix at https://stackoverflow.com/questions/31800639/an-internal-error-occurred-during-updating-maven-project-org-eclipse-m2e-wtp – Lisa Nov 22 '21 at 01:00

1 Answers1

0

Switch workspace to another, then return to your original workspace.

Another solution: restart eclipse.

Rubén Aguado
  • 123
  • 2
  • 9