Ejemplo n.º 1
0
void ParserTestProvider::initialize(CIMOMHandle & cimom)
{
    cout << "ParserTestProvider::initialize" << endl;

    CIMInstance instance1("Sample_PClassOne");
    CIMObjectPath reference1("Sample_PClassOne.CName=ClassOne");
    // keys
    instance1.addProperty(CIMProperty("CName", String("Sample_PClassOne")));
    instance1.addProperty(CIMProperty("CNum", Uint16(1)));
    instance1.addProperty(CIMProperty("BadStringName", String(BADSTR_1)));

    //other 
    instance1.addProperty(CIMProperty("BadStringNum", Uint16(1)));

    _instances.append(instance1);
    _instanceNames.append(reference1);

    CIMInstance instance2("Sample_PClassOne");
    CIMObjectPath reference2("Sample_PClassOne.CName=ClassTwo");

    // keys
    instance2.addProperty(CIMProperty("CName", String("Sample_PClassOne")));
    instance2.addProperty(CIMProperty("CNum", Uint16(2)));
    instance2.addProperty(CIMProperty("BadStringName", String(BADSTR_2)));

    // other
    instance2.addProperty(CIMProperty("BadStringNum", Uint16(2)));

    _instances.append(instance2);
    _instanceNames.append(reference2);
}
Ejemplo n.º 2
0
void ExceptionsTest::initialize(CIMOMHandle & cimom)
{

    cout <<" ExceptionsTest::initialize" << endl;

    CheckExceptionType(EXCEPTION_TYPE);

    // create default instances for FirstClass
    CIMInstance instance1("FirstClass");
    CIMObjectPath reference1("FirstClass.Id=1");

    instance1.addProperty(CIMProperty("Id", Uint8(1)));   // key
    instance1.addProperty(CIMProperty("Message", String("Subodh.....")));

    _instances.append(instance1);
    _instanceNames.append(reference1);

    CheckExceptionType(EXCEPTION_TYPE);

    CIMInstance instance2("FirstClass");
    CIMObjectPath reference2("FirstClass.Id=2");

    instance2.addProperty(CIMProperty("Id", Uint8(2)));   // key
    instance2.addProperty(CIMProperty("Message", String("Soni....")));

    _instances.append(instance2);
    _instanceNames.append(reference2);

    CheckExceptionType(EXCEPTION_TYPE);

    // create default instances for SecondClass
    CIMInstance instance_1("SecondClass");
    CIMObjectPath reference_1("SecondClass.Srno=11");

    instance_1.addProperty(CIMProperty("Srno", Uint8(1)));   // key
    instance_1.addProperty(
        CIMProperty("Name", String("Class Two Instance 1.....")));

    _instances_second.append(instance_1);
    _instanceNames_second.append(reference_1);

    CheckExceptionType(EXCEPTION_TYPE);

    CIMInstance instance_2("SecondClass");
    CIMObjectPath reference_2("SecondClass.Srno=2");

    instance_2.addProperty(CIMProperty("Srno", Uint8(2)));   // key
    instance_2.addProperty(
        CIMProperty("Name", String("Class Two Instance 2....")));

    _instances_second.append(instance_2);
    _instanceNames_second.append(reference_2);

    CheckExceptionType(EXCEPTION_TYPE);
}
Ejemplo n.º 3
0
void TimingProvider::initialize(CIMOMHandle & cimom)
{
    cout <<" TimingProvider::initialize" << endl;

    // Create Instances for TimeOne Class
    CIMInstance instance1("TimeOne");
    CIMObjectPath reference1("TimeOne.Id=1");

    instance1.addProperty(CIMProperty("Id", Uint8(1)));   // key
    instance1.addProperty(CIMProperty("Message", String("Class One I1")));

    _instances.append(instance1);
    _instanceNames.append(reference1);


    CIMInstance instance2("TimeOne");
    CIMObjectPath reference2("TimeOne.Id=2");

    instance2.addProperty(CIMProperty("Id", Uint8(2)));   // key
    instance2.addProperty(CIMProperty("Message", String("Class One I2")));

    _instances.append(instance2);
    _instanceNames.append(reference2);

    // Create Instances for TimeTwo Class
     CIMInstance instance_1("TimeTwo");
     CIMObjectPath reference_1("TimeTwo.Srno=22");

    instance_1.addProperty(CIMProperty("Srno", Uint8(1)));   // key
    instance_1.addProperty(CIMProperty("TimeVar", Uint16(1111)));
    _instances_2.append(instance_1);
    _instanceNames_2.append(reference_1);

    CIMInstance instance_2("TimeTwo");
    CIMObjectPath reference_2("TimeTwo.Srno=2");

    instance_2.addProperty(CIMProperty("Srno", Uint8(2)));   // key
    instance_2.addProperty(CIMProperty("TimeVar", Uint16(2222)));

    _instances_2.append(instance_2);
    _instanceNames_2.append(reference_2);
}
Ejemplo n.º 4
0
/***********************************************************************//**
 * @brief Test GTimeReference
 ***************************************************************************/
