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


Java Assert.fail方法代码示例

本文整理汇总了Java中junit.framework.Assert.fail方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.fail方法的具体用法?Java Assert.fail怎么用?Java Assert.fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在junit.framework.Assert的用法示例。


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

示例1: suite

import junit.framework.Assert; //导入方法依赖的package包/类
/** Executes the execution compatibility kit tests on the provided instance
 * of execution engine.
 */
public static Test suite(ExecutionEngine engine) {
    System.setProperty("org.openide.util.Lookup", ExecutionCompatibilityTest.class.getName() + "$Lkp");
    Object o = Lookup.getDefault();
    if (!(o instanceof Lkp)) {
        Assert.fail("Wrong lookup object: " + o);
    }
    
    Lkp l = (Lkp)o;
    l.assignExecutionEngine(engine);
    
    if (engine != null) {
        Assert.assertEquals("Same engine found", engine, ExecutionEngine.getDefault());
    } else {
        o = ExecutionEngine.getDefault();
        Assert.assertNotNull("Engine found", o);
        Assert.assertEquals(ExecutionEngine.Trivial.class, o.getClass());
    }
    
    TestSuite ts = new TestSuite();
    ts.addTestSuite(ExecutionEngineHid.class);
    
    return ts;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ExecutionCompatibilityTest.java

示例2: assertEqualIgnoringOrder

import junit.framework.Assert; //导入方法依赖的package包/类
public static void assertEqualIgnoringOrder(Iterable<?> expected, Iterable<?> actual) {
  List<?> exp = copyToList(expected);
  List<?> act = copyToList(actual);
  String actString = act.toString();

  // Of course we could take pains to give the complete description of the
  // problem on any failure.

  // Yeah it's n^2.
  for (Object object : exp) {
    if (!act.remove(object)) {
      Assert.fail(
          "did not contain expected element "
              + object
              + ", "
              + "expected = "
              + exp
              + ", actual = "
              + actString);
    }
  }
  assertTrue("unexpected elements: " + act, act.isEmpty());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:24,代码来源:Helpers.java

示例3: changeMap

import junit.framework.Assert; //导入方法依赖的package包/类
private void changeMap(IUT2004Server server, String map) {
   	if (awaitAgentUp((AbstractAgent)server)) {
   		System.out.println("Changing map to '" + map + "'...");
   		Future<Boolean> future = server.setGameMap(map);
   		try {
   			System.out.println("Waiting for the GB2004 to change the map (60sec timeout).");
   			Boolean result = future.get(99990000, TimeUnit.MILLISECONDS);
       		if (result == null || !result) {
       			Assert.fail("Failed to change map to '" + map + "'.");
       		}
   		} catch (Exception e) {
   			Assert.fail("Failed to change map to '" + map + "'.");
   		}
   	} else {
   		Assert.fail("Failed to connect to GB2004...");
   	}
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:18,代码来源:UT2004Test07_UT2004Server_SetGameMap.java

示例4: testDir

import junit.framework.Assert; //导入方法依赖的package包/类
private void testDir(String dirName) {
    File location = new File(dirName);
    if (!location.isDirectory()) {
        try {
            Assert.fail(String.format("Directory %s cannot be found",
                location.getCanonicalPath()));
        } catch (IOException e) {
            Assert.fail(String.format("Directory %s cannot be parsed",
                location.getAbsolutePath()));
        }
    }
    for (File file : location.listFiles()) {
        if (FileType.GRAMMAR.hasExtension(file)) {
            testGrammar(file);
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:18,代码来源:GrammarsTest.java

示例5: run

import junit.framework.Assert; //导入方法依赖的package包/类
public void run() {
    if (check()) {
        return;
    }

    long timeout = mTimeout;
    while (timeout > 0) {
        try {
            Thread.sleep(TIME_SLICE);
        } catch (InterruptedException e) {
            Assert.fail("unexpected InterruptedException");
        }

        if (check()) {
            return;
        }

        timeout -= TIME_SLICE;
    }

    Assert.fail("unexpected timeout");
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:23,代码来源:PollingCheck.java

示例6: findPlatform

import junit.framework.Assert; //导入方法依赖的package包/类
private static File findPlatform() {
    try {
        Class<?> lookup = Class.forName("org.openide.util.Lookup"); // NOI18N
        File util = new File(lookup.getProtectionDomain().getCodeSource().getLocation().toURI());
        Assert.assertTrue("Util exists: " + util, util.exists());

        return util.getParentFile().getParentFile();
    } catch (Exception ex) {
        try {
            File nbjunit = new File(MeasureStartupTimeTestCase.class.getProtectionDomain().getCodeSource().getLocation().toURI());
            File harness = nbjunit.getParentFile().getParentFile();
            Assert.assertEquals("NbJUnit is in harness", "harness", harness.getName());
            TreeSet<File> sorted = new TreeSet<>();
            for (File p : harness.getParentFile().listFiles()) {
                if (p.getName().startsWith("platform")) {
                    sorted.add(p);
                }
            }
            Assert.assertFalse("Platform shall be found in " + harness.getParent(), sorted.isEmpty());
            return sorted.last();
        } catch (Exception ex2) {
            Assert.fail("Cannot find utilities JAR: " + ex + " and: " + ex2);
        }
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:MeasureStartupTimeTestCase.java

示例7: check

import junit.framework.Assert; //导入方法依赖的package包/类
public static void check(CharSequence message, long timeout, Callable<Boolean> condition)
        throws Exception {
    while (timeout > 0) {
        if (condition.call()) {
            return;
        }

        Thread.sleep(TIME_SLICE);
        timeout -= TIME_SLICE;
    }

    Assert.fail(message.toString());
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:14,代码来源:PollingCheck.java

示例8: testNonSerializedParameter

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testNonSerializedParameter() throws Exception
{
    DemoService service = new DemoServiceImpl();
    protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:9050/" + DemoService.class.getName() + "?codec=exchange")));
    service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:9050/" + DemoService.class.getName() + "?codec=exchange")));
    try {
        service.nonSerializedParameter(new NonSerialized());
        Assert.fail();
    } catch (RpcException e) {
        Assert.assertTrue(e.getMessage().contains("com.alibaba.dubbo.rpc.protocol.dubbo.support.NonSerialized must implement java.io.Serializable"));
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:14,代码来源:DubboProtocolTest.java

示例9: testReferGenericExport

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testReferGenericExport() throws Exception {
    ApplicationConfig ac = new ApplicationConfig("test-refer-generic-export");
    RegistryConfig rc = new RegistryConfig();
    rc.setAddress(RegistryConfig.NO_AVAILABLE);

    ServiceConfig<GenericService> sc = new ServiceConfig<GenericService>();
    sc.setApplication(ac);
    sc.setRegistry(rc);
    sc.setInterface(DemoService.class.getName());
    sc.setRef(new GenericService() {

        public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException {
            return null;
        }
    });

    ReferenceConfig<DemoService> ref = new ReferenceConfig<DemoService>();
    ref.setApplication(ac);
    ref.setRegistry(rc);
    ref.setInterface(DemoService.class.getName());

    try {
        sc.export();
        ref.get();
        Assert.fail();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        sc.unexport();
        ref.destroy();
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:34,代码来源:ConfigTest.java

示例10: testProcessNoStart

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testProcessNoStart() throws Exception {
  try {
    source.process();
    Assert.fail();
  } catch (EventDeliveryException expected) {

  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:10,代码来源:TestJMSSource.java

示例11: test

import junit.framework.Assert; //导入方法依赖的package包/类
protected void test() {
	
	try {
		if (log.isLoggable(Level.INFO)) log.info("Starting worldview...");
		worldViewStarter.manualStart("starting worldview");
		if (log.isLoggable(Level.INFO)) log.info("Starting mediator...");
		mediator.start();
	} catch (PogamutException e) {
		e.printStackTrace();
		Assert.fail("WorldView failed to start.");
	}

	testBody();
	
	new WaitForFlagChange(mediator.getRunning(), false).await(900000, TimeUnit.MILLISECONDS);
	
	if (mediator.getEventQueueLength() != 0) {
		Assert.fail("Mediator failed to process all events in the queue...");
	}

	// STOP THE WORLDVIEW
	if (log.isLoggable(Level.INFO)) log.info("Stopping worldview...");
	worldViewStarter.manualStop("Stopping the test.");

	// VERIFY LISTENERS
	if (log.isLoggable(Level.INFO)) log.info("Verifying listeners...");
	verifyListeners();	
	
	Assert.assertFalse("Mediator did not stopped.", mediator.getRunning().getFlag());
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:31,代码来源:EventDrivenWorldViewTester.java

示例12: testDecreaseCapacity

import junit.framework.Assert; //导入方法依赖的package包/类
@Test(expected = BadCheckpointException.class)
public void testDecreaseCapacity() throws Exception {
  Assert.assertTrue(checkpoint.delete());
  EventQueueBackingStore backingStore =
      EventQueueBackingStoreFactory.get(checkpoint, 10, "test");
  backingStore.close();
  EventQueueBackingStoreFactory.get(checkpoint, 9, "test");
  Assert.fail();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:10,代码来源:TestEventQueueBackingStoreFactory.java

示例13: testLoadAltStart

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testLoadAltStart() {
    int nodecount = 12;
    int edgecount = 14;
    try {
        testControl(Groove.loadGrammar(DIRECTORY),
            ALT_START,
            DEF_CONTROL,
            nodecount,
            edgecount);
    } catch (IOException e) {
        Assert.fail(e.toString());
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:15,代码来源:IOTest.java

示例14: loadGrammar

import junit.framework.Assert; //导入方法依赖的package包/类
private Grammar loadGrammar(String grammarName, String startGraphName) {
    Grammar result = null;
    try {
        GrammarModel model = GrammarModel.newInstance(new File(INPUT_DIR, grammarName), false);
        model.setLocalActiveNames(ResourceKind.HOST, QualName.parse(startGraphName));
        result = model.toGrammar();
    } catch (IOException exc) {
        throw new RuntimeException(exc);
    } catch (FormatException ex) {
        Assert.fail("Could not load grammar. " + ex.getMessage());
    }
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:14,代码来源:ReteNetworkTest.java

示例15: testResetBadgeCount_shouldNotFail_withNullListener_failureWithException

import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testResetBadgeCount_shouldNotFail_withNullListener_failureWithException() {
    inbox.setAppLoginParameters(appLoginParameters_withCredentials);

    Exception expectedException = new Exception("FakeRestClientException");
    inbox.client = new FakeRestClient(expectedException);

    try {
        inbox.resetBadgeCount(null);
        Thread.sleep(150);
    } catch (Exception e) {
        Assert.fail("Should not throw exception!");
    }
}
 
开发者ID:emartech,项目名称:android-mobile-engage-sdk,代码行数:15,代码来源:InboxInternalTest.java


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