Package org.rhq.core.domain.resource

Examples of org.rhq.core.domain.resource.Resource


        ResourceType writeResourceType = new ResourceType();
        writeResourceType.setName("reflectiveType");
        writeResourceType.setPlugin("reflectivePlugin");
        writeResourceType.setId(7);

        Resource writeParentResource = new Resource();
        writeParentResource.setId(11);
        writeParentResource.setName("reflectiveParentResource");
        writeParentResource.setResourceKey("reflectiveParentKey");

        Resource writeResource = new Resource();
        writeResource.setId(42);
        writeResource.setName("reflectiveResource");
        writeResource.setResourceKey("reflectiveKey");

        // setup relationships
        writeResource.setAgent(writeAgent);
        writeResource.setResourceType(writeResourceType);
        writeResource.setParentResource(writeParentResource);

        System.out.println("BEFORE");
        System.out.println(writeResource.toString());
        System.out.println("BEFORE");

        String tempDir = System.getProperty("java.io.tmpdir");
        File tempFile = new File(tempDir, "entitySerializerTest.txt");

        FileOutputStream fos = new FileOutputStream(tempFile);
        try {
            ObjectOutput output = new ObjectOutputStream(fos);
            try {
                writeExternalRemote(writeResource, output);
            } finally {
                output.close();
            }
        } finally {
            fos.close();
        }

        Resource readResource = new Resource();
        FileInputStream fis = new FileInputStream(tempFile);
        try {
            ObjectInput ois = new ObjectInputStream(fis);
            try {
                readExternalRemote(readResource, ois);
            } finally {
                ois.close();
            }
        } finally {
            fis.close();
        }

        // quick verification
        System.out.println("AFTER");
        System.out.println(readResource.toString());
        System.out.println("AFTER");

        // deeper verification
        boolean equalsResource = writeResource.equals(readResource);
        boolean equalsParentResource = writeParentResource.equals(readResource.getParentResource());
        boolean equalsResourceType = writeResourceType.equals(readResource.getResourceType());
        boolean equalsAgent = writeAgent.equals(readResource.getAgent());

        System.out.println("equalsResource: " + equalsResource);
        System.out.println("equalsParentResource: " + equalsParentResource);
        System.out.println("equalsResourceType: " + equalsResourceType);
        System.out.println("equalsAgent: " + equalsAgent);
View Full Code Here


     */
    public static Resource getBaseServerOrService(Resource resource) {
        if (resource == null) {
            throw new IllegalArgumentException("resource is null");
        }
        Resource current, parent = resource;
        do {
            current = parent;
            parent = current.getParentResource();
        } while (parent != null && parent.getResourceType().getCategory() != PLATFORM);
        return current;
    }
View Full Code Here

        //tell the method story as it happens: mock or create dependencies and configure
        //those dependencies to get the method under test to completion.
        ResourceType mockResourceType = mock(ResourceType.class);

        Resource mockResource = mock(Resource.class);
        when(mockResource.getResourceKey()).thenReturn(inputResourceKey);
        when(mockResource.getUuid()).thenReturn(inputResourceUuid);
        when(mockResource.getResourceType()).thenReturn(mockResourceType);

        ResourceContext<?> parentResourceContext = mock(ResourceContext.class);
        when(parentResourceContext.getResourceKey()).thenReturn(inputParentResourceKey);

        File mockNewResourceDirectory = mock(File.class);
View Full Code Here

        //tell the method story as it happens: mock or create dependencies and configure
        //those dependencies to get the method under test to completion.
        ResourceType mockResourceType = mock(ResourceType.class);

        Resource mockResource = mock(Resource.class);
        when(mockResource.getResourceKey()).thenReturn(inputResourceKey);
        when(mockResource.getUuid()).thenReturn(inputResourceUuid);
        when(mockResource.getResourceType()).thenReturn(mockResourceType);

        ResourceContext parent3ResourceContext = mock(ResourceContext.class);
        when(parent3ResourceContext.getResourceKey()).thenReturn(inputParent3ResourceKey);

        ResourceContext parent2ResourceContext = mock(ResourceContext.class);