void TestGObservation::test_time_reference(void)
{
    // Test void constructor
    test_try("Void constructor");
    try {
        GTimeReference reference;
        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test copy constructor
    test_try("Copy constructor");
    try {
        GTimeReference reference;
        GTimeReference reference2(reference);
        test_try_success();
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test reference constructor
    test_try("Reference constructor");
    try {
        GTimeReference reference(55197.0, "s", "TT", "LOCAL");
        test_try_success();
        test_value(reference.mjdref(), 55197.0);
        test_assert(reference.timeunit() == "s",
                    "Time unit was \""+reference.timeunit()+"\", expected \"s\"");
        test_assert(reference.timesys() == "TT",
                    "Time system was \""+reference.timesys()+"\", expected \"TT\"");
        test_assert(reference.timeref() == "LOCAL",
                    "Time reference was \""+reference.timeref()+"\", expected \"LOCAL\"");
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test reference constructor
    test_try("Reference constructor (split reference)");
    try {
        GTimeReference reference(55197, 0.000766018518519, "s", "TT", "LOCAL");
        test_try_success();
        test_value(reference.mjdref(), 55197.000766018518519);
        test_assert(reference.timeunit() == "s",
                    "Time unit was \""+reference.timeunit()+"\", expected \"s\"");
        test_assert(reference.timesys() == "TT",
                    "Time system was \""+reference.timesys()+"\", expected \"TT\"");
        test_assert(reference.timeref() == "LOCAL",
                    "Time reference was \""+reference.timeref()+"\", expected \"LOCAL\"");
    }
    catch (std::exception &e) {
        test_try_failure(e);
    }

    // Test FITS file writing
    GTimeReference reference(55197.000766018518519, "s", "TT", "LOCAL");
    GFits          fits;
    GFitsBinTable  table;
    reference.write(table);
    fits.append(table);
    fits.saveto("test_time_reference.fits", true);
    fits.close();

    // Read back from FITS file and check values
    fits.open("test_time_reference.fits");
    const GFitsTable& hdu = *fits.table(1);
    GTimeReference value(hdu);
    fits.close();
    test_value(value.mjdref(),  reference.mjdref());
    test_value(value.mjdrefi(), reference.mjdrefi());
    test_value(value.mjdreff(), reference.mjdreff());
    test_assert(value.timeunit() == reference.timeunit(),
                "Time unit was \""+value.timeunit()+"\", expected "+reference.timeunit()+".");
    test_assert(value.timesys() == reference.timesys(),
                "Time system was \""+value.timesys()+"\", expected "+reference.timesys()+".");
    test_assert(value.timeref() == reference.timeref(),
                "Time reference was \""+value.timeref()+"\", expected "+reference.timeref()+".");

    // Return
    return;
}