Examples of AppService


Examples of com.github.ebnew.ki4so.core.app.AppService

        String password = "pwdsssss";
        UsernamePasswordCredential credential = new UsernamePasswordCredential(username, password);
        DefaultUserPrincipal principal = new DefaultUserPrincipal();
        principal.setId(username);
        //设置模拟服务。
        AppService appService = Mockito.mock(AppService.class);
        Mockito.when(appService.findKi4soServerApp()).thenReturn(null);
        this.handler.setAppService(appService);
        try {
            this.handler.postAuthentication(credential, principal);
            fail("应该抛出异常");
        } catch (NoKi4soKeyException e) {

        }

         /**
         * 测试参数正确的情况,但是ki4so 服务器的app对象不为空的情况。
         * 服务对应的key信息不为的正常情况。
         */
        String appId = "1000";
        String app2Id = "1001";
        String keyId = "1000000";
        String encStringValue = "ssssdafdsafdsafdsafdasfdsafdsa";
        String service = "http://loacahost:8080/ki4so-app/home.do";
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put(WebConstants.SERVICE_PARAM_NAME, service);
        credential.setParameters(parameters);
        App app = new App();
        app.setAppId(appId);
       
        App clientApp = new App();
        clientApp.setAppId(app2Id);
       
        Ki4soKey key = new Ki4soKey();
        key.setKeyId(keyId);
       
        Mockito.when(appService.findKi4soServerApp()).thenReturn(app);
        Mockito.when(appService.findAppByHost(service)).thenReturn(clientApp);
        
        KeyService keyService = Mockito.mock(KeyService.class);
        Mockito.when(keyService.findKeyByAppId(appId)).thenReturn(key);
        Mockito.when(keyService.findKeyByAppId(app2Id)).thenReturn(key);
       
View Full Code Here

Examples of com.github.ebnew.ki4so.core.app.AppService

  public void testGetAppList(){
   
    //当调用认证方法则抛出异常信息。模拟测试数据。
    AuthenticationManager authenticationManager = Mockito.mock(AuthenticationManager.class);
    UserLoggedStatusStore userLoggedStatusStore = Mockito.mock(UserLoggedStatusStore.class);
    AppService appService = Mockito.mock(AppService.class);
    this.ki4soService.setAuthenticationManager(authenticationManager);
    this.ki4soService.setUserLoggedStatusStore(userLoggedStatusStore);
    this.ki4soService.setAppService(appService);
   
    /**
     * 测试传递错误参数的情况。
     */
    Assert.assertEquals(0, this.ki4soService.getAppList(null).size());
   
    /**
     * 测试正确参数的情况。
     */
    Credential credential = Mockito.mock(Credential.class);
    Assert.assertEquals(0, this.ki4soService.getAppList(credential).size());
   
    /**
     * 测试正确参数,但是返回值的属principal为空的情况。
     */
    credential = Mockito.mock(Credential.class);
    Authentication authentication = Mockito.mock(Authentication.class);
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    Assert.assertEquals(0, this.ki4soService.getAppList(credential).size());
   
   
    /**
     * 测试正确参数,但是返回值的属principal不是空的情况。
     */
    credential = Mockito.mock(Credential.class);
    authentication = Mockito.mock(Authentication.class);
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    Mockito.when(authentication.getPrincipal()).thenReturn(Mockito.mock(Principal.class));
    List<UserLoggedStatus> list = new ArrayList<UserLoggedStatus>();
    UserLoggedStatus loggedStatus = new UserLoggedStatus("test", "1001");
    list.add(loggedStatus);
    Mockito.when(userLoggedStatusStore.findUserLoggedStatus(Mockito.anyString())).thenReturn(list);
    App app = new App();
    Mockito.when(appService.findAppById(Mockito.anyString())).thenReturn(app);
    Assert.assertEquals(1, this.ki4soService.getAppList(credential).size());
  }
View Full Code Here