View Full Code Here

        //tell the method story as it happens: mock or create dependencies and configure
        //those dependencies to get the method under test to completion.
        ResourceType mockResourceType = mock(ResourceType.class);

        Resource mockResource = mock(Resource.class);
        when(mockResource.getResourceKey()).thenReturn(inputResourceKey);
        when(mockResource.getUuid()).thenReturn(inputResourceUuid);
        when(mockResource.getResourceType()).thenReturn(mockResourceType);

        ResourceContext<?> parentResourceContext = mock(ResourceContext.class);
        when(parentResourceContext.getResourceKey()).thenReturn(inputParentResourceKey);

        File mockNewResourceDirectory = mock(File.class);
View Full Code Here

        //tell the method story as it happens: mock or create dependencies and configure
        //those dependencies to get the method under test to completion.
        ResourceType mockResourceType = mock(ResourceType.class);

        Resource mockResource = mock(Resource.class);
        when(mockResource.getResourceKey()).thenReturn(inputResourceKey);
        when(mockResource.getUuid()).thenReturn(inputResourceUuid);
        when(mockResource.getResourceType()).thenReturn(mockResourceType);

        ResourceContext<?> parentResourceContext = mock(ResourceContext.class);
        when(parentResourceContext.getResourceKey()).thenReturn(inputParentResourceKey);

        File mockNewResourceDirectory = mock(File.class);
View Full Code Here

        //tell the method story as it happens: mock or create dependencies and configure
        //those dependencies to get the method under test to completion.
        ResourceType mockResourceType = mock(ResourceType.class);

        Resource mockResource = mock(Resource.class);
        when(mockResource.getResourceKey()).thenReturn(inputResourceKey);
        when(mockResource.getUuid()).thenReturn(inputResourceUuid);
        when(mockResource.getResourceType()).thenReturn(mockResourceType);

        ResourceContext<?> parentResourceContext = mock(ResourceContext.class);
        when(parentResourceContext.getResourceKey()).thenReturn(inputParentResourceKey);

        File mockNewResourceDirectory = mock(File.class);
View Full Code Here

        //tell the method story as it happens: mock or create dependencies and configure
        //those dependencies to get the method under test to completion.
        ResourceType mockResourceType = mock(ResourceType.class);

        Resource mockResource = mock(Resource.class);
        when(mockResource.getResourceKey()).thenReturn(inputResourceKey);
        when(mockResource.getUuid()).thenReturn(inputResourceUuid);
        when(mockResource.getResourceType()).thenReturn(mockResourceType);

        ResourceContext parent3ResourceContext = mock(ResourceContext.class);
        when(parent3ResourceContext.getResourceKey()).thenReturn(inputParent3ResourceKey);

        ResourceContext parent2ResourceContext = mock(ResourceContext.class);
View Full Code Here

        Date now = new Date();

        Query q = em.createQuery("SELECT r FROM Resource r");
        List<Resource> resources = q.getResultList();
        Resource res = resources.get(0);
        Agent agent = agentManager.getAgentByResourceId(overlord, res.getId());

        q = em.createQuery("SELECT COUNT(a) FROM Availability a ");
        Object o = q.getSingleResult();
        Long l = (Long) o;
        if (l != 0) {
View Full Code Here

    public void testRandom() throws Exception {
        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        Query q = em.createQuery("SELECT r FROM Resource r");
        List<Resource> resources = q.getResultList();
        Resource res = resources.get(0);
        Agent agent = agentManager.getAgentByResourceId(overlord, res.getId());

        for (int MULTI : ROUNDS) {
            String round = String.format(ROUND__FORMAT, MULTI);

            long t1 = System.currentTimeMillis() - (MULTI * MILLIS_APART);
 
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.Resource

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.