junit.framework.TestCase Java Examples

The following examples show how to use junit.framework.TestCase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConccSemanticsTests.java    From Concurnas with MIT License 6 votes vote down vote up
@Test
public void includeFriendsFromDirManyFriends() throws IOException {
	ConccTestMockFileLoader mockFL = new ConccTestMockFileLoader();
	ConccTestMockFileWriter mockWriter = new ConccTestMockFileWriter(mockFL);

	Path workDir = mockFL.fs.getPath("/work/com/thing/");
	Files.createDirectories(workDir);
	Files.createFile(workDir.resolve("MyFirstClass.conc"));
	Files.createFile(workDir.resolve("MyFirstClass2.conc"));
	
	Concc concc = new Concc("/work/[com/thing/MyFirstClass.conc com/thing/MyFirstClass2.conc]", mockFL, mockWriter);
	
	ValidationErrorsAndValidObject validAndVO = concc.validateConccInstance(concc.getConccInstance());
	//no filtering at this point
	TestCase.assertNull(validAndVO.validationErrs);
	String expect = "/work/com/thing/MyFirstClass.conc[com.thing true] /work/com/thing/MyFirstClass2.conc[com.thing false] /work/com/thing/MyFirstClass2.conc[com.thing true] /work/com/thing/MyFirstClass.conc[com.thing false]";
	TestCase.assertEquals(expect, validAndVO.validconcObject.toString());
}
 
Example #2
Source File: IUserServiceTest.java    From spring-boot-seed with MIT License 6 votes vote down vote up
@Test
public void addUser(){
    User user = new User();
    user.setUserName("admin_abc");
    user.setPassword("123456");
    user.setNickName("ADMINABC");
    user.setEmail("[email protected]");
    user.setStateCode(BooleanEnum.YES.getValue());
    user.setMobile("18912345678");
    userService.addUser(user);
    User result = userService.queryByIdOrName(null, "admin_abc");
    log.info("==========================================================================");
    log.info("查询结果 ==> {}", result);
    log.info("==========================================================================");
    TestCase.assertNotNull(user);
}
 
Example #3
Source File: OFErrorTest.java    From floodlight_with_topoguard with Apache License 2.0 6 votes vote down vote up
public void testGarbageAtEnd() throws MessageParseException {
    // This is a OFError msg (12 bytes), that encaps a OFVendor msg (24
    // bytes)
    // AND some zeros at the end (40 bytes) for a total of 76 bytes
    // THIS is what an NEC sends in reply to Nox's VENDOR request
    byte[] oferrorRaw = { 0x01, 0x01, 0x00, 0x4c, 0x00, 0x00, 0x10,
            (byte) 0xcc, 0x00, 0x01, 0x00, 0x01, 0x01, 0x04, 0x00, 0x18,
            0x00, 0x00, 0x10, (byte) 0xcc, 0x00, 0x00, 0x23, 0x20, 0x00,
            0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00 };
    OFMessageFactory factory = BasicFactory.getInstance();
    ChannelBuffer oferrorBuf = 
            ChannelBuffers.wrappedBuffer(oferrorRaw);
    List<OFMessage> msg = factory.parseMessage(oferrorBuf);
    TestCase.assertNotNull(msg);
    TestCase.assertEquals(msg.size(), 1);
    TestCase.assertEquals(76, msg.get(0).getLengthU());
    ChannelBuffer out = ChannelBuffers.dynamicBuffer();
    msg.get(0).writeTo(out);
    TestCase.assertEquals(76, out.readableBytes());
}
 