Examples of org.apache.wink.common.model.app.AppService

        // Map of all APP workspaces
        Map<String, AppWorkspace> workspaces = new LinkedHashMap<String, AppWorkspace>();

        // Create APP Service Document
        AppService appService = new AppService();

        // Get list of Workspaces
        List<AppWorkspace> workspaceList = appService.getWorkspace();

        // Loop over the list of Service Document Collections, and add each
        // to relevant Workspace
        for (ServiceDocumentCollectionData serviceDocumentCollection : collectionList) {
View Full Code Here

Examples of org.apache.wink.common.model.app.AppService

            RestClient restClient = new RestClient();

            // Create new Resource on given URL
            Resource resource = restClient.resource(defectsFeed);

            AppService service =
                resource.accept(MediaTypeUtils.ATOM_SERVICE_DOCUMENT).get(AppService.class);

            // Find workspace by it's title
            AppWorkspace workspace = service.getWorkspace(WORKSPACE_TITLE);

            // Find collection by title
            AppCollection collection = workspace.getCollection(COLLECTION_TITLE);
            String href = collection.getHref();
View Full Code Here

Examples of org.apache.wink.common.model.app.AppService

        // Map of all APP workspaces
        Map<String, AppWorkspace> workspaces = new LinkedHashMap<String, AppWorkspace>();

        // Create APP Service Document
        AppService appService = new AppService();

        // Get list of Workspaces
        List<AppWorkspace> workspaceList = appService.getWorkspace();

        // Loop over the list of Service Document Collections, and add each
        // to relevant Workspace
        for (ServiceDocumentCollectionData serviceDocumentCollection : collectionList) {
View Full Code Here

Examples of org.apache.wink.common.model.app.AppService

                                                        "/",
                                                        MediaTypeUtils.ATOM_SERVICE_DOCUMENT_TYPE);
        MockHttpServletResponse response = invoke(request);
        assertEquals("status", HttpStatus.OK.getCode(), response.getStatus());
        String contentString = response.getContentAsString();
        AppService service = AppService.unmarshal(new StringReader(contentString));
        AppWorkspace workspace = service.getWorkspace().get(0);
        AppCollection collection = workspace.getCollection().get(0);
        String href = collection.getHref();
        assertTrue("ipv6 URI: " + href, href.startsWith(http));
    }
View Full Code Here

Examples of org.apache.wink.common.model.app.AppService

                                                        MediaTypeUtils.ATOM_SERVICE_DOCUMENT_TYPE);
        request.setSecure(true);
        MockHttpServletResponse response = invoke(request);
        assertEquals("status", HttpStatus.OK.getCode(), response.getStatus());
        String contentString = response.getContentAsString();
        AppService service = AppService.unmarshal(new StringReader(contentString));
        AppWorkspace workspace = service.getWorkspace().get(0);
        AppCollection collection = workspace.getCollection().get(0);
        String href = collection.getHref();
        assertTrue("ipv6 URI: " + href, href.startsWith(https));
    }
View Full Code Here

Examples of org.apache.wink.common.model.app.AppService

    public void testAppMarshal() throws IOException {
        // Marshaller m = AtomJAXBUtils.createMarshaller(ctx, new
        // JAXBNamespacePrefixMapper(RestConstants.NAMESPACE_APP));
        Marshaller m = AppService.getMarshaller();

        AppService service = getService();
        JAXBElement<AppService> element = (new ObjectFactory()).createService(service);
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        AtomJAXBUtils.marshal(m, element, null, os);
        assertEquals(SERVICE_DOCUMENT, os.toString());
    }
View Full Code Here

Examples of org.apache.wink.common.model.app.AppService

        Unmarshaller u = AppService.getUnmarshaller();
        Object element = AtomJAXBUtils.unmarshal(u, new StringReader(SERVICE_DOCUMENT));
        assertNotNull(element);
        assertTrue(element instanceof AppService);

        AppService service = (AppService)element;
        AppService expectedService = getService();

        assertService(expectedService, service);
    }
View Full Code Here

Examples of org.apache.wink.common.model.app.AppService

            assertEquals(expectedCategories.get(1).getHref(), categories.get(1).getHref());
        }
    }

    private AppService getService() {
        AppService service = new AppService();
        service.setLang("en-us");
        service.setBase("http://base/service");
        service.getOtherAttributes().put(new QName("anyAttirbService"), "anyAttribValueService");

        service.getWorkspace().add(getWorkspace("1"));
        service.getWorkspace().add(getWorkspace("2"));

        service.getWorkspace();
        return service;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.