Package org.jmock

Examples of org.jmock.Mock


  public void testSanitySuccess()
  {
    //some very basic sanity test
    //
    DoubleRangeValidator validator = new DoubleRangeValidator();
    Mock mock = buildMockUIComponent();
    UIComponent component = (UIComponent) mock.proxy();
    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);

    Double values[]   = {200d,500d};
    validator.setMinimum(2);
    for (int i = 0; i < values.length ; i++)
View Full Code Here


        JarOutputStream out = new JarOutputStream( new FileOutputStream( file ) );
        writeEntry( out, "a/b/c.class", "class a.b.c" );
        writeEntry( out, "x/y/z.class", "class x.y.z" );
        out.close();

        Mock mock = mock( ClassFileVisitor.class );
        expectVisitClass( mock, "a.b.c", "class a.b.c" );
        expectVisitClass( mock, "x.y.z", "class x.y.z" );

        ClassFileVisitorUtils.accept( file.toURI().toURL(), (ClassFileVisitor) mock.proxy() );

        mock.verify();
    }
View Full Code Here

        File file = createJar();
        JarOutputStream out = new JarOutputStream( new FileOutputStream( file ) );
        writeEntry( out, "a/b/c.jpg", "jpeg a.b.c" );
        out.close();

        Mock mock = mock( ClassFileVisitor.class );

        ClassFileVisitorUtils.accept( file.toURI().toURL(), (ClassFileVisitor) mock.proxy() );

        mock.verify();
    }
View Full Code Here

        createFile( abDir, "c.class", "class a.b.c" );

        File xyDir = mkdirs( dir, "x/y" );
        createFile( xyDir, "z.class", "class x.y.z" );

        Mock mock = mock( ClassFileVisitor.class );
        expectVisitClass( mock, "a.b.c", "class a.b.c" );
        expectVisitClass( mock, "x.y.z", "class x.y.z" );

        ClassFileVisitorUtils.accept( dir.toURI().toURL(), (ClassFileVisitor) mock.proxy() );

        FileUtils.deleteDirectory( dir );

        mock.verify();
    }
View Full Code Here

        File dir = createDir();

        File abDir = mkdirs( dir, "a/b" );
        createFile( abDir, "c.jpg", "jpeg a.b.c" );

        Mock mock = mock( ClassFileVisitor.class );

        ClassFileVisitorUtils.accept( dir.toURI().toURL(), (ClassFileVisitor) mock.proxy() );

        FileUtils.deleteDirectory( dir );

        mock.verify();
    }
View Full Code Here

        throws IOException
    {
        File file = File.createTempFile( "test", ".class" );
        file.deleteOnExit();

        Mock mock = mock( ClassFileVisitor.class );

        URL url = file.toURI().toURL();

        try
        {
            ClassFileVisitorUtils.accept( url, (ClassFileVisitor) mock.proxy() );
        }
        catch ( IllegalArgumentException exception )
        {
            assertEquals( "Cannot accept visitor on URL: " + url, exception.getMessage() );
        }
View Full Code Here

    }

    public void testAcceptWithUnsupportedScheme()
        throws IOException
    {
        Mock mock = mock( ClassFileVisitor.class );

        URL url = new URL( "http://localhost/" );

        try
        {
            ClassFileVisitorUtils.accept( url, (ClassFileVisitor) mock.proxy() );
        }
        catch ( IllegalArgumentException exception )
        {
            assertEquals( "Cannot accept visitor on URL: " + url, exception.getMessage() );
        }
View Full Code Here

   *
   * @throws ValidatorException  when test fails
   */
  public void testNull() throws ValidatorException
  {
    Mock mock = buildMockUIComponent();
    UIComponent component = (UIComponent) mock.proxy();
    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
    LongRangeValidator validator = new LongRangeValidator();

    doTestNull(facesContext, wrapper, validator);
  }
View Full Code Here

  /**
   * Test when context is set to null
   */
  public void testNullContext()
  {
    Mock mock = buildMockUIComponent();
    UIComponent component = (UIComponent) mock.proxy();
    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
    LongRangeValidator validator = new LongRangeValidator();

    doTestNullContext(wrapper, validator);
  }
View Full Code Here

  public void testTooLarge()
  {
    // since the pattern has not been set it will be null
    // let us push some arbitary value
    Mock mock = mock(UIComponent.class);
    UIComponent component = (UIComponent) mock.proxy();
    MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
    setMockLabelForComponent(wrapper);

    try
    {
      LongRangeValidator validator = new LongRangeValidator();
      validator.setMaximum(100);
      validator.validate(facesContext, component, 1000);
      // test fails if it is here

      fail("Expected Null pointer exception");
    }
    catch (ValidatorException ve)
    {
      // suppress it - this is as expected
    }
    mock.verify();
  }
View Full Code Here

TOP

Related Classes of org.jmock.Mock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.