List of usage examples for junit.framework AssertionFailedError AssertionFailedError
public AssertionFailedError(String message)
From source file:test.org.osuosl.srw.sort.SortToolTests.java
public void testFloatsStrings() { SortTool sorttool = new SortTool(); SortKey sortkey1 = new SortKey(SORTKEY_FLOAT); sortkey1.setMissingValue(SortKey.MISSINGVALUE_LOWVALUE); SortKey sortkey2 = new SortKey(SORTKEY_STRING); sortkey2.setMissingValue(SortKey.MISSINGVALUE_LOWVALUE); SortKey[] sortKeys = { sortkey1, sortkey2 }; sorttool.setSortKeys(sortKeys);//from ww w .j a v a2 s. c o m log.info("SortTool: " + sorttool); try { addEntries(sorttool); ArrayList sortedlist = sorttool.getEntries(); assertEquals("Value out of order", "3", ((SortEntry) sortedlist.get(0)).getIdentifier()); assertEquals("Value out of order", "2", ((SortEntry) sortedlist.get(1)).getIdentifier()); assertEquals("Value out of order", "4", ((SortEntry) sortedlist.get(2)).getIdentifier()); assertEquals("Value out of order", "1", ((SortEntry) sortedlist.get(3)).getIdentifier()); assertEquals("Value out of order", "5", ((SortEntry) sortedlist.get(4)).getIdentifier()); assertEquals("Value out of order", "0", ((SortEntry) sortedlist.get(5)).getIdentifier()); } catch (SRWDiagnostic e) { throw new AssertionFailedError(e.toString()); } }
From source file:test.org.osuosl.srw.translator.TranslatorTestsBase.java
/** * Validates a query given the expected results. * * The query will be checked for:/*from w ww . j av a2 s . c om*/ * * <ol>CQLParser's ability to parse query. Doesn't validate results just that a CQL tree was returned * <ol>Contents of result set. * * @param query - CQL Query * @param expectedIndex - int[] containing an expected result set */ private void query(String query, int[] expectedIndex) { try { log.info("===================================================================================="); /** * parse query */ CQLNode node = parser.parse(query); assertNotNull("Unable to parse CQL into CQL objects", node); log.info("CQL Query : [" + query + "]"); /** * execute query */ ResolvingQueryResult results = (ResolvingQueryResult) translator.search(node, null); results.setResolver(resolver); assertNotNull("Null result set", results); /** * iterate through the results retrieving the full records * create an int[] containing the array of identifiers * * todo implement this instead of the following section of code */ /** * Convert result set to an String[] of identifiers so that they can be * compared to the expect results. * */ String[] resultsStr = new String[(int) results.getNumberOfRecords()]; RecordIterator iter = results.newRecordIterator(0, resultsStr.length, null); for (int i = 0; i < resultsStr.length; i++) { IdentifiableRecord record = (IdentifiableRecord) iter.nextRecord(); if (record == null) { resultsStr[i] = null; } else { resultsStr[i] = record.getIdentifier(); } } /** * convert expected results to String[] */ String[] expectedIndexStr = new String[expectedIndex.length]; for (int i = 0; i < expectedIndex.length; i++) { expectedIndexStr[i] = expectedIndex[i] + ""; } /** * Sort both input and output so when they are compared * you can tell if there is a missing record no matter what * order either list is in. */ Arrays.sort(resultsStr); Arrays.sort(expectedIndexStr); /** * output expected and actual results */ StringBuffer temp = new StringBuffer(); for (int i = 0; i < expectedIndexStr.length; i++) { temp.append(expectedIndexStr[i]); if (i + 1 != expectedIndexStr.length) { temp.append(", "); } } log.info("Expected Result set : " + temp.toString()); temp = new StringBuffer(); for (int i = 0; i < resultsStr.length; i++) { temp.append(resultsStr[i]); if (i + 1 != resultsStr.length) { temp.append(", "); } } log.info("Actual Result set : " + temp.toString()); /** * check the size of the result set */ assertEquals("Incorrect number of results", resultsStr.length, expectedIndex.length); /** * check contents of results - this check determines if the correct * SET of documents was returned. * * for this test both arrays must be copied and sorted */ for (int i = 0; i < expectedIndex.length; i++) { String id = expectedIndexStr[i]; assertEquals("Missing Value ", id, resultsStr[i]); } } catch (Exception e) { if (e instanceof SRWDiagnostic && ((SRWDiagnostic) e).code == 19) { throw new AssertionFailedError("Unsupported Relation"); } throw new RuntimeException(e); } }
From source file:test.wsdl.choice.ChoiceServiceTestCase.java
public void testSerialization() throws Exception { ChoiceServiceSoap binding;//from w w w. j a va2 s . com try { ChoiceServiceLocator locator = new ChoiceServiceLocator(); binding = locator.getChoiceServiceSoap(); deployServer(); } catch (javax.xml.rpc.ServiceException jre) { throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre); } catch (Exception e) { throw new AssertionFailedError("Binding initialization Exception caught: " + e); } assertTrue("binding is null", binding != null); FaultPropertyType fp1; FaultPropertyType fp2; Record1 r1; Record2 r2; // test 1 FaultType f1 = new FaultType(); f1.setDescription("foo"); f1.setCommand("bar"); fp1 = new FaultPropertyType(); fp1.setFault1(f1); r1 = new Record1(); r1.setElem(fp1); r2 = binding.get(r1); assertTrue(r2 != null); fp2 = r2.getElem(); assertTrue(fp2 != null); assertTrue(fp2.getFault1() != null); assertTrue(fp2.getFault1() instanceof FaultType); assertEquals("foo", ((FaultType) fp2.getFault1()).getDescription()); assertEquals("bar", ((FaultType) fp2.getFault1()).getCommand()); // test 2 StagingFaultType f2 = new StagingFaultType(); f2.setDescription("foo1"); f2.setCommand("bar1"); f2.setAttribute("moo"); fp1 = new FaultPropertyType(); fp1.setFault2(f2); r1 = new Record1(); r1.setElem(fp1); r2 = binding.get(r1); assertTrue(r2 != null); fp2 = r2.getElem(); assertTrue(fp2 != null); assertTrue(fp2.getFault2() != null); assertTrue(fp2.getFault2() instanceof StagingFaultType); assertEquals("foo1", ((FaultType) fp2.getFault2()).getDescription()); assertEquals("bar1", ((FaultType) fp2.getFault2()).getCommand()); assertEquals("moo", ((StagingFaultType) fp2.getFault2()).getAttribute()); }
From source file:test.wsdl.choice.ChoiceServiceTestCase.java
public void testChoiceSerialization() throws Exception { ChoiceServiceSoap binding;/*from w w w . j a va 2s . c o m*/ try { ChoiceServiceLocator locator = new ChoiceServiceLocator(); binding = locator.getChoiceServiceSoap(); deployServer(); } catch (javax.xml.rpc.ServiceException jre) { throw new AssertionFailedError("JAX-RPC ServiceException caught: " + jre); } catch (Exception e) { throw new AssertionFailedError("Binding initialization Exception caught: " + e); } assertTrue("binding is null", binding != null); FaultPropertyType fp1; Record1 r1; Record2 r2; // serialize f1 FaultType f1 = new FaultType(); f1.setDescription("foo"); f1.setCommand("bar"); fp1 = new FaultPropertyType(); fp1.setFault1(f1); r1 = new Record1(); r1.setElem(fp1); r2 = binding.get(r1); assertTrue(r2 != null); // serialize f2 StagingFaultType f2 = new StagingFaultType(); f2.setDescription("foo1"); f2.setCommand("bar1"); f2.setAttribute("moo"); fp1 = new FaultPropertyType(); fp1.setFault2(f2); r1 = new Record1(); r1.setElem(fp1); r2 = binding.get(r1); assertTrue(r2 != null); }