Package org.rhq.modules.plugins.jbossas7.json

Examples of org.rhq.modules.plugins.jbossas7.json.Result


            .withParameterTypes(ConfigurationDefinition.class, ASConnection.class, Address.class)
            .withArguments(any(ConfigurationDefinition.class), any(ASConnection.class), any(Address.class))
            .thenReturn(mockConfigurationWriteDelegate);

        ASConnection mockASConnection = mock(ASConnection.class);
        when(mockASConnection.execute(any(ReadResource.class))).thenReturn(new Result());


        //create object to test and inject required dependencies
        TemplatedComponent objectUnderTest = new TemplatedComponent();
View Full Code Here


            .withParameterTypes(ConfigurationDefinition.class, ASConnection.class, Address.class)
            .withArguments(any(ConfigurationDefinition.class), any(ASConnection.class), any(Address.class))
            .thenReturn(mockConfigurationWriteDelegate);

        ASConnection mockASConnection = mock(ASConnection.class);
        when(mockASConnection.execute(any(ReadResource.class))).thenReturn(new Result());

        //create object to test and inject required dependencies
        TemplatedComponent objectUnderTest = new TemplatedComponent();

        objectUnderTest.context = mockResourceContext;
View Full Code Here

        if (verbose) {
            log.info("total path: [" + path + "]");
        }

        Address addr = new Address(parentPath);
        Result result = connection.execute(new ReadChildrenNames(addr, confPath));

        if (result.isSuccess()) {

            @SuppressWarnings("unchecked")
            List<String> deployments = (List<String>) result.getResult();

            // There may be multiple children of the given type
            for (String val : deployments) {

                String newPath = confPath + "=" + val;
View Full Code Here

                subTypes.add(confPath);

            for (String cpath : subTypes) {

                Address addr = new Address(parentPath);
                Result result = connection.execute(new ReadChildrenNames(addr, cpath));

                if (result.isSuccess()) {

                    @SuppressWarnings("unchecked")
                    List<String> subsystems = (List<String>) result.getResult();

                    // There may be multiple children of the given type
                    for (String val : subsystems) {

                        String newPath = cpath + "=" + val;
                        Configuration config2 = context.getDefaultPluginConfiguration();

                        String resKey;

                        if (path == null || path.isEmpty())
                            resKey = newPath;
                        else {
                            if (path.startsWith(","))
                                path = path.substring(1);
                            resKey = path + "," + cpath + "=" + val;
                        }

                        PropertySimple pathProp = new PropertySimple("path", resKey);
                        config2.put(pathProp);

                        DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(), // DataType
                            resKey, // Key
                            val, // Name
                            null, // Version
                            context.getResourceType().getDescription(), // subsystem.description
                            config2, null);
                        details.add(detail);
                    }
                }
            }
        } else {
            // Single subsystem
            path += "," + confPath;
            if (path.startsWith(","))
                path = path.substring(1);
            Result result = connection.execute(new ReadResource(new Address(path)));
            if (result.isSuccess()) {

                String resKey = path;
                String name = resKey.substring(resKey.lastIndexOf("=") + 1);
                Configuration config2 = context.getDefaultPluginConfiguration();
                PropertySimple pathProp = new PropertySimple("path", path);
View Full Code Here

    public OperationResult invokeOperation(String name,
                                           Configuration parameters) throws  Exception {

        if (name.equals("get-all-thread-ids")) {
            Operation op = new ReadAttribute(getAddress(), "all-thread-ids");
            Result res = getASConnection().execute(op);
            OperationResult operationResult;
            if (res.isSuccess()) {
                List<Long> ids = (List<Long>) res.getResult();
                operationResult = new OperationResult(ids.toString());
            } else {
                operationResult = new OperationResult();
                String errorMessage = "Got no result back";
                if (!res.isSuccess()) {
                    errorMessage += ": " + res.getFailureDescription();
                }
                operationResult.setErrorMessage(errorMessage);
            }
            return operationResult;
        }
View Full Code Here

        destination.addSegment(SECURITY_RESOURCE_KEY);
        String securityDomainId = TEST_DOMAIN + "2";
        destination.addSegment(SECURITY_DOMAIN_RESOURCE_KEY + "=" + securityDomainId);

        ASConnection connection = getDomainControllerASConnection();
        Result result = new Result();
        Operation op = null;
        //delete old one if present to setup clean slate
        op = new Operation("remove", destination);
        result = connection.execute(op);

        //build/rebuild hierarchy
        op = new Operation("add", destination);
        result = connection.execute(op);
        assert result.getOutcome().equals("success") : "Add of Security Domain has failed: "
            + result.getFailureDescription();

        //Ex. profile=standalone-ha,subsystem=security,security-domain
        String addressPrefix = PROFILE + "," + SECURITY_RESOURCE_KEY + "," + SECURITY_DOMAIN_RESOURCE_KEY;

        //loop over standard types and add base details for all of them to security domain
        String address = "";
        for (String attribute : jsonMap.keySet()) {
            if (attribute.equals("policy-modules")) {
                address = addressPrefix + "=" + securityDomainId + ",authorization=classic";
            } else if (attribute.equals("acl-modules")) {
                address = addressPrefix + "=" + securityDomainId + ",acl=classic";
            } else if (attribute.equals("mapping-modules")) {
                address = addressPrefix + "=" + securityDomainId + ",mapping=classic";
            } else if (attribute.equals("trust-modules")) {
                address = addressPrefix + "=" + securityDomainId + ",identity-trust=classic";
            } else if (attribute.equals("provider-modules")) {
                address = addressPrefix + "=" + securityDomainId + ",audit=classic";
            } else if (attribute.equals("login-modules")) {
                address = addressPrefix + "=" + securityDomainId + ",authentication=classic";
            } else {
                assert false : "An unknown attribute '" + attribute
                    + "' was found. Is there a new type to be supported?";
            }

            //build the operation to add the component
            ////Load json map into ModuleOptionType
            try {
                // loading jsonMap contents for Ex. 'login-module'
                JsonNode node = mapper.readTree(jsonMap.get(attribute));
                Object obj = mapper.treeToValue(node, Object.class);
                result.setResult(obj);
                result.setOutcome("success");
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

            //populate the Value component complete with module Options.
            List<Value> moduleTypeValue = populateSecurityDomainModuleOptions(result, loadModuleOptionType(attribute));
            op = createAddModuleOptionTypeOperation(new Address(address), attribute, moduleTypeValue);
            //submit the command
            result = connection.execute(op);
            assert result.getOutcome().equals("success") : "Add ModuleOptionType has failed: "
                + result.getFailureDescription();
        }
    }
View Full Code Here

                }
            }

            //retrieve module options as well.
            String jsonContent = jsonMap.get(attribute);
            Result result = new Result();
            try {
                // loading jsonMap contents for Ex. 'login-module'
                JsonNode node = mapper.readTree(jsonContent);
                Object obj = mapper.treeToValue(node, Object.class);
                result.setResult(obj);
                result.setOutcome("success");
            } catch (JsonProcessingException e) {
                e.printStackTrace();
                assert false;
            } catch (IOException e) {
                e.printStackTrace();
View Full Code Here

        if (verboseOutput) {
            System.out.println("@@@@ OUTBOUND JSON#\n" + jsonToSend + "#");
        }

        //Execute the operation
        Result result = new Result();
        if (execute) {
            result = con.execute(op);
        } else {
            if (verboseOutput) {
                System.out.println("**** NOTE: Execution disabled . NOT exercising write-attribute operation. **** ");
            }
        }
        if (verboseOutput) {
            //result wrapper details
            System.out.println("\tResult:" + result);
            //detailed results
            System.out.println("\tValue:" + result.getResult());
            System.out.println("-----------------------------------------------------\n");
        }
        return result;
    }
View Full Code Here

    private File findLogDirForManagedDeployment() {
        Address logDirAddress = new Address(findManagedASServerComponent().getServerAddress());
        logDirAddress.add("path", "jboss.server.log.dir");
        ReadResource readResource = new ReadResource(logDirAddress);
        Result result = getASConnection().execute(readResource);
        if (result.isSuccess()) {
            @SuppressWarnings("unchecked")
            Map<String, Object> resultData = (Map<String, Object>) result.getResult();
            String dir = resultData.get("path").toString();
            if (resultData.get("relative-to") != null) {
                return new File(resultData.get("relative-to").toString(), dir);
            }
            return new File(dir);
View Full Code Here

        assertTrue(response.isSuccess(), getFailureMessage(response));

        Address ejb3SubsystemAddress = new Address();
        ejb3SubsystemAddress.add("profile", "full");
        ejb3SubsystemAddress.add("subsystem", "ejb3");
        Result readAttributeResult = getDomainControllerASConnection().execute(
            new ReadAttribute(ejb3SubsystemAddress, "default-singleton-bean-access-timeout"));

        assertTrue(readAttributeResult.isSuccess(), readAttributeResult.getFailureDescription());

        Integer defaultSingletonBeanAccessTimeout = (Integer) readAttributeResult.getResult();

        assertEquals(defaultSingletonBeanAccessTimeout, Integer.valueOf(7777));
    }
View Full Code Here

TOP

Related Classes of org.rhq.modules.plugins.jbossas7.json.Result

Copyright © 2018 www.massapicom. 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.