当前位置: 首页>>代码示例>>Java>>正文


Java CustomAction类代码示例

本文整理汇总了Java中org.jmock.lib.action.CustomAction的典型用法代码示例。如果您正苦于以下问题:Java CustomAction类的具体用法?Java CustomAction怎么用?Java CustomAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CustomAction类属于org.jmock.lib.action包,在下文中一共展示了CustomAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetBlockAtSector2

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
public void testGetBlockAtSector2() throws RecordStoreException {
    final INorFlashSectorState sector = mock(INorFlashSectorState.class);
    final int offset = 10;
    final MemoryHeapBlock block = new MemoryHeapBlock();
    final Address address = Address.fromPrimitive(11);
    final int sectorSize = 1024;

    expects(new InAnyOrder() {{
        one(sector).getSize();will(returnValue(sectorSize));
        one(sector).getStartAddress();will(returnValue(address));
        one(sector).readBytes(with(equal(offset)), with(an(byte[].class)), with(equal(0)), with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)));will(new CustomAction("") {
            public Object invoke(Invocation invocation) throws Throwable {
                block.setBytes(new byte[] {0, 0}, 0, 1);
                return null;
            }
        });
    }});
    try {
        castHeap.getBlockAt(block, sector, offset);
        fail();
    } catch (UnexpectedException e) {
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:24,代码来源:NorFlashMemoryHeapTest.java

示例2: shouldGenerateContent

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
@Test(dataProvider = "cmdLinesCases")
public void shouldGenerateContent(@NotNull final RunAsParams runAsParams, @NotNull final String expectedCmdLine) {
  // Given
  final ResourceGenerator<RunAsParams> instance = createInstance();
  myCtx.checking(new Expectations() {{
    allowing(myArgumentConverter).convert(with(any(String.class)));
    will(new CustomAction("convert") {
      @Override
      public Object invoke(final Invocation invocation) throws Throwable {
        return "'" + invocation.getParameter(0) + "'";
      }
    });
  }});

  // When
  final String content = instance.create(runAsParams);

  // Then
  then(content).isEqualTo("@ECHO OFF"
                          + LINE_SEPARATOR + expectedCmdLine
                          + LINE_SEPARATOR + "SET \"EXIT_CODE=%ERRORLEVEL%\""
                          + LINE_SEPARATOR + "EXIT /B %EXIT_CODE%");
}
 
开发者ID:JetBrains,项目名称:teamcity-runas-plugin,代码行数:24,代码来源:CmdGeneratorTest.java

示例3: shouldGenerateContent

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
@Test(dataProvider = "cmdLinesCases")
public void shouldGenerateContent(@NotNull final RunAsParams runAsParams, @NotNull final String expectedCmdLine) {
  // Given
  final ResourceGenerator<RunAsParams> instance = createInstance();
  myCtx.checking(new Expectations() {{
    allowing(myArgumentConverter).convert(with(any(String.class)));
    will(new CustomAction("convert") {
      @Override
      public Object invoke(final Invocation invocation) throws Throwable {
        return "'" + invocation.getParameter(0) + "'";
      }
    });
  }});

  // When
  final String content = instance.create(runAsParams);

  // Then
  then(content).isEqualTo(ShGenerator.BASH_HEADER + LINE_SEPARATOR + expectedCmdLine);
}
 
开发者ID:JetBrains,项目名称:teamcity-runas-plugin,代码行数:21,代码来源:ShGeneratorTest.java

示例4: sendRequestWithSenderVouchesToken

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
@Test
public void sendRequestWithSenderVouchesToken() throws Exception {
	ServiceClient client = this.client.getServiceClient();
	client.setToken(assertion);
	
	final StringValueHolder holder = new StringValueHolder();
	context.checking(new Expectations() {{
		one(soapClient).wsCall(with(equal(ADDRESS)), with(aNull(String.class)), with(aNull(String.class)), with(equal(true)), with(holder), with(equal("urn:action")));
		will(new CustomAction("test") {
			public Object invoke(Invocation invocation) throws Throwable {
				return buildResponse(holder.getValue(), false);
			}
		});
	}});
	Assertion body = SAMLUtil.buildXMLObject(Assertion.class);
	client.sendRequest(body, ADDRESS, "urn:action", null, null);

	OIOSoapEnvelope env = new OIOSoapEnvelope((Envelope) SAMLUtil.unmarshallElementFromString(holder.getValue()));
	assertFalse(env.isHolderOfKey());
	assertTrue(env.isSigned());
	
	Security sec = env.getHeaderElement(Security.class);
	assertNotNull(sec);
	assertNotNull(SAMLUtil.getFirstElement(sec, Assertion.class));
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:26,代码来源:TokenClientTest.java

示例5: testJAXBRequest

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
@Test
public void testJAXBRequest() throws Exception {
	final StringValueHolder holder = new StringValueHolder();
	context.checking(new Expectations() {{
		one(soapClient).wsCall(with(equal(ADDRESS)), with(aNull(String.class)), with(aNull(String.class)), with(equal(true)), with(holder), with(equal("urn:action")));
		will(new CustomAction("test") {
			public Object invoke(Invocation invocation) throws Throwable {
				OIOSoapEnvelope env = new OIOSoapEnvelope((Envelope) SAMLUtil.unmarshallElementFromString(holder.getValue()));
				
				Envelope response = SAMLUtil.buildXMLObject(Envelope.class);
				response.setHeader(SAMLUtil.buildXMLObject(Header.class));
				RelatesTo relatesTo = SAMLUtil.buildXMLObject(RelatesTo.class);
				relatesTo.setValue(env.getMessageID());
				response.getHeader().getUnknownXMLObjects().add(relatesTo);
				
				String xml = "<test:blah xmlns:test='urn:testing'><test:more>blah</test:more></test:blah>";
				response.setBody(SAMLUtil.buildXMLObject(Body.class));
				response.getBody().getUnknownXMLObjects().add(new XSAnyUnmarshaller().unmarshall(SAMLUtil.loadElementFromString(xml)));
				return response;
			}
		});
	}});
	
	client.getServiceClient().sendRequest(new TestBean(), JAXBContext.newInstance(TestBean.class), ADDRESS, "urn:action", null, null);
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:26,代码来源:TokenClientTest.java

示例6: setUp

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
@Before
public void setUp() {
  myMockery = new JUnit4Mockery() {{
    setImposteriser(ClassImposteriser.INSTANCE);
  }};
  myDocument = myMockery.mock(DocumentImpl.class);
  
  myMockery.checking(new Expectations() {{
    allowing(myDocument).getTextLength(); will(new CustomAction("getTextLength") {
      @Override
      public Object invoke(Invocation invocation) throws Throwable {
        return myArray.length();
      }
    });
  }});
  
  init(10);
  if (myConfig != null) {
    myArray.insert(myConfig.text(), 0);
    myArray.setDeferredChangeMode(myConfig.deferred());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:CharArrayTest.java

示例7: countDown

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
public static Action countDown(final CountDownLatch latch)
{
    return new CustomAction("Count Down Latch")
    {
        public Object invoke(Invocation invocation) throws Throwable
        {
            latch.countDown();
            return null;
        }
    };
}
 
开发者ID:winwill2012,项目名称:disruptor-code-analysis,代码行数:12,代码来源:Actions.java

示例8: testCheckMIDletVersionUpgrade

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
public void testCheckMIDletVersionUpgrade() throws RecordStoreException {
        final String midletName = "name";
        final String midletVendor = "vendor";
        final String[] midletVersionHandle = new String[] {""};

        final IApplicationDescriptorEntry applicationEntry = mock(IApplicationDescriptorEntry.class);
        castManager.currentApplicationDescriptor = applicationEntry;
        expects(new InAnyOrder() {{
            allowing(applicationEntry).getMidletName();will(returnValue(midletName));
            allowing(applicationEntry).getMidletVendor();will(returnValue(midletVendor));
            allowing(applicationEntry).getMidletVersion();will(new CustomAction("getMidletVersion") {
                public Object invoke(Invocation invocation) throws Throwable {
                    return midletVersionHandle[0];
                }
            });
        }});

        midletVersionHandle[0] = "1.0";
        assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.0"));
        assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.1"));
        assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.1.1"));
        assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.00"));

        midletVersionHandle[0] = "1.1";
        assertNotNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.0"));
        assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.1"));
        assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.2"));
        assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.1.1"));
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:30,代码来源:RecordStoreManagerTest.java

示例9: testGetBlockAtSector1

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
public void testGetBlockAtSector1() throws RecordStoreException {
    final INorFlashSectorState sector = mock(INorFlashSectorState.class);
    final int offset = 10;
    final Address address = Address.fromPrimitive(11);
    
    expects(new InAnyOrder() {{
        one(sector).getSize();will(returnValue(1024));
        one(sector).getStartAddress();will(returnValue(address));
        one(sector).readBytes(with(equal(offset)), with(an(byte[].class)), with(equal(0)), with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)));will(new CustomAction("") {
            public Object invoke(Invocation invocation) throws Throwable {
                ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
                DataOutputStream dataOut = new DataOutputStream(bytesOut);
                dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
                dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
                dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
                dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
                dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
                dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
                assertEquals(bytesOut.size(), NorFlashMemoryHeap.BLOCK_HEADER_SIZE);
                System.arraycopy(bytesOut.toByteArray(), 0, (byte[]) invocation.getParameter(1), 0, NorFlashMemoryHeap.BLOCK_HEADER_SIZE);
                return null;
            }
        });
    }});
    MemoryHeapBlock block = new MemoryHeapBlock();
    assertFalse(castHeap.getBlockAt(block, sector, offset));
    assertSame(address.add(offset), block.getAddress());
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:29,代码来源:NorFlashMemoryHeapTest.java

示例10: shouldGetPath

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
@Test
public void shouldGetPath() throws IOException, ExecutionException {
  // Given
  final File pluginRootDir = new File("plugin");
  final File binPath = new File(pluginRootDir, RunAsToolProvider.BIN_PATH);

  final List<ToolProvider> toolProviders = new ArrayList<ToolProvider>();
  myCtx.checking(new Expectations() {{
    oneOf(myPluginDescriptor).getPluginRoot();
    will(returnValue(pluginRootDir));

    oneOf(myToolProvidersRegistry).registerToolProvider(with(any(ToolProvider.class)));
    will(new CustomAction("registerToolProvider") {
      @Override
      public Object invoke(final Invocation invocation) throws Throwable {
        toolProviders.add((ToolProvider)invocation.getParameter(0));
        return null;
      }
    });
  }});

  // When
  createInstance();

  final ToolProvider toolProvider = toolProviders.get(0);
  final String toolPath = toolProvider.getPath(Constants.RUN_AS_TOOL_NAME);

  // Then
  myCtx.assertIsSatisfied();
  then(toolProviders.size()).isEqualTo(1);
  then(toolProvider.supports(Constants.RUN_AS_TOOL_NAME)).isTrue();
  then(new File(toolPath).getAbsolutePath()).isEqualTo(binPath.getAbsolutePath());
}
 
开发者ID:JetBrains,项目名称:teamcity-runas-plugin,代码行数:34,代码来源:RunAsToolProviderTest.java

示例11: shouldSetPermissions

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
@Test(dataProvider = "getSetPermissionsCases")
public void shouldSetPermissions(
  @NotNull final Iterable<AccessControlList> accessControlLists,
  @NotNull final Iterable<AccessControlList> expectedAccessControlLists,
  final int expectedGlobalCacheSize,
  final int expectedBuildCacheSize) throws ExecutionException {
  // Given
  final List<AccessControlList> actualAccessControlLists = new ArrayList<AccessControlList>();
  final FileAccessService instance = createInstance();

  myCtx.checking(new Expectations() {{
    allowing(myLoggerService).onMessage(with(any(ServiceMessage.class)));

    allowing(myFileAccessService).setAccess(with(any(AccessControlList.class)));
    will(new CustomAction("setAccess") {
      @Override
      public Object invoke(final Invocation invocation) throws Throwable {
        actualAccessControlLists.add((AccessControlList)invocation.getParameter(0));
        return Lists.emptyList();
      }
    });
  }});

  // When
  for (AccessControlList acl: accessControlLists) {
    instance.setAccess(acl);
  }

  // Then
  myCtx.assertIsSatisfied();
  then(actualAccessControlLists).isEqualTo(expectedAccessControlLists);
  then(myGlobalFileAccessCache.size()).isEqualTo(expectedGlobalCacheSize);
  then(myBuildFileAccessCache.size()).isEqualTo(expectedBuildCacheSize);
}
 
开发者ID:JetBrains,项目名称:teamcity-runas-plugin,代码行数:35,代码来源:ScopedFileAccessServiceTest.java

示例12: sendRequestWithoutToken

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
@Test
public void sendRequestWithoutToken() throws Exception {
	Assertion body = SAMLUtil.buildXMLObject(Assertion.class);
	
	final StringValueHolder holder = new StringValueHolder();
	context.checking(new Expectations() {{
		one(soapClient).wsCall(with(equal(ADDRESS)), with(aNull(String.class)), with(aNull(String.class)), with(equal(true)), with(holder), with(equal("urn:action")));
		will(new CustomAction("test") {
			public Object invoke(Invocation invocation) throws Throwable {
				return buildResponse(holder.getValue(), false);
			}
		});
	}});
	
	client.getServiceClient().sendRequest(body, ADDRESS, "urn:action", null, new ResultHandler<XMLObject>() {
		public void handleResult(XMLObject res) {
			assertTrue(res instanceof Assertion);
		}
	});
	
	OIOSoapEnvelope env = new OIOSoapEnvelope((Envelope) SAMLUtil.unmarshallElementFromString(holder.getValue()));
	assertTrue(env.isSigned());
	assertNotNull(env.getHeaderElement(MessageID.class));
	assertNotNull(env.getHeaderElement(Action.class));
	assertNotNull(env.getHeaderElement(ReplyTo.class));
	
	Security sec = env.getHeaderElement(Security.class);
	assertNotNull(sec);
	assertNull(SAMLUtil.getFirstElement(sec, Assertion.class));
	
	assertTrue(env.verifySignature(credential.getPublicKey()));
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:33,代码来源:TokenClientTest.java

示例13: failIfResponseIsNotSigned

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
@Test(expected=TrustException.class)
public void failIfResponseIsNotSigned() throws Exception {
	final StringValueHolder holder = new StringValueHolder();
	context.checking(new Expectations() {{
		one(soapClient).wsCall(with(equal(ADDRESS)), with(aNull(String.class)), with(aNull(String.class)), with(equal(true)), with(holder), with(equal("urn:action")));
		will(new CustomAction("test") {
			public Object invoke(Invocation invocation) throws Throwable {
				return buildResponse(holder.getValue(), false);
			}
		});
	}});
	Assertion body = SAMLUtil.buildXMLObject(Assertion.class);
	client.getServiceClient().sendRequest(body, ADDRESS, "urn:action", stsCredential.getPublicKey(), null);
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:15,代码来源:TokenClientTest.java

示例14: failIfResponseIsSignedWithValidKey

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
@Test(expected=TrustException.class)
public void failIfResponseIsSignedWithValidKey() throws Exception {
	final StringValueHolder holder = new StringValueHolder();
	context.checking(new Expectations() {{
		one(soapClient).wsCall(with(equal(ADDRESS)), with(aNull(String.class)), with(aNull(String.class)), with(equal(true)), with(holder), with(equal("urn:action")));
		will(new CustomAction("test") {
			public Object invoke(Invocation invocation) throws Throwable {
				return buildResponse(holder.getValue(), false);
			}
		});
	}});
	Assertion body = SAMLUtil.buildXMLObject(Assertion.class);
	client.getServiceClient().sendRequest(body, ADDRESS, "urn:action", credential.getPublicKey(), null);
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:15,代码来源:TokenClientTest.java

示例15: testValidateResponseSignature

import org.jmock.lib.action.CustomAction; //导入依赖的package包/类
@Test
public void testValidateResponseSignature() throws Exception {
	final StringValueHolder holder = new StringValueHolder();
	context.checking(new Expectations() {{
		one(soapClient).wsCall(with(equal(ADDRESS)), with(aNull(String.class)), with(aNull(String.class)), with(equal(true)), with(holder), with(equal("urn:action")));
		will(new CustomAction("test") {
			public Object invoke(Invocation invocation) throws Throwable {
				return buildResponse(holder.getValue(), true);
			}
		});
	}});
	Assertion body = SAMLUtil.buildXMLObject(Assertion.class);
	client.getServiceClient().sendRequest(body, ADDRESS, "urn:action", stsCredential.getPublicKey(), null);
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:15,代码来源:TokenClientTest.java


注:本文中的org.jmock.lib.action.CustomAction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。