### Question:
BasicSubjectServletCreator implements SubjectCreate { @Override public Subject createSubject(Object context) { String authorization = ((HttpServletRequest)context).getHeader(AUTHORIZATION); String basicAuth = authorization.replace(BASIC, "").trim(); basicAuth = new String(Base64.getDecoder().decode(basicAuth), StandardCharsets.UTF_8); String[] auth = basicAuth.split(":"); if (auth.length != COUNT_2) { if (logger.isInfoEnabled()) { logger.info("can not create basic auth PasswordSubject by this request message"); } return null; } String username = auth[0]; if (username == null || "".equals(username)) { if (logger.isInfoEnabled()) { logger.info("can not create basic auth PasswordSubject by this request message, appId can not null"); } return null; } String password = auth[1]; String remoteHost = ((HttpServletRequest) context).getRemoteHost(); String requestUri = ((HttpServletRequest) context).getRequestURI(); String requestType = ((HttpServletRequest) context).getMethod(); String targetUri = requestUri.concat("===").concat(requestType).toLowerCase(); return PasswordSubject.builder(username, password) .setRemoteHost(remoteHost) .setTargetResource(targetUri) .build(); }  @Override boolean canSupportSubject(Object context); @Override Subject createSubject(Object context);  }### Answer:
@Test public void createSubject() { HttpServletRequest request = createNiceMock(HttpServletRequest.class); expect(request.getHeader(AUTHORIZATION)).andReturn(BASIC + " " + new String(Base64.getEncoder().encode("admin:admin".getBytes(StandardCharsets.UTF_8)))); expect(request.getRequestURI()).andReturn("/api/v1/book"); expect(request.getMethod()).andReturn("put"); expect(request.getRemoteHost()).andReturn("192.167.2.1"); replay(request); assertNotNull(creator.createSubject(request)); verify(request); }