Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv15725/input/javasrc/biz/xsoftware/test/mock
Modified Files:
TestExtendMockSuperclass.java TestMockCreator.java
TestBehavior.java TestMethodVerifier.java
TestOrderedCalls.java TestMockObject.java
TestMockTestCase.java TestCloningBehavior.java MockOne.java
TestMockLogHandler.java
Added Files:
TestInjection.java
Log Message:
- Adding Apache License header
- Javadoc cleanup
Index: TestMockCreator.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock/TestMockCreator.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** TestMockCreator.java 23 May 2008 19:05:47 -0000 1.14
--- TestMockCreator.java 11 Feb 2009 18:25:58 -0000 1.15
***************
*** 1,2 ****
--- 1,16 ----
+ /*
+ * Copyright 2009 mocklib.sourceforge.net
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package biz.xsoftware.test.mock;
--- NEW FILE: TestInjection.java ---
/*
* Copyright 2009 mocklib.sourceforge.net
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package biz.xsoftware.test.mock;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import junit.framework.JUnit4TestAdapter;
import org.junit.Test;
import biz.xsoftware.mock.MockObject;
import biz.xsoftware.mock.MockObjectFactory;
/**
* Test the {@link MockObjectFactory#injectMock(Object, String, Class[])} method
* to verify it works as expected.
*
*
* @author Brian Freeman
* @since 11 Feb 2009
*/
public class TestInjection {
/**
* Test passing a null object instance
*/
@Test(expected = NullPointerException.class)
public void testFailScenario1() {
MockObjectFactory.injectMock(null, "", TestIntf.class);
}
/**
* Test passing an invalid field name into the method
*/
@Test
public void testFailScenario2() {
TestClass testClass = new TestClass();
try {
MockObjectFactory.injectMock(testClass, "junk", TestIntf.class);
} catch (RuntimeException e) {
assertEquals(NoSuchFieldException.class, e.getCause().getClass());
}
}
/**
* Test the {@link MockObjectFactory#injectMock(Object, String, Class[])}
* method works as expected
*/
@Test
public void testInjection() {
// create an instance of the class
TestClass testClass = new TestClass();
// now inject a mock implementation of the TestIntf into
// the class instance
MockObject mock = MockObjectFactory.injectMock(testClass, "testIntf",
TestIntf.class);
assertNotNull(mock);
String testStr = "Hello World";
mock.addReturnValue("foo", testStr);
// call the testClass's test method in order to verify
// that the MockObject was successfully injected
assertEquals(testStr, testClass.testMethod());
// verify that by calling the test method that the foo
// method was called in the MockObject
mock.expect("foo");
}
/**
* Test class to inject the MockObject into
*/
private static class TestClass {
private TestIntf testIntf;
public String testMethod() {
return testIntf.foo();
}
}
/**
* Test interface to create the {@link MockObject} with
*/
private interface TestIntf {
String foo();
}
/**
* Added for backwards compatibility with JUnit 3
*/
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(TestBehavior.class);
}
}
Index: TestCloningBehavior.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock/TestCloningBehavior.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestCloningBehavior.java 23 May 2008 19:05:51 -0000 1.1
--- TestCloningBehavior.java 11 Feb 2009 18:25:58 -0000 1.2
***************
*** 1,4 ****
/*
! * TestCloningBehavior.java
*/
package biz.xsoftware.test.mock;
--- 1,15 ----
/*
! * Copyright 2009 mocklib.sourceforge.net
! *
! * Licensed under the Apache License, Version 2.0 (the "License");
! * you may not use this file except in compliance with the License.
! * You may obtain a copy of the License at
! * http://www.apache.org/licenses/LICENSE-2.0
! *
! * Unless required by applicable law or agreed to in writing, software
! * distributed under the License is distributed on an "AS IS" BASIS,
! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! * See the License for the specific language governing permissions and
! * limitations under the License.
*/
package biz.xsoftware.test.mock;
Index: TestExtendMockSuperclass.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock/TestExtendMockSuperclass.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestExtendMockSuperclass.java 23 May 2008 19:05:52 -0000 1.1
--- TestExtendMockSuperclass.java 11 Feb 2009 18:25:58 -0000 1.2
***************
*** 1,4 ****
/*
! * TestExtendMockSuperclass.java
*/
package biz.xsoftware.test.mock;
--- 1,15 ----
/*
! * Copyright 2009 mocklib.sourceforge.net
! *
! * Licensed under the Apache License, Version 2.0 (the "License");
! * you may not use this file except in compliance with the License.
! * You may obtain a copy of the License at
! * http://www.apache.org/licenses/LICENSE-2.0
! *
! * Unless required by applicable law or agreed to in writing, software
! * distributed under the License is distributed on an "AS IS" BASIS,
! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! * See the License for the specific language governing permissions and
! * limitations under the License.
*/
package biz.xsoftware.test.mock;
***************
*** 9,18 ****
import biz.xsoftware.impl.mock.MockSuperclass;
!
/**
* @author Brian Freeman
* @since Aug 13, 2007
- *
*/
public class TestExtendMockSuperclass {
--- 20,34 ----
import biz.xsoftware.impl.mock.MockSuperclass;
! import biz.xsoftware.mock.Behavior;
/**
+ * Test extending {@link MockSuperclass} to verify non-breakage of code that
+ * uses MockLib this way.
+ * <p>
+ * Note: It is not recommended to extend {@link MockSuperclass}.
+ * {@link Behavior}s should be used instead.
+ *
* @author Brian Freeman
* @since Aug 13, 2007
*/
public class TestExtendMockSuperclass {
Index: TestMethodVerifier.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock/TestMethodVerifier.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestMethodVerifier.java 23 May 2008 19:05:53 -0000 1.1
--- TestMethodVerifier.java 11 Feb 2009 18:25:58 -0000 1.2
***************
*** 1,2 ****
--- 1,16 ----
+ /*
+ * Copyright 2009 mocklib.sourceforge.net
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package biz.xsoftware.test.mock;
***************
*** 223,227 ****
/**
! * helper interface
*/
private static interface TestOne {
--- 237,241 ----
/**
! * Helper interface
*/
private static interface TestOne {
***************
*** 241,244 ****
--- 255,261 ----
}
+ /**
+ * Helper class
+ */
private static class TestOneImpl implements TestOne {
Index: MockOne.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock/MockOne.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MockOne.java 23 May 2008 19:05:59 -0000 1.4
--- MockOne.java 11 Feb 2009 18:25:58 -0000 1.5
***************
*** 1,2 ****
--- 1,16 ----
+ /*
+ * Copyright 2009 mocklib.sourceforge.net
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package biz.xsoftware.test.mock;
***************
*** 48,54 ****
return new Class<?>[] { MockOne.class };
}
- public Object inst() {
- // TODO Auto-generated method stub
- return null;
- }
}
--- 62,64 ----
Index: TestMockLogHandler.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock/TestMockLogHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestMockLogHandler.java 23 May 2008 19:05:55 -0000 1.1
--- TestMockLogHandler.java 11 Feb 2009 18:25:58 -0000 1.2
***************
*** 1,2 ****
--- 1,16 ----
+ /*
+ * Copyright 2009 mocklib.sourceforge.net
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package biz.xsoftware.test.mock;
Index: TestBehavior.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock/TestBehavior.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestBehavior.java 23 May 2008 19:05:58 -0000 1.1
--- TestBehavior.java 11 Feb 2009 18:25:58 -0000 1.2
***************
*** 1,4 ****
/*
! * TestBehavior.java
*/
package biz.xsoftware.test.mock;
--- 1,15 ----
/*
! * Copyright 2009 mocklib.sourceforge.net
! *
! * Licensed under the Apache License, Version 2.0 (the "License");
! * you may not use this file except in compliance with the License.
! * You may obtain a copy of the License at
! * http://www.apache.org/licenses/LICENSE-2.0
! *
! * Unless required by applicable law or agreed to in writing, software
! * distributed under the License is distributed on an "AS IS" BASIS,
! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! * See the License for the specific language governing permissions and
! * limitations under the License.
*/
package biz.xsoftware.test.mock;
***************
*** 23,26 ****
--- 34,40 ----
public class TestBehavior {
+ /**
+ * Added for backwards compatibility with JUnit 3
+ */
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(TestBehavior.class);
Index: TestMockObject.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock/TestMockObject.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestMockObject.java 23 May 2008 19:05:48 -0000 1.1
--- TestMockObject.java 11 Feb 2009 18:25:58 -0000 1.2
***************
*** 1,2 ****
--- 1,16 ----
+ /*
+ * Copyright 2009 mocklib.sourceforge.net
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package biz.xsoftware.test.mock;
***************
*** 10,13 ****
--- 24,28 ----
import org.junit.After;
import org.junit.Before;
+ import org.junit.Ignore;
import org.junit.Test;
***************
*** 334,338 ****
* {@link biz.xsoftware.mock.MockObject#setDefaultBehavior(java.lang.String, biz.xsoftware.mock.Behavior)}.
*/
! // @Test
public void testSetDefaultBehaviorStringBehavior() {
// TODO: Not yet implemented
--- 349,354 ----
* {@link biz.xsoftware.mock.MockObject#setDefaultBehavior(java.lang.String, biz.xsoftware.mock.Behavior)}.
*/
! @Test
! @Ignore
public void testSetDefaultBehaviorStringBehavior() {
// TODO: Not yet implemented
***************
*** 343,347 ****
* {@link biz.xsoftware.mock.MockObject#setDefaultBehavior(java.lang.String, biz.xsoftware.mock.Behavior, java.lang.Class[])}.
*/
! // @Test
public void testSetDefaultBehaviorStringBehaviorClassArray() {
// TODO: Not yet implemented
--- 359,364 ----
* {@link biz.xsoftware.mock.MockObject#setDefaultBehavior(java.lang.String, biz.xsoftware.mock.Behavior, java.lang.Class[])}.
*/
! @Test
! @Ignore
public void testSetDefaultBehaviorStringBehaviorClassArray() {
// TODO: Not yet implemented
***************
*** 543,547 ****
* {@link biz.xsoftware.mock.MockObject#addBehavior(java.lang.String, biz.xsoftware.mock.Behavior)}.
*/
! // @Test
public void testAddBehaviorStringBehavior() {
// TODO: Not yet implemented
--- 560,565 ----
* {@link biz.xsoftware.mock.MockObject#addBehavior(java.lang.String, biz.xsoftware.mock.Behavior)}.
*/
! @Test
! @Ignore
public void testAddBehaviorStringBehavior() {
// TODO: Not yet implemented
***************
*** 552,556 ****
* {@link biz.xsoftware.mock.MockObject#addBehavior(java.lang.String, biz.xsoftware.mock.Behavior, java.lang.Class[])}.
*/
! // @Test
public void testAddBehaviorStringBehaviorClassArray() {
// TODO: Not yet implemented
--- 570,575 ----
* {@link biz.xsoftware.mock.MockObject#addBehavior(java.lang.String, biz.xsoftware.mock.Behavior, java.lang.Class[])}.
*/
! @Test
! @Ignore
public void testAddBehaviorStringBehaviorClassArray() {
// TODO: Not yet implemented
Index: TestOrderedCalls.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock/TestOrderedCalls.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** TestOrderedCalls.java 23 May 2008 19:05:57 -0000 1.6
--- TestOrderedCalls.java 11 Feb 2009 18:25:58 -0000 1.7
***************
*** 1,2 ****
--- 1,16 ----
+ /*
+ * Copyright 2009 mocklib.sourceforge.net
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package biz.xsoftware.test.mock;
***************
*** 11,14 ****
--- 25,29 ----
/**
+ * Test the methods are called in t
* @author Dean Hiller
* @since Apr 24, 2004
Index: TestMockTestCase.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/test/mock/TestMockTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TestMockTestCase.java 23 May 2008 19:05:48 -0000 1.3
--- TestMockTestCase.java 11 Feb 2009 18:25:58 -0000 1.4
***************
*** 1,2 ****
--- 1,16 ----
+ /*
+ * Copyright 2009 mocklib.sourceforge.net
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package biz.xsoftware.test.mock;
|