Search in sources :

Example 31 with UUID

use of java.util.UUID in project scale7-pelops by s7.

the class BytesUnitTest method testUuid.

@Test
public void testUuid() {
    UUID value = UUID.randomUUID();
    Bytes from = Bytes.fromUuid(value);
    UUID to = from.toUuid();
    assertEquals("Conversion did not match", value, to);
    // make sure the buffer is rewound
    from.toUuid();
}
Also used : UUID(java.util.UUID) Test(org.junit.Test)

Example 32 with UUID

use of java.util.UUID in project scale7-pelops by s7.

the class BytesUnitTest method testUuidNull.

@Test
public void testUuidNull() {
    UUID value = null;
    Bytes from = Bytes.fromUuid(value);
    UUID to = from.toUuid();
    assertEquals("Conversion did not match", value, to);
    ;
}
Also used : UUID(java.util.UUID) Test(org.junit.Test)

Example 33 with UUID

use of java.util.UUID in project platform_frameworks_base by android.

the class GenericSoundModelTest method testFuzzGenericSoundModel.

/**
     * Tests a more complicated pattern of loading, unloading, triggering, starting and stopping
     * recognition. Intended to find unexpected errors that occur in unexpected states.
     */
@LargeTest
public void testFuzzGenericSoundModel() throws Exception {
    int numModels = 2;
    final int STATUS_UNLOADED = 0;
    final int STATUS_LOADED = 1;
    final int STATUS_STARTED = 2;
    class ModelInfo {

        int status;

        GenericSoundModel model;

        public ModelInfo(GenericSoundModel model, int status) {
            this.status = status;
            this.model = model;
        }
    }
    Random predictableRandom = new Random(100);
    ArrayList modelInfos = new ArrayList<ModelInfo>();
    for (int i = 0; i < numModels; i++) {
        // Create sound model
        byte[] data = new byte[1024];
        predictableRandom.nextBytes(data);
        UUID modelUuid = UUID.randomUUID();
        UUID mVendorUuid = UUID.randomUUID();
        GenericSoundModel model = new GenericSoundModel(modelUuid, mVendorUuid, data);
        ModelInfo modelInfo = new ModelInfo(model, STATUS_UNLOADED);
        modelInfos.add(modelInfo);
    }
    boolean captureTriggerAudio = true;
    boolean allowMultipleTriggers = true;
    RecognitionConfig config = new RecognitionConfig(captureTriggerAudio, allowMultipleTriggers, null, null);
    TestRecognitionStatusCallback spyCallback = spy(new TestRecognitionStatusCallback());
    int numOperationsToRun = 100;
    for (int i = 0; i < numOperationsToRun; i++) {
        // Select a random model
        int modelInfoIndex = predictableRandom.nextInt(modelInfos.size());
        ModelInfo modelInfo = (ModelInfo) modelInfos.get(modelInfoIndex);
        // Perform a random operation
        int operation = predictableRandom.nextInt(5);
        if (operation == 0 && modelInfo.status == STATUS_UNLOADED) {
            // Update and start sound model
            soundTriggerService.updateSoundModel(modelInfo.model);
            loadedModelUuids.add(modelInfo.model.uuid);
            modelInfo.status = STATUS_LOADED;
        } else if (operation == 1 && modelInfo.status == STATUS_LOADED) {
            // Start the sound model
            int r = soundTriggerService.startRecognition(new ParcelUuid(modelInfo.model.uuid), spyCallback, config);
            assertEquals("Could Not Start Recognition with code: " + r, android.hardware.soundtrigger.SoundTrigger.STATUS_OK, r);
            modelInfo.status = STATUS_STARTED;
        } else if (operation == 2 && modelInfo.status == STATUS_STARTED) {
            // Send trigger to stub HAL
            Socket socket = new Socket(InetAddress.getLocalHost(), 14035);
            DataOutputStream out = new DataOutputStream(socket.getOutputStream());
            out.writeBytes("trig " + modelInfo.model.uuid + "\r\n");
            out.flush();
            socket.close();
            // Verify trigger was received
            verify(spyCallback, timeout(100)).onGenericSoundTriggerDetected(any());
            reset(spyCallback);
        } else if (operation == 3 && modelInfo.status == STATUS_STARTED) {
            // Stop recognition
            int r = soundTriggerService.stopRecognition(new ParcelUuid(modelInfo.model.uuid), spyCallback);
            assertEquals("Could Not Stop Recognition with code: " + r, android.hardware.soundtrigger.SoundTrigger.STATUS_OK, r);
            modelInfo.status = STATUS_LOADED;
        } else if (operation == 4 && modelInfo.status != STATUS_UNLOADED) {
            // Delete sound model
            soundTriggerService.deleteSoundModel(new ParcelUuid(modelInfo.model.uuid));
            loadedModelUuids.remove(modelInfo.model.uuid);
            // Confirm it was deleted
            GenericSoundModel returnedModel = soundTriggerService.getSoundModel(new ParcelUuid(modelInfo.model.uuid));
            assertEquals(null, returnedModel);
            modelInfo.status = STATUS_UNLOADED;
        }
    }
}
Also used : ParcelUuid(android.os.ParcelUuid) DataOutputStream(java.io.DataOutputStream) ArrayList(java.util.ArrayList) GenericSoundModel(android.hardware.soundtrigger.SoundTrigger.GenericSoundModel) Random(java.util.Random) RecognitionConfig(android.hardware.soundtrigger.SoundTrigger.RecognitionConfig) UUID(java.util.UUID) Socket(java.net.Socket) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 34 with UUID

use of java.util.UUID in project platform_frameworks_base by android.

the class GenericSoundModelTest method new_sound_model.

GenericSoundModel new_sound_model() {
    // Create sound model
    byte[] data = new byte[1024];
    random.nextBytes(data);
    UUID modelUuid = UUID.randomUUID();
    UUID mVendorUuid = UUID.randomUUID();
    return new GenericSoundModel(modelUuid, mVendorUuid, data);
}
Also used : GenericSoundModel(android.hardware.soundtrigger.SoundTrigger.GenericSoundModel) UUID(java.util.UUID)

Example 35 with UUID

use of java.util.UUID in project nutz by nutzam.

the class RTest method test_uu32.

@Test
public void test_uu32() {
    for (int i = 0; i < 100000; i++) {
        UUID uuid = UUID.randomUUID();
        // System.out.println(uuid);
        // System.out.println(R.UU32(uuid));
        // System.out.println(R.fromUU32(R.UU32(uuid)));
        assertEquals(uuid, R.fromUU32(R.UU32(uuid)));
    }
}
Also used : UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

UUID (java.util.UUID)2848 Test (org.junit.Test)641 ArrayList (java.util.ArrayList)337 Test (org.testng.annotations.Test)308 HashMap (java.util.HashMap)306 Map (java.util.Map)201 ClusterNode (org.apache.ignite.cluster.ClusterNode)182 List (java.util.List)163 BigDecimal (java.math.BigDecimal)148 LocalDate (org.joda.time.LocalDate)145 Ignite (org.apache.ignite.Ignite)131 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)118 DateTime (org.joda.time.DateTime)109 HashSet (java.util.HashSet)107 Invoice (org.killbill.billing.invoice.api.Invoice)105 CountDownLatch (java.util.concurrent.CountDownLatch)101 IOException (java.io.IOException)92 ByteBuffer (java.nio.ByteBuffer)81 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)75 File (java.io.File)73