本文整理了Java中org.easymock.EasyMock.aryEq()
方法的一些代码示例,展示了EasyMock.aryEq()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.aryEq()
方法的具体详情如下:
包路径:org.easymock.EasyMock
类名称:EasyMock
方法名:aryEq
[英]Expects a byte array that is equal to the given array, i.e. it has to have the same length, and each element has to be equal.
[中]需要一个与给定数组相等的字节数组,即它必须具有相同的长度,并且每个元素必须相等。
代码示例来源:origin: apache/incubator-druid
@Test
public void testStartCorrect()
{
final Announcer announcer = EasyMock.createStrictMock(Announcer.class);
final HostAndPortWithScheme node = HostAndPortWithScheme.fromString("some_host");
final ListenerResourceAnnouncer resourceAnnouncer = new ListenerResourceAnnouncer(
announcer,
listeningAnnouncerConfig,
listenerKey,
node
)
{
};
announcer.announce(
EasyMock.eq(ZKPaths.makePath(announcePath, StringUtils.format("%s:%s", node.getScheme(), node.getHostText()))),
EasyMock.aryEq(resourceAnnouncer.getAnnounceBytes())
);
EasyMock.expectLastCall().once();
EasyMock.replay(announcer);
resourceAnnouncer.start();
EasyMock.verify(announcer);
}
}
代码示例来源:origin: geoserver/geoserver
expect(keyStoreProvider.isKeyStorePassword(aryEq("geoserver".toCharArray())))
.andReturn(true)
.anyTimes();
代码示例来源:origin: org.nakedobjects/nof-reflector-core
public void testExecuteOK() {
ServerActionResultData results = encoder.createServerActionResult((Naked) eq(adapter), aryEq(new ObjectData[0]),
aryEq(new ReferenceData[0]), (ObjectData) isNull(), aryEq(new ObjectData[0]), aryEq(new String[0]),
aryEq(new String[0]));
expectLastCall().andReturn(null);
replay(encoder, action);
ServerActionResultData result = server.executeServerAction(new NullSession(), NakedObjectAction.USER.getName(),
Movie.class.getName() + "#action()", targetData, parameterData);
verify(encoder, action);
assertEquals(results, result);
}
代码示例来源:origin: apache/tapestry-5
private void ignoreEvent(ComponentResources resources, String event, Object... context)
{
EasyMock.expect(resources.triggerEvent(EasyMock.eq(event),
EasyMock.aryEq(context),
EasyMock.isA(ComponentEventCallback.class))).andReturn(false);
}
代码示例来源:origin: org.nakedobjects/nof-reflector-core
public void testExecuteWhereObjectChanged() {
encoder.createForUpdate(adapter);
ObjectData changedObjectData = new DummyObjectData();
expectLastCall().andReturn(changedObjectData);
ServerActionResultData results = encoder.createServerActionResult((Naked) eq(adapter),
aryEq(new ObjectData[] { changedObjectData }), aryEq(new ReferenceData[0]), (ObjectData) isNull(),
aryEq(new ObjectData[0]), aryEq(new String[0]), aryEq(new String[0]));
expectLastCall().andReturn(null);
replay(encoder, action);
NakedObjectsContext.getUpdateNotifer().addChangedObject(adapter);
ServerActionResultData result = server.executeServerAction(new NullSession(), NakedObjectAction.USER.getName(),
Movie.class.getName() + "#action()", targetData, parameterData);
verify(encoder, action);
assertEquals(results, result);
}
代码示例来源:origin: org.nakedobjects/nof-reflector-core
public void testExecuteWhereObjectDeleted() {
encoder.createIdentityData(adapter);
ReferenceData deletedObjectIdentityData = new DummyReferenceData(adapter.getOid(), "", adapter.getVersion());
expectLastCall().andReturn(deletedObjectIdentityData);
ServerActionResultData results = encoder.createServerActionResult((Naked) eq(adapter), aryEq(new ObjectData[0]),
aryEq(new ReferenceData[] { deletedObjectIdentityData }), (ObjectData) isNull(), aryEq(new ObjectData[0]),
aryEq(new String[0]), aryEq(new String[0]));
expectLastCall().andReturn(null);
replay(encoder, action);
NakedObjectsContext.getUpdateNotifer().addDisposedObject(adapter);
ServerActionResultData result = server.executeServerAction(new NullSession(), NakedObjectAction.USER.getName(),
Movie.class.getName() + "#action()", targetData, parameterData);
verify(encoder, action);
assertEquals(results, result);
}
代码示例来源:origin: org.nakedobjects/nof-reflector-core
public void testExecuteWhereMessagesAndWarningGenerated() {
ServerActionResultData results = encoder.createServerActionResult((Naked) eq(adapter), aryEq(new ObjectData[0]),
aryEq(new ReferenceData[0]), (ObjectData) isNull(), aryEq(new ObjectData[0]), aryEq(new String[] { "message 1",
"message 2" }), aryEq(new String[] { "warning 1", "warning 2" }));
expectLastCall().andReturn(null);
replay(encoder, action);
NakedObjectsContext.getMessageBroker().addMessage("message 1");
NakedObjectsContext.getMessageBroker().addMessage("message 2");
NakedObjectsContext.getMessageBroker().addWarning("warning 1");
NakedObjectsContext.getMessageBroker().addWarning("warning 2");
ServerActionResultData result = server.executeServerAction(new NullSession(), NakedObjectAction.USER.getName(),
Movie.class.getName() + "#action()", targetData, parameterData);
verify(encoder, action);
assertEquals(results, result);
}
代码示例来源:origin: org.nakedobjects/nof-reflector-core
public void testExecuteClientActionWhereObjectDeleted() {
NakedObject adapter = system.createPersistentTestObject();
Oid oid = adapter.getOid();
DummyIdentityData identityData = new DummyIdentityData(oid, TestProxyNakedObject.class.getName(), new TestProxyVersion(1));
// return results
encoder.createClientActionResult(aryEq(new ReferenceData[1]), aryEq(new Version[1]) ,aryEq(new ObjectData[0]));
DummyClientResultData results = new DummyClientResultData(new ObjectData[0], new Version[0], null);
expectLastCall().andReturn(results);
replay();
ClientActionResultData result = server.executeClientAction(new NullSession(), new ReferenceData[] { identityData },
new int[] { ClientTransactionEvent.DELETE });
verify();
assertEquals(results, result);
}
代码示例来源:origin: org.nakedobjects/nof-reflector-core
public void testExecuteClientActionWithNoWork() {
NakedObjectsContext.getObjectPersistor().startTransaction();
encoder.createClientActionResult(aryEq(new ObjectData[0]), aryEq(new Version[0]), aryEq(new ObjectData[0]));
expectLastCall().andReturn(new DummyClientResultData(new ObjectData[0], new Version[0], null));
NakedObjectsContext.getObjectPersistor().endTransaction();
replay();
ClientActionResultData result = server.executeClientAction(session, new ReferenceData[0], new int[0]);
verify();
assertEquals(0, result.getPersisted().length);
assertEquals(0, result.getChanged().length);
}
代码示例来源:origin: GeoWebCache/geowebcache
@Test
public void testNoFilterPass() throws Exception {
SecurityDispatcher secDispatcher = new SecurityDispatcher();
secDispatcher.setApplicationContext(extensions.getMockContext());
ConveyorTile conv = EasyMock.createMock("conv", ConveyorTile.class);
TileLayer layer = EasyMock.createMock("layer", TileLayer.class);
GridSubset subset = EasyMock.createMock("subset", GridSubset.class);
SRS srs = EasyMock.createMock("srs", SRS.class);
BoundingBox bbox = new BoundingBox(10, 20, 30, 40);
EasyMock.expect(conv.getLayer()).andStubReturn(layer);
EasyMock.expect(conv.getGridSubset()).andStubReturn(subset);
EasyMock.expect(conv.getTileIndex()).andStubReturn(new long[] {1, 2, 3});
EasyMock.expect(subset.boundsFromIndex(EasyMock.aryEq(new long[] {1, 2, 3})))
.andStubReturn(bbox);
EasyMock.expect(subset.getSRS()).andStubReturn(srs);
EasyMock.replay(conv, layer, subset, srs);
secDispatcher.checkSecurity(conv);
EasyMock.verify(conv, layer, subset, srs);
}
}
代码示例来源:origin: org.nakedobjects/nof-reflector-core
protected void setUp() throws Exception {
BasicConfigurator.configure();
LogManager.getRootLogger().setLevel(Level.OFF);
system = new TestProxySystem();
system.init();
actionPeer = createMock(ActionPeer.class);
encoder = createMock(ObjectEncoder.class);
remoteInterface = createMock(Distribution.class);
proxy = new ProxyAction(actionPeer, remoteInterface, encoder);
actionPeer.getIdentifier();
identifier = new DummyIdentifier();
expectLastCall().andStubReturn(identifier);
target = system.createTransientTestObject();
actionPeer.execute(eq(target), aryEq(new Naked[] { param1, param1 }));
expectLastCall().andReturn(null);
}
代码示例来源:origin: GeoWebCache/geowebcache
@Test
public void testOneFilterPass() throws Exception {
SecurityDispatcher secDispatcher = new SecurityDispatcher();
secDispatcher.setApplicationContext(extensions.getMockContext());
ConveyorTile conv = EasyMock.createMock("conv", ConveyorTile.class);
TileLayer layer = EasyMock.createMock("layer", TileLayer.class);
GridSubset subset = EasyMock.createMock("subset", GridSubset.class);
SRS srs = EasyMock.createMock("srs", SRS.class);
BoundingBox bbox = new BoundingBox(10, 20, 30, 40);
SecurityFilter filter = EasyMock.createMock("filter", SecurityFilter.class);
extensions.addBean("testSecurityFilter", filter, SecurityFilter.class);
EasyMock.expect(conv.getLayer()).andStubReturn(layer);
EasyMock.expect(conv.getGridSubset()).andStubReturn(subset);
EasyMock.expect(conv.getTileIndex()).andStubReturn(new long[] {1, 2, 3});
EasyMock.expect(subset.boundsFromIndex(EasyMock.aryEq(new long[] {1, 2, 3})))
.andStubReturn(bbox);
EasyMock.expect(subset.getSRS()).andStubReturn(srs);
filter.checkSecurity(layer, bbox, srs);
EasyMock.expectLastCall().once();
EasyMock.replay(conv, layer, subset, srs, filter);
secDispatcher.checkSecurity(conv);
EasyMock.verify(conv, layer, subset, srs, filter);
}
代码示例来源:origin: GeoWebCache/geowebcache
@Test
public void testOneFilterFail() throws Exception {
SecurityDispatcher secDispatcher = new SecurityDispatcher();
secDispatcher.setApplicationContext(extensions.getMockContext());
ConveyorTile conv = EasyMock.createMock("conv", ConveyorTile.class);
TileLayer layer = EasyMock.createMock("layer", TileLayer.class);
GridSubset subset = EasyMock.createMock("subset", GridSubset.class);
SRS srs = EasyMock.createMock("srs", SRS.class);
BoundingBox bbox = new BoundingBox(10, 20, 30, 40);
SecurityFilter filter = EasyMock.createMock("filter", SecurityFilter.class);
extensions.addBean("testSecurityFilter", filter, SecurityFilter.class);
EasyMock.expect(conv.getLayer()).andStubReturn(layer);
EasyMock.expect(conv.getGridSubset()).andStubReturn(subset);
EasyMock.expect(conv.getTileIndex()).andStubReturn(new long[] {1, 2, 3});
EasyMock.expect(subset.boundsFromIndex(EasyMock.aryEq(new long[] {1, 2, 3})))
.andStubReturn(bbox);
EasyMock.expect(subset.getSRS()).andStubReturn(srs);
filter.checkSecurity(layer, bbox, srs);
EasyMock.expectLastCall().andThrow(new SecurityException()).once();
EasyMock.replay(conv, layer, subset, srs, filter);
exception.expect(instanceOf(SecurityException.class));
try {
secDispatcher.checkSecurity(conv);
} finally {
EasyMock.verify(conv, layer, subset, srs, filter);
}
}
代码示例来源:origin: org.nakedobjects/nof-reflector-core
public void testClientSideActionWhereObjectDeleted() throws Exception {
NakedObject movieAdapter = system.createPersistentTestObject();
system.setObjectPersistor(proxy);
DummyIdentityData identityOfObjectToDelete = new DummyIdentityData();
expect(encoder.createIdentityData(movieAdapter)).andReturn(identityOfObjectToDelete);
remoteInterface.executeClientAction( EasyMock.eq(session), EasyMock.aryEq(new ReferenceData[] {identityOfObjectToDelete}), EasyMock.aryEq(new int[] {ClientTransactionEvent.DELETE}));
Version[] versionUpdates = new Version[] {};
expectLastCall().andReturn(new DummyClientResultData(new ObjectData[] {}, versionUpdates, new ObjectData[0]));
replay();
proxy.startTransaction();
proxy.destroyObject(movieAdapter);
proxy.endTransaction();
verify();
Enumeration allDisposedObjects = NakedObjectsContext.getUpdateNotifer().allDisposedObjects();
assertTrue(allDisposedObjects.hasMoreElements());
assertEquals(movieAdapter, allDisposedObjects.nextElement());
}
代码示例来源:origin: org.nakedobjects/nof-reflector-core
public void testExecuteClientActionWhereObjectMadePersistent() {
NakedObject adapter = system.createTransientTestObject();
DummyObjectData data = new DummyObjectData(adapter.getOid(), "none", true, new TestProxyVersion(1));
// restore the object on the server
expect(encoder.restore(data, new KnownObjects())).andReturn(adapter);
expect(encoder.createIdentityData(adapter)).andReturn(null);
// return results
DummyClientResultData results = new DummyClientResultData(new ObjectData[0], new Version[0], new ObjectData[0]);
encoder.createClientActionResult(aryEq(new ReferenceData[1]), aryEq(new Version[1]), aryEq(new ObjectData[0]));
expectLastCall().andReturn(results);
replay();
ClientActionResultData result = server.executeClientAction(session, new ReferenceData[] { data },
new int[] { ClientTransactionEvent.ADD });
verify();
assertEquals(result, result);
NakedObject object = NakedObjectsContext.getObjectPersistor().getObject(adapter.getOid(), adapter.getSpecification());
assertEquals(adapter, object);
assertEquals(new TestProxyVersion(1), object.getVersion());
}
代码示例来源:origin: apache/tapestry-5
@SuppressWarnings({"unchecked"})
@Test
public void to_client_via_translator()
{
Object value = new Integer(99);
ComponentResources resources = mockComponentResources();
FieldTranslator translator = mockFieldTranslator();
NullFieldStrategy nullFieldStrategy = mockNullFieldStrategy();
expect(translator.getType()).andReturn(Integer.class);
String clientValue = "abracadabra";
EasyMock.expect(resources.triggerEvent(EasyMock.eq(EventConstants.TO_CLIENT),
EasyMock.aryEq(new Object[]{value}),
EasyMock.isA(ComponentEventCallback.class))).andReturn(false);
expect(translator.toClient(value)).andReturn(clientValue);
replay();
FieldValidationSupport support = new FieldValidationSupportImpl(typeCoercer, propertyAccess);
String actual = support.toClient(value, resources, translator, nullFieldStrategy);
assertEquals(actual, clientValue);
verify();
}
代码示例来源:origin: org.nakedobjects/nof-reflector-core
public void testExecuteClientActionWhereObjectChanged() {
NakedObject adapter = system.createPersistentTestObject();
DummyObjectData data = new DummyObjectData(adapter.getOid(), "none", true, new TestProxyVersion(1));
// prepare the update data to return
expect(encoder.restore(data, new KnownObjects())).andReturn(adapter);
// results returned in their own container
DummyClientResultData results = new DummyClientResultData(new ObjectData[0], new Version[0], null);
encoder.createClientActionResult(aryEq(new ReferenceData[1]), aryEq(new Version[] { new TestProxyVersion(2) }), aryEq(new ObjectData[0]));
// encoderControl.setMatcher(MockControl.ARRAY_MATCHER);
expectLastCall().andReturn(results);
replay();
ClientActionResultData result = server.executeClientAction(session, new ReferenceData[] { data },
new int[] { ClientTransactionEvent.CHANGE });
verify();
NakedObject object = NakedObjectsContext.getObjectPersistor().getObject(adapter.getOid(), adapter.getSpecification());
assertEquals(new TestProxyVersion(2), object.getVersion());
assertEquals(result, result);
}
代码示例来源:origin: apache/tapestry-5
@SuppressWarnings({"unchecked"})
@Test
public void event_triggered_after_delegate_invoked() throws Exception
{
getMocksControl().checkOrder(true);
ComponentResources resources = mockComponentResources();
FieldValidator fv = mockFieldValidator();
Object value = new Object();
fv.validate(value);
ComponentEventCallback handler = null;
expect(resources.triggerEvent(EasyMock.eq(EventConstants.VALIDATE),
EasyMock.aryEq(new Object[]{value}), EasyMock.eq(handler))).andReturn(true);
replay();
FieldValidationSupport support = new FieldValidationSupportImpl(typeCoercer, propertyAccess);
support.validate(value, resources, fv);
verify();
}
代码示例来源:origin: org.nakedobjects/nof-reflector-core
public void testClientSideActionWhereTransientObjectMadePersistent() throws Exception {
system.setObjectPersistor(proxy);
proxy.setOidGenerator(new SimpleOidGenerator(10));
DummyObjectData movieData = new DummyObjectData(new DummyOid(-1), Movie.class.getName(), true, null);
NullData directorData = new DummyNullValue(Person.class.getName());
DummyValueData nameData = new DummyValueData("Star Wars", String.class.getName());
movieData.setFieldContent(new Data[] { directorData, nameData });
TestProxyOid newOid = new TestProxyOid(123, true);
newOid.previous = new TestProxyOid(-1);
DummyReferenceData updateData = new DummyReferenceData(newOid, "type", new DummyVersion(456));
NakedObject transientObject = new DummyNakedObject(newOid.previous, ResolveState.NEW);
NakedObjectsContext.getObjectLoader().createAdapterForTransient(transientObject, false);
// client needs to encode the object's transient aspects
expect(encoder.createMakePersistentGraph(transientObject, new KnownObjects())).andReturn(movieData);
// the server is called with data (movieData) for the object to be persisted
remoteInterface.executeClientAction(eq(session), aryEq(new ReferenceData[] { movieData }), aryEq(new int[] { ClientTransactionEvent.ADD }));
expectLastCall().andReturn(new DummyClientResultData(new ReferenceData[] { updateData }, null, new ObjectData[0]));
replay();
proxy.startTransaction();
proxy.makePersistent(transientObject);
proxy.endTransaction();
verify();
}
代码示例来源:origin: org.nakedobjects/nof-reflector-core
protected void setUp() throws Exception {
BasicConfigurator.configure();
LogManager.getRootLogger().setLevel(Level.OFF);
encoder = createMock(ObjectEncoder.class);
server = new ServerDistribution(null);
server.setEncoder(encoder);
server.init();
reset(encoder); // server calls encoder, so we need to ignore this
system = new TestProxySystem();
system.init();
adapter = system.createPersistentTestObject();
oid = adapter.getOid();
targetData = new DummyIdentityData(oid, TestProxyNakedObject.class.getName(), new TestProxyVersion(1));
parameterData = new ReferenceData[] {};
TestProxySpecification proxySpecification = (TestProxySpecification) adapter.getSpecification();
action = createMock(NakedObjectAction.class);
proxySpecification.setupAction(action);
action.getId();
expectLastCall().andStubReturn("action()");
action.execute(eq(adapter), aryEq(new Naked[0]));
expectLastCall().andReturn(adapter);
}
内容来源于网络,如有侵权,请联系作者删除!