| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 import google.protobuf.no_generic_services_test.UnittestNoGenericServices; | 35 import google.protobuf.no_generic_services_test.UnittestNoGenericServices; |
| 36 import protobuf_unittest.MessageWithNoOuter; | 36 import protobuf_unittest.MessageWithNoOuter; |
| 37 import protobuf_unittest.ServiceWithNoOuter; | 37 import protobuf_unittest.ServiceWithNoOuter; |
| 38 import protobuf_unittest.UnittestProto.BarRequest; | 38 import protobuf_unittest.UnittestProto.BarRequest; |
| 39 import protobuf_unittest.UnittestProto.BarResponse; | 39 import protobuf_unittest.UnittestProto.BarResponse; |
| 40 import protobuf_unittest.UnittestProto.FooRequest; | 40 import protobuf_unittest.UnittestProto.FooRequest; |
| 41 import protobuf_unittest.UnittestProto.FooResponse; | 41 import protobuf_unittest.UnittestProto.FooResponse; |
| 42 import protobuf_unittest.UnittestProto.TestAllTypes; | 42 import protobuf_unittest.UnittestProto.TestAllTypes; |
| 43 import protobuf_unittest.UnittestProto.TestService; | 43 import protobuf_unittest.UnittestProto.TestService; |
| 44 | 44 |
| 45 import java.util.HashSet; | |
| 46 import java.util.Set; | |
| 47 import junit.framework.TestCase; | 45 import junit.framework.TestCase; |
| 46 |
| 48 import org.easymock.classextension.EasyMock; | 47 import org.easymock.classextension.EasyMock; |
| 49 import org.easymock.IArgumentMatcher; | 48 import org.easymock.IArgumentMatcher; |
| 50 import org.easymock.classextension.IMocksControl; | 49 import org.easymock.classextension.IMocksControl; |
| 51 | 50 |
| 51 import java.util.HashSet; |
| 52 import java.util.Set; |
| 53 |
| 52 /** | 54 /** |
| 53 * Tests services and stubs. | 55 * Tests services and stubs. |
| 54 * | 56 * |
| 55 * @author kenton@google.com Kenton Varda | 57 * @author kenton@google.com Kenton Varda |
| 56 */ | 58 */ |
| 57 public class ServiceTest extends TestCase { | 59 public class ServiceTest extends TestCase { |
| 58 private IMocksControl control; | 60 private IMocksControl control; |
| 59 private RpcController mockController; | 61 private RpcController mockController; |
| 60 | 62 |
| 61 private final Descriptors.MethodDescriptor fooDescriptor = | 63 private final Descriptors.MethodDescriptor fooDescriptor = |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 264 |
| 263 // But descriptors are there. | 265 // But descriptors are there. |
| 264 FileDescriptor file = UnittestNoGenericServices.getDescriptor(); | 266 FileDescriptor file = UnittestNoGenericServices.getDescriptor(); |
| 265 assertEquals(1, file.getServices().size()); | 267 assertEquals(1, file.getServices().size()); |
| 266 assertEquals("TestService", file.getServices().get(0).getName()); | 268 assertEquals("TestService", file.getServices().get(0).getName()); |
| 267 assertEquals(1, file.getServices().get(0).getMethods().size()); | 269 assertEquals(1, file.getServices().get(0).getMethods().size()); |
| 268 assertEquals("Foo", | 270 assertEquals("Foo", |
| 269 file.getServices().get(0).getMethods().get(0).getName()); | 271 file.getServices().get(0).getMethods().get(0).getName()); |
| 270 } | 272 } |
| 271 | 273 |
| 272 | |
| 273 | |
| 274 // ================================================================= | 274 // ================================================================= |
| 275 | 275 |
| 276 /** | 276 /** |
| 277 * wrapsCallback() is an EasyMock argument predicate. wrapsCallback(c) | 277 * wrapsCallback() is an EasyMock argument predicate. wrapsCallback(c) |
| 278 * matches a callback if calling that callback causes c to be called. | 278 * matches a callback if calling that callback causes c to be called. |
| 279 * In other words, c wraps the given callback. | 279 * In other words, c wraps the given callback. |
| 280 */ | 280 */ |
| 281 private <Type extends Message> RpcCallback<Type> wrapsCallback( | 281 private <Type extends Message> RpcCallback<Type> wrapsCallback( |
| 282 MockCallback<?> callback) { | 282 MockCallback<?> callback) { |
| 283 EasyMock.reportMatcher(new WrapsCallback(callback)); | 283 EasyMock.reportMatcher(new WrapsCallback(callback)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 actualCallback.run(null); | 317 actualCallback.run(null); |
| 318 return callback.isCalled(); | 318 return callback.isCalled(); |
| 319 } | 319 } |
| 320 | 320 |
| 321 @Override | 321 @Override |
| 322 public void appendTo(StringBuffer buffer) { | 322 public void appendTo(StringBuffer buffer) { |
| 323 buffer.append("wrapsCallback(mockCallback)"); | 323 buffer.append("wrapsCallback(mockCallback)"); |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 } | 326 } |
| OLD | NEW |