//2013-02-19 johnpfeiffer
//TODO: fix use of Mocks
package com.oxygencloud.sdk.util;
import static org.junit.Assert.assertNotNull;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import com.oxygen.sdk.O2Agent;
import com.oxygen.sdk.O2AgentFactory;
import com.oxygen.sdk.O2SessionInfo;
import com.oxygen.sdk.exception.O2NetworkException;
import com.oxygen.sdk.exception.O2RuleException;
import com.oxygen.sdk.exception.O2UnexpectedException;
public class OxygenLoginTest {
private OxygenLogin defaultTester;
private O2AgentFactory mockO2AgentFactory = null;
private O2Agent mockO2Agent = null;
private String apiURL = "https://my.example.net/gateway";
private String apiKey = "mykey33799cdc5bdf0d56a62";
private String user = "my-user-qa";
private String password = "my-password";
// @RunWith( PowerMockRunner.class )
@Before
public void setUp() throws Exception {
// mockStatic( O2AgentFactory.class);
mockO2AgentFactory = EasyMock.createMock( O2AgentFactory.class );
mockO2Agent = EasyMock.createMock( O2Agent.class );
O2SessionInfo dummyO2SessionInfo = null;
String dummySessionId = "dummySessionId";
EasyMock.expect( mockO2AgentFactory.createAndroidO2AgentCustomURL( apiURL ) ).andReturn( mockO2Agent );
EasyMock.replay( mockO2AgentFactory );
EasyMock.expect( mockO2Agent.login( apiKey, user , password )).andReturn( dummyO2SessionInfo );
EasyMock.replay( mockO2Agent );
defaultTester = new OxygenLogin.Builder().apiURL( apiURL ).apiKey( apiKey ).oxygenUserId( user ).oxygenPassword( password ).O2AgentFactory( mockO2AgentFactory ).build();
}
@Ignore
@Test
public void SessionId_Is_Not_Null() {
assertNotNull( defaultTester.getSessionId() );
System.out.println( "SessionId_Is_Not_Null: " + defaultTester.getSessionId() );
}
@Ignore
@Test
public void testGetAgent() {
// fail( "Not yet implemented" );
}
@Ignore
@Test
public void testGetLoginDurationInMilliseconds() {
// fail( "Not yet implemented" );
}
//INPUT VALIDATION
@Ignore
@Test( expected = IllegalArgumentException.class )
public void apiUrl_Null_Should_Throw_An_IllegalArgumentException() throws O2NetworkException, IllegalArgumentException, O2RuleException, O2UnexpectedException {
new OxygenLogin.Builder().apiURL( null ).apiKey( apiKey ).oxygenUserId( user ).oxygenPassword( password ).O2AgentFactory( mockO2AgentFactory ).build();
}
/*
class O2AgentFactoryStub extends O2AgentFactory {
O2Agent mockO2Agent;
String expectedGetResult;
void setExpectedO2Agent( O2Agent agent )
{
mockO2Agent = agent;
}
@Override
O2Agent createAndroidO2AgentCustomURL( String url )
{
}
} //end inner stub class
*/
} //end class