As the first option you can insert test user:
@isTest
private class test{
static TestMethod void Test1_TestInsertWithValue() {
Meeting_Master__c master=new Meeting_Master__c();
Event event =new Event();
Profile p=[SELECT Id From Profile WHERE Name='Standard User'];
User u2 =new User( Alias = 'newUser1' ,
Email ='newuser123@testorg.com',
EmailEncodingKey = 'UTF-8',
LastName = 'Testing',
LanguageLocaleKey='en_US',
LocaleSidKey='en_US', // changed for to avoid: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Locale: bad value for restricted picklist field: America/Los_Angeles
UserName='newuser123@testorg.com',
ProfileId=p.Id,
TimeZoneSidKey = 'America/Los_Angeles');
insert u2;
event.OwnerId = u2.Id;
event.StartDateTime = datetime.newInstance(2008, 12, 1);
event.EndDateTime = datetime.newInstance(2008,12,10); // changed to 10-12-2008 for to avoid: FIELD_INTEGRITY_EXCEPTION, Event duration can not be longer than 14 days
event.subject='call';
event.WhatId=master.Id;
Insert master;
insert event;
}
}
The second option is a trying to use System.runAs()
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_tools_runas.htm
@isTest
private class test{
static TestMethod void Test1_TestInsertWithValue() {
Meeting_Master__c master=new Meeting_Master__c();
Event event =new Event();
Profile p=[SELECT Id From Profile WHERE Name='Standard User'];
User u2 =new User( Alias = 'newUser1' ,
Email ='newuser123@testorg.com',
EmailEncodingKey = 'UTF-8',
LastName = 'Testing',
LanguageLocaleKey='en_US',
LocaleSidKey='en_US',
UserName='newuser123@testorg.com',
ProfileId=p.Id,
TimeZoneSidKey = 'America/Los_Angeles');
Insert master;
System.runAs(u2) {
event.StartDateTime = datetime.newInstance(2008, 12, 1);
event.EndDateTime = datetime.newInstance(2008,12,10);
event.subject='call';
event.WhatId=master.Id;
insert event;
}
}
}