mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestAssetDirectoryServiceNamespace.java
@Test
    public final void testScanForNewAssets() throws UnknownHostException, IOException
    {                
        MessageListener listener = new MessageListener(socket);
        String[] topics = new String[]{AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS, 
            AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE, FactoryDescriptor.TOPIC_FACTORY_OBJ_CREATED};
        
        int regId = RemoteEventRegistration.regRemoteEventMessages(socket, topics);
        
        //create new request to scan for assets of specific type
        ScanForNewAssetsRequestData request = ScanForNewAssetsRequestData.newBuilder().
                setProductType(ExampleAsset.class.getName()).build();      
              
        TerraHarvestMessage message = AssetNamespaceUtils.createAssetDirSvcNamespaceMessage(
                AssetDirectoryServiceMessageType.ScanForNewAssetsRequest, request);        
        message.writeDelimitedTo(socket.getOutputStream());

        listener.waitForMessages(15000, new EventMessageMatcher(AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS),
                new EventMessageMatcher(AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE),
                new EventMessageMatcher(FactoryDescriptor.TOPIC_FACTORY_OBJ_CREATED),
                new BasicMessageMatcher(Namespace.AssetDirectoryService, 
                        AssetDirectoryServiceMessageType.ScanForNewAssetsResponse));

        //create request to scan for ALL asset types
        request = ScanForNewAssetsRequestData.newBuilder().build(); 

        message = AssetNamespaceUtils.createAssetDirSvcNamespaceMessage(
                AssetDirectoryServiceMessageType.ScanForNewAssetsRequest, request);        
        message.writeDelimitedTo(socket.getOutputStream());
        
        // scanned again, but should not find obj
        listener.waitForMessages(15000, new EventMessageMatcher(AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS),
                new EventMessageMatcher(AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE),
                new BasicMessageMatcher(Namespace.AssetDirectoryService, 
                        AssetDirectoryServiceMessageType.ScanForNewAssetsResponse));
        
        //clean up registrations and new asset
        MessageListener.unregisterEvent(regId, socket);
    }
/**
     * Verifies the ability of the system to handle a remote request to scan for any new assets.
     */
Verifies the ability of the system to handle a remote request to scan for any new assets.
Verifies the ability of the system to handle a remote request to scan for any new assets .
@Test
    public final void testScanForNewAssets() throws UnknownHostException, IOException
    {                
        MessageListener listener = new MessageListener(socket);
        String[] topics = new String[]{AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS, 
            AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE, FactoryDescriptor.TOPIC_FACTORY_OBJ_CREATED};
        int regId = RemoteEventRegistration.regRemoteEventMessages(socket, topics);
        ScanForNewAssetsRequestData request = ScanForNewAssetsRequestData.newBuilder().
                setProductType(ExampleAsset.class.getName()).build();      
        TerraHarvestMessage message = AssetNamespaceUtils.createAssetDirSvcNamespaceMessage(
                AssetDirectoryServiceMessageType.ScanForNewAssetsRequest, request);        
        message.writeDelimitedTo(socket.getOutputStream());
        listener.waitForMessages(15000, new EventMessageMatcher(AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS),
                new EventMessageMatcher(AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE),
                new EventMessageMatcher(FactoryDescriptor.TOPIC_FACTORY_OBJ_CREATED),
                new BasicMessageMatcher(Namespace.AssetDirectoryService, 
                        AssetDirectoryServiceMessageType.ScanForNewAssetsResponse));
        request = ScanForNewAssetsRequestData.newBuilder().build(); 
        message = AssetNamespaceUtils.createAssetDirSvcNamespaceMessage(
                AssetDirectoryServiceMessageType.ScanForNewAssetsRequest, request);        
        message.writeDelimitedTo(socket.getOutputStream());
        listener.waitForMessages(15000, new EventMessageMatcher(AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS),
                new EventMessageMatcher(AssetDirectoryService.TOPIC_SCANNING_FOR_ASSETS_COMPLETE),
                new BasicMessageMatcher(Namespace.AssetDirectoryService, 
                        AssetDirectoryServiceMessageType.ScanForNewAssetsResponse));
        MessageListener.unregisterEvent(regId, socket);
    }
@ Test public final void testScanForNewAssets ( ) throws UnknownHostException , IOException { MessageListener listener = new MessageListener ( socket ) ; String [ ] topics = new String [ ] { AssetDirectoryService . TOPIC_SCANNING_FOR_ASSETS , AssetDirectoryService . TOPIC_SCANNING_FOR_ASSETS_COMPLETE , FactoryDescriptor . TOPIC_FACTORY_OBJ_CREATED } ; int regId = RemoteEventRegistration . regRemoteEventMessages ( socket , topics ) ; ScanForNewAssetsRequestData request = ScanForNewAssetsRequestData . newBuilder ( ) . setProductType ( ExampleAsset . class . getName ( ) ) . build ( ) ; TerraHarvestMessage message = AssetNamespaceUtils . createAssetDirSvcNamespaceMessage ( AssetDirectoryServiceMessageType . ScanForNewAssetsRequest , request ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; listener . waitForMessages ( 15000 , new EventMessageMatcher ( AssetDirectoryService . TOPIC_SCANNING_FOR_ASSETS ) , new EventMessageMatcher ( AssetDirectoryService . TOPIC_SCANNING_FOR_ASSETS_COMPLETE ) , new EventMessageMatcher ( FactoryDescriptor . TOPIC_FACTORY_OBJ_CREATED ) , new BasicMessageMatcher ( Namespace . AssetDirectoryService , AssetDirectoryServiceMessageType . ScanForNewAssetsResponse ) ) ; request = ScanForNewAssetsRequestData . newBuilder ( ) . build ( ) ; message = AssetNamespaceUtils . createAssetDirSvcNamespaceMessage ( AssetDirectoryServiceMessageType . ScanForNewAssetsRequest , request ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; listener . waitForMessages ( 15000 , new EventMessageMatcher ( AssetDirectoryService . TOPIC_SCANNING_FOR_ASSETS ) , new EventMessageMatcher ( AssetDirectoryService . TOPIC_SCANNING_FOR_ASSETS_COMPLETE ) , new BasicMessageMatcher ( Namespace . AssetDirectoryService , AssetDirectoryServiceMessageType . ScanForNewAssetsResponse ) ) ; MessageListener . unregisterEvent ( regId , socket ) ; }
Verifies the ability of the system to handle a remote request to scan for any new assets.
Verifies the ability of the system to handle a remote request to scan for any new assets .
//create new request to scan for assets of specific type //create request to scan for ALL asset types // scanned again, but should not find obj //clean up registrations and new asset