Example #4
Source File: OFStatisticsRequestTest.java    From floodlight_with_topoguard with Apache License 2.0 6 votes vote down vote up
public void testOFStatisticsRequestVendor() throws Exception {
    byte[] packet = new byte[] { 0x01, 0x10, 0x00, 0x50, 0x00, 0x00, 0x00,
            0x63, (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x4c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x01, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x20,
            (byte) 0xe0, 0x00, 0x11, 0x00, 0x0c, 0x29, (byte) 0xc5,
            (byte) 0x95, 0x57, 0x02, 0x25, 0x5c, (byte) 0xca, 0x00, 0x02,
            (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x50, 0x04,
            0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x00, 0x00, 0x00,
            (byte) 0xff, (byte) 0xff, 0x4e, 0x20 };

    OFMessageFactory factory = BasicFactory.getInstance();
    ChannelBuffer packetBuf = ChannelBuffers.wrappedBuffer(packet);
    List<OFMessage> msg = factory.parseMessage(packetBuf);
    TestCase.assertNotNull(msg);
    TestCase.assertEquals(msg.size(), 1);
    TestCase.assertTrue(msg.get(0) instanceof OFStatisticsRequest);
    OFStatisticsRequest sr = (OFStatisticsRequest) msg.get(0);
    TestCase.assertEquals(OFStatisticsType.VENDOR, sr.getStatisticType());
    TestCase.assertEquals(1, sr.getStatistics().size());
    TestCase.assertTrue(sr.getStatistics().get(0) instanceof OFVendorStatistics);
    TestCase.assertEquals(68, ((OFVendorStatistics)sr.getStatistics().get(0)).getLength());
}
 
Example #5
Source File: TestCaseTest.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testErrorTearingDownDoesntMaskErrorRunning() {
	final Exception running= new Exception("Running");
	TestCase t= new TestCase() {
		protected void runTest() throws Throwable {
			throw running;
		}
		protected void tearDown() throws Exception {
			throw new Error("Tearing down");
		}
	};
	try {
		t.runBare();
	} catch (Throwable thrown) {
		assertSame(running, thrown);
	}
}
 
Example #6
Source File: DebugReportRunner.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void executeAll( final MasterReport report ) throws Exception {
  logger.debug( "   GRAPHICS2D .." );
  TestCase.assertTrue( DebugReportRunner.execGraphics2D( report ) );
  logger.debug( "   PDF .." );
  TestCase.assertTrue( DebugReportRunner.createPDF( report ) );
  logger.debug( "   CSV .." );
  DebugReportRunner.createCSV( report );
  logger.debug( "   PLAIN_TEXT .." );
  TestCase.assertTrue( DebugReportRunner.createPlainText( report ) );
  logger.debug( "   RTF .." );
  DebugReportRunner.createRTF( report );
  logger.debug( "   STREAM_HTML .." );
  DebugReportRunner.createStreamHTML( report );
  logger.debug( "   EXCEL .." );
  DebugReportRunner.createXLS( report );
  logger.debug( "   ZIP_HTML .." );
  DebugReportRunner.createZIPHTML( report );
}
 
Example #7
Source File: TestTransforms.java    From DataVec with Apache License 2.0 6 votes vote down vote up
@Test
public void testReplaceEmptyIntegerWithValueTransform() {
    Schema schema = getSchema(ColumnType.Integer);

    Transform transform = new ReplaceEmptyIntegerWithValueTransform("column", 1000);
    transform.setInputSchema(schema);
    Schema out = transform.transform(schema);

    assertEquals(1, out.getColumnMetaData().size());
    TestCase.assertEquals(ColumnType.Integer, out.getMetaData(0).getColumnType());

    assertEquals(Collections.singletonList((Writable) new IntWritable(0)),
            transform.map(Collections.singletonList((Writable) new IntWritable(0))));
    assertEquals(Collections.singletonList((Writable) new IntWritable(1)),
            transform.map(Collections.singletonList((Writable) new IntWritable(1))));
    assertEquals(Collections.singletonList((Writable) new IntWritable(1000)),
            transform.map(Collections.singletonList((Writable) new Text(""))));
}
 
Example #8
Source File: IntegrationUtilityTest.java    From datasync with MIT License 6 votes vote down vote up
@Test
public void testUpsertTSVFile() throws IOException, SodaError, InterruptedException, LongRunningQueryException {
    final Soda2Producer producer = createProducer();
    final SodaDdl ddl = createSodaDdl();

    // Ensures dataset is in known state (2 rows)
    File twoRowsFile = new File("src/test/resources/datasync_unit_test_two_rows.csv");
    Soda2Publisher.replaceNew(producer, ddl, UNITTEST_DATASET_ID, twoRowsFile, true);

    File threeRowsFile = new File("src/test/resources/datasync_unit_test_three_rows.tsv");
    UpsertResult result = Soda2Publisher.appendUpsert(producer, ddl, UNITTEST_DATASET_ID, threeRowsFile, 0, true);

    TestCase.assertEquals(0, result.errorCount());
    TestCase.assertEquals(2, result.getRowsUpdated());
    TestCase.assertEquals(1, result.getRowsCreated());
    TestCase.assertEquals(3, getTotalRows(UNITTEST_DATASET_ID));
}
 
Example #9
Source File: CacheStorageTestUtils.java    From esigate with Apache License 2.0 6 votes vote down vote up
static void testBasicOperations(CacheStorage cacheStorage) throws Exception {
    String key = "foo";
    HttpCacheEntry entry = makeCacheEntry("entry");
    TestCase.assertNull("Cache should be empty", cacheStorage.getEntry(key));
    cacheStorage.putEntry(key, entry);
    TestCase.assertEquals("Now the entry should be in cache", getContent(entry),
            getContent(cacheStorage.getEntry(key)));
    final HttpCacheEntry newEntry = makeCacheEntry("new entry");
    HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
        @Override
        public HttpCacheEntry update(HttpCacheEntry existing) {
            return newEntry;
        }
    };
    cacheStorage.updateEntry(key, callback);
    TestCase.assertEquals("Entry should have been updated", getContent(newEntry),
            getContent(cacheStorage.getEntry(key)));
    cacheStorage.removeEntry(key);
    TestCase.assertNull("Entry should have been deleted", cacheStorage.getEntry(key));
}
 
Example #10
Source File: GraphemeClusterProducerTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testGraphemeClusterGenerationUnix() {
  CodePointBuffer buffer = Utf16LE.getInstance().decodeString( "T\n\n\nT", null ); //$NON-NLS-1$
  final int[] data = buffer.getBuffer();
  final boolean[] result = new boolean[]
    {
      true, true, true, true, true
    };
  GraphemeClusterProducer prod = new GraphemeClusterProducer();

  for ( int i = 0; i < buffer.getLength(); i++ ) {
    final int codepoint = data[ i ];
    if ( prod.createGraphemeCluster( codepoint ) != result[ i ] ) {
      TestCase.fail();
    }
  }
}
 
Example #11
Source File: TestTransforms.java    From DataVec with Apache License 2.0 6 votes vote down vote up
@Test
public void testTimeMathOpTransform() {
    Schema schema = new Schema.Builder().addColumnTime("column", DateTimeZone.UTC).build();

    Transform transform = new TimeMathOpTransform("column", MathOp.Add, 12, TimeUnit.HOURS); //12 hours: 43200000 milliseconds
    transform.setInputSchema(schema);

    Schema out = transform.transform(schema);
    assertEquals(1, out.getColumnMetaData().size());
    TestCase.assertEquals(ColumnType.Time, out.getType(0));

    assertEquals(Collections.singletonList((Writable) new LongWritable(1000 + 43200000)),
            transform.map(Collections.singletonList((Writable) new LongWritable(1000))));
    assertEquals(Collections.singletonList((Writable) new LongWritable(1452441600000L + 43200000)),
            transform.map(Collections.singletonList((Writable) new LongWritable(1452441600000L))));
}
 
Example #12
Source File: GoogleMapShapeConverterUtils.java    From geopackage-android-map with MIT License 6 votes vote down vote up
/**
 * Test the CompoundCurve conversion
 * 
 * @param converter
 * @param compoundCurve
 */
private static void convertCompoundCurve(GoogleMapShapeConverter converter,
		CompoundCurve compoundCurve) {

	MultiPolylineOptions polylines = converter.toPolylines(compoundCurve);
	TestCase.assertNotNull(polylines);
	TestCase.assertFalse(polylines.getPolylineOptions().isEmpty());

	List<LineString> lineStrings = compoundCurve.getLineStrings();
	compareLineStringsAndPolylines(converter, lineStrings,
			polylines.getPolylineOptions());

	CompoundCurve compoundCurve2 = converter
			.toCompoundCurveWithOptions(polylines);
	compareLineStrings(lineStrings, compoundCurve2.getLineStrings());
}
 
Example #13
Source File: UserPreferencesTest.java    From datasync with MIT License 6 votes vote down vote up
@Test
public void testLoadUserPreferencesFromFile() throws IOException {
    File configFile = new File(PATH_TO_PROD_CONFIG_FILE);
    ObjectMapper mapper = new ObjectMapper();
    UserPreferences userPrefs = mapper.readValue(configFile, UserPreferencesFile.class);
    TestCase.assertEquals("https://sandbox.demo.socrata.com", userPrefs.getDomain());
    TestCase.assertEquals("[email protected]", userPrefs.getUsername());
    TestCase.assertEquals("OpenData", userPrefs.getPassword());
    TestCase.assertEquals("D8Atrg62F2j017ZTdkMpuZ9vY", userPrefs.getAPIKey());
    TestCase.assertEquals("[email protected]", userPrefs.getAdminEmail());
    TestCase.assertEquals(false, userPrefs.emailUponError());
    TestCase.assertEquals("", userPrefs.getLogDatasetID());
    TestCase.assertEquals("smtp.something.com", userPrefs.getOutgoingMailServer());
    TestCase.assertEquals("21", userPrefs.getSmtpPort());
    TestCase.assertEquals("47", userPrefs.getSslPort());
    TestCase.assertEquals("[email protected]", userPrefs.getSmtpUsername());
    TestCase.assertEquals("smtppass", userPrefs.getSmtpPassword());
    TestCase.assertEquals("10", userPrefs.getFilesizeChunkingCutoffMB());
    TestCase.assertEquals("10000", userPrefs.getNumRowsPerChunk());
}
 
Example #14
Source File: ConccCompileTests.java    From Concurnas with MIT License 6 votes vote down vote up
@Test
public void localRootOverride() throws Throwable {
	ConccTestMockFileLoader mockFL = new ConccTestMockFileLoader();
	ConccTestMockFileWriter mockWriter = new ConccTestMockFileWriter(mockFL);
	
	Path root = mockFL.fs.getPath("/work/hg");
	Files.createDirectory(root);
	
	Path myClass = root.resolve("MyClass.conc"); 
	Files.write(myClass, ListMaker.make("def doings() => 'hi there'"), StandardCharsets.UTF_8);
	Concc concc = new Concc("/work[/hg]", mockFL, mockWriter);
	
	TestCase.assertEquals("", concc.doit());
	
	byte[] code = Files.readAllBytes(mockFL.fs.getPath("/work/hg/MyClass.class"));
	
	String res = new Executor().execute("hg.MyClass", code);
	
	TestCase.assertEquals("hi there", res);
}
 
Example #15
Source File: MetadataJobTest.java    From datasync with MIT License 6 votes vote down vote up
@Test
public void testValidation() {
	MetadataJob metadataJob = new MetadataJob();
	UserPreferencesJava prefs = setupUserPreferencesForTest();
	
	//Base Validation
	metadataJob.setDatasetID(UNITTEST_DATASET_ID);
	metadataJob.setTitle(RESET_TITLE);
	TestCase.assertEquals(JobStatus.VALID, metadataJob.validate(prefs.getConnectionInfo()));
	
	//Invalid Domain
	prefs.saveDomain(INVALID_DOMAIN);
	TestCase.assertEquals(JobStatus.INVALID_DOMAIN, metadataJob.validate(prefs.getConnectionInfo()));
	prefs.saveDomain(DOMAIN);
	
	//Invalid Dataset ID
	metadataJob.setDatasetID(INVALID_DATASET_ID);
	TestCase.assertEquals(JobStatus.INVALID_DATASET_ID, metadataJob.validate(prefs.getConnectionInfo()));
	metadataJob.setDatasetID(UNITTEST_DATASET_ID);
	
	//Invalid Title
	metadataJob.setTitle("");
	TestCase.assertEquals(JobStatus.MISSING_METADATA_TITLE, metadataJob.validate(prefs.getConnectionInfo()));
	metadataJob.setTitle(RESET_TITLE);
}
 
Example #16
Source File: Uninstaller.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@org.junit.Test
public void testUninstaller() {
    TestData data = new TestData(Logger.getLogger("global"));

    try {
        String wd = System.getenv("WORKSPACE");
        TestCase.assertNotNull(wd);
        data.setWorkDir(new File(wd));
    } catch (IOException ex) {
        TestCase.fail("Can not get WorkDir");
    }


    System.setProperty("nbi.dont.use.system.exit", "true");
    System.setProperty("nbi.utils.log.to.console", "false");
    System.setProperty("servicetag.allow.register", "false");
    System.setProperty("show.uninstallation.survey", "false");
    System.setProperty("user.home", data.getWorkDirCanonicalPath());

    Utils.phaseFive(data);
}
 
Example #17
Source File: PercentToBraceConverterTest.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Launch the test.
 *
 * @param args
 *            the command line arguments
 *
 * @generatedBy CodePro at 25.01.11 11:00
 */
public static void main(String[] args) {
    if (args.length == 0) {
        // Run all of the tests
        junit.textui.TestRunner.run(PercentToBraceConverterTest.class);
    } else {
        // Run only the named tests
        TestSuite suite = new TestSuite("Selected tests");
        for (int i = 0; i < args.length; i++) {
            TestCase test = new PercentToBraceConverterTest();
            test.setName(args[i]);
            suite.addTest(test);
        }
        junit.textui.TestRunner.run(suite);
    }
}
 
Example #18
Source File: ConccCompileTests.java    From Concurnas with MIT License 6 votes vote down vote up
@Test
public void compileMultipleWithDependancies() throws Throwable {
	ConccTestMockFileLoader mockFL = new ConccTestMockFileLoader();
	ConccTestMockFileWriter mockWriter = new ConccTestMockFileWriter(mockFL);

	Path root = mockFL.fs.getPath("/work/com/myorg");
	Files.createDirectories(root);
	
	Path myClass = root.resolve("MyClass.conc"); 
	Files.write(myClass, ListMaker.make("from com.myorg.code2 import myfunc; def doings() => myfunc() "), StandardCharsets.UTF_8);
	
	Path code2 = root.resolve("code2.conc"); 
	Files.write(code2, ListMaker.make("def myfunc() => 'hi there' "), StandardCharsets.UTF_8);
	
	Concc concc = new Concc("/work/[com/myorg/MyClass.conc]", mockFL, mockWriter);
	
	TestCase.assertEquals("", concc.doit());
	
	byte[] code = Files.readAllBytes(mockFL.fs.getPath("/work/com/myorg/MyClass.class"));
	byte[] codeDep = Files.readAllBytes(mockFL.fs.getPath("/work/com/myorg/code2.class"));
	
	//String res = new Executor().addToExecute("hg.MyClass$MySubClass", codeDep).execute("hg.MyClass", code);
	String res = new Executor().addToExecute("com.myorg.code2", codeDep).execute("com.myorg.MyClass", code);
	
	TestCase.assertEquals("hi there", res);
}
 
Example #19
Source File: ConcExeTests.java    From Concurnas with MIT License 6 votes vote down vote up
@Test
public void concFromJarMainCmdLineArgs() throws Throwable {
	ConccTestMockFileLoader mockFL = new ConccTestMockFileLoader();
	ConccTestMockFileWriter mockWriter = new ConccTestMockFileWriter(mockFL);
	
	Path root = mockFL.fs.getPath("/work/hg");
	Files.createDirectory(root);

	Files.createDirectory(mockFL.fs.getPath("/bin"));
	
	Path myClass = root.resolve("MyClass.conc"); 
	Files.write(myClass, ListMaker.make("def main(args String[]) => System.err.println('got: ' + args)"), StandardCharsets.UTF_8);

	Concc concc = new Concc("-jar myJar[hg.MyClass] -d /bin -a /work", mockFL, mockWriter);
	
	TestCase.assertEquals("", concc.doit());
	TestCase.assertTrue(Files.exists(mockFL.fs.getPath("/bin/myJar.jar")));

	Conc conc = new Conc("/bin/myJar one two three", mockFL);//ok
	checkOutput(conc, "got: [one two three]");
}
 
Example #20
Source File: ConccSyntaxTests.java    From Concurnas with MIT License 5 votes vote down vote up
@Test
public void testWErrors() {
	Concc concc = new Concc("-a -werror -jar output.jar thing.conc /some/dir another/dir/ ", null, null);
	String expect = "-werror -a -jar output.jar thing.conc /some/dir another/dir/";
	
	TestCase.assertEquals(expect, ""+concc.getConccInstance());
}
 
Example #21
Source File: TestQueueMuxMonitor.java    From oodt with Apache License 2.0 5 votes vote down vote up
public void removeNodeById() {
    try {
        ResourceNode node = new ResourceNode("a-new-node",null,2);
        qm.addNodeToQueue(node.getNodeId(), "queue-1");
        monitor.addNode(node);
        TestCase.assertEquals(node,mock1.getAdded());
        monitor.removeNodeById(node.getNodeId());
        TestCase.assertEquals(null,mock1.getAdded());
    } catch(MonitorException e) {
        TestCase.fail("Unanticipated monitor exception caught: "+e.getMessage());
    } catch (QueueManagerException e1) {
        TestCase.fail("Unanticipated queue manager exception caught: "+e1.getMessage());
    }
}
 
Example #22
Source File: ConcSemanticsTests.java    From Concurnas with MIT License 5 votes vote down vote up
@Test
public void noServerModeInREPL() throws IOException {
	ConccTestMockFileLoader mockFL = new ConccTestMockFileLoader();
	Conc concc = new Conc("-s", mockFL);//ok
	
	TestCase.assertEquals("Server mode is applicable only when run in non-interactive mode", concc.validateConcInstance(concc.getConcInstance()).validationErrs);
}
 
Example #23
Source File: AlignmentCenterApiIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected boolean startInlineBox( final InlineRenderBox box ) {
  if ( box instanceof ParagraphPoolBox ) {
    count += 1;
    final long x = box.getX();
    if ( x == 0 ) {
      TestCase.fail( "X position is wrong: " + x );
    }
  }
  return super.startInlineBox( box );
}
 
Example #24
Source File: RelatedMediaUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Validate contents
 *
 * @param mediaTable media table
 * @param contents   contents
 */
private static void validateContents(MediaTable mediaTable,
                                     Contents contents) {
    TestCase.assertNotNull(contents);
    TestCase.assertNotNull(contents.getDataType());
    TestCase.assertEquals(MediaTable.RELATION_TYPE.getDataType(), contents
            .getDataType().getName());
    TestCase.assertEquals(MediaTable.RELATION_TYPE.getDataType(),
            contents.getDataTypeString());
    TestCase.assertEquals(mediaTable.getTableName(),
            contents.getTableName());
    TestCase.assertNotNull(contents.getLastChange());
}
 
Example #25
Source File: PortUtilityTest.java    From datasync with MIT License 5 votes vote down vote up
@Test
public void testPublishDataset() throws SodaError, InterruptedException {
    // Port a dataset's schema and confirm that it is unpublished by default.
    String unpublishedID = PortUtility.portSchema(sourceDdl, sinkDdl, UNITTEST_DATASET_ID, "", false);
    DatasetInfo source = sourceDdl.loadDatasetInfo(unpublishedID);
    TestCase.assertEquals("unpublished", source.getPublicationStage());

    // Perform the test operation.  Confirm the dataset is published afterwards.
    String publishedID = PortUtility.publishDataset(sinkDdl, unpublishedID);
    DatasetInfo sink = sinkDdl.loadDatasetInfo(publishedID);
    TestCase.assertEquals("published", sink.getPublicationStage());

    sinkDdl.deleteDataset(publishedID);
}
 
Example #26
Source File: TestSignal.java    From Bulldog with Apache License 2.0 5 votes vote down vote up
@Test
public void testBooleanValue() {
	TestCase.assertTrue(Signal.High.getBooleanValue());
	TestCase.assertFalse(Signal.Low.getBooleanValue());
	
	TestCase.assertEquals(Signal.Low, Signal.fromBooleanValue(false));
	TestCase.assertEquals(Signal.High, Signal.fromBooleanValue(true));
}
 
Example #27
Source File: FullModelComparisons.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void cnnBatchNormLargerTest() throws IOException, UnsupportedKerasConfigurationException,
        InvalidKerasConfigurationException {

    String modelPath = "modelimport/keras/fullconfigs/cnn_batch_norm/cnn_batch_norm_medium.h5";

    KerasSequentialModel kerasModel = new KerasModel().modelBuilder()
            .modelHdf5Filename(Resources.asFile(modelPath).getAbsolutePath())
            .enforceTrainingConfig(false)
            .buildSequential();

    MultiLayerNetwork model = kerasModel.getMultiLayerNetwork();
    model.init();

    System.out.println(model.summary());

    INDArray input = Nd4j.createFromNpyFile(Resources.asFile("modelimport/keras/fullconfigs/cnn_batch_norm/input.npy"));
    input = input.permute(0, 3, 1, 2);
    assertTrue(Arrays.equals(input.shape(), new long[] {5, 1, 48, 48}));

    INDArray output = model.output(input);

    INDArray kerasOutput = Nd4j.createFromNpyFile(Resources.asFile("modelimport/keras/fullconfigs/cnn_batch_norm/predictions.npy"));

    for (int i = 0; i < 5; i++) {
        // TODO this should be a little closer
        TestCase.assertEquals(output.getDouble(i), kerasOutput.getDouble(i), 1e-2);
    }
}
 
Example #28
Source File: DefaultValueConverterRegistryTest.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
    public void testGetValueConverterRecursive() {
        final DefaultValueConverterRegistry reg = new DefaultValueConverterRegistry();
        final ValueConverter<Literal> converter = new LiteralValueConverter();
        reg.registerValueConverter(converter);
//        TestCase.assertEquals(converter, reg.getValueConverter(Literal.class));
//        TestCase.assertEquals(converter, reg.getValueConverter(SimpleLiteral.class));
        TestCase.assertEquals(converter, reg.getValueConverter(ComplexLiteral.class));
    }
 
Example #29
Source File: NbModuleSuite.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void runTest(Test test, TestResult result) {
    int e = result.errorCount();
    int f = result.failureCount();
    LOG.log(Level.FINE, "Running test {0}", test);
    super.runTest(test, result);
    LOG.log(Level.FINE, "Finished: {0}", test);
    if (e == result.errorCount() && f == result.failureCount()) {
        NbModuleLogHandler.checkFailures((TestCase) test, result, test instanceof NbTestCase ? ((NbTestCase) test).getWorkDirPath() : Manager.getWorkDirPath());
    }
}
 
Example #30
Source File: IShiroServiceTest.java    From spring-boot-seed with MIT License 5 votes vote down vote up
@Test
public void login() {
    User user = shiroService.login(null, "admin", "123456");
    TestCase.assertNotNull(user);
    log.info("----------------------------------------------------------------------------");
    log.info("User: {}", user);
    log.info("----------------------------------------------------------------------------");
